akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
char sig[3]={'-','+','*'};
char g[50];
void swap(int *x,int *y){
	int z;
	z=*x;*x=*y;*y=z;
}
char* sign(char *x,char *y,int c){
	g[0]='\0';
	strcpy(g,"(");
	if(c<3)strcat(g,x); else strcat(g,y);
	switch(c%3){
	case 0: strcat(g," - "); break;
	case 1: strcat(g," + "); break;
	case 2: strcat(g," * "); break;
	}
	if(c<3)strcat(g,y); else strcat(g,x);
	strcat(g,")");
	return g;
}
int calc(int x,int y,int c){
	switch(c){
	case 0:return x-y;
	case 1:return x+y;
	case 2:return x*y;
	case 3:return y-x;
	}
	return 0;
}
int check(int a,int b,int c,int d,int o){
	int i,j,k;
	char p[50],q[50],r[50],s[50];
	sprintf(p,"%d",a);
	sprintf(q,"%d",b);
	sprintf(r,"%d",c);
	sprintf(s,"%d",d);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			for(k=0;k<4;k++){
				if(o){
					if(calc(calc(a,b,i),calc(c,d,j),k)==10){
						if(i==3)swap(&a,&b);
						if(j==3)swap(&c,&d);
						if(k==3){swap(&a,&c);swap(&b,&d);swap(&i,&j);}
						printf("((%d %c %d) %c (%d %c %d))\n",a,sig[i%3],b,sig[k%3],c,sig[j%3],d);
						return 1;}
				}

				if(calc(calc(calc(a,b,i),c,j),d,k)==10){
					strcpy(p,sign(p,q,i));
					strcpy(p,sign(p,r,j));
					strcpy(p,sign(p,s,k));
					printf("%s\n",p);return 1;}
			}
		}
	}
	return 0;
}
int main(void){
	int a,b,c,d;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF){
		if(a==0 && b==0 && c==0 && d==0)break;
		if(check(a,b,c,d,1))continue;
		if(check(a,c,b,d,1))continue;
		if(check(a,d,c,b,1))continue;
		if(check(c,d,a,b,0))continue;
		if(check(b,d,a,c,0))continue;
		if(check(b,c,a,d,0))continue;
		if(check(a,b,d,c,0))continue;
		if(check(a,c,d,b,0))continue;
		if(check(a,d,b,c,0))continue;
		if(check(c,d,b,a,0))continue;
		if(check(b,d,c,a,0))continue;
		if(check(b,c,d,a,0))continue;
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;

int main(){
  int n, m;

  while(cin >> n, n){
    int sum = 0;

    cin >> m;

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      sum += b - a;
    }

    if(sum >= n){
      cout << "OK\n";
    }
    else{
      cout << n - sum << endl;
    }
  }
}

Measured memory_bytes: 0
import sys
import itertools
h, w = map(int, sys.stdin.readline().split())
dp = [[0] * w for _ in range(h)]
G = [[int(j) for j in sys.stdin.readline().split()] for _ in range(h)]
for x in range(h):
    dp[x][0] = 1 if G[x][0] == 0 else 0
for y in range(w):
    dp[0][y] = 1 if G[0][y] == 0 else 0
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
print(max(max(i) for i in dp) ** 2)

Measured memory_bytes: 57816
import java.util.*;

class Main{
    //149c
    static final int DIV = 100000007;
    static final int MAX = 2000000000;
    static long[] num = new long[20];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int div;
        for(int i = a;i <= 100003;i++){
            div = 0;
            for(int j = 1;j <= i;j++){
                if(i%j==0)div++;
            }
            if(div==2){
                System.out.println(i);
                return;
            }
        }
    }
    
}

Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>
using namespace std;
char map[520][520];
int h,w;
int main(){
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			scanf("%c",&map[i][j]);
			while(map[i][j]=='\n'||map[i][j]==' '||map[i][j]=='\0'||map[i][j]=='\r')
				scanf("%c",&map[i][j]);	
			}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i%2==1){
				if(j!=w&&map[i][j]!='#'){
					map[i][j]='R';
				}
				else if(map[i][j]!='#')
					map[i][j]='B';
			}
			else{
				if(j!=1&&map[i][j]!='#'){
					map[i][j]='B';
				}
				else if(map[i][j]!='#')
					map[i][j]='R';
			}
		}
	}
/*	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
				printf("%c",map[i][j]);
			}
			printf("\n");
		}*/
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(map[i][j]=='#'||map[i][j]=='R')
				printf("#");
			else
				printf(".");}
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(map[i][j]=='#'||map[i][j]=='B')
				printf("#");
			else
				printf(".");}
		printf("\n");	
		}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, T, ans = INT_MAX;
  cin >> N >> T;
  for(int i = 0; i < N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T)ans = min(ans, c);
  }
  if(ans == INT_MAX) cout << "TLE" << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x = 0,cnt = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I')
        cnt++;
        if(s[i] == 'D')
        cnt--;
        if(x < cnt)
        {
            x = cnt;
        }
    }
    cout << x << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a,b,c;
int main(){
    cin >> a >> b >> c;
    cout << max(a,max(b,c)) - min(a,min(b,c)) << endl;
}

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

int main() {
  char A, B, C, D;
  scanf("%c%c%c%c", &A, &B, &C, &D);
  int a = A - '0', b = B - '0', c = C - '0', d = D - '0';
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < 2; j++) {
      for(int k = 0; k < 2; k++) {
        char op1 = (i == 0)? '+': '-', op2 = (j == 0)? '+': '-', op3 = (k == 0)? '+': '-';
        int sum = a;
        sum = i == 0? (sum + b): (sum - b);
        sum = j == 0? (sum + c): (sum - c);
        sum = k == 0? (sum + d): (sum - d);
        if(sum == 7) {
          printf("%d%c%d%c%d%c%d=7", a, op1, b, op2, c, op3, d);
          goto OUT;
        }
      }
    }
  }
  OUT:;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  int a,b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
  return 0;
}


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

using namespace std;

long long int gcd(long long int p,long long int q){
if(p % q == 0)return q;
 return gcd(q, p % q);
  }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int k;
	cin>>k;
	long long int ans=0;
	long long int m;
	for(long long int i=1;i<=k;i++){
		for(long long int j=1;j<=k;j++){
			for(long long int l=1;l<=k;l++){
				m=gcd(gcd(i,j),l);
				ans+=m;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if (d > t*s) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 35812
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010], B[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i <= N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += min(A[i], B[i]);
		B[i] = max(0, B[i] - A[i]);
		ans += min(A[i + 1], B[i]);
		A[i + 1] = max(0,A[i + 1] - B[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,a[100];
	cin >> n;
    fori(n)cin>>a[i];
    fori(n){
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 9
int main(){
  int x,y;
  scanf("%d %d", &x,&y);
  if(x<y){
    for(int i=0; i<y; i++){
      printf("%d", x);
    }}
	else if(x>y){
      for(int i=0; i<x; i++){
      printf("%d", y);
      }}
      else{
        for(int i=0; i<x; i++){
          printf("%d", x);
        }
      }
      printf("\n");
      return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
using namespace std;

int n, wt;
int v[100], w[100];
int a[101][10001];

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

	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];

	memset(a, 0, sizeof(a));

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= wt; j++) {
			if (j >= w[i - 1]) {
				if (a[i - 1][j - w[i - 1]] + v[i - 1] > a[i - 1][j])
					a[i][j] = a[i - 1][j - w[i - 1]] + v[i - 1];
				else
					a[i][j] = a[i - 1][j];
			}
			else
				a[i][j] = a[i - 1][j];
		}
	}

	cout << a[n][wt] << endl;

	return 0;
}


Measured memory_bytes: 7028
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int n,m,a,b;
  cin>>n>>m;
  vector<int>h(n);
  vector<bool>is_good(n,true);
  vector<list<int>> path(n);
  for(int i=0;i<n;i++){
      cin>>h[i];
  }
  for(int i=0;i<m;i++){
      cin>>a>>b;
      a--;
      b--;
      path[a].push_back(b);
  }
  int ans=0;
  for(int i=0;i<n;i++){
      for(auto itr=path[i].begin();itr!=path[i].end();itr++){
          if(h[i]>h[*itr]){
              is_good[*itr]=false;
          }
          else if(h[i]<h[*itr]){
              is_good[i]=false;
          }
          else{
              is_good[i]=false;
              is_good[*itr]=false;
          }
      }
  }
  for(int i=0;i<n;i++){
      if(is_good[i]){
   //       cout<<"good="<<i<<endl;
          ans++;
      }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8976
def main():
    R, G, B, N = [int(n) for n in input().split()]
    res = 0
    for r in range(3001):
        for g in range(3001):
            RG = R *r + G * g
            if RG > N:
                break
            elif (N - RG) % B == 0:
                res += 1
    print(res)

main()

Measured memory_bytes: 2940
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

tmp = 1
for i in a:
  tmp = (i//fractions.gcd(i, tmp)) * tmp

ans = 0
for i in a:
  ans += tmp//i
#print(tmp)
print(ans %mod)


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

int main(){
    int r;cin >> r;
    cout << 2*acos(-1)*r << endl;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include <math.h>

int main(void)
{
  int n,i,j,ans,no;

  while(1){
    scanf("%d", &n);
    if(!n) break;
    if(n==1){
      printf("1\n");
      continue;
    }
    ans=0;
    if(n%2==0){
      for(i=n+1;i<2*n+1;i+=2){
	if(i%2==0) continue;
	for(j=3;j<i/5+1;j+=2){
	  if(i%j==0){
	    no=1; break;
	  }
	}
	if(no==1){
	  no=0; continue;
	}
	ans++;
      }
    } else {
      for(i=n+2;i<2*n+1;i+=2){
	if(i%2==0) continue;
	for(j=3;j<sqrt(i)+1;j+=2){
	  if(i%j==0){
	    no=1; break;
	  }
	}
	if(no==1){
	  no=0; continue;
	}
	ans++;
      }
    }
    printf("%d\n", ans);
  }
    
  return 0;
}


Measured memory_bytes: 612
// https://atcoder.jp/contests/abc082/tasks/arc087_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 8000;

char s[S_MAX + 1];
int x, y;
int hl, vl;
vector<int> hs, vs;
int dp[S_MAX + 1];

bool execDP(vector<int> &vec, int w) {
  fill(dp, dp + w + 1, 0);
  dp[0] = 1;
  for (int x : vec) {
    for (int j = w; j >= x; j--) {
      dp[j] = max(dp[j], dp[j - x]);
    }
  }
  // DUMP(dp, w + 1);
  return dp[w] > 0;
}

void solve() {
  bool initial = true;
  bool isH = true;
  int h = 0;
  int v = 0;
  REP(i, strlen(s) + 1) {
    if (s[i] == 'T' || s[i] == '\0') {
      if (initial) {
        initial = false;
      } else {
        if (isH) {
          if (h > 0) hs.push_back(h);
          v = 0;
        } else {
          if (v > 0) vs.push_back(v);
          h = 0;
        }
      }
      isH = !isH;
    }
    if (s[i] == 'F') {
      if (initial) x--;
      else if (isH) { hl++; h++; }
      else { vl++; v++; }
    }
  }
  // printf("x:%d y:%d hl:%d vl:%d\n", x, y, hl, vl);
  hl += abs(x); vl += abs(y);
  if (hl % 2) { puts("No"); return; }
  if (vl % 2) { puts("No"); return; }
  if (!execDP(hs, hl / 2)) { puts("No"); return; }
  if (!execDP(vs, vl / 2)) { puts("No"); return; }
  puts("Yes");
}

void input() {
  scanf("%s", s);
  scanf("%d%d", &x, &y);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2;
	int a,b;
	cin >> a >> b;
	cin >> s3;
	if(s3 == s1) a--;
	else b--;
	cout << a << " " << b << endl; 
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
   lint n;
   lint countr=0;
   lint countg=0;
   lint countb=0;
   string s;
   cin>>n>>s;
   rep(i,s.size()){
       if(s[i]=='R')countr++;
       if(s[i]=='G')countg++;
       if(s[i]=='B')countb++;
   }
   lint ans=countr*countg*countb;
   lint countx=0;
    
   repp(i,1,n){
        rep(j,s.size()){
            if(s.size()-1<j+i*2)break;
                if(s[j]=='R'&&s[j+i]=='G'&&s[j+i*2]=='B')countx++;
                if(s[j]=='R'&&s[j+i]=='B'&&s[j+i*2]=='G')countx++;
                if(s[j]=='G'&&s[j+i]=='R'&&s[j+i*2]=='B')countx++;
                if(s[j]=='G'&&s[j+i]=='B'&&s[j+i*2]=='R')countx++;
                if(s[j]=='B'&&s[j+i]=='G'&&s[j+i*2]=='R')countx++;
                if(s[j]=='B'&&s[j+i]=='R'&&s[j+i*2]=='G')countx++;
        }
   }
    cout<<ans-countx;
  }
  
     


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007;
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;}
const int maxn=1e5+10;

int main()
{
    char ch[30];
    scanf("%s",ch);
    int l=strlen(ch);
    for(int i = 0; i < l; ++i) {
        if(ch[i]==',') printf(" ");
        else printf("%c",ch[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

h = 10**11+7
b = 10**7+7

H = [1]
for _ in range(N):
    H.append((H[-1]*b)%h)

allSum = 0
for i in range(N):
    allSum = (allSum + H[i]) % h

ok = [True]*N
ans = [0]*N

C = []
D = []
for i in range(N):
    C.append(A[i-1]^A[i])
    D.append(B[i-1]^B[i])


HashA = 0
for i, a in enumerate(C):
    HashA = (HashA + a*H[i]%h) % h

HashB = 0
for i, a in enumerate(D):
    HashB = (HashB + a*H[i]%h) % h

ans = []
for k in range(N):
    if HashA == HashB:
        ans.append(k)
    HashB = (HashB * b) % h
    HashB = (HashB + (1-H[N])*D[-k-1] % h) % h

for k in ans:
    print(k, A[k]^B[0])

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ans = 1;
    int N; cin >> N;
    string S[2]; cin >> S[0] >> S[1];
    int pos;
    if(S[0][0] == S[1][0]){
        ans = 3;
        pos = 1;
    }
    else{
        ans = 6;
        pos = 2;
    }
    while(pos < N){
        if(S[0][pos] == S[1][pos]){
            if(S[0][pos-1] == S[1][pos-1]){
                ans = (ans*2) % mod;
                //cout << pos << ": " << 2 << endl;
            }
            //else cout << pos << ": " << 1 << endl;
            pos++;
        }
        else{
            if(S[0][pos-1] == S[1][pos-1]){
                ans = (ans*2) % mod;
            }
            else{
                ans = (ans*3) % mod;
            }
            //cout << pos << ", " << pos+1 << ": " << 2 << endl;
            pos += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	if (b == 1) {
		cout << "0" << endl;
		return 0;
	}
	int x = a,cnt=1;
	while (x < b) {
		x += a;
		--x;
		++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s;
    vector<char> v;
    for (int i=0; i<4; i++) {
        v.push_back(s[i]);
    }
    sort(v.begin(), v.end());
    if (count(v.begin(), v.end(), v[0]) == 2 && count(v.begin(), v.end(), v[2]) == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 500010;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]);
    lint X = 0;
    For(i, 2, n) X ^= a[i];

    lint dp[45][2][2];
    rep(i, 45)rep(j, 2)rep(k, 2) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, 44)rep(j, 2)rep(k, 2)if(dp[i][j][k] < INF){
        int digit = X>>i & 1;
        int x = a[0]>>i & 1, y = a[1]>>i & 1;
        rep(d, 2)if(((x^d^j) ^ (y^d^k)) == digit){
            chmin(dp[i+1][(x<d) | (j&(x==d))][y+d+k>=2], dp[i][j][k] + ((lint)d<<i));
        }
    }
    printf("%lld\n", dp[44][0][0] < a[0] ? dp[44][0][0] : -1);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], book[maxn];
vector <int> g[maxn];
int n, m;
void dfs(int k)
{
	book[k] = 1;
	for(int i = 0; i < g[k].size(); i++){
		int v = g[k][i];
		if(book[v] == 0){
			a[v] = a[v] + a[k];
			dfs(v);
		}
	}
}
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n - 1; i++){
		int c, d;
		scanf("%d %d", &c, &d);
		g[c].push_back(d);
	}
	for(int i = 1; i <= m; i++){
		int c, d;
		scanf("%d %d", &c, &d);
		a[c] += d;
	}
	dfs(1);
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);
	}
	return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string S;
    cin>>S;
    map<char,int> M;
    M['a']=0;
    M['b']=0;
    M['c']=0;
    int n=S.size();
    for(int i=0;i<n;i++) M[S[i]]++;
    if(M['a']==M['b'] && M['b']==M['c']) cout<<"YES"<<endl;
    else{
        int max_cnt=-1,min_cnt=INF;
        for(int i=0;i<3;i++){
            chmax(max_cnt,M['a'+i]);
            chmin(min_cnt,M['a'+i]);
        }
        if(max_cnt-min_cnt>=2) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}


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

int weight[10] = {1,2,4,8,16,32,64,128,256,512};

int main(){
    int input,count;
    bool is_use[10];

    while(1){

      cin >> input;

      if(cin.eof()){
        break;
      }

      for(int i=0;i<10;i++){
        is_use[i] = false;
      }

      count = 0;

      for(int i=9;i>=0;i--){
        if(input >= weight[i]){
          input -= weight[i];
          is_use[i] = true;
          count++;
          if(input == 0){
            break;
          }
        }
      }

      for(int i=0; i<10; i++){
        if(is_use[i]){
          count--;
          if(count==0){
            cout << weight[i] << endl;
          }
          else{
            cout << weight[i] << " ";
          }
        }
      }


    }


    return 0;
}

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

#define FOR(i,s,t )for(int i = s; i <t ; i++)
using LL = long long; using ll = LL;
using PLL = pair<LL, LL>; using  pll = PLL;
using PII = pair<int, int>; using  pii = PII;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))



int main() {
	LL n;
	cin >> n;
	LL i = 1;
	int cnt = 0;
	while (i<=n)	{
		i <<= 1;
		cnt++;
	}
	cout << cnt << endl;

	return 0;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int64_t X, Y;
    cin >> X >> Y;
    Y /= X;
    int ans = 1;
    while (Y >= 2)
        Y /= 2, ans++;
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int[][] A = new int[3][3];
        for(int i=0;i<3;i++){
            for(int l=0;l<3;l++){
                A[i][l]=scan.nextInt();
            }
        }
        int b = scan.nextInt();
        for(int p=0;p<b;p++){
            int c = scan.nextInt();
            for(int i=0;i<3;i++){
                for(int l=0;l<3;l++){
                    if(c==A[i][l]){
                        A[i][l]=0;
                    }
                }
            }
        }

        int[] r = new int[8];
        for(int i=0;i<3;i++){
            r[0]+=A[0][i];
            r[1]+=A[1][i];
            r[2]+=A[2][i];
            r[3]+=A[i][0];
            r[4]+=A[i][1];
            r[5]+=A[i][2];
            r[6]+=A[i][i];
            r[7]+=A[2-i][i];
        }
        boolean flg = false;
        for(int i=0;i<8;i++){
            if(r[i]==0){
                flg=true;
                break;
            }
        }
        if(flg){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main()
{
    int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='+')
        cout<<a+b<<endl;
    else
    {
        
            cout<<a-b<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)


ll K;
double N;

int main() {
    cin >> N >> K;
    double res = 0;
    if (N < K){
        for (ll i=1; i<=N; i++) {
            ll temp = i;
            ll cnt = 0;
            while(temp * 2 < K){
                cnt ++;
                temp *= 2;
            }
            cnt ++;
            res += (1/N) *pow(0.5,cnt);
            
        }
    }
    else {
        for (ll i=1; i<=N; i++) {
            if (i >= K) {
                res += (1/N);
                continue;
            }
            ll temp = i;
            ll cnt = 0;
            while(temp * 2 < K){
                cnt ++;
                temp *= 2;
            }
            cnt ++;
            res += (1/N) * pow(0.5,cnt);
            
        }
    }
    printf("%.16lf\n", res);
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

def getcnt(aa):
    cnt = 0
    for i in range(len(aa)):
        cnt *= len(aa) - i
        cnt += aa[i] - 1
        for j in range(i+1,len(aa)):
            if aa[j] > aa[i]:
                aa[j] -= 1
    return cnt+1

print(abs(getcnt(aa) -getcnt(bb)) )

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int h,w;
	char a[114][514];
	cin>>h>>w;
	for(int i=0;i<h;i++){
	   for(int j=0;j<w;j++){
	   	cin>>a[i][j];
	   }
	}
	for(int i=0;i<w+2;i++){cout<<"#";}
	cout<<endl;
	for(int i=0;i<h;i++){cout<<"#";
	for(int j=0;j<w;j++){cout<<a[i][j];
	}
	cout<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++){cout<<"#";}
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,Mod;
#define Maxn 200010
int a[Maxn];

inline void rd(int &x){
	x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
}

inline int Judge(int mid){
	for(int i=2*mid-1;i<=2*n;++i)
		if(a[2*n+2*mid-1-i]+a[i]<Mod)return false;
	return true;
}

int main(){
	rd(n);rd(Mod);
	for(int i=1;i<=2*n;++i)rd(a[i]);
	sort(a+1,a+2*n+1);
	int l=1,r=n+1;
	while(l<r){
		int mid=(l+r)>>1;
		if(Judge(mid))r=mid;
		else l=mid+1;
	}
	int res=0;
	for(int i=2*r-1;i<=2*n;++i)res=max(res,a[2*r-1+2*n-i]+a[i]-Mod);
	for(int i=1;i<=2*r-2;++i)res=max(res,a[i]+a[2*r-1-i]);
	printf("%d\n",res);
	return 0;
} 

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =1e5+100;

int main()
{
    int n,x,s;
    while(~scanf("%d%d",&n,&x))
    {
        int sum =0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&s);
            if(s>=x)
                sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<long long> total(n, 0);
    vector<long long> car;
    total[0] = a[0];
    car.push_back(total[0]);
    long long ans = 0;
    if(total[0] == 0) ans++;
    
    
    for(int i = 1; i < n ; i++){
        total[i] = total[i-1] + a[i];
        car.push_back(total[i]);
        if(total[i] == 0){
            ans++;
        }
    }
    sort(car.begin(), car.end());
    long long num = 1;

    //  for(int i = 0; i < car.size();i++){
    //      cout << " car: " << car[i];
    //  }
    //  cout << endl;

    for(int i =1; i<car.size(); i++){
        if(car[i-1] == car[i]){
            num++;
        }else{
            ans += num * (num-1)/2;
            //cout << "ans: " << ans << endl;
            num = 1;
        }
    }
    ans += num * (num-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int A, B, m;
    cin >> A >> B >> m;

    ll mna = inf, mnb = inf;
    vector<ll> a(A), b(B);
    rep(i, A) {
        cin >> a[i];
        chmin(mna, a[i]);
    }
    rep(i, B) {
        cin >> b[i];
        chmin(mnb, b[i]);
    }
    ll ans = mna + mnb;
    while(m--) {
        int x, y, c;
        cin >> x >> y >> c;
        chmin(ans, a[x - 1] + b[y - 1] - c);
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i,j;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(n+1,sizeof(int64));
  for(i=1;i<=n;i++){
    if(n%2==i%2){
      for(j=0;j<n-i+1;j++){
	dp[j]=MAX(dp[j+1]+a[j],dp[j]+a[j+i-1]);
      }
    } else {
      for(j=0;j<n-i+1;j++){
	dp[j]=MIN(dp[j+1]-a[j],dp[j]-a[j+i-1]);
      }
    }
  }
  printf("%lld\n",dp[0]);
}

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


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data.txt");
    // cin.rdbuf(in.rdbuf());
    int N, D;
    cin >> N >> D;

    int div = D * 2 + 1;
    int ans = (N + (div - 1)) / div;
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * C - Divide the Problems
 * https://atcoder.jp/contests/abc132/tasks/abc132_c
 * 
 * 方針
 * 1. d をソートする
 * 2. d[N/2], d[N/2-1] であればどんな K でも Ok
 * 
 * 制約条件
 * 2 <= N <= 10^5
 * 1 <= d[i] <= 10^5 
 * 
 **/
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int MAX_N = 100000;

int N;
vector<int> d;

void solve() {
    int ans;
    sort(d.begin(), d.end());
    ans = d[(N/2)] - d[(N/2)-1];
    cout << ans << endl;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    solve();
}


Measured memory_bytes: 892
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);

	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice = 0;
	int bob = 0;
	int ans = 0;

	for (int j = 0; j < N;j++) {
		if (j % 2 == 0) {
			alice += a.at(j);
		}
		else {
			bob += a.at(j);
		}
	}
	ans = alice - bob;
	cout << ans << endl;

	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define N 4

int num(int,int,int,int);

int tum();
void rum(int *, int *);

int ma[N]={-1,0,1,0},lon[N]={0,-1,0,1};
int rin[N][N],sum;
int main(){
  int i,j,mizu,tani;
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      scanf("%d",&rin[i][j]);
      if(rin[i][j]==0){
	
	mizu=j;
	tani=i;	
      }
    }
  }
  
  for(sum=0;;sum++){
    if(num(0,10,mizu,tani)==1) break;
  }
  printf("%d\n",sum);  
  return 0;
}
int  num(int a, int b, int c, int d){
  int i,xx,yy,ta;
  ta=tum();
  if(ta==0) return 1;
  if(a+ta>sum) return -1;
  
    for(i=0;i<4;i++){
      if(i-b==-2 || i-b==2) continue;
      xx=c+ma[i];
      yy=d+lon[i];
      if(xx<0 || yy<0 || xx>=4 || yy>=4) continue;
      rum(&rin[d][c],&rin[yy][xx]);
      
      if(num(a+1,i,xx,yy)==1) return 1;
      rum(&rin[d][c],&rin[yy][xx]);
      
    }
    return -1;
    
}



int tum(){
  int i,j,a=0;
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(rin[i][j]==0) continue;
      a+=abs((rin[i][j]-1)/4-i)+abs((rin[i][j]-1)%4-j);
      
 
    }
  }
  return a;
}


void rum(int * xu, int *fan){  
  int c;
  c=*xu;
  *xu=*fan;
  *fan=c;
}



Measured memory_bytes: 2084
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	vector<pair<int, int> > pairs(m);
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		b--;
		pairs[i] = make_pair(a, b);
	}

	sort(pairs.begin(), pairs.end());

	int front = pairs[0].first, end = pairs[0].second, cnt = 1;
	for (int i = 0;i<m - 1;i++) {
		if (pairs[i + 1].first >= front && pairs[i + 1].first <= end) {
			front = max(front, pairs[i + 1].first);
			end = min(end, pairs[i + 1].second);
		}
		else {
			front = pairs[i + 1].first;
			end = pairs[i + 1].second;
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, n; cin >> h >> w >> n;
  vector<int> A(n); rep(i, n) cin >> A[i];
  int tmp = 0;
  int col = 1;
  vector<vector<int>> ans(h, vector<int>(w));
  while(tmp < h*w) {
    rep(i, A[col-1]) {
      int x = tmp/w;
      int y = (x%2 ? w-tmp%w-1 : tmp%w);
      ans[x][y] = col;
      tmp++;
    }
    col++;
  }
  rep(i, h) {
    rep(j, w) {
      if(j) cout << ' ';
      cout << ans[i][j];
    }
    cout << endk;
  }
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    char b = 0;
    for(char s = 'a'; s <= 'z'; s++){
        bool d = true;
        for(int i = 0; i<S.length() ;i++){
            if(s == S[i]){
                d = false;
            }
        }
        if(d){
            b = s;
            goto NINE;
        }
    }

    NINE:

    if(b == 0){
        cout << "None" << endl;
    }else{cout << b << endl;}
    
    return 0;
}



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

char s[1000];

int main(){
    int n; scanf("%d %s", &n, s+1);
    if (strlen(s+1) <= n) printf("%s\n", s+1);
    else { s[n+1] = '.'; s[n+2] = '.'; s[n+3] = '.'; s[n+4] = 0; printf("%s\n", s+1); }
    return 0;
}


Measured memory_bytes: 3688
N, M = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(M)]
 
graph_ex = [[0 for _ in range(N)] for _ in range(N)]
for i in graph:
  graph_ex[i[0]-1][i[1]-1] = 1
  graph_ex[i[1]-1][i[0]-1] = 1

al_vis = [False for _ in range(N)]
al_vis[0] = True
def dfs(v, visited, cnt):
  if cnt == N-1:
    return 1
  ret = 0
  for i in range(N):
    if graph_ex[v][i] == 1 and visited[i] == False:
      visited[i] = True
      ret += dfs(i, visited, cnt+1)
      visited[i] = False
  return ret
ret = dfs(0, al_vis, 0)
print(ret)

Measured memory_bytes: 42588
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;

long long T[100000];
int main(){
    int N;
    long long C;
    long long K;
    cin >> N >> C >> K;
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    sort(T, T + N);
    int ans = 0;
    int cur_cap = 0;
    long long leave = -1;
    for(int i = 0; i < N; i++){
        if(T[i] > leave || cur_cap >= C){
            ans ++;
            leave = T[i] + K;
            cur_cap = 1;
        } else {
            cur_cap ++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {
	float a,b,c,d,e,f,ansx,ansy;
	while(scanf("%f %f %f %f %f %f",&a, &b, &c, &d, &e, &f) != EOF){
		ansy = (d * c - a * f) / (b * d - a * e);
		ansx = (-b * ansy + c) / a;
		if (ansy == -0) ansy = 0;
		if (ansx == -0) ansx = 0;
		printf("%.3f %.3f\n",ansx,ansy);
	}
	return 0;
}

Measured memory_bytes: 648
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, 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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vector<unsigned long long> a(n);
	rep(i, n) {
		cin >> a[i];

		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	unsigned long long ans = 1;
	rep(i, n) {
		if (((ll)1e18 + 1)/ans < a[i] || ans * a[i] > (ll)1e18) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}

	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  ll x3, y3, x4, y4;

  x3 = x2 - y2 + y1;
  y3 = y2 + x2 - x1;

  x4 = x3 - y3 + y2;
  y4 = y3 + x3 - x2;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve()
{
  lint N;
  cin>>N;
 
  lint MIN = I64_MAX;
 
  for (lint i = 1; i <= sqrt(N); i++)
  {
    if(N%i == 0)
    {
      MIN = min(MIN,N/i + i - 2);
    }
  }
 
 
  cout<<MIN<<endl;
  
 
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

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

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int len[52], pat[52];

int dfs(int N, int X) {
	if (N == 0) return X > 0;
	if (X >= len[N]) return pat[N];
	if (X == len[N] / 2 + 1) return pat[N - 1] + 1;
	if (X < len[N] / 2 + 1) return dfs(N - 1, X - 1);
	return dfs(N - 1, X - (len[N] / 2 + 1)) + pat[N - 1] + 1;
}

signed main() {
	len[0] = 1;
	pat[0] = 1;

	REP(i, 1, 50) {
		len[i] = 2 * len[i - 1] + 3;
		pat[i] = 2 * pat[i - 1] + 1;
	}

	int N, X;
	cin >> N >> X;

	cout << dfs(N, X) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String str = scn.nextLine();
		int ans = 0;
		switch(str) {
		case "SUN":
			ans = 7;
			break;
		case "MON":
			ans = 6;
			break;
		case "TUE":
			ans = 5;
			break;
		case "WED":
			ans = 4;
			break;
		case "THU":
			ans = 3;
			break;
		case "FRI":
			ans = 2;
			break;
		case "SAT":
			ans = 1;
			break;
			default:
				break;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        BigInteger N=new BigInteger("1000000000000000000");
        BigInteger ans=new BigInteger("1");
        BigInteger n0=new BigInteger("0");


        int flag=1;
        int num=1;
        for(int i=1;i<=n;++i){
            BigInteger x=sc.nextBigInteger();
            if(x.compareTo(n0)==0) num=0;
            if(flag==0) continue;
            ans=ans.multiply(x);
            if(ans.compareTo(N)>0) {
                flag=0;
            }
        }

        if(num==0) System.out.println(0);
        else if(ans.compareTo(N)>0||flag==0) System.out.println("-1");
        else System.out.println(ans);
    }
}


Measured memory_bytes: 60200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    bool graph[n][m] = {};
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    int visited[n];
    rep(i, 0, n) visited[i] = i;

    int ans = 0;
    do {
        if (visited[0] != 0) continue;
        bool flag = true;
        rep(i, 0, n - 1) {
            if (!graph[visited[i]][visited[i + 1]]) flag = false;
        }
        if (flag) ans++;
    } while(next_permutation(visited, visited + n));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256