akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 2e5 + 10;
const int Mod = 1e9 + 7;
const int oo = 1e9;

int n, m;
map <int, int> vf;

int main()
{
/**
    #ifndef ONLINE_JUDGE

        ifstream cin("test.in");

    #endif // ONLINE_JUDGE
*/

    cin >> n;

    long long ans = 0, x;
    for(int i = 1; i <= n; i++)
    {
        cin >> x;
        ans += vf[(i - x > 0 ? i - x : 0)];
        vf[x + i] ++;
    }

    cout << ans;
    return 0;
}


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

int main() {
	int n;
	string a,b,c;
	cin >> n;
	cin >> a;
	cin >> b;
	for(int i=0;i<n;++i){
		c.push_back(a[i]);
		c.push_back(b[i]);
	}
	cout << c << endl;
	
return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

struct Node {
	char c;
	Node * next;
	Node * pre;
	Node(char v) : c(v), next(NULL), pre(NULL){}
};


Node* head, * tail;
bool first = false;

void insertAtEnd(char c) {
	Node* newnode = new Node(c);

	if (tail != NULL) { 
		tail->next = newnode;
		newnode->pre = tail;
	} else {
		head = newnode;
	}

	tail = newnode;
}

void insertAtStart(char c) {
	Node * newnode = new Node(c);
	//cout << "created new node: " << newnode->c <<"\n";
	newnode->next = head;
	head->pre = newnode;

	head = newnode;
}

void reverse() {
//	cout << head->c << " " << tail->c << "\n";
	// Node * temp = head;
	// head = tail;
	// tail = temp;
	//cout << head->c << " " << tail->c << "\n";
} 

void print() {
	if (first) {
		Node * t = head;
		while (t != NULL) {
			cout << t->c;
			t = t->next;
		}
	} else {
		Node * t = tail;
		while (t) {
			cout << t->c;
			t = t->pre;
		}
	}
	cout << "\n";
}
void testcase() {
    head = tail = NULL;
    string s; cin >> s;

    for (char c : s)
    	insertAtEnd(c);

   // print();
    int q; cin >> q;
    first = true;
    while (q--) {
    	int t; cin >> t;
    	if (t==1) {
    		first = !first;
    		reverse();
    	} else {
    		int f; char c;
    		cin >> f >> c;
    		if (f==1) {
    			if (first)
    				insertAtStart(c);
    			else 
    				insertAtEnd(c);
    		} else {
    			if (first)
    				insertAtEnd(c);
    			else
    				insertAtStart(c);
    		}
    	}
    	//print();
    }

    print();
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

inline void Main() {
  int64_t n, r = 0; cin >> n;
  map< int64_t, int > p = prime_factor(n);
  for (auto& [k, v] : p) {
    int64_t tmp = 1;
    while (v - tmp >= 0) {
      r++;
      v -= tmp;
      tmp++;
    }
  }
  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3652
N = int(input())
locs = []
S = 0

for _ in range(N):
  locs.append(list(map(int,input().split())))
  
for i in range(N):
  for j in range(i+1,N):
    dis = ((locs[i][0]-locs[j][0])**2 + (locs[i][1]-locs[j][1])**2)**(1/2)
    S += dis

print(2*S/N)

Measured memory_bytes: 9448
#include <iostream>

using namespace std;

int main() {
  int H, W;
  while (1) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i%2 == j%2) cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, D;
int X[220000], Y[220000];
signed main() {
    cin >> N >> D;
    rep(i, N) { cin >> X[i] >> Y[i]; }
    int ans = 0;
    rep(i, N) {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D) { ans++; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6716
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
ans = []
for i in range(1,N):
    candind = bisect.bisect_left(a,a[i]/2)
    if candind == i:
        candind -= 1
        cand = a[candind]
    elif candind == 0:
        cand = a[candind]
    else:
        if a[candind]-a[i]/2 <= a[i]/2-a[candind-1]:
            cand = a[candind]
        else:
            cand = a[candind-1]
    ans.append([a[i],cand])
ans.sort(reverse=True)
x1 = ans[0][1]
ans2 = [ans[0]]
for i in range(1,len(ans)):
    if x1 >= ans[i][1]:
        break
    ans2.append(ans[i])
    x1 = ans[i][1]
print(*ans2[-1])
    
    

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

int A[6],B[6];

// {{{ Solve
bool dfs(int fieldL, int fieldR, int count, int a, int b, bool pSkip){
	// {{{ 葉に到達したときのみ呼び出し
		if(a==0) return true;
		else if(b==0) return false;
	// }}}
	int ret=0;
	int flag=0;

	if(count%2){
		// Bのターン
		for(int i=0; i<6; i++){
			if(B[i]-fieldR==1){
				flag++;

				int next=B[i];
				//printf("B[%d]: %d\n",count,next);

				B[i]=-1;
				ret+=dfs(fieldL, next, count+1, a, b-1, false);
				B[i]=next;

			}else if(fieldL-B[i]==1){
				flag++;

				int next=B[i];
				//printf("B[%d]: %d\n",count,next);

				B[i]=-1;
				ret=dfs(next, fieldR, count+1, a, b-1, false);
				B[i]=next;
			}
		}
		if(flag==false){
			flag=1;
			// skip せざるを得ない
			if(pSkip==true){
				// Aがスキップした次にBもスキップするってどゆこと？　詰んでるやん
				cout<<"???"<<endl;
				exit(1);
			}
			//printf("B[%d] -skip\n",count);
			ret+=dfs(fieldL, fieldR, count+1, a, b, true);
		}

		// Bの如何なる選択においても必勝でないといけないので
		if(flag==ret)return true;
		else return false;

	}else{
		// Aのターン
		// {{{ Bの逆バージョンなので見る必要なし
		for(int i=0; i<6; i++){
			if(A[i]-fieldR==1){
				flag++;

				int next=A[i];
				//printf("A[%d]: %d\n",count,next);

				A[i]=-1;
				ret+=dfs(fieldL, next, count+1, a-1, b, false);
				A[i]=next;

			}else if(fieldL-A[i]==1){
				flag++;

				int next=A[i];
				//printf("A[%d]: %d\n",count,next);

				A[i]=-1;
				ret=dfs(next, fieldR, count+1, a-1, b, false);
				A[i]=next;
			}
		}
		if(flag==false){
			flag=1;
			 //skip せざるを得ない
			if(pSkip==true){
				cout<<"?"<<endl;
				exit(1);
			}
			//printf("A[%d] -skip\n",count);
			ret+=dfs(fieldL, fieldR, count+1, a, b,true);
		}
		// }}}

		// 勝ち筋1本でもあればいいので
		if(ret)return true;
		else return false;
	}


}
// }}}


int main(){
	int n;	cin>>n;
	for(int g=0; g<n; g++){
		// {{{ input
		vector<bool> used(14,false);
		used[7]=true;
		for(int i=0; i<6; i++){
			cin>>A[i];
			used[A[i]]=true;
		}

		int pos=0;
		for(int i=1; i<=13; i++){
			if(used[i]==false){
				B[pos]=i;
				pos++;
			}
		}
		// }}}

		bool flag=false;
		bool ans=false;

		// {{{ A・最初の1手を探す
		for(int i=0; i<6; i++){
			if(7-A[i]==1){
				flag=true;
				int next=A[i];	// next = 6
			//printf("A[0]: %d\n",next);

				A[i]=-1;
				ans=dfs(next,7,		1,5,6, false);
				A[i]=next;

			}else if(7-A[i]==-1){
				flag=true;

				int next=A[i];	// next = 8
			//printf("A[0]: %d\n",next);

				A[i]=-1;
				ans=dfs(7,next,		1,5,6, false);
				A[i]=next;
			}

				//printf("[%d]: %c\n",A[i],(ans? 'Y':'N'));
			// 勝ち確定の1手がひとつでもあるんなら、以降もう処理しなくていいよね！
			if(ans==true)break;
		}

		if(flag==false){
			//printf("A[0] -skip\n");
			ans=dfs(7,7,	1,6,6, true);
		}
		// }}}


		if(ans==true){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}

	}

	return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define pb(x) push_back(x)
#define HAYAKU_HAYAKU ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    HAYAKU_HAYAKU; 
    int n,ans = 0;
    cin>>n;
    string s;
    cin>>s;
    for (int i = 0; i < n-2; i++)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#define MAX 100001

using namespace std;

int main() {
  bool didAppear[MAX];
  for (int i = 0; i < MAX; i++) {
    didAppear[i] = false;
  }
  int N;
  vector<int> inputs;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int input;
    cin >> input;
    inputs.push_back(input);
  }

  int numDifferent = 0;
  for (int i = 0; i < N; i++) {
    int input = inputs[i];
    if (!didAppear[input]) {
      numDifferent++;
      didAppear[input] = true;
    }
  }

  if (numDifferent % 2 == 0) numDifferent -= 1;

  cout << numDifferent << endl;
  return 0;
}


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

int main(){
    ll n, m, t;
    vector<ll> a, b;
    cin >> n;
    for(auto i = 0; i < n; i++){
        cin >> t;
        a.push_back(t);
    }
    cin >> m;
    for(auto i = 0; i < m; i++){
        cin >> t;
        b.push_back(t);
    }
    cout << (int)includes(a.begin(), a.end(), b.begin(), b.end()) << endl;
    return 0;
}


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

int main()
{
    long N, A, B;
    long ANS1, ANS2, ANS3;

    cin >> N >> A >> B;

    if ((B - A) % 2 == 0){
        ANS1 = (A + B - 2) / 2;
        ANS2 = N - (A + B -2) / 2;
        ANS3 = (B - A) / 2;

    }
    else{
        ANS1 = (A + B - 1) / 2;
        ANS2 = N - (A + B - 1) / 2;
        ANS3 = N;
    }

    if (ANS1 < ANS2){
        if(ANS3 < ANS1)
            cout << ANS3;
        else
            cout << ANS1;
    }
    else{
        if(ANS3 < ANS2)
            cout << ANS3;
        else
            cout << ANS2;
    }
    
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N,0);
  for(int i=0;i<N;i++) cin >> P[i];

  int saidai=0;
  for(int i=0;i<N;i++) saidai=max(saidai,P[i]);

  int sum=0;
  for(int i=0;i<N;i++) sum +=P[i];
  
   sum=sum-saidai/2;
  
  cout << sum <<endl;
 

}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int arrSize = in.nextInt(), array[] = new int[arrSize];
		for(int i = 0; i < arrSize; i++) {
			array[i] = Integer.parseInt(in.next());
		}

		int query = in.nextInt();
		for(int i = 0; i < query; i++) {
			int begin = Integer.parseInt(in.next()), end = Integer.parseInt(in.next()), k = Integer.parseInt(in.next());

			int count = 0;
			for(int j = begin; j < end; j++) {
				if(array[j] == k)count++;
			}
			out.println(count);
		}
		out.flush();
		in.close();
	}

}



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

 int main() {
   vector<vector<char>> data(3,vector<char>(3));
   
   for(int i = 0; i < 3;i++){
     for(int j = 0;j < 3;j++){
       cin >> data.at(i).at(j);
     }
   }
   for(int i = 0; i < 3;i++){
     for(int j = 0;j < 3;j++){
       //cout << data.at(i).at(j);
       if(i == j){
         cout << data.at(i).at(j);
       }
      /* if (j == 2) {
        cout << endl;  // 行末なら改行
      }  */   
     }     
   }                            
 }

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void){
	int a[MAX][MAX], b[MAX][MAX], i, j, k, n, m, l;
	long c[MAX][MAX];
	scanf("%d %d %d", &n, &m, &l);
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d", &a[i][j]);
		}
	}

	for(j = 0; j < m; j++){
		for(k = 0; k < l; k++){
			scanf("%d", &b[j][k]);
		}
	}

	for(i = 0; i < n; i++){
		for(k = 0; k < l; k++){
			c[i][k] = 0;
			for(j = 0; j < m; j++){
				c[i][k] += a[i][j] * b[j][k];
			}
		}
	}

	for(i = 0; i < n; i++){
		for(k = 0; k < l; k++){
			if(k != l - 1){
				printf("%ld ", c[i][k]);
			}
			else{
				printf("%ld\n", c[i][k]);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 756
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 230, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int g[maxn][maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll k, ans = 0;
	for(int i = 0; i <= 200; i++)
		for(int j = 0; j <= 200; j++)
			g[i][j] = i==0&&j==0?0:__gcd(i, j);
	cin >> k;
	for(int i = 1; i <= k; i++)
		for(int j = 1; j <= k; j++)
			for(int z = 1; z <= k; z++)
				ans += g[i][g[j][z]];
	cout << ans;
	return 0;
}


Measured memory_bytes: 3844
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String s = sc.next();
        
        if (a >= 3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N, M;
	cin >> N >> M;

	long long ans = 1;

	long long bv = 1000000007;

	if (abs(N - M) > 1) {
		cout << 0 << endl;
	}
	else if (abs(N - M) == 1) {
		for (long long i = 1; i <= N; i++) {
			ans *= i;
			ans %= bv;
		}
		for (long long i = 1; i <= M; i++) {
			ans *= i;
			ans %= bv;
		}
		cout << ans << endl;
	}
	else {
		ans = 2;
		for (long long i = 1; i <= N; i++) {
			ans *= i;
			ans %= bv;
		}
		for (long long i = 1; i <= M; i++) {
			ans *= i;
			ans %= bv;
		}
		cout << ans << endl;
	}

	

	return 0;
}

Measured memory_bytes: 3484
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{int a,b,c,x,y;
 cin>>a>>b>>c>>x>>y;
 if(x>y){
 int z=2*y;
 int half1=z*c;
 int d=x-y;
 int half2=d*a;
 int ans1=half1+half2;
 int reans1=a*x+b*y;
 int woans1=x*2*c;
 cout<<min(ans1,min(reans1,woans1))<<endl;
 }
 else if(y>x)
 {int v=2*x;
  int s1=v*c;
  int d2=y-x;
  int s2=d2*b;
  int ans2=s1+s2;
  int reans2=a*x+b*y;
  int woans2=y*2*c;
  cout<<min(ans2,min(reans2,woans2))<<endl;
  }
 else if(x==y)
 {int reans3=(a+b)*x;
  cout<<min(x*2*c,reans3)<<endl;
 }
 system("pause");
 return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String S=sc.next();

    	int index=S.lastIndexOf("FESTIVAL");


    	String result=S.substring(0,index);

    	System.out.println(result);
    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int N=5;
    vector<int>time={a,b,c,d,e};
    vector<int>index={0,1,2,3,4};
    int bestTime=(int)1e9;//10の9乗

    do{
        int Nowtime=0;
        for(int i=0;i<N;i++){
            while(Nowtime%10!=0)Nowtime++;
            Nowtime+=time[index[i]];
        }
        bestTime=min(Nowtime,bestTime);
    }while(next_permutation(index.begin(),index.end()));
    cout<<bestTime<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long long n;
  long long t[100001] = {};
  long long a[100001] = {};
  long long prev_t = 0;
  long long prev_a;
  long long ans = 1;
  cin >> n;
  for (long long i = 0;i<n;i++) {
    long long tmp;
    cin >> tmp;
    t[i] = tmp;
  }
  for (long long i = 0;i<n;i++) {
    long long tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  a[n] = 0;
  if (n==0) {
    if (t[0] == a[0]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return(0);
  }
  prev_a = a[1];
  for (long long i = 0;i<n;i++) {
    if (prev_t != t[i] && prev_a != a[i]) {
      if (t[i] != a[i]) {
	ans = 0;
	break;
      } 
    } else if (prev_t != t[i] && t[i] > a[i]) {
      ans = 0;
      break;
    } else if (prev_a != a[i] && a[i] > t[i]) {
      ans = 0;
      break;
    } else if (prev_t == t[i] && prev_a == a[i]) {
      long long tmp_h = t[i] < a[i]?t[i]:a[i];
      //      cout << i << "\t" << t[i] << "\t" << a[i] << "\t" << prev_t << "\t" << prev_a << endl;
      ans = ans * (tmp_h % 1000000007);
    }
    ans = ans % 1000000007;
    if (i < n-1) {
      prev_t = t[i];
      prev_a = a[i+2];
    }
  }
  cout << ans << endl;
  return(0);
}


Measured memory_bytes: 1792
#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 o, e;
  cin >> o >> e;

  rep(i, o.length()) {
    cout << o[i];
    if (i < e.length()) {
      cout << e[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    string s;
    if(abs(a - b) > abs(a - c))s = "B";
    else s = "A";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define FOR(i, n) for(int i = 0; i < (n); i++)

#define itn int

typedef uint64_t INT64;

int main()
{
    using namespace std;

    bool flg[26] = {false};

    string s;

    cin >> s;

    for(size_t i = 0; i < s.size(); i++)
    {
        flg[s[i] - 'a'] = true;
    }

    FOR(i, 26)
    {
        if(!flg[i])
        {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;
const long long int INF = 99999999999999999;
struct ab {
	long long int a, b;
};

bool cmp(ab x,ab y){
	return x.b < y.b;
}
int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	string str;
	long long int a,b,c,d,n,time=0,k;
	ab task[200005];
	cin >> n>>k;
	if ((n - 2) * (n - 1) / 2 < k) {
		cout << -1;
		return 0;
	}
	time = n * (n - 1) / 2 - k;
	cout << n * (n - 1) / 2 - k << endl;
	for (int i = 2; i <= n; i++) {
		cout << 1 << " " << i << endl;
		time--;

		if (time == 0) { return 0; }
	}
	for (int i = 2; i <= n-1; i++) {
		for (int j = i + 1; j <= n;j++) {
			cout << i << " " << j << endl;
			time--;
			if (time == 0) { return 0; }
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main()
{
	char s[201], t[101], p[101];

	scanf("%s %s", s, p);
	strcpy(t, s);
	strcat(s, t);

	if (strstr(s, p) == NULL)printf("No\n");
	else printf("Yes\n");

	return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1000000009)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void vout(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
//----------------------------------------START-------------------------------------------
const ll maxN = (ll)(1 * 1e5 + 5 );


void solve()
{
	ll n;
	cin >> n;
	if (400 <= n && n <= 599)cout << 8 << '\n';
	else if (600 <= n && n <= 799)cout << 7 << '\n';
	else if (800 <= n && n <= 999)cout << 6 << '\n';
	else if (1000 <= n && n <= 1199)cout << 5 << '\n';
	else if (1200 <= n && n <= 1399)cout << 4 << '\n';
	else if (1400 <= n && n <= 1599)cout << 3 << '\n';
	else if (1600 <= n && n <= 1799)cout << 2 << '\n';
	else if (1800 <= n && n <= 1999)cout << 1 << '\n';

}
int main()
{
	fast();
#ifndef ONLINE_JUDGE
	freopen ("inp1.txt", "r", stdin);
	freopen ("out1.txt", "w", stdout);
#endif
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, a, b;
vector<llint> vec;
vector<llint> comp;

int main(void)
{
	cin >> n >> a >> b;
	if(n < a+b-1 || n > a*b){
		cout << -1 << endl;
		return 0;
	}
	
	llint rem = n - b;
	for(int i = 1; i <= b; i++){
		llint x = min(rem, a-1);
		rem -= x;
		x++;
		for(int j = 0; j < x; j++) vec.push_back(-100000000LL*i+j);
	}
	for(int i = 0; i < vec.size(); i++) comp.push_back(vec[i]);
	sort(comp.begin(), comp.end());
	comp.erase(unique(comp.begin(), comp.end()), comp.end());
	for(int i = 0; i < vec.size(); i++) vec[i] = lower_bound(comp.begin(), comp.end(), vec[i]) - comp.begin() + 1;
	
	for(int i = 0; i < vec.size(); i++) cout << vec[i] << " "; cout << endl;
	
	return 0;
}


Measured memory_bytes: 12524
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, M; cin >> N >> M;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    
    ll ans = 0;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                vector<ll> V;
                for(int l=0; l<N; l++){
                    ll item_sum = 0;
                    if(i%2) item_sum += A[l];
                    else item_sum += -A[l];
                    if(j%2) item_sum += B[l];
                    else item_sum += -B[l];
                    if(k%2) item_sum += C[l];
                    else item_sum += -C[l];
                    V.push_back(item_sum);
                }
                sort(V.begin(), V.end());
                reverse(V.begin(), V.end());
                ll sum = 0;
                for(int l=0; l<M; l++){
                    sum += V[l];
                }
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
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();
		int x = sc.nextInt();
		String ans = "NO";

		if ((x - a) <= b && (x - a) >= 0) {
			ans = "YES";
		}

		System.out.println(ans);

		sc.close();
	}
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vi g[10010];
int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vi c(n);
    rep(i,n) cin >> c[i];
    sort(rall(c));

    vi ans(n);
    int idx = 0;
    queue<pii> Q;
    Q.emplace(0, -1);
    ans[0] = c[idx++];
    while(!Q.empty()){
        int v = Q.front().fi;
        int p = Q.front().se;
        Q.pop();
        for(auto u : g[v]){
            if(u == p) continue;
            ans[u] = c[idx++];
            Q.emplace(u, v);
        }
    }
    cout << accumulate(++c.begin(), c.end(), 0) << endl;
    cout << join(ans, " ") << endl;
    return 0;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
void Debug(auto a);
int Switch(int a,int b){
    if(a<0){
        if(b<0){
            return -1*a;
        }
        int x = -1*a*2+b;
        int y = -1*a+b*2;
        return min(x,y);
    }
    else{
        return b;
    }
}


signed main(){
    int n,k;
    cin >> n >> k;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    int mini = 1000000000;
    REP(i,n-k+1){
        int t = Switch(a[i],a[i+k-1]);
        mini = min(mini,t);
    }
    cout << mini << endl;


    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll X, A;
    cin >> X >> A;

    cout << (X < A  ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

using namespace std;
int binarySearch( int data[], int size, int key ){  
    int mid, left, right;  
    left = 0; // ??????  
    right = size; // ?????? + 1  
  
    while ( left < right ){  
        mid = ( left + right ) / 2; // ??????????????????????????????????±???????  
        if ( data[mid] == key ) return key; // ?????????????????????  
        else if ( key < data[mid] ) right = mid; // ????????¨??????  
        else left = mid + 1; // ????????¨??????  
    }  
  
    return -1; // ???????????????????????£???  
}  

int main()
{
   int n,q;
   int ans = 0;
   scanf("%d",&n);
   int s[n];
   for(int i=0; i<n; i++){scanf("%d", &s[i]);}
   scanf("%d",&q);
   int t[q];
   for(int i=0; i<q; i++){scanf("%d", &t[i]);}
   
   for(int i=0; i<q; i++){
       int result = binarySearch(s, n, t[i]);
       if(t[i]==result){ans = ans+1;}
   }
   printf("%d\n", ans);
   return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC138
    int N;

    cin>>N;

    vector<double> vec(N,0);
    for (int i = 0; i < N; i++)
    {
        cin>>vec[i];
    }

    for (int i = 0; i < N; i++)
    {
        vec[i]=1/vec[i];
    }

    double sum = 0;

    for (int i = 0; i < N; i++)
    {
        sum += vec[i];
    }

    sum = 1/sum;

    cout<<sum;
    
    
    
    

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char in[9][5]={
  {'.',',','!','?',' '},
  {'a','b','c'},
  {'d','e','f'},
  {'g','h','i'},
  {'j','k','l'},
  {'m','n','o'},
  {'p','q','r','s'},
  {'t','u','v'},
  {'w','x','y','z'},
};
int in1[9]={5,3,3,3,3,3,4,3,4};
int main(){
  int n;
  cin>>n;
  rep(j,n){
    string s;
    cin>>s;
    int i=0;
    while(i!=s.size()){
      int co=0;
      while(s[i]!='0'){
	co++;
	i++;
      }
      //cout<<co<<endl;
      if(co)cout<<in[s[i-1]-'0'-1][(co-1)%in1[s[i-1]-'0'-1]];
      i++;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int H, W;
string A[101];
//---------------------------------------------------------------------------------------------------
int check() {
    rep(y, 0, H) {
        int ok = 1;
        rep(x, 0, W) if (A[y][x] == '#') ok = 0;
        if (ok) {
            rep(yy, y + 1, H) swap(A[yy - 1], A[yy]);
            H--;
            return 1;
        }
    }

    rep(x, 0, W) {
        int ok = 1;
        rep(y, 0, H) if (A[y][x] == '#') ok = 0;
        if (ok) {
            rep(yy, 0, H) A[yy] = A[yy].substr(0, x) + A[yy].substr(x + 1);
            W--;
            return 1;
        }
    }

    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W;
    rep(y, 0, H) cin >> A[y];
    while (check());
    rep(y, 0, H) cout << A[y] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
	string a;
	string c[8] = { "black","blue","lime","aqua","red","fuchsia","yellow","white" };
	int d[8][3] = { {0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},
	{255,0,255},{255,255,0},{255,255,255} };
	while (cin>>a&&a!="0")
	{
		double t[3];
		for (int i = 1; i < a.length(); i += 2) {
			double b = 0;
			for (int j = 0; j <= 1; j++) {
				if ((int)a[i + j] >= '0' && (int)a[i +j] <= '9')
					b += (pow(16, (j+1)%2)*(int)(a[i +j] - '0'));
				else 
					b += (pow(16, (j+1)%2)*(10 + (int)a[i + j] - 'a'));
			}
			t[(i - 1) / 2] = b;
		}
		double e = 100000;
		string f = "";
		for (int i = 7; i >= 0; i--) {
			double g = sqrt(pow((t[0] - d[i][0]), 2) + pow((t[1] - d[i][1]), 2) + pow((t[2] - d[i][2]), 2));
			if (g <= e) {
				e = g;
				f = c[i];
			}
		}
		cout << f << endl;
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

bool is_sq(int a)
{
    for (int i = 0; i * i <= a; i++)
    {
        if (i * i == a)
            return true;
    }
    return false;
}

int main()
{
    int ans = 0, N, D;
    cin >> N >> D;
    vector<vector<int>> x(N, vector<int>(D));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> x[i][j];
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int sum = 0;
            for (int k = 0; k < D; k++)
            {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            ans += is_sq(sum);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b;
    int k;
    scanf("%d %d",&a,&b);

    if((a+b)%2==0){
        printf("%d",(a+b)/2);
    }
    else
    {
        printf("IMPOSSIBLE");

    }
    

  
    return 0;
}


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

int n;
int t[110];
int m;
int p[110];
int x[110];

signed main() {
	int time = 0;
	cin >> n;
	rep(i,n)
	{
		cin >> t[i];
		time += t[i];
	}
	cin >> m;
	rep(i,m)
	{
		cin >> p[i] >> x[i];
		p[i]--;
		cout << time - t[p[i]] + x[i] << endl;
	}
}


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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> price(12, 0);
  vector<vector<int>> add(N, vector<int> (M));
  for (int i = 0; i < N; i++) {
    cin >> price.at(i);
    for (int j = 0; j < M; j++) {
      cin >> add.at(i).at(j);
    }
  }
  int m = 0;
  for (int i = 0; i < N; i++) {
    m += price.at(i);
  }
  bool c = false;
  for (int k = 0; k < (1 << N); k++) {
    vector<int> sum(M, 0);
    bitset<12> buy(k);
    int total = 0;
    for  (int l = 0; l < 12; l++) {
      if (buy.test(l)) {
        total += price.at(l);
        for (int i = 0; i < M; i++) {
          sum.at(i) += add.at(l).at(i);
        }
      }
    }
    bool a = true;
    for (int i = 0; i < M; i++) {
      if (sum.at(i) < X) {
        a = false;
      }
    }
    if (a) {
      c = true;
      if (total < m) {
        m = total;
      }
    }
  }
  if (c) {
    cout << m << endl;
  }
  else {
    cout << -1 << endl;
  }  
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

void merge(long long a1[],int len_a1,long long a2[],int len_a2,long long a[],int b1[],int b2[],int b[]){
    int i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            b[i+j] = b1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            b[i+j] = b2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],int len_a,int b[]){
    if(len_a > 1){
        int m = len_a/2;
        int n = len_a - m;
        long long a1[m];
        long long a2[n];
        int b1[m];
        int b2[n];
        for(int i = 0;i < m;i++) a1[i] = a[i];
        for(int i = 0;i < n;i++) a2[i] = a[m+i];
        for(int i = 0;i < m;i++) b1[i] = b[i];
        for(int i = 0;i < n;i++) b2[i] = b[m+i];
        mergeSort(a1,m,b1);
        mergeSort(a2,n,b2);
        merge(a1,m,a2,n,a,b1,b2,b);
    }
}

//////////////////////////////////////////

int N,M;
long long A[100010];
int B[100010];

int main(){
    scanf("%d%d",&N,&M);
    for(int i = 0;i < N;i++){
        scanf("%lld%d",&A[i],&B[i]);
    }
    
    mergeSort(A,N,B);

    long long count = 0;

    int hon = 0;
    int keep = 0;
    int i = 0;

    while(hon < M){
        //printf("  %d\n",B[i]);
        while(keep < B[i] && hon < M){
            count += A[i];
            //printf("%lld %d\n",A[i],hon);
            keep++;
            hon++;
        }
        keep = 0;
        i++;
        //printf("%d\n",hon);
    }
    printf("%lld\n",count);
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


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

#define lugan "proP"
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _io ios_base::sync_with_stdio(0);   cin.tie(NULL); cout.tie(NULL);

using namespace std;

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

inline void initf()
{
    freopen(lugan".inp", "r", stdin);
    freopen(lugan".out", "w", stdout);
}

int n;
vector<int> g[N];
ll dp[N][3];

void enter()
{
    cin >> n;
    int u, v;
    for (int i=1; i<n; i++)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int p = -1)
{
    dp[u][0] = dp[u][1] = 1;
    for (int v : g[u])
    {
        if (v == p) continue;
        dfs(v, u);
        dp[u][0] *= (dp[v][0] + dp[v][1]);
        dp[u][1] *= dp[v][0];
        dp[u][0] %= oo;
        dp[u][1] %= oo;
    }
}

int main()
{
    _io
    ///initf();
    enter();
    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % oo;
    return 0;
}


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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

const ll INF = 1LL << 30;

int main()
{
    ll H, W;
    cin >> H >> W;

    set<pll> nodes;
    multiset<ll> costs;

    rep (i, W)
    {
        nodes.emplace(i, i);
        costs.emplace(0);
    }

    rep (y, H)
    {
        ll a, b;
        cin >> a >> b, --a, --b;

        ll newSrc = -1;
        const auto newDst = b + 1;

        // ひとつだけ残して削除する (TODO: 範囲削除)
        {
            auto it = nodes.lower_bound(pll(a, 0));
            while (it != nodes.end())
            {
                const auto src = it->second, dst = it->first;
                if (b < dst) { break; }

                // nodesとcostsは同期してるので必ずdst-srcな値があるはず
                costs.erase(costs.find(dst - src));
                it = nodes.erase(it);

                newSrc = max(newSrc, src);
            }
        }


        if (newSrc != -1 && newDst != W)
        {
            nodes.emplace(newDst, newSrc);
            costs.emplace(newDst - newSrc);
        }

        const auto cost = costs.begin() != costs.end() ? *costs.begin() : W;
        cout << (cost != W ? cost + y + 1 : -1) << endl;
    }

    return 0;
}


Measured memory_bytes: 25452
#include<iostream>
using namespace std;
long long solve(long long p) {
	long long q = p, cnt = 1;
	for (long long i = 2; i*i <= q; i++) {
		long long cnt2 = 0;
		while (p%i == 0) { p /= i; cnt2++; }
		cnt *= cnt2 * 2 + 1;
	}
	if (p >= 2)cnt *= 3;
	return cnt;
}
int main() {
	while (true) {
		long long n; cin >> n; if (n == 0)break;
		cout << (solve(n) + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std ;
int L[1000010] , R[1000010] , D[1000010] , bcj[1000010] ;
vector< pair< int , int > > v[1000010] ;
int d[1000010] ;
vector< int > vv[1000010] ;
bool vis[1000010] ;
int father( int x ){
    return bcj[x] == x ? x : bcj[x] = father( bcj[x] ) ;
}
void join( int x , int y ){
     int fx = father( x ) ;
     int fy = father( y ) ;
     if ( fx != fy ) bcj[fx] = fy ;
}
bool dfs( int x ){
     bool flag = true ;
     vis[x] = true ;
     for( int i = 0 ; i < v[x].size() ; i++ ){
         int f = v[x][i].first ;
         int s = v[x][i].second ;
         if ( vis[f] ){
             if ( d[f] == d[x] + s ) continue ;
             else return false ;
         }
         else{
             d[f] = d[x] + s ;
             flag &= dfs( f ) ;
         }
     }
     return flag ;
}
int main(){
    int N , M ;
    cin >> N >> M ;
    for( int i = 1 ; i <= N ; i++ )
        bcj[i] = i ;
    for( int i = 1 ; i <= M ; i++ ){
        scanf( "%d%d%d" , &L[i] , &R[i] , &D[i] ) ;
        v[L[i]].push_back( make_pair( R[i] , D[i] ) );
        v[R[i]].push_back( make_pair( L[i] , -D[i] ) ) ;
        join( L[i] , R[i] ) ;
    }
    for( int i = 1 ; i <= N ; i++ )
        bcj[i] = father( bcj[i] ) ;
    for( int i = 1 ; i <= N ; i++ )
        vv[bcj[i]].push_back( i ) ;
    bool flag = true ;
    for( int i = 1 ; i <= N ; i++ ){
        if ( vv[i].size() ){
            d[i] = 0 ;
            flag &= dfs( i ) ;
        }
    }
    if ( flag ) cout << "Yes" << endl ;
    else cout << "No" << endl ;
    return 0 ;
}

Measured memory_bytes: 70268
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    println(if (N % 1000 % 111 == 0 || (N / 10: Int) % 111 == 0) ("Yes") else ("No"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25668