akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    if(N % 2 == 0) {
        for(int i = N - 1;i >= 0;i -= 2) {
            cout << vec.at(i) << " ";
        }
        for(int i = 0;i < N;i += 2) {
            cout << vec.at(i) << " ";
        }
        cout << endl;
    }
    else {
        for(int i = N - 1;i >= 0;i -= 2) {
            cout << vec.at(i) << " ";
        }
        for(int i = 1;i < N;i += 2) {
            cout << vec.at(i) << " ";
        }
        cout << endl;
    }
}

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

int f(int n) {
    int ret = 0;

    do {
        ret += n % 10;
    } while ((n /= 10) > 0);

    return ret;
}

int main() {
    int n;
    cin >> n;

    int min = 1000000000;
    for (int i = 1; i <= n / 2; i++) {
        min = std::min(min, f(i) + f(n - i));
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        
        int[] count = new int[n];
        for (int i = 0; i < n; i++) {
            count[i] = sc.nextInt();
        }
        
        int nowh = 0;
        int noww = 0;
        int now = 0;
        int index = 0;
        int[][] board = new int[h][w];
        while (now < h * w) {
            board[nowh][noww] = index + 1;
            
            count[index]--;
            if (count[index] == 0) index++;
            now++;
            
            if (nowh % 2 == 0) {
                if (noww != w - 1) {
                    noww++;
                } else {
                    nowh++;
                }
            } else {
                if (noww != 0) {
                    noww--;
                } else {
                    nowh++;
                }
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(board[i][j]);
                
                if (j != w - 1) {
                    System.out.print(" ");
                } else {
                    System.out.println();
                }
            }
        }
    }
}

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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  ll n; cin >> n;
  set<ll> s;

  rep(n, i) {
    ll tmp; cin >> tmp;
    s.insert(tmp);
  }
  
  cout << (ll)s.size() << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		List<int[]> path = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			int[] a = { Integer.parseInt(sc.next()), Integer.parseInt(sc.next()) };
			path.add(a);
		}
		Collections.sort(path, new PathComp());
		int cnt = 1;
		int tmp = path.get(0)[1];
		for (int i = 1; i < m; i++) {
			if (path.get(i)[0] >= tmp) {
				tmp = path.get(i)[1];
				cnt++;
			}
		}
		System.out.println(cnt);

	}

	static class PathComp implements Comparator<int[]> {
		@Override
		public int compare(int[] a, int[] b) {
			return a[1] > b[1] ? 1 : -1;
		}
	}

}


Measured memory_bytes: 63652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define f first
#define sc second
bool cmp(int a, int b) {
    return a < b;
}
void solve() {
    int n, k, ans = 0;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << "\n";
    return;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    solve();
}


Measured memory_bytes: 3664
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;
    public static int MOD = 1000000007;

    public static boolean[] vis;
    public static int[] col;
    public static int size;
    public static boolean is2;

    public static void dfs(int u, int c){
        size++;
        col[u] = c;

        for(int v : adjList.get(u)){
            if(vis[v]){
                if(col[u] == col[v]){
                    is2 = false;
                }
            } else{
                vis[v] = true;
                dfs(v, c*-1);
            }
        }
    }


    public static void main(String[] args) throws Exception{
        st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        adjList = new ArrayList<ArrayList<Integer>>();
        for(int i = 0; i < N; i++){
            adjList.add(new ArrayList<Integer>());
        }

        for(int i = 0; i < M; i++){
            st = new StringTokenizer(br.readLine());
            int u = Integer.parseInt(st.nextToken()) - 1;
            int v = Integer.parseInt(st.nextToken()) - 1;
            adjList.get(u).add(v);
            adjList.get(v).add(u);
        }

        vis = new boolean[N];
        col = new int[N];

        long n0 = 0;
        long n1 = 0;
        long n2 = 0;
 
        for(int i = 0; i < N; i++){
            if(vis[i]) continue;
            vis[i] = true;
            size = 0;
            is2 = true;
            dfs(i, 1);
            if(size == 1){
                n0++;
            } else{
                if(is2){
                    n2++;
                } else{
                    n1++;
                }
            }
        }
        long ans = 0;
        ans += (N * n0) + (N - n0) * n0;
        ans += (n2 * n2 * 2);
        ans += (n1 * n1);
        ans += (n1 * n2 * 2);
        pw.print(ans + "\n");
        
        pw.close(); 
        br.close();
    }
}

class Pair {
    public int a, b;

    Pair(int a, int b){
        this.a = a;
        this.b = b;
    }

}

Measured memory_bytes: 88520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    ll ans = 0;
    rep(i, n){
        if(i == 0)continue;
        else if(i == 1)ans += a[0];
        else{
            ans += a[i/2];
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	double xa1,xa2,ya1,ya2;
	double xb1,xb2,yb1,yb2;
	
	while(cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
		if(xa1<=xb2&&xa2>=xb1&&ya1<=yb2&&ya2>=yb1)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	
	
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int total = 0;
    vector<pair<int,int>> ps, ms;
    for (int i=0;i<N;i++){
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (int j=0;j<s.size();j++){
            if (s[j] == '(') h++; else h--;
            b = min(b, h);
        }
        if (h>=0) ps.emplace_back(b,h);
        else ms.emplace_back(b-h,-h);
        total += h;
    }
    if (total != 0) {
        cout << "No" << "\n";
        return 0;
    }
    sort(ps.rbegin(),ps.rend());
    sort(ms.rbegin(),ms.rend());
    int x = 0;
    for (int i=0;i<ps.size();i++){
        if (x + ps[i].first < 0) {
            cout << "No" << "\n";
            return 0;
        }
        x += ps[i].second;
    }
    x = 0;
    for (int i=0;i<ms.size();i++){
        if (x + ms[i].first < 0) {
            cout << "No" << "\n";
            return 0;
        }
        x += ms[i].second;
    }
    cout << "Yes" << "\n";
}

Measured memory_bytes: 11224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a>>b;
	c=0;
	if(a<4)c+=(4-a)*100000;
	if(b<4)c+=(4-b)*100000;
	if(a==1 && b==1)c+=400000;
	cout<<c<<endl;
}

Measured memory_bytes: 256
/*
 * ALDS1_3_D.cpp
 *
 *  Created on: Apr 26, 2018
 *      Author: 13743
 */

#include<iostream>
#include<stack>

using namespace std;

int main() {
	int slope[20000];
	int n = 0;
	int maxH = 0;
	int nowH = 0;
	stack<int> tops;
	stack<int> topInds;
	bool nextTop = true;
	char s;
	while(cin >> s) {
		if(s == '_') {
			slope[n] = 0;
		}
		else if(s == '/') {
			slope[n] = 1;
			nextTop = true;
			nowH++;
			while(!tops.empty() && nowH > tops.top() && maxH > tops.top()) {
				tops.pop();
				topInds.pop();
			}
		}
		else {
			slope[n] = -1;
			if(nextTop) {
				tops.push(nowH);
				topInds.push(n);
				nextTop = false;
			}
			maxH = (nowH > maxH) ? nowH : maxH;
			nowH--;
		}
		n++;
	}
	if(nextTop) {
		tops.push(nowH);
		topInds.push(n);
	}

	int sumR = 0;
	int count = 0;
	int rains[20000];
	int tpR = tops.top(); tops.pop();
	int tpRInd = topInds.top(); topInds.pop();
	while(!tops.empty()) {
		int tpL = tops.top();
		int depth = 0;
		int rain = 0;
		int slC = 0;
		if(tpL > tpR) {
			do {
				tpRInd--;
				int sl = -slope[tpRInd];
				slC += sl*sl;
				rain += depth;
				depth -= sl;
				if(sl == 1) rain--;
			} while(depth != 0 || slC == 0);
		}
		else {
			int tpLInd = topInds.top();
			do {
				int sl = slope[tpLInd];
				slC += sl*sl;
				rain += depth;
				depth -= sl;
				tpLInd++;
				if(sl == 1) rain--;
			} while(depth != 0 || slC == 0);
		}
		rain += slC / 2;
		sumR += rain;
		rains[count] = rain;
		count++;
		tpR = tops.top(); tops.pop();
		tpRInd = topInds.top(); topInds.pop();
	}

	cout << sumR << endl;
	cout << count;
	for(int i=0; i<count; i++) {
		cout << " " << rains[count-1-i];
	}
	cout << endl;
}





Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

ll n, arr[N];

int main()
{
    inlld(n);
    for(ll a=1; a<=n; a++)
    {
        ll x;
        inlld(x);
        if(x%2==1)
            continue;
        if(x%3!=0 && x%5!=0)
        {
            printf("DENIED\n");
            return 0;
        }
    }
    printf("APPROVED\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int H, W;

multiset<pair<char, char>> cps, cpss;
vector<string> Grid(12), OG(12);
bool solo = 1;
int solow = -1;

bool stp(string &s, string &t) {
	//sとtで点対称配置になるか
	cps = cpss;
	char a, b;
	for (int i = 0;i < W;i++) {
		a = s[i];b = t[i];
		auto it = cps.find({ b,a });
		if (it == cps.end()) {
			cps.insert({ a,b });
		}
		else {
			cps.erase(it);
		}
	}
	if (cps.size() == 0)return 1;
	if (cps.size() > 1)return 0;
	tie(a, b) = *cps.begin();
	if (a == b)return 1;
	return 0;
}

bool stpst(string &s, string t) {
	reverse(t.begin(), t.end());
	if (s == t)return 1;
	return 0;
}

bool stpst(string &s) {
	string t = s;
	return stpst(s, t);
}

bool fsolve(vector<bool> &V) {

	for (int i = 0;i < W;i++) {
		if (V[i])continue;
		for (int j = i + 1;j < W;j++) {
			if (V[j])continue;

			if (stpst(OG[i], OG[j])) {
				V[i] = 1, V[j] = 1;
				if (fsolve(V))return 1;
				V[i] = 0;V[j] = 0;
			}
		}
		if (solow < 0) {
			solow = i;
			V[i] = 1;
			if (fsolve(V))return 1;
			V[i] = 0;
			solow = -1;
		}
	}
	for (bool i : V)if (!i)return 0;
	if (solow < 0)return 1;
	if (stpst(OG[solow]))return 1;
	return 0;
}

bool solve(vector<bool>&V,multiset<pair<int,int>> &st) {
	
	for (int i = 0;i < H;i++) {
		if (V[i])continue;
		for (int j = i + 1;j < H;j++) {
			if (V[j])continue;

			if (stp(Grid[i], Grid[j])) {
				V[i] = 1, V[j] = 1;
				st.insert({ i,j });
				if (solve(V, st))return 1;
				st.erase(--st.end());
				V[i] = 0;V[j] = 0;
			}
		}
		
		if (solo) {
			solo = 0;
			V[i] = 1;
			st.insert({ 512411,i });
			if (solve(V, st))return 1;
			st.erase(--st.end());
			V[i] = 0;
			solo = 1;
		}
		else return 0;
	}

	for (bool i : V)if (!i)return 0;

	int a = 0, b = -1;
	for (auto i : st) {
		for (int k = 0;k < W;k++) {
			if (i.first == 512411)OG[k][a] = Grid[i.second][k];
			else {
				OG[k][a] = Grid[i.first][k];
				OG[k][H - a - 1] = Grid[i.second][k];
			}
		}
		a++;
	}



	/*
	for (int i = 0;i < W;i++) {
		for (int j = 0;j < H;j++)
			cout << OG[i][j] << " ";
		cout << endl;
	}*/
	
	vector<bool> thr(W, 0);
	if (fsolve(thr))
		return 1;
	return 0;
}

int main(){
	cin >> H >> W;
	
	for (int i = 0;i < H;i++)cin >> Grid[i];
	
	for (int i = 0;i < W;i++)
		for (int j = 0;j < H;j++)
			OG[i].push_back('?');

	vector<bool> qwe(H, 0);
	multiset<pair<int, int>> rty;
	if (solve(qwe, rty))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
const int mod=1e9+7;
ll quick(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)
		{
			ans*=x;ans%=mod;
		}
		x*=x;x%=mod;y>>=1;
	}
	return ans;
}
ll solve(ll h,ll w)
{
	//t=1
	ll res=quick(2,h)+quick(2,w)-1;
	res%=mod;
	ll g=__gcd(h,w);
	res+=(quick(2,g)-2);
	return (res+mod)%mod;
}
int main()
{
	ll h,w,t;scanf("%d%d%d",&h,&w,&t);
	ll gh=__gcd(h,t),gw=__gcd(w,t);
	ll now=solve(h/gh,w/gw);
	printf("%lld\n",(quick(now,gh*gw)%mod+mod)%mod);
 } 

Measured memory_bytes: 256
#include <iostream>

int main () {
    int n, m, a, b;
    std::cin >> n >> m;
    int ans[60]={0};
    for(int i = 0; i < m; ++i){
        std::cin >> a >> b;
        ++ans[a];
        ++ans[b];
    }
    for(int i = 1; i <= n; ++i){
        std::cout << ans[i] << std::endl;
    }
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if (X == 1) {
            System.out.println("0");            
        }
        if (X == 0) {
            System.out.println("1");            
        }
    }

}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if (a[0]+a[1]==a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int64 N, M, K, A, B, C, T, S[3001];

  cin >> N >> M >> K;
  cin >> A >> B >> C;
  cin >> T;
  for(int i = 0; i < M; i++) cin >> S[i];
  S[M] = N + 1;
  K -= M;

  int64 ret = -1;

  priority_queue< int64, vector< int64 >, greater< int64 > > que;

  for(int i = 0; i < M; i++) {
    int64 rest = T - (S[i] - 1) * B;
    if(rest < 0) break;
    int64 pv = S[i], reach = min(S[i + 1], pv + rest / A + 1);
    ret += reach - S[i];
    for(int j = 0; j < K && reach < S[i + 1]; j++) {
      rest -= (reach - pv) * C;
      if(rest < 0) break;
      pv = reach;
      reach = min(S[i + 1], pv + rest / A + 1);
      if(que.size() > K && que.top() >= reach - pv) continue;
      que.push(reach - pv);
      ret += reach - pv;
      if(que.size() > K) ret -= que.top(), que.pop();
    }
  }

  cout << ret << endl;
}

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


int main(){
  int n;
  cin >> n;
  int a,t;
  cin >> t >> a;
  vector<int> h(n);
  for(int i=0;i<n;++i){
    cin >> h[i];
  }
  int ans=0;
  int an=1<<30;
  for(int i=0;i<n;++i){
    int cal=abs((t*1000-h[i]*6)-a*1000);

    if(an>cal){
      an=cal;
      ans=i;
    }
  }
  ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    V<int> a(n);
    cinf(n,a);
    V<int> s(1000001);
    V<bool> p(1000001,1);
    for(int i=2;i<=1000000;i++){
        if(p[i]){
            s[i]=i;
            for(int j=2*i;j<=1000000;j+=i){
                p[j]=0;
                s[j]=i;
            }
        }
    }
    V<int> cnt(1000001,0);
    rep(i,n){
        int cur=a[i];
        int div=s[a[i]];
        while(cur>1){
            while(cur%div==0) cur/=div;
            cnt[div]++;
            div=s[cur];
        }
    }
    bool ok=1;
    int g=a[0];
    for(int i=1;i<n;i++) g=__gcd(g,a[i]);
    for(int i=2;i<=1000000;i++){
        if(cnt[i]>1){
            ok=0;
        }
    }
    if(ok) out("pairwise coprime");
    else if(g==1) out("setwise coprime");
    else out("not coprime");
}

Measured memory_bytes: 15052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		String s = stdin.next();
		if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
			System.out.println("Yes");
		} else if (s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");

		}

	}

}

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

int main(){
  int N;
  cin >> N;
  int X=0;
  for(int i=0; i<50000; i++){
    if(i*108/100==N) X=i;
  }
  if(X!=0) cout << X << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
hash = Hash.new(0)
arr.each do |num|
  hash[num] += 1
end

m.times do
  b, c = gets.chomp.split(' ').map(&:to_i)
  hash[c] += b
end
a = hash.to_a.sort_by { |num, count| -1 * num }
sum = 0
rest_count = n
a.each do |num, count|
  if count >= rest_count
    sum += num * rest_count
    break
  else
    sum += num * count
    rest_count -= count
  end
end
puts sum


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	double a,b; cin >> a >> b;

	printf("%.10f\n", a/b);

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  const ll mod=1000000007;
  ll ans=0;
  ll x=0;
  for(int i=0;i<n;++i){
    ans=(ans+a[i]*x)%mod;
    x=(x+a[i])%mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x;
    cin >> x;
    if (x < 4) {
        cout << 1 << endl;
        return 0;
    }
    ll b_max = floorl(sqrt(x));
    vll ans_list;
    for (int b = 2; b <= b_max; b++) {
        ll p = 2;
        while (true) {
            if (pow(b, p) > x) break;
            ans_list.push_back(pow(b, p));
            p++;
        }
    }
    sort(ALL(ans_list));
    cout << ans_list.at(ans_list.size()-1) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	
	static long M;
	static int N, K;
	
	static long[][] comb;
	static long[][] table;
	static long[][] acumTable;
	
	static void calcComb() {
		comb = new long[N + 1][];
		comb[0] = new long[1];
		comb[0][0] = 1;
		for (int i = 1; i <= N; i++) {
			comb[i] = new long[i + 1];
			comb[i][0] = comb[i][i] = 1;
			for (int j = 1; j < i; j++) {
				comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % M;
			}
		}
	}
	
	static long calc() {
		table = new long[N + 1][K + 1];
		acumTable = new long[N + 1][K + 1];
		for (int n = 0; n <= N; n++) {
			for (int k = 0; k <= K; k++) {
				if (n == 0) {
					table[n][k] = 1;
					acumTable[n][k] = (table[n][k] + (k > 0 ? acumTable[n][k - 1] : 0)) % M;
					continue;
				}
				table[n][k] = 0;
				for (int i = 1; i <= n; i++) {
					long tmp = (comb[n - 1][i - 1] * table[n - i][k]) % M;
					long tmp2 = (acumTable[i - 1][K] + M - acumTable[i - 1][k]) % M;
					table[n][k] += tmp * tmp2;
					table[n][k] %= M;
				}
				acumTable[n][k] = (table[n][k] + (k > 0 ? acumTable[n][k - 1] : 0)) % M;
			}
		}
		return table[N][0];
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		N = sc.nextInt();
		K = sc.nextInt();
		M = sc.nextInt();
		calcComb();
		System.out.println(calc());
	}
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

struct State {
  ll a;
  int i;
  int c;
};

ll solve(ll A1, ll A2, ll A3) {
  // cout << A1 << " " << A2 << " " << A3 << endl;
  if (A3 == 0) {
    if (A1 == A2) return 0;
    ll d = A1 - A2;
    if (d < 0) return -1;
    if (d % 2) return -1;
    return d/2;
  }
  if ( ((A1 ^ A2)&1) != (A3&1) ) return -1;
  if ((A1^A2) == A3) return 0;

  ll S = A1 + A2;
  ll X = A3;

  queue<State> q;
  q.push((State){0, 61, 0});

  ll ans = -1;

  while (!q.empty()) {
    ll a = q.front().a;
    int i = q.front().i;
    int c = q.front().c;
    q.pop();

    if (a > A1) continue;
    if (i == -1) {
      if (c) continue;
      if (!(1 <= a && a <= A1)) continue;
      if (a + (a^X) != S) continue;
      chmax(ans, a);
      continue;
    }

    int s = (S >> i & 1);
    int x = (X >> i & 1);

    if (x == 0) {
      ll na = a;
      if (c == 1) {
        na |= (1LL << i);
      }
      int nc = s;
      q.push({na, i-1, nc});
    } else if (x == 1) {
      if (c == 1 && s == 1) return -1;
      if (c == 0 && s == 0) return -1;
      ll na = a | (1LL << i);


      q.push({na, i-1, c});

      if (a + (1LL << i)*2 > A1)
        q.push({a, i-1, c});
    }
  }

  if (ans == -1) return -1;
  return A1 - ans;
}

int main2() {
  int N = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();
  for (int i = 3; i < N; i++) A[2] ^= A[i];

  ll ans = solve(A[0], A[1], A[2]);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define V vector
#define W V<long>
using namespace std;long E=70,M=2e17,i,a,b;W S(V<W>p){if(!E)return{1,0};V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1)T[x[1]&1].push_back({x[0]/2,++x[1]/2});}for(long i;i<2;i++){a=0;for(W x:T[!i])a^=(2*x[0]+x[1])%3+1;if(!a){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p)v[0]++;W A=S(p);A[0]--;return A;}int main(){cin>>i;V<W>p(i);while(i--,cin>>a>>b)p[i]={a+M,b+M};W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include<stdio.h>
int main(void)
{

        int a=0,b,c,s=0,i=0,j=0;

        scanf("%d%d%d",&a,&b,&c);

        a-= b + c*2;

        for(i=0;a>=0;i++)a-=b+c;

        printf("%d\n",i);

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    string res;
    for(int64_t i=s.size()-1; i>=0; i--){
        string sub = s.substr(0,i);
        string sub2 = s.substr(0,i/2);
        if(sub == sub2 + sub2){
            cout << sub.size() << endl;
            break;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

struct edge { ll to, from, cost; };
edge es[MAX_M];
ll d[MAX_M];
ll V, E;
bool bellmanford(int s) {
	repe(i, 1, V)d[i] = INF;
	d[s] = 0;
	ll k = 0;
	rep(k, 0, 2 * V) {
		bool update = false;
		repe(i, 1, E) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (k > V && e.to == V) {
					return true;
				}
			}
		}
	}

	return false;
}

int main() {
	cin >> V >> E;
	repe(i, 1, E) {
		ll a, b, c; cin >> a >> b >> c;
		edge e;
		e.from = a;
		e.to = b;
		e.cost = -c;
		es[i] = e;
	}
	if (!bellmanford(1)) {
		cout << -d[V] << endl;
	}
	else {
		cout << "inf" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int vis[maxn][maxn];
int main(){
	int n, m; cin >> n >> m;
	vector<string> g(n); for(auto & i : g) cin >> i;
	vector<pair<int,int> > q, nq;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) if(g[i][j] == '#') q.push_back({i, j}), vis[i][j] = 1;
	for(int i = 0; ; i++){
		for(auto e : q){
			int x, y; tie(x, y) = e;
			for(int di = -1; di <= 1; di++){
				for(int dj = -1; dj <= 1; dj++){
					if(abs(di) + abs(dj) != 1) continue;
					int nx = x + di, ny = y + dj;
					if(nx >= 0 && nx < n && ny >= 0 && ny < m && !vis[nx][ny]) nq.push_back({nx, ny}), vis[nx][ny] = 1;
				}
			}
		}
		if(nq.empty()){
			cout << i << endl;
			return 0;
		}
		q = nq;
		nq.clear();
	}
	return 0;
}


Measured memory_bytes: 17000
package main

import "fmt"

func main() {
        var n, max, maxN int
        fmt.Scan(&n)
        for i := 1; i <= n; i++ {
                tmp := i
                num := 1
                for tmp > 0 && tmp%2 == 0 {
                        tmp /= 2
                        num++
                }
                if num > max {
                        maxN = i
                        max = num
                }
        }
        fmt.Printf("%d\n", maxN)
}

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

int64_t solve(int64_t n, int64_t m, int64_t q, vector<int64_t> &as, vector<int64_t> &bs, vector<int64_t> &cs, vector<int64_t> &ds, vector<int64_t> &nv, int64_t now = 0, int64_t last = 1)
{
	if (nv.size() == n)
	{
		return now;
	}

	int64_t score = 0;
	for (int64_t i = last; i <= m; i++)
	{
		nv.emplace_back(i);

		int64_t tmp = 0;
		for (int64_t j = 0; j < q; j++)
		{
			if ((bs[j] < nv.size()) && (nv[bs[j]] - nv[as[j]] == cs[j]))
			{
				tmp += ds[j];
			}
		}

		score = max(score, solve(n, m, q, as, bs, cs, ds, nv, tmp, i));

		nv.pop_back();
	}

	return score;
}

int main()
{
	int64_t n, m, q;
	cin >> n >> m >> q;
	vector<int64_t> as(q), bs(q), cs(q), ds(q);
	for (int64_t i = 0; i < q; i++)
	{
		cin >> as[i] >> bs[i] >> cs[i] >> ds[i];
		as[i]--;
		bs[i]--;
	}

	vector<int64_t> nv;

	cout << solve(n, m, q, as, bs, cs, ds, nv) << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int size;
  double *seq;
  double child=0;
  scanf("%d",&size);

  if((seq=malloc(size*sizeof(double)))==NULL){
    printf("error");
    exit(1);
  }

  for(int i=0;i<size;i++){
    scanf("%lf",&seq[i]);
    child+=(1.0/seq[i]);
  }

  printf("%f\n",1.0/child);

  free((void *)seq);

  return 0;
}


Measured memory_bytes: 128
unittest
{
	assert( [ "11 16", "11 17" ].parse.expand.solve == 0 );
	assert( [ "11 30", "12 1" ].parse.expand.solve == 1 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto md1 = input.front.split.to!( long[] );
	input.popFront;
	auto md2 = input.front.split.to!( long[] );
	return tuple( md1[ 0 ], md2[ 0 ] );
}

auto solve( long m1, long m2 )
{
	return ( m1 == m2 ) ? 0 : 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7
typedef long long ll; 
typedef vector<long long> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si; 
typedef map<string, int> msi; 

int main(){
  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t,n;
   cin>>t>>n;
  if(n>=t) cout<<"unsafe\n";
  else cout<<"safe\n";
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int N=510;
int n,m,d;
const char s[]="RGBY";
int main(){
    cin>>n>>m>>d;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            putchar(s[(N+i+j)/d%2*2+(N+i-j)/d%2]);
		}
		puts("");
	}
}

Measured memory_bytes: 512
# -*- coding: utf-8
def powmod(x,y):
    res =1
    for i in range(y):
        res = res*x%1000000007
    return res
n = int(input())
ans = powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n)
ans %=1000000007
ans =(ans+1000000007)%1000000007
print(ans)

Measured memory_bytes: 62664
card_ = lambda:set([i for i in range(1, 14)])
n = int(input())
count = 0
card = {"S": card_(), "H": card_(), "C": card_(), "D": card_()}
while count < n:
    i = list(input().split(" "))
    card[i[0]] -= {int(i[1])}
    count += 1
 
mark = ["S", "H", "C", "D"]
for m in mark:
    for c in sorted(card[m]):
        print("%s %d" % (m, c))

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

/**
 * Created by Ayushi on 26 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        //ArrayList<String> arr = new ArrayList<>();
        //HashMap<String, Integer> hmap = new HashMap<>();
        Set<String> s = new HashSet<>();
        //int ans = 0;
        while (n-- > 0) {
            String a = br.readLine();
            s.add(a);
            /*if (!arr.contains(a)) {
                ans++;
                arr.add(a);
            }*/
        }
        br.close();
        System.out.println(s.size());
    }
}


Measured memory_bytes: 66016
#include <stdio.h>
#define N 100

int min(int a , int b)
{
	if(a < b) return a;
	else return b;
}

int main()
{
	int n , p[N+1] , m[N+1][N+1];
	scanf("%d",&n);
	for( int i = 1; i <= n; i++)
	{
		scanf("%d %d",&p[i-1],&p[i]);
	}
		for(int i = 1; i <= n; i++) m[i][i] = 0;
		for(int l = 2; l <= n; l++)
		{
			for(int i = 1; i <= n - l + 1; i++)
			{
				int j = i + l -1;
				m[i][j] = ( 1 << 21);
				for(int k = i; k <= j -1 ; k++)
				{
					m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
				}
			}
		}
		printf("%d\n",m[1][n]);
		return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
      cin >> v[i];
  }
  int b,e,k,q;
  cin >> q;
  for(int i=0; i<q; i++) {
      int cnt=0;
      cin >> b >> e >> k;
      for(int i=b; i<e; i++) {
          if(v[i]==k) {
              cnt++;
          }
      }
      cout << cnt << endl;
  }
}


Measured memory_bytes: 3116
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a)) if all((a, b)) else a if a else b
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
done = set()
total = 1
for (a, b), v in d.items():
    if (b, -a) in done or (-b, a) in done:
        continue
    done.add((a, b))
    w = d.get((b, -a), 0) + d.get((-b, a), 0)
    total = total * (pow(2, v, MOD) + pow(2, w, MOD) - 1) % MOD
print((total + zeros + MOD - 1) % MOD)

Measured memory_bytes: 72012
s = input()
n = len(s)

ans = [0] * n

cnt = 0
for i in range(n):
  if s[i] == 'R':
    cnt += 1
  else:
    ans[i-1] += cnt//2 + (cnt % 2)
    ans[i] += cnt//2
    cnt = 0

for i in range(n):
  if s[-1-i] == 'L':
    cnt += 1
  else:
    ans[-i] += cnt//2 + (cnt % 2)
    ans[-1-i] += cnt//2
    cnt = 0

print(" ".join([str(a) for a in ans]))

Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long L,R;
  cin >> L >> R;
  if (R - L > 2020) {
    cout << 0 << endl;
  }
  else {
    long long ans = 1000000000;
    for (long long i = L; i <= R; i++) {
      for (long long j = L; j <= R;j++ ) {
        if (i <  j) {
          
          ans = min(ans,(i*j) % 2019);
        }
      }
    }
    cout << ans << endl;
  }
}




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

int main(void){
	int N,M;
	string s;
	bool locked=true;
	map<string,bool> ID;

	cin>>N;
	rep(i,N){
		cin>>s;
		ID[s]=true;
	}

	cin>>M;
	rep(i,M){
		cin>>s;
		if(ID[s]){
			cout<<(locked ? "Opened" : "Closed")<<" by "<<s<<endl;
			locked = !locked;
		}else {
			cout<<"Unknown "<<s<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1240
# A - AKIBA
S = str(input())

# 文字列からAを抜いて KIHBRになればOK

if S.find('AA') == -1 :
    if S.find('KA') == -1 :
        if S.find('IA') == -1:
            S2 = S.replace('A','')
            if S2 == 'KIHBR':
                print('YES')
            else:
                print('NO')
        else:
            print('NO')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 3060
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin>>s;
	i = 0;
	j = s.length()-1;
	n = s.length();
	bool flag = true;
	while(i<j){
		if(s[i] != s[j]){
			flag = false;
		}
		i++;
		j--;
	}
	s = "#" + s;
	i = 1;
	j = (n-1)/2;
	while(i<j){
		if(s[i] != s[j]){
			flag = false;
		}
		i++;
		j--;
	}
	i = (n+3)/2;
	j = n;
	while(i < j){
		if(s[i] != s[j]){
			flag = false;
		}
		i++;
		j--;
	}
	if(flag){
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
}
//.........

Measured memory_bytes: 256
y = [31,29,31,30,31,30,31,31,30,31,30,31]
dow = {0:"Monday", 1:"Tuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"}

while True:
    m, d = map(int, raw_input().split())
    if m == 0 and d == 0:
        break
    n = 0
    for i in range(m):
        n += y[i]
    n -= (y[m-1]-d+1)
    print dow[(n+3)%7]

Measured memory_bytes: 4228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(a>b) {
			for(int i=0; i<a; i++) {
				System.out.print(b);
			}
		}else {
			for(int i=0; i<b; i++) {
				System.out.print(a);
			}
		}
	}

}

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

int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int n, m;
	cin >> n >> m;
	
	int sum = 0;
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		sum += a;
	}
	if(n - sum >= 0) cout << n - sum << "\n";
	else cout << "-1" << "\n";
	return 0;
	 
 }        


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int toint(char ch)
{
  return ch - '0';
}

int eval_expr(const char* buf)
{
  int total = toint(buf[0]);
  for(size_t i = 1; i < strlen(buf); i += 2) {
    switch(buf[i]) {
      case '+':
        total += toint(buf[i+1]);
        break;
      case '-':
        total -= toint(buf[i+1]);
        break;
      default:
        fprintf(stderr, "eval_expr: Unknown operator found: %c\n", buf[i]);
        exit(1);
    }
  }
  return total;
}

int next_expr(char* buf)
{
  for(size_t i = 1; i < strlen(buf); i += 2) {
    switch(buf[i]) {
      case '+':
        buf[i] = '-';
        return 0;
      case '-':
        buf[i] = '+';
        continue;
      default:
        fprintf(stderr, "next_expr: Unknown operator: %c\n", buf[i]);
        exit(1);
    }
  }
  return 1;
}

int main()
{
  char buf[8];
  memset(buf, 0, sizeof(buf));
  for(int i = 0; i < 4; i++) {
    buf[2*i] = fgetc(stdin);
    buf[2*i+1] = '+';
  }
  // clear last operator
  buf[strlen(buf)-1] = '\0';

  while(1) {
    int val = eval_expr(buf);
    if(val == 7) {
      printf("%s=7\n", buf);
      break;
    }
    if(next_expr(buf)) {
      fputs("Not found\n", stderr);
      exit(1);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i < n; i++) 
	{
		ans += i;
	}


	cout << ans << endl;

}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;

vector<int> g[M];
int n, m;
int vis[M];


int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(vis, 0, sizeof(vis));
	queue<int> q;
	q.push(1);
	vis[1] = true;
	while(!q.empty()) {
		int cur = q.front();
		q.pop();
		for(int i : g[cur]) {
			if(!vis[i]) {
				vis[i] = cur;
				q.push(i);
			}
		}
	}
	printf("Yes\n");
	for(int i = 2; i <= n; i++) {
		printf("%d\n", vis[i]);
	}
  return 0;
}


Measured memory_bytes: 10604
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var k = parseInt(input[1], 10);

    var ans = 1;
    for (var i = 0; i < n; i++) {
        if (ans < k) {
            ans *= 2;
        }
        else {
            ans += k;
        }
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 12236
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;



int main(void){

int w, h;
string ss;
	while(cin >> h >> w ){
		if(h==0 && w==0 || cin.eof()) break;
		vector<string> bd(h);
		vector<vector<char> > lc(h,vector<char>(w,' '));
		rep(i,h) cin >> bd[i];
		int y=0, x=0, loop=0;
		while(1){
			if(x<0 || y<0 || x>=w || y >=h) {loop=99;break;}
			if(lc[y][x]=='z'){ loop=1; break; }
			lc[y][x] = 'z';
			if(bd[y][x]=='.') break;
			else if(bd[y][x]=='>') x++;
			else if(bd[y][x]=='<') x--;
			else if(bd[y][x]=='^') y--;
			else if(bd[y][x]=='v') y++;
		}
		if(loop>0 && loop < 90) cout << "LOOP" << endl;
		else if(loop==0) cout << x << " " << y << endl;
	}
	return 0;
	
}

Measured memory_bytes: 1268
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int d;
vector<vector<int>> s(365,vector<int>(26));
vector<int> c(26);

ll calc(vector<int> t,int k){
    ll score=0;
    vector<int> last(26);
    for(int i=0;i<(int)t.size();i++){
        last[t[i]]=i;
        for(int j=0;j<26;j++) score-=c[j]*(i+1-last[j]);
        score+=s[i][t[i]];
    }
    for(int i=(int)t.size();i<min(d,(int)t.size()+k);i++){
        for(int j=0;j<26;j++) score-=c[j]*(i+1-last[j]);
    }
    return score;
}

void solve(){
    vector<int> v;
    for(int i=0;i<d;i++){
        ll max_score=-1e9;
        int b=0;
        for(int j=0;j<26;j++){
            v.push_back(j);
            ll score=calc(v,9);
            if(max_score<score){
                max_score=score;
                b=j;
            }
            v.pop_back();
        }
        v.push_back(b);
    }
    for(int k : v) cout<<k+1<<endl;
}

int main(){
    cin>>d;
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    solve();
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
	int o;
	cin>>o;
	for(int i=1;i<=o;i++){
		long long a,b;
		cin>>a>>b;
		if(a<b) swap(a,b);
		long long r=1000000000,l=0;
		while(r-l>1){
			long long m=(r+l)/2;
			if(m*m<a*b) l=m;
			else
			r=m;
		}
		long long s=0;
		if(l*(l+1)<a*b) s=l*2;
		else
		s=l*2-1;
		if(a<=l) s--;
		if(b<=l) s--;
		cout<<s<<endl;
	}
}

Measured memory_bytes: 3576
a,b=map(int,input().split())
x=0
y=0
z=0
m=0
if(b//1000<a or b//10000>a):
	print("-1 -1 -1")
else:	
	c=(b//1000)-a
	for i in range(0,a+1):
		if((c-(4*i))%9==0):
			y=i
			z=(c-(4*i))//9
			break
		m+=1
	if(m==a and a!=y):
		print("-1 -1 -1")
	else:
		if(a-z-y<0 or z<0 or y<0):
			print("-1 -1 -1")
		else:	
			print(z,y,a-z-y)	





Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  	string s; cin>>s;
  	if(s[2]==s[3]&&s[4]==s[5])
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
      
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
 
map<char,vector<int>>m3;
string s,t;
int binarySearch(int i,int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
 
        // Check if x is present at mid
        if ((m3[t[i]][m]<=x)&&(m3[t[i]][m+1]>x))
            return m+1;
 
        // If x greater, ignore left half
        if (m3[t[i]][m] < x)
            l = m + 1;
 
        // If x is smaller, ignore right half
        else
            r = m - 1;
    }
  return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    map<char,int>m1,m2;
    for(int i=0;i<n;i++){
        m1[s[i]]=1;
    }
    for(int i=0;i<m;i++){
        m2[t[i]]=1;
    }
    map<char,int>::iterator it=m2.begin();
    for(it;it!=m2.end();it++){
        if(m1[it->first]!=1){cout<<-1<<endl;return 0;}
    }
    for(int i=0;i<n;i++){
        m3[s[i]].push_back(i);
    }
    map<char,vector<int>>::iterator it1=m3.begin();
    for(it1;it1!=m3.end();it1++){
        sort((it1->second).begin(),(it1->second).end());
    }
    ll res=0;
    int last=0;
    for(int i=0;i<m;i++){
        if(i==0){res+=ll(1+m3[t[0]][0]);last=m3[t[0]][0];continue;}
        int taille=m3[t[i]].size();
        int el=0;
        if(last>=m3[t[i]][taille-1])el=m3[t[i]][0];
        else{el=m3[t[i]][binarySearch(i,0,taille-1,last)];}
        if(el>last){res+=ll(el-last);}
        else{res+=ll(el+1);res+=ll(n-last-1);}
        last=el;
    }
    cout<<res<<endl;
    return 0;
    }

Measured memory_bytes: 1232
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int r,g,b;
	div_t d;
	scanf("%d %d %d", &r, &g, &b);
	d = div(r*100 + g*10 + b, 4);
	if(d.rem == 0) {
		printf("YES\n");
	} else if(d.rem == 1 || d.rem == 2 || d.rem == 3) {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128