akhauriyash/Code-Regression huggingface dataset:
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,m,u,v;
struct edge{
    int to,nxt;
}e[maxn<<1];
int cnt,head[maxn];
inline void add(int u,int v){
    e[++cnt] = (edge){v,head[u]};
    head[u] = cnt;
}
struct node{
    int x,len;
    friend bool operator<(node a,node b){
        return a.len > b.len;
    }
};
int dis[maxn],dp[maxn];
bool solve(){
    priority_queue<node> q;
    q.push((node){1,0});
    memset(dis,0x3f,sizeof(dis));
    dis[1] = 0;
    while(!q.empty()){
        node now = q.top(); q.pop();
        if(dis[now.x] < now.len) continue;
        for(int i = head[now.x];i > 0;i = e[i].nxt){
            int v = e[i].to;
            if(dis[v] > dis[now.x]+1){
                dis[v] = dis[now.x]+1;
                q.push((node){v,dis[v]});
                dp[v] = now.x;
            }
        } 
    }
    for(int i = 2;i <= n; ++i){
        if(dis[i] > n) return false;
    }
    return true;
}
int main(){
    scanf("%d %d",&n,&m);
    for(int i = 1;i <= m; ++i){
        scanf("%d %d",&u,&v);
        add(u,v); add(v,u);
    }
    if(!solve()) puts("No");
    else{
        puts("Yes");
        for(int i = 2;i <= n; ++i) printf("%d\n",dp[i]);
    }
    return 0;
}

Measured memory_bytes: 8812
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, T = LI()
t = LI()
ans = 0
time = 0
for i in t:
    if time < i:
        time = i + T
        ans += T
    else:
        ans += i - time + T
        time = i + T
print(ans)

Measured memory_bytes: 77648
N = int(input())
S = [input() for _ in range(N)]

dic={}
for i in range(N):
    if S[i] not in dic:
        dic[S[i]]=1
    else:
        dic[S[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for word in ans:
    print(word)

Measured memory_bytes: 35216
import java.io.*;
import java.util.*;
class Pair implements Comparable<Pair>{
    int cost, time;
    Pair(int cost, int time){
        this.cost = cost;
        this.time = time;
    }
    public int compareTo(Pair other){
        return this.cost-other.cost;
    }
}
class Main{
    public static void main(String[] args) {
        //Program obj = new Program();
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(); int T = in.nextInt();
        ArrayList<Pair> arr = new ArrayList<>();
        while(N-->0){
            arr.add(new Pair(in.nextInt(),in.nextInt()));
        }
        in.close();
        Collections.sort(arr);
        boolean flag = true;
        for(int i=0;i<arr.size();i++){
            if (arr.get(i).time<=T) {
                System.out.println(arr.get(i).cost);
                flag = false;
                break;
            }
        }
        if (flag) System.out.println("TLE");
    }
}

Measured memory_bytes: 21204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ANot solver = new ANot();
        solver.solve(1, in, out);
        out.close();
    }

    static class ANot {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            if (x == 0)
                out.println(1);
            else if (x == 1)
                out.println(0);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32456
#include<bits/stdc++.h>
using namespace std;

int main(){
int K;
int A,B;
cin >> K; 
cin >> A >> B;
  
int largest = (B / K) * K;
if(A <= largest){
  cout << "OK" << endl;
} 
else{
  cout << "NG" << endl;
}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

int main() {
  string w;
  cin >> w;

  map<char, int> m;

  rep(i, w.length()) {
    char c = w[i];
    int cnt = 0;
    if (m.count(c) > 0) continue;
    rep(j, w.length()) {
      char c2 = w[j];
      if (c == c2) cnt++;
    }
    m[c] = cnt;
  }

  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N, R;
    cin >> N >> R;

    if (N>= 10)
    {
        cout << R << endl;
    } else
    {
        cout << R + 100 * (10 - N) << endl;
    }
    
    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,k,a[202020],cnt,ans;
int main()
{
	cin>>n>>k;
	for(int i=0;i<201000;i++)
	{
		a[i]=1e9;
	}
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(a[x]==1e9)
		{
			a[x]=0;
		}
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]<1e9)
		{
			cnt++;
		}
	}
	sort(a,a+n+1);
	for(int i=0;i<cnt-k;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;
int n,res=0,a[1234567],dem=1;
int main()
{
   cin>>n;
   for (int i=0;i<n;i++) cin>>a[i];
   sort(a,a+n);
   a[n]=1000000001;
   for (int i=1;i<=n;i++) {
        if (a[i]!=a[i-1]){
            if (dem%2!=0) res++;
            dem=1;
        }
        else dem++;
   }
   cout<<res;
   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int a, b; cin >> a >> b;
	cout << max(0, a-2*b) << endl;
	return 0;
}


Measured memory_bytes: 256
P1 = list(map(int,input().split()))
P2 = list(map(int,input().split()))
P3 = list(map(int,input().split()))

li = []
for i in range(2):
    li.append(P1[i])
    li.append(P2[i])
    li.append(P3[i])

flag = 0
for j in range(1, 5):
    score = li.count(j)
    if score == 3:
        flag = 1

if flag == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
w=list(input())
w.sort()
ans='Yes'
count=1
for i in range(len(w)-1):
  if w[i]==w[i+1]:
    count+=1
  else:
    if count%2==1:
      ans='No'
      break
    count=1
if count%2==1:
  ans='No'
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;

bool f(int x){
	set<string> st;
	for(int i=0;i<n-x+1;i++){
		if(i>=x) st.insert(s.substr(i-x,x));
		if(st.find(s.substr(i,x))!=st.end()) return 1;
	}
	return 0;
}

int main(){
	cin>>n>>s;
	int l=0,r=n+1;
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)) l=m;
		else r=m;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B; cin >> A >> B;
	char S[10]; cin >> S;

	bool check1 = false;
	rep(i, 0, A) {
		if (S[i] >= '0' && S[i] <= '9') {
			check1 = true;
		}
	}

	bool check2 = false;
	if (S[A] == '-') {
		check2 = true;
	}

	bool check3 = false;
	rep(i, A + 1, A + B + 1) {
		if (S[i] >= '0' && S[i] <= '9') {
			check3 = true;
		}
	}
	cout << ((check1 && check2 && check3) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
def searchInf(s, k):
    l = k if len(s) >= k else len(s)
    for i in range(l):
        if s[i] == "1":
            continue
        else:
            print(s[i])
            return 0
    print(1)
    return 0


S = list(input())
K = int(input())
searchInf(S, K)


Measured memory_bytes: 2940
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let result = vec![a + b, a - b, a * b];
    println!("{}", result.iter().max().unwrap());
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)
	ans := (h2*60 + m2) - (h1*60 + m1) - k
	fmt.Println(ans)
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D, T, S;
    cin >> D >> T >> S;

    if(T*S >= D)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    

    return 0;
}


Measured memory_bytes: 3648
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int trees = sc.nextInt();
        int inspector = sc.nextInt();
        int a = 2*inspector + 1;
        int ans = 0;
        if (trees % a == 0) {
            ans = trees /a;
        } else {
            ans = (trees/a) + 1;
        }
        
        System.out.print(ans);
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
 
string kk(string a,int b){
  int buf[103];
  for(int i=0;i<100;i++) buf[i]=0;
  for(int i=0;i<100;i++){
    int d = 0;
    if( i <(int)a.size() ) d=(a[i]-'0')*b;  
    buf[i+2] += (d/100);
    d %= 100;
    buf[i+1] += (d/10);
    d %= 10;
    buf[i] += d;
    if( buf[i]/100 ) buf[i+2] += buf[i]/100;
    buf[i]%=100;
    if( buf[i]/10 ) buf[i+1] += buf[i]/10;
    buf[i]%=10;
  }
  string res="";
  for(int i=99;i>0;i--){
    if( 1 <= buf[i-1]  && buf[i-1] <= 9 ){
      buf[i] = -1;
      break;
    }
  }
  for(int i=0;i<100;i++) {
    if( buf[i]==-1 ) break;
    res += (buf[i]+'0');
  }
  //cout << res.size() << endl;
  //  cout << a << " " << b << " " << res << endl;
  return res;
}
 
string pows(int m,int n){
  stringstream s;
  string a;
  s << m;
  s >> a;
  reverse(a.begin(),a.end());
  //  cout << a << endl;
  if( n == 1 ) return a;
  for(int i=1;i<n;i++){
    a = kk( a, m );
    // cout << i << endl;
    //cout << a<< endl;
  }
  return a;
}
 
string tab[]={"_","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts","err","err","err"};
 
bool check( string a, int id ){
  for(int j=id+1; j<id+5&&j<(int)a.size();j++ ){
    if( '1'<=a[j] && a[j] <='9' ) return true;
  }
  return false;
}
 
int main(){
  int n,m;
  while(cin >> m >> n && (n||m) ){
    string res;
    res = pows(m,n);
    for(int i=res.size()-1;i>=0;i--){
      if( i == 0 && check(res,i-1) ){
    bool f = false;
    for(int j=min(i+3,(int)res.size()-1);j>=i;j--){
      if( res[j] != '0' ) f = true;
      if( f ) cout << res[j];
    }
      }
      if( (i+1)%4 == 0 && check(res,i)) {
    bool f = false;
    for(int j=min(i+4,(int)res.size()-1);j>i;j--){
      if( res[j] != '0' ) f = true;
      if( f ) cout << res[j];
    }
    if( tab[(i+1)/4] != "err" )  cout << tab[(i+1)/4];
      }
    }
    cout << endl;
  }
 
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <utility>
#include <iterator>
#include <sstream>
#include <fstream>
#include <functional>
#include <ctime>
#include <cassert>
#include <limits>

using namespace std;

#define SyncFalse ios::sync_with_stdio(0); cin.tie(0)
#define MEM(a, v) memset(a, v, sizeof(a))
#define CLRV(a, sz, v) a.clear(); a.resize(sz, v)
#define CLR(a, sz) a.clear(); a.resize(sz)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.end(), a.begin()
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define SZ(a) (int)a.size()
#define LNG(a) (int)a.length()
#define LPI 3.141592653589793238462643383279502884L
#define SI(n) scanf("%d", &n)
#define SL(n) scanf("%lld", &n)
#define SD(n) scanf("%lf", &n)
#define SLD(n) scanf("%llf", &n)
#define SC(n) scanf(" %c", &n)
#define SS(n) scanf("%s", n)
#define FR(i, n) for (int i = 0; i < n; i++)
#define RFR(i, n) for (int i = n - 1; i >= 0; i--)
#define FR1(i, n) for (int i = 1; i <= n; i++)
#define RFR1(i, n) for (int i = n; i >= 1; i--)
#define FOREACH(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<ld> VLD;
typedef vector<double> VD;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

const double PI = acos(-1.0);
const double EPS = numeric_limits<double>::epsilon();
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int MOD = (int) 1e9 + 7;

//------------------------------------------------------------------------

int main() {
	int a, b, c; SI(a), SI(b), SI(c);
	FR1(i, 1000000) {
		if ((a * i - c) % b == 0) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private final static int MAX_VALUE = 100*1000;

    private static int solve(int N, int W, int[] w, int[] v) {
        long[] minWeight = new long[MAX_VALUE + 1];
        Arrays.fill(minWeight, Long.MAX_VALUE);
        minWeight[0] = 0;

        for (int k = 0; k < N; k++) {
            for (int value = MAX_VALUE - v[k]; value >= 0; value--) {
                if (minWeight[value] == Long.MAX_VALUE) continue;

                int newValue = value + v[k];
                long newWeight = minWeight[value] + w[k];
                long currentMinWeight = minWeight[newValue];

                if (newWeight < currentMinWeight) minWeight[newValue] = newWeight;
            }
        }

        for (int value = MAX_VALUE; value > 0; value--) {
            if (minWeight[value] <= W) return value;
        }

        return 0;
    }

    public static void main(String[] args) {
        int N, W;
        int[] w;
        int[] v;
        try (Scanner scanner = new Scanner(System.in)) {
            N = scanner.nextInt();
            W = scanner.nextInt();

            w = new int[N];
            v = new int[N];
            for (int i = 0; i < N; i++) {
                w[i] = scanner.nextInt();
                v[i] = scanner.nextInt();
            }
        }

        long result = solve(N, W, w, v);
        System.out.println(result);

        //test();
    }

    private static void test() {
        testCase(3, 8, new int[] {3, 4, 5}, new int[] {30, 50, 60}, 90);
        testCase(1, 1000000000, new int[] { 1000000000 }, new int[] { 10 }, 10);
        testCase(6, 15, new int[] {6,5,6,6,3,7}, new int[] {5,6,4,6,5,2}, 17);

        timingTest(100);

        System.out.println("DONE");
    }

    private static void timingTest(int size) {
        int[] w = new int[size];
        int[] v = new int[size];
        for (int i=0; i < size; i++) {
            w[i] = i*i*i;
            v[i] = Math.max(i*i, 1000);
        }

        long start = System.currentTimeMillis();
        solve(size, 1000000, w, v);
        long elapsed = System.currentTimeMillis() - start;
        System.out.println("timing size=" + size + " elapsed=" + elapsed);
    }

    private static void testCase(int N, int W, int[] w, int[] v, int expected) {
        int result = solve(N, W, w, v);
        if (result != expected) {
            System.out.println("FAILED N=" + N + " W=" + W + " w=" + Arrays.toString(w) + " v=" + Arrays.toString(v)
                    + ", was " + result + " expected " + expected);
        }
    }
}


Measured memory_bytes: 22228
N,A,B,K=map(int,input().split())
P=998244353
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Fact[0]=1
Finv[0]=1
for i in range(1,N+1):
    Fact[i]=(i*Fact[i-1])%P
    Finv[i]=(Finv[i-1]*inv(i))%P
ans=0
def NC(k):
    tmp=(Finv[k]*Finv[N-k])%P
    return (Fact[N]*tmp)%P
for x in range(N+1):
    y=(K-x*A)//B
    if x*A+y*B==K and 0<=y<=N:
        ans+=(NC(x)*NC(y))%P
print(ans%P)


Measured memory_bytes: 28996
n,m,*c=map(int,open(0).read().split())
c=sorted(c)
dp=[float("inf")]*50001
dp[0]=0
for i in range(50001):
    for j in c:
        if i+j>50000:
            continue
        else:
            dp[i+j]=min(dp[i+j],dp[i]+1)
print(dp[n])


Measured memory_bytes: 7252
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
  }
  int b[n];
  if(n%2==0){
    int j = 0;
    for(int i = 0; i < n/2; i++){
      b[n/2+i] = a[j];
      j++;
      b[n/2-1-i] = a[j];
      j++;
    }
  }
  
  else{
    b[n/2]=a[0];
    int j = 1;
    for(int i = 1; i < n/2+1; i++){
      b[n/2+i] = a[j];
      j++;
      b[n/2-i] = a[j];
      j++;
    }
  }
  for(int i = 0; i < n; i++){
    cout<<b[i]<<" ";
  }
  cout<<endl;
  return 0;
}
  



Measured memory_bytes: 3840
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] h = new int[N]; 
		int count = 0;

		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
			if(h[i] >= K) count++;
		}

		System.out.println(count);
		
		}
}



Measured memory_bytes: 47096
import itertools
import math
import collections
N = int(input())
candidate = range(1, math.ceil(N ** (1 / 2)) + 1)
answers = [0] * (N + 1)
for x, y, z in itertools.combinations_with_replacement(candidate, 3):
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    counter = collections.Counter([x,y,z])
    if q < N + 1:
        add = math.factorial(3)
        for key in counter:
            add //= math.factorial(counter[key])
        answers[q] += add
for a in answers[1:N + 1]:
    print(a)

Measured memory_bytes: 9852
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e18;
 
typedef long long ll;
typedef long double ld;  
using u128 = __uint128_t;

void test_case()
{
    ll n,i,j;
    cin >> n;
    ll a[n];
    u128 res = 1;
    f(i,0,n)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    f(i,0,n)
    {
        res = (u128)res * (u128)a[i];
        // cout << res << ' ';
        if(res > N )
        {
            cout << -1 << '\n';
            return ;
        }
    }
    ll ans = res;
    cout << ans << '\n';
    
}

int32_t main()
{
    IOS(); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 4452
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j;

  while(1){
    cin >> h >> w;
      if(h==0 && w==0) break;
    for(j=1;j<=h;j++){
      for(i=1;i<=w;i++){
	cout << '#';
      }
      cout << endl;
    }
    cout <<endl;
  }
  return 0;
}




Measured memory_bytes: 3092
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

M = 10**9+7
n = inp()
dp = [0]*2001
if n <= 2:
    print(dp[n])
    exit()
dp[0] = 1
for i in range(3,n+1):
    dp[i] = (dp[i-3]+dp[i-1])%M
print(dp[n]%M)

Measured memory_bytes: 63536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;
string S[100010];


int main(void){
    int N;
    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>S[i];
    }



    for (int i = 0; i < N; ++i) {
        sort(S[i].begin(), S[i].end());
    }

    long long ans=0;

    sort(S, S+N);


//    for (int j = 0; j < N; ++j) {
//        cout<<S[j]<<endl;
//    }


    long long  count = 1;
    string temp = S[0];
    for (int i = 1; i < N; ++i) {
        if(temp == S[i]){
            count++;
        }else{
            temp = S[i];
            if(count>1){
                ans += (count * (count-1)) / 2;
                count = 1;
            }
        }
    }

    if(count>1){
        ans += (count * (count-1)) / 2;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2688
from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    c = list(map(int,input().split()))

    ans=-10**18
    for i in range(n):
        start,count=i,1
        val=c[start]
        while p[start]-1 != i:
            start = p[start]-1
            count += 1
            val += c[start]
        start = i
        if val > 0:
            a = (k//count-1)*val
            ans=max(a,ans)
            num=count+k%count
        else:
            a=0
            num=min(k,count)
        for _ in range(num):
            a += c[start]
            start=p[start]-1
            ans=max(a,ans)
    print(ans)
main()

Measured memory_bytes: 119896
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int inputN = sc.nextInt();
		boolean division = false;

		for(int i = 1	; i < 10; i++) {
			if(inputN % i == 0 && inputN / i < 10) {
				division = true;
				break;
			}
		}

		if(division) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 22740
#include <iostream>
using namespace std;
typedef long long LL;
const LL MOD=1000000007;
int n,x,y,z;
LL dp[42][1<<18];
int main() {
    int T;
        cin>>n>>x>>y>>z;
        dp[0][0]=1;
        int ban=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
        for(int i=0;i<n;i++){
            for(int s=0;s<(1<<18);s++){
                for(int j=1;j<=10;j++){
                    //a[i+1]=j
                    int nex=(s<<j)|(1<<(j-1)); nex=nex&((1<<18)-1);
                    if ((nex&ban)!=ban){
                        (dp[i+1][nex]+=dp[i][s])%=MOD;
                    }
                }
            }
        }
        LL ret=0;
        for(int i=0;i<1<<18;i++) ret=(ret+dp[n][i])%MOD;
        LL tot=1;
        for(int i=1;i<=n;i++) tot=tot*10LL%MOD;
        LL ans=((tot-ret)%MOD+MOD)%MOD;
        printf("%lld\n",ans);

}


Measured memory_bytes: 84224
n, q = [int(i) for i in input().split()]
s = input()
imos = [0 for _ in range(len(s))]
for i in range(1, len(s)):
    if s[i] == "C" and s[i-1] == "A":
        imos[i] = 1
for i in range(1, len(s)):
    imos[i] += imos[i-1]
for _ in range(q):
    l, r = [int(i) - 1 for i in input().split()]
    print(imos[r] - imos[l])

Measured memory_bytes: 7788
a, b, c, d = map(int, input().split())
cnt = 0
while a > 0 and c > 0:
    if cnt % 2 == 0:
        c -= b
    else:
        a -= d
    cnt += 1
if (cnt - 1) % 2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9116
require 'pp'

n, m = gets.chomp!.split(" ").map!(&:to_i)
a = Array.new(0, n + 2)

before = -1
z = false

memo_a = {}

a[0]= -1
1.upto(m) do |i|
    a[i] = gets.chomp!.to_i
    memo_a[a[i]] = a[i]
    if before + 1 == a[i]
        z = true
        break
    end
    before = a[i]
end
a[m+1]=n+1

tree = {
    1 => 1,
    2 => 2
}

if z 
    puts 0
else
    dan_max = 0
    #pp a
    dan = a.each_cons(2).map do |s, e|
        d = (e-s)-2
        if d > dan_max
            dan_max = d
        end 
        d
    end

    #pp dan

    if dan_max >= 3
        3.upto(dan_max) do |x|
            tree[x] = tree[x-1] + tree[x-2]
        end
    end

    total = (dan.inject(1) {|sum, x|
        if x <= 0
            sum
        else
            sum *= tree[x]
            sum %= 1_000_000_007
        end
    }) 

    puts total
end


Measured memory_bytes: 438652
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string s;	getline(cin,s);
	string word;
	map<string,int> dic;
	for(int i=0;i<s.size();i++){
		if(s[i]!=' '){
			word+=s[i];
		}
		else{
			dic[word]++;
			word="";
		}
	}
	dic[word]++;
	int num=0;
	for(auto it:dic)	num=max(num,it.second);
	for(auto it:dic){
		if(num==it.second) 	cout<<it.first<<" ";
	}
	num=0;
	for(auto it:dic)	num=max(num,(int)it.first.size());
	for(auto it:dic){
		if(num==it.first.size())	cout<<it.first<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
def gcd(a,b):
    if b==0:
        return max(a,b)
    else:
        if a%b == 0:
            return(b)
        else:
            return gcd(b,a%b)
n = int(input())
a = list(map(int,input().split()))
l=[0 for i in range(n)]
r=[0 for i in range(n)]
e=[0 for i in range(n)]
for i in range(1,n):
    l[i]=gcd(l[i-1],a[i-1])
    r[i]=gcd(r[i-1],a[n-i])
for i in range(n):
    e[i] = gcd(l[i],r[n-1-i])
print(max(e))


Measured memory_bytes: 14488
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int d[100][101];
bool b[100];
vector<pair<int,int>> g[100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int res=0;
		int mo,day,h,m; char c; int id; int tm=0; bool flag=0;
		vector<int> t(1000,0);
		vector<int> sum(1000,0);
		while(n--){
			scanf("%d/%d %d:%d %c %d",&mo,&day,&h,&m,&c,&id);
			tm=h*60+m;
			if(c=='I'){
				if(id){
					t[id]=tm;
				}
				else{
					for(int i=1;i<1000;i++){
						if(t[i])t[i]=tm;
					}
					flag=1;
				}
			}
			else{
				if(id){
					if(flag){
						sum[id]+=tm-t[id];
						res=max(res,sum[id]);
					}
					t[id]=0;
				}
				else{
					for(int i=1;i<1000;i++){
						if(t[i]){
							sum[i]+=tm-t[i];
							res=max(res,sum[i]);
						}
					}
					flag=0;
				}
			}
		}
		printf("%d\n",res);
	}
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i+=2) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 512
import java.util.*;
class Main{
    static int[][] c;
    static int w,h;
    static void check(int x,int y){
        c[x][y]=0;
        if(x>0){
            if(y>0){
                if(c[x-1][y-1]==1){
					check(x-1,y-1);
				}
            }
			if(y<h-1){
                if(c[x-1][y+1]==1){
					check(x-1,y+1);
					check(x-1,y+1);
				}
            }
			if(c[x-1][y]==1){
				check(x-1,y);
			}
        }
        if(x<w-1){
            if(y>0){
                if(c[x+1][y-1]==1){
					check(x+1,y-1);
				}
            }
			if(y<h-1){
                if(c[x+1][y+1]==1){
					check(x+1,y+1);
				}
            }
			if(c[x+1][y]==1){
				check(x+1,y);
			}
        }
        if(y>0){
			if(c[x][y-1]==1){
				check(x,y-1);
			}
		}
        if(y<h-1){
			if(c[x][y+1]==1){
				check(x,y+1);
			}
		}
    }
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h!=0||w!=0){
				c=new int[w][h];
				for(int i=0;i<w;i++){
					for(int j=0;j<h;j++){
						c[i][j]=sc.nextInt();
					}
				}
				int ans=0;
				for(int i=0;i<w;i++){
					for(int j=0;j<h;j++){
						if(c[i][j]==1){
							ans++;
							check(i,j);
						}
					}
				}
				System.out.println(ans);
			}
			else{
				break;
			}
        }
    }
}


Measured memory_bytes: 44752
//	-*- mode: C++ -*-
//	Toggling Cases
//
//		Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
//
//	Input
//		A string is given in a line.
//
//	Output
//		Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.
//
//	Constraints
//		The length of the input string < 1200
//	Sample Input
//		fAIR, LATER, OCCASIONALLY CLOUDY.
//	Sample Output
//		Fair, later, occasionally cloudy.

#include <iostream>
#include <string>
#include <cctype>

int	main(int	argc,
		 char*	argv[])
{
	std::string	str;

	std::getline(std::cin, str);

	for(unsigned int i = 0; i < str.length(); i++){
		if(isupper(str[i])){
			str[i] = tolower(str[i]);
		}
		else if(islower(str[i])){
			str[i] = toupper(str[i]);
		}
		else{
			;
		}
	}

	std::cout << str << '\n';

    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;

int main(void){
    int n;
    cin >> n;
    double a[n],sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += 1/a[i];
    }
    double ans = 1/sum;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main(){
    int H,W;
    char a[100][100];
    vector<int> ignoreH,ignoreW;
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<H;i++){
        bool ignoretmp = true;
        if(a[i][0] == '.'){
            for(int j=0;j<W;j++){
                if(a[i][j] == '#'){ignoretmp = false;}
            }
            if(ignoretmp){
                ignoreH.push_back(i);
            }
        }
    }
    for(int j=0;j<W;j++){
        bool ignoretmp = true;
        if(a[0][j] == '.'){
            for(int i=0;i<H;i++){
                if(a[i][j] == '#'){ignoretmp = false;}
            }
            if(ignoretmp){
                ignoreW.push_back(j);
            }
        }
    }
    for(int i=0;i<H;i++){ 
        bool skiph = false;
        bool skipw = false;
        for(auto iter=ignoreH.begin();iter!=ignoreH.end();iter++){
            if(i == *iter){skiph=true;}
        }
        if(skiph){continue;}
        for(int j=0;j<W;j++){
            for(auto iter=ignoreW.begin();iter!=ignoreW.end();iter++){
                if(j == *iter){skipw=true;}
            }
            if(skipw){skipw=false;continue;}
            cout << a[i][j];
        }
        cout <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
#include<functional>
#define P pair<double,int>//cost to
using namespace std;

int x[100], y[100], k[100];
unordered_map<int, int>U;
vector<P>rinsetu[100];
double mincost[100];
int Prev[100];
vector<int>V;
int s, g;
void saiki(int a) {
	V.push_back(a);
	if (Prev[a] != s) {
		saiki(Prev[a]);
	}
}
int main() {
	int a;
	while (cin >> a, a) {
		U.clear();
		for (int b = 0; b < a; b++) {
			int c;
			scanf("%d%d%d",&c, &x[b], &y[b]);
			U[c] = b;
			k[b] = c;
			rinsetu[b].clear();
		}
		for (int b = 0; b < a; b++) {
			for (int c = b + 1; c < a; c++) {
				double d = pow(x[b] - x[c], 2)+pow(y[b] - y[c], 2);
				d = sqrt(d);
				if (d <= 50) {
					rinsetu[b].push_back(P(d, c));
					rinsetu[c].push_back(P(d, b));
				}
			}
		}
		int b; cin >> b;
		for (int c = 0; c < b; c++) {
		    scanf("%d%d", &s, &g);
			s = U[s]; g = U[g];
			fill(mincost, mincost + a, 1 << 29);
			mincost[s] = 0;
			priority_queue<P, vector<P>, greater<P>>Q;
			Q.push(P(0,s));
			while (Q.size()) {
				P t = Q.top(); Q.pop();
				if (mincost[t.second] > t.first)continue;
				for (P i : rinsetu[t.second]) {
					if (mincost[i.second] > t.first + i.first) {
						mincost[i.second] = t.first + i.first;
						Q.push(P(mincost[i.second],i.second));
						Prev[i.second] = t.second;
					}
				}
			}
			if (mincost[g] == 1 << 29) { puts("NA"); }
			else {
				V.clear();
				saiki(g);
				V.push_back(s);
				reverse(V.begin(), V.end());
				for (int i = 0; i < V.size(); i++) {
					if (i)cout << " ";
					cout << k[V[i]];
				}
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 3144
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    String T = sc.next();

    int count = 0;

    for(int i = 0; i < 3; i++){
      if(S.substring(i,i + 1).contains(T.substring(i,i + 1))){
       count = count + 1;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, m;
	string sn[102], sm[102];

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> sn[i];
	}

	cin >> m;

	for (i = 0; i < m; i++) {
		cin >> sm[i];
	}

	map<string, int>mp;

	for (i = 0; i < n; i++) {
		
		auto itr = mp.find(sn[i]);
		if (itr != mp.end()) {
			mp[sn[i]]++;
		}
		else {
			mp.insert(pair<string, int>(sn[i], 1));
		}

	}

	for (i = 0; i < m; i++) {

		auto itr = mp.find(sm[i]);
		if (itr != mp.end()) {
			mp[sm[i]]--;
		}
		else {
			mp.insert(pair<string, int>(sm[i], -1));
		}

	}

	int maxn = 0;

	for (i = 0; i < n; i++) {
		maxn = max(maxn, mp[sn[i]]);
	}

	for (i = 0; i < m; i++) {
		maxn = max(maxn, mp[sm[i]]);
	}

	if (maxn < 0) {
		cout << 0 << endl;
	}
	else {
		cout << maxn << endl;
	}


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, M; cin >> N >> M;
  ll lft = 1, rgt = N/2;
  ll lft2 = rgt+1, rgt2 = N;
  if ((rgt2-lft2+1)%2 == rgt%2) rgt2--;
  while (lft < rgt && M > 0) {
    cout << lft << ' ' << rgt << endl;
    lft++;
    rgt--;
    M--;
  }
  while (lft2 < rgt2 && M > 0) {
    cout << lft2 << ' ' << rgt2 << endl;
    lft2++;
    rgt2--;
    M--;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;

int main(){
  int n, i, j, minj, tmp;
  int count = 0;

  cin>>n;
  int a[n];
  for(i =0; i < n; i++){
    cin>>a[i];
  }

  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    if(i != minj){
      tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      count++;
    }
  }

  for(i = 0; i < n-1; i++){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl<<count<<endl;
}

Measured memory_bytes: 1160
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n,m);
    // LCA(LowestCommonAncestor)
    map<ll,ll> T; 
    REP(i,m){
        inl(a,b);
        T[a]++;
        T[b]++;
    }
    ll f= 1;
    each(x,T){
        if(x.second&1) f=0;
    }
    out(((f)?"YES":"NO"));
}

Measured memory_bytes: 5632
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  int s = a + b + c;
  cout << (s >= 22 ? "bust" : "win");
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
    cin >> n;
  string a[n], ans = "Yes";
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n-1; i++){
      if(a[i+1][0] != a[i][a[i].size()-1]){
        ans = "No";
        break;
      }
    }
    sort(a, a+n);
    for(int i=0; i<n-1; i++){
      if(a[i] == a[i+1]) ans = "No";
    }
    cout << ans << endl;

}

Measured memory_bytes: 256