akhauriyash/Code-Regression huggingface dataset:
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const int logN = 32;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	int n, a[100010]; cin >> n;
	REP(i, 0, n) cin >> a[i], a[i]--;
	
	int c = 0;
	REP(i, 0, n) if(i == a[a[i]]) c++;
	cout << c / 2 << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<tuple<string, int,int>> S;
  for(int i = 0; i < n; i++){
  	string s;
    int r;
    cin >> s >> r;
    S.emplace_back(s, -r, i+1);
  }
  sort(begin(S),end(S));
  for( auto x : S )
  {
      cout << get<2>( x ) << endl;
  }
  return 0;
}

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

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int ans, tmp;
    tmp = n / a;
    if(n % a > 0) tmp++;
    ans = tmp * b;
    tmp = n / c;
    if(n % c > 0) tmp++;
    ans = min(ans, tmp * d);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <vector>
#include <set>
typedef unsigned long long ull;
using namespace std;
struct Point {
	int x,y;
	Point(int _x,int _y) {x=_x,y=_y;}
};
set<ull> S;
vector<Point> A,B;
int main() {
	int m,n;
	int X,Y;
	while(scanf("%d",&m),m) {
		S.clear();
		A.clear();
		B.clear();
		scanf("%d %d",&X,&Y);
		A.push_back(Point(0,0));
		for(int i=0;i<m-1;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			A.push_back(Point(x-X,y-Y));
		}
		scanf("%d",&n);
		for(int i=0;i<n;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			B.push_back(Point(x,y));
			S.insert((ull)x*1000000+y);
		}
		for(int i=0;i<n;i++) {
			bool OK=true;
			for(int j=0;j<m;j++) {
				int x=B[i].x+A[j].x,y=B[i].y+A[j].y;
				if(0>x||0>y) {OK=false; break;}
				if(S.find((ull)x*1000000+y)==S.end()) {OK=false; break;}
			}
			if(OK) {printf("%d %d\n",B[i].x-X,B[i].y-Y); break;}
		}
	}
}

Measured memory_bytes: 1096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int a,b;
  cin >> a >> b;
  if (a%3==0||b%3==0||(a+b)%3==0)
  {
    cout << "Possible"<< endl;
  }else
  {
    cout << "Impossible" << endl;
  }
  
  
  
  
  
  
  
    
  
  
    


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int h,w;
  while(scanf("%d %d", &w, &h), w|h){
    int n;
    cin>>n;
    vector<int> x1(n), y1(n), x2(n), y2(n);
    rep(i,n) scanf("%d %d %d %d", &x1[i], &y1[i], &x2[i], &y2[i]);

    // ??§??§
    vector<int> sx, sy;
    rep(i,n){
      for(int j=0; j<=1; j++){
        sx.pb(x1[i]+j);
        sy.pb(y1[i]+j);
        sx.pb(x2[i]+j-1);
        sy.pb(y2[i]+j-1);
      }
    }
    sx.pb(0); sx.pb(w-1); sx.pb(w);
    sy.pb(0); sy.pb(h-1); sy.pb(h);
    sort(all(sx)); sx.erase(unique(all(sx)), sx.end());
    sort(all(sy)); sy.erase(unique(all(sy)), sy.end());

    int x=sx.size();
    int y=sy.size();

    vector<vector<int> > vec(x, vector<int>(y, 0));

    // imos ??????
    rep(i,n){
      int nx1 = lower_bound(all(sx), x1[i]) - sx.begin();
      int ny1 = lower_bound(all(sy), y1[i]) - sy.begin();
      int nx2 = lower_bound(all(sx), x2[i]) - sx.begin();
      int ny2 = lower_bound(all(sy), y2[i]) - sy.begin();
      vec[nx1][ny1]++;
      vec[nx2][ny1]--;
      vec[nx1][ny2]--;
      vec[nx2][ny2]++;
    }

    // imos??????
    rep(i,x) repl(j,1,y) vec[i][j] += vec[i][j-1];
    rep(j,y) repl(i,1,x) vec[i][j] += vec[i-1][j];

    int res=0;
    rep(i,x-1) rep(j,y-1) if(vec[i][j]==0){
      res++;
      stack<pair<int, int> > s;
      s.push(mp(i,j));
      while(!s.empty()){
        pair<int, int> p = s.top(); s.pop();
        vec[p.fi][p.se]=1;
        const int dx[]={-1,0,0,1}, dy[]={0,-1,1,0};
        rep(k,4){
          int nx = p.fi+dx[k], ny = p.se+dy[k];
          if(nx<0 || nx>=x-1 || ny<0 || ny>=y-1) continue;
          if(vec[nx][ny]==0) s.push(mp(nx,ny));
        }
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 9920
from bisect import bisect
import sys
n = int(input())
A = [int(i.rstrip("\n")) for i in sys.stdin.readlines()]
 #?????????i+1??§???????¢??????¨??????????????????????´????????°???????????´?
L = []
def LIS():
    L.append(A[0])
    length = 0
    for i in range(n):
        if L[length] < A[i]:
            length += 1
            L.append(A[i])
        else:
            if A[i] in L: continue
            j = bisect(L, A[i], 0, length) #L????????§?????????A[i]??\?????¨????????????????????????
            L[j] = A[i]
    return length + 1

print(LIS())

Measured memory_bytes: 18772
#include <iostream>
#include <cstring>
#include <algorithm>
long long tseq[100];
double sums[100005];
int cnt(int x,int lim){
    int ret = 0;
    while(x < lim){
        x = x * 2;
        ret ++;
    }
    return ret;
}
int main() {
    int n,k;
    std::cin >> n >> k;
    long long cur = 1;
    for(int i = 0 ; i <= 62; ++ i) tseq[i] = cur, cur *= 2ll;
    long double c = 1;
    for(int i = 0; i <= 100000; ++ i) {
        sums[i] = c;
        c = c * 0.5;
    }
    long double ret = 0;
    double curh = 1 / (1.0 * n);
    if (k <= n){
        for(int i = 1; i < k; ++ i){
           int idx =  cnt(i,k);
            ret +=   sums[idx];
        }
        ret = ret * curh;
        ret = ret + (1.0 * (n - k + 1))/ (1.0 * n);
        printf("%.15Lf",ret);
  //      std::cout << ret;
    }else {
        for(int i = 1; i <= n; ++ i){
            int idx = cnt(i, k);
          //  std::cout << idx << std::endl;
            ret +=  sums[idx];
        }
        ret = ret * curh;
        printf("%.15Lf",ret);
   //     std::cout << ret;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int saidai,mannaka,saishou;
  saidai=max(a,max(b,c));
  saishou=min(a,min(b,c));
  mannaka=a+b+c-saidai-saishou;
  int sa1=0,sa2=0;
  sa1=saidai-mannaka;
  sa2=mannaka-saishou;
  int kotae=0;
  if(sa2%2==0){
    kotae=sa1+sa2/2;
  }else{
    kotae=sa1+sa2/2+2;
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 1
flag = True
memo = 0
for i in range(1, n):
    if flag:
        if a[i] > a[i - 1]:
            memo = 1
            flag = False
        if a[i] < a[i - 1]:
            flag = False
            memo = 0
        else:
            continue
    else:
        if memo == 1 and a[i] < a[i - 1]:
            cnt += 1
            flag = True
        elif memo == 0 and a[i] > a[i - 1]:
            cnt += 1
            flag = True
print(cnt)


Measured memory_bytes: 12968
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define INF 0x3f3f3f3f
#define ll long long
#define N 500010
using namespace std;
ll a[N];
int main()
{
	int n,k;
	while(cin>>n)
    {int t=0;
     if(n%4==0)
     cout<<"Yes"<<endl;
     else if(n%7==0)
     cout<<"Yes"<<endl;
     else
    {
        for(int i=1;i<25;i++)
          {
              for(int j=1;j<=15;j++)
           {
                if(n%(4*i+7*j)==0)
            {      t=1;
                  break;

            }
           }
           if(t==1)
            break;
             }
           if(t==0)
            cout<<"No"<<endl;
            else
            cout<<"Yes"<<endl;
        }
    }

	return 0;
}


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

using namespace std;

vector < long long > v;

long long res = 0;
long long st = 1;

const long long mod = 1000000007;

void Step(int n) {
	long long cnt = 0;
	for (int i = 0; i < n; i++) { 
		cnt += (v[i] % 2);
		v[i] /= 2;
	}
	res = res + ((st%mod) * ((cnt * (n - cnt)) % mod)) % mod;
	res %= mod;
	st *= 2;
	st %= mod;
}

int main() {
	int n;
	cin>>n;
	long long val = 0;
	for (int i = 0; i < n; i++) {
		long long k;
		cin>>k;
		v.push_back(k);
		val = max(val, k);
	}
	for (; val > 0; val /= 2)
		Step(n);
	cout<<res;
}

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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x+r > W || x-r < 0 || y+r > H || y-r < 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


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

int main()
{
    double  r;
    cin>>r;
    double pi=3.14159265359;
    cout<<fixed;
    cout<<setprecision(6)<<pi*r*r<<" "<<2*pi*r;
    cout<<"\n";
        return 0;
}



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

struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

signed main(){
    string a,b;
    cin >> a >> b;
    if(a>b) printf(">\n");
    else if(a<b) printf("<\n");
    else if(a==b) printf("=\n");

    return 0;
}

Measured memory_bytes: 384
import math

a, b, x = [int(_) for _ in input().split()]

s = x / a
if a * b / 2 < s:
    b2 = 2 * (a * b - s) / a
    ans = math.atan2(b2, a) * 180 / math.pi

else:
    a2 = 2*s/b
    ans = math.atan2(b,a2) * 180 / math.pi
print(ans)


Measured memory_bytes: 3188
n=int(input())
l=list(map(int,input().split()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  elif before-l[i]==0:continue
  else:d=0
  before=l[i]
print("Yes")

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++ i) cin >> A[i];
	for (int i = 0; i < N; ++ i) cin >> B[i];
	int res = 0;
	for (int p = 0; p <= 28; ++ p) {
		long long s1 = 0, s2 = 0;
		for (int x : A) if (x & (1<<p)) ++ s1;
		for (int x : B) if (x & (1<<p)) ++ s2;
		long long s = s1 * (N-s2) + (N-s1) * s2;
		//cerr << p << ":" << s << endl;
		if (p > 0) {
			vector<int> a(N), b(N);
			for (int i = 0; i < N; ++ i) a[i] = A[i] & ((1<<p)-1);
			for (int i = 0; i < N; ++ i) b[i] = B[i] & ((1<<p)-1);
			sort(a.rbegin(), a.rend());
			sort(b.rbegin(), b.rend());
			int j = N;
			for (int i = 0; i < N; ++ i) {
				while (j > 0 && a[i] + b[j-1] < (1<<p)) -- j;
				if (j == 0) break;
				//cerr << i << " " << j << endl;
				s += j;
			}
		}
		//cerr << " " << s << endl;
		if (s & 1) res |= 1<<p;
	}
	cout << res << endl;
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
    cout << ((e - a) <= k ? "Yay!" : ":(") << '\n';
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    count = 0
    for i in range(1, N+1):
        if not (i % 3 == 0 or i % 5 == 0):
            count += i
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72648
#include <iostream>
using namespace std;
int main(void){
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
    
}



Measured memory_bytes: 3112
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
 
        int x = 800 * N;
        int y = 200 * (N / 15);
 
        _out.println((x - y));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,s,c,k,MOD; 
long long p(long long u,long long v){
	if(v==1) return u%MOD;
	//cout<<v<<endl;
	if(v%2==0) {
		long long y=p(u,v/2);
		return (y*y)%MOD;
		
	}
	return (p(u,v-1)*u)%MOD;
}
int main(){
	cin>>n>>a>>b;
     MOD=1000000000+7;
	s=p(2,n)-1; 
	s=s%MOD; 
	c=1; 
	for(k=max(n-a,a)+1;k<=n;k++)
	{
		c*=k;
		c%=MOD;
	} 
	long long f=1;
	for(k=1;k<=min(n-a,a);k++)
	{
		f*=k;
		f%=MOD;
	}
	long long x=(c*p(f,MOD-2))%MOD;	
	s-=x; 
	s+=MOD;
	s%=MOD;
c=1;
		for(k=max(n-b,b)+1;k<=n;k++)
	{
		c*=k;
		c%=MOD;
	} 
	f=1;
	for(k=1;k<=min(n-b,b);k++){
		f*=k;
		f%=MOD;
	}
	 x=(c*p(f,MOD-2))%MOD;	
	s-=x; s+=MOD;
	s%=MOD;
	 cout<<s;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    register int n,i;
    while(cin >> n,n){
		register int p;
        register int min = 1000;
        register int max = 0;
		register int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair <int, int> pii;

int stair[101010];
int main()
{
    usecppio
    int n;
    cin >> n;
    for (int i = 1; i<=n; i++)
    {
        cin >> stair[i];
    }
    for (int i = 1; i<=n; i++)
    {
        if (stair[i] > stair[i-1])
            stair[i]--;
    }
    bool ok = true;
    for (int i = 1; i<=n; i++)
        if (stair[i] < stair[i-1])
            ok = false;
    cout << (ok?"Yes":"No");
}

Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int i = 0;
        while (s.contains("B")) {
            if (s.charAt(i) == 'B') {
                s = s.replaceFirst("(.?B)", "");
                i = -1;
            }
            i++;
        }
        System.out.println(s);
    }
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pii pair<int,int>

int N;
vector<pii> G[100010];
int ans[100010];

void DFS(int v, int d, int p=0)
{
    ans[v] = d;
    for(auto e : G[v])if(e.first != p)
    {
        DFS(e.first, e.second ^ d, v);
    }
}

signed main()
{
    cin >> N;
    rep(i, N - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        w = w % 2;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    DFS(1, 0);

    for(int i = 1; i <= N; i++)cout << ans[i] << endl;

    return 0;
}


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

using namespace std;

int N, K;
vector<int> a;

bool judge(int m) {
    bool dp[5010] = {false};
    dp[0] = true;
    for (auto i = 0; i < N; i++) {
        if (i == m) continue;
        for (auto j = K-a[i]-1; j >= 0; j--) {
            if (!dp[j]) continue;
            if (K-a[m] <= j+a[i]) {
                return true;
            }
            dp[j+a[i]] = true;
        }
    }
    return false;
}

int main() {
    int x;
    
    cin >> N >> K;
    for (auto i = 0; i < N; i++) {
        cin >> x;
        if (x < K) {
            a.push_back(x);
        }
    }
    sort(a.begin(), a.end());
    
    N = a.size();
    int l, r, m;
    l = -1;
    r = N;
    while (r - l > 1) {
        m = (l + r) / 2;
        if (judge(m)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
typedef long long int li;
	
	#include<bits/stdc++.h>

	using namespace std;
	
	int main()
	{	
		ios_base::sync_with_stdio(false);
    		cin.tie(NULL);

    		li a;

    		string s;

    		cin>>a>>s;

    		if(a>=3200)
    		{
    			cout<<s;
    		}

    		else
    		{
    			cout<<"red";
    		}

		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
    int p,x;
    int y;
}model;
model a[100005];
char s[15];
int flag[100005];

int cmp(model x,model y)
{
    return x.y < y.y;
}
int cmp1(model x,model y)
{
    return x.x < y.x;
}

int solve(int pos,int num)
{
    while(num)
    {
        int ans = num%10;
        s[pos] = ans+'0';
        pos--;
        num /= 10;
    }
}

int main()
{
    int n,m;
    int i,j;

    scanf("%d%d",&n,&m);
    for(i = 0;i < m;i++)
    {
        scanf("%d%d",&a[i].p,&a[i].y);
        a[i].x = i;
    }
    sort(a,a+m,cmp);
    for(i = 0;i < m;i++)
    {
        flag[a[i].p]++;
        a[i].y = flag[a[i].p];
    }
    sort(a,a+m,cmp1);

    for(i = 0;i < m;i++)
    {
        for(j = 0;j < 12;j++)
            s[j] = '0';
        s[j] = '\0';
        solve(5,a[i].p);
        solve(11,a[i].y);
        puts(s);
    }

    return 0;
}


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

unordered_map<ll, ll> m;

ll lucas(ll n)
{
    if(n == 0)
        return 2;

    if(n == 1)
        return 1;
    
    ll l, r;
    
    if(m[n-1])
        l = m[n-1];
    else
    {
        l = lucas(n - 1);
        m[n-1] = l;
    }

    if(m[n-2])
        r = m[n-2];
    else
    {
        r = lucas(n - 2);
        m[n-2] = r;
    }

    return l + r;
}

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

    cout << lucas(n) << "\n";
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  cout << string(w + 2, '#') << endl;
  for (int i = 0; i < h; i++) {
    cout << '#' + a[i] + '#' << endl;
  }
  cout << string(w + 2, '#') << endl;
}

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

int K, N;
int A[200000];


// int index = 0;

int main(){
    cin >> K >> N;

    int diff_max = 0;
    cin >> A[0];
    for (int i = 1; i < N; i++)
    {
        cin >> A[i];
        if (A[i] - A[i - 1] > diff_max)
        {
            diff_max = A[i] - A[i - 1];
        }
    }
    if(K - A[N - 1] + A[0] > diff_max){
        diff_max = K - A[N - 1] + A[0];
    }

    cout << K - diff_max << endl;
}

Measured memory_bytes: 4388
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
void dfs(int& result, int pos, const vector<int>& m,  const vector<string>& ss,vector<int>& assoc, vector<int> &visited, vector<int>& cof){
  int sum = 0;
  REP(i,cof.size())if(assoc[i]!=-1) sum += cof[i]*assoc[i];
  if(pos==assoc.size()){
    /*
    vector<int> vs(ss.size());
    REP(i,ss.size()){
      REP(j,ss[i].size()){
        vs[i] = vs[i] * 10 + assoc[m[ss[i][j]]];
      }
    }
    if(vs.back() == accumulate(vs.begin(), vs.end()-1, 0)){
      ++result;
    }
    */
    if(sum==0) ++result;
    return;
  }else{
    if(sum>0){
      FOR(i,pos,assoc.size()){
        if(cof[i]<0) sum += 9 * cof[i];
      }
      if(sum>0) return;
    }else{
      FOR(i,pos,assoc.size()){
        if(cof[i]>0) sum += 9 * cof[i];
      }
      if(sum<0) return;
    }

    REP(k,10){
      if(visited[k])continue;
      if(k==0){ 
        REP(i,ss.size())if(ss[i].size() > 1 && m[ss[i][0]] == pos){
            goto NEXT;
        }
      }
      visited[k] = true;
      assoc[pos] = k;
      dfs(result,pos+1,m,ss,assoc,visited,cof);
      assoc[pos] = -1;
      visited[k] = false;
      NEXT:;
    }
  }
}
int main(void){
  int n;
  while(cin>>n,n){
    vector<string> ss(n);
    REP(i,n)cin>>ss[i];
    vector<int> m(256,-1);
    int p = 0;
    int ans = 0;
    REP(i,ss.size())REP(j,ss[i].size()) if(m[ss[i][j]]<0) m[ss[i][j]] = p++;
    vector<int> visited(10,0);
    vector<int> assoc(p,-1);
    vector<int> cof(p,0);
    REP(i,ss.size())REP(j,ss[i].size()){
      cof[m[ss[i][j]]] += pow(10,ss[i].size()-j-1) * ((i==ss.size()-1)?(-1):1);
    }
    /*
    REP(i,cof.size())FOR(j,i+1,cof.size())if(abs(cof[i])<abs(cof[j])){
      swap(cof[i],cof[j]);
      REP(k,m.size()){
        if(m[k]==i)m[k]=j;
        if(m[k]==j)m[k]=i;
      }
    }
    */
    dfs(ans,0,m,ss,assoc,visited,cof);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 952
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}

signed main(){
    int n;
    cin>>n;
    for(int i=n;;i++){
        if(prime(i)){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

ll powerMod(ll m, ll n) {
    ll x = m % mod;
    ll result = 1;
    while (n > 0) {
        if (n % 2 != 0) {
            result = (result * x) % mod;
        }
        x = (x * x) % mod;
        n = n / 2;
        
    }
    return result;
}

int main() {
    ll m, n;
    cin >> m >> n;
    cout << powerMod(m, n) << endl;
    return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main()
{
    int h,w;
    cin>>h>>w;

    vector<vector<char>>a(h,vector<char>(w));
    rep(i,h){
        rep(j,w)cin>>a[i][j];
    }

    rep(i,w+2)cout<<'#';
    cout<<endl;
    rep(i,h){
        cout<<'#';
        rep(j,w)cout<<a[i][j];
        cout<<'#'<<endl;
    }

    rep(i,w+2)cout<<'#';
    cout<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <map>

using namespace std;
int N;
long a=0;

int main(){
cin>>N;
  for(int i=1;i<N+1;i++){
    if(!(i%3==0||i%5==0)){
      a=a+i;
    }
  }
	cout<<a<<endl;

}


Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 5050
using namespace std;

int n, a, b, p[N];
long long f[N << 1][N];

inline int calc(int j, int i) {
    if (p[j] < i) return a;
    if (p[j] > i) return b;
    return 0;
}

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> a >> b;
    for (int i = 1, x; i <= n; ++i)
        scanf("%d", &x), p[x] = i;

    memset(f, 0x3f, sizeof f);
    f[0][0] = 0;
    for (int i = 1; i <= (n << 1 | 1); ++i) {
        f[i][0] = 0;
        for (int j = 1; j <= n; ++j)
            if (i & 1) {
                f[i][j] = min(f[i - 1][j], f[i][j - 1] + (p[j] <= i / 2 ? a : b));
            } else {
                f[i][j] = min(f[i - 1][j], f[i - 1][j - 1] + calc(j, i / 2));
            }
    }

    cout << f[n << 1 | 1][n] << endl;

    return 0;
}


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

int main() {
 
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n);
  vector<int> y(m);
  for(int i=0;i<n;i++) {
    cin >> x[i];
  }
  for(int i=0;i<m;i++) {
    cin >> y[i];
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  int A=x[n-1], B=y[0];
  if ((X<B && B<=Y) && B>A) {
    cout << "No War" << endl;
   }
  else {
      cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorlonglong(vector<long long> * p, long long a){
    rep(i, a){
        long long input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}


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

    long long N;
    N = inputValueLongLong();

    int i;
    long long A[N];
    long long sumA[N];
    long long len;
    for(i=0;i<N;i++){
        sumA[i] = 0;
    }
    A[0] = inputValueLongLong();
    len += A[0];
    sumA[0] = A[0];
    for(i=1;i<N;i++){
        A[i] = inputValueLongLong();
        len += A[i];
        sumA[i] = sumA[i-1] + A[i];
    }

    long long ptr=0;

    for(i=0;i<N;i++){
        if(len/2<=sumA[i]){
            ptr = i;
            if(len/2-sumA[i-1]>=sumA[i]-len/2){
                ptr = i;
            }else{
                ptr = i-1;
            }
            break;
        }
    }

    long long left = sumA[ptr];
    long long right = len - sumA[ptr];
    if(left>right){
        cout << left-right <<endl;
        return 0;
    }else{
        cout << right-left <<endl;
        return 0; 
    }

    cout << left-right << endl;
    return 0;

}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};


int solve(int year,int month,int day){
    int gy = 1000,gm=1,gd=1;
    for(int i=0;;i++){
        if(year == gy and month == gm and day == gd) return i;
        day++;
        if(year % 3 == 0){
            if(day == 21){
                day = 1;
                month++;
                if(month == 11){
                    month = 1;
                    year++;
                }
            }
        }else{
            if(month % 2 == 1){
                if(day == 21){
                    day = 1;
                    month++;
                    if(month == 11){
                        month = 1;
                        year++;
                    }
                }
            }else{
                if(day == 20){
                    day = 1;
                    month++;
                    if(month == 11){
                        month = 1;
                        year++;
                    }
                }
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int y,m,d;
        cin >> y >> m >> d;
        cout << solve(y,m,d) << endl;
    }
    return 0;
}

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



void test() {
    int x,y;
    cin >> x >> y;
    if ((y%2)||(y<2*x)||(y>4*x))
        cout << "No\n";
    else
        cout << "Yes\n";
}

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

    // int t;
    // cin >> t;
    // while (t--) {
    //     test();
    // }
    test();

    return 0;
}

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

using namespace std;
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}


int N = 1.5 * 1e7 + 5;

ll GCD(ll a, ll b) {
    if (!b)return a;
    return GCD(b, a % b);
}

ll fastExpo(ll a, ll b) {
    if (!b)return 1;
    ll half = fastExpo(a, b / 2);
    ll ans = (half * half);
    if (b & 1)return (ans * a);
    return ans;
}

int sumofdigits(int n) {
    int t = 0;
    while (n != 0) {
        t += n % 10;
        n /= 10;
    }
    return t;
}

ll fact(int n) {
    if (n <= 1)return 1;
    return n * fact(n - 1);
}


int freq[200];


int main() {
    fast();
    int n;cin>>n;
    bool ans=true;
    for (int i = 0; i <n ; ++i) {
        int k;cin>>k;
        if(k%2==0&&ans)ans= k % 3 == 0 || k % 5 == 0;
    }
    if(ans)cout<<"APPROVED";
    else cout<<"DENIED";
}


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

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll power(ll x, ll y)
{
    ll res = 1;

    while (y > 0) {

        if (y & 1)
            res = res * x;


        y = y >> 1;
        x = x * x;
    }
    return res;
}

vector<int> w[1000000];

int vis[1000000];

void dfs(int nxt , int prev , int val)
{
    vis[nxt] += val;
    for(int i=0;i<(int)w[nxt].size();i++)
        if(w[nxt][i]!=prev)
            dfs(w[nxt][i],nxt,vis[nxt]);
}

int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        w[a].push_back(b);
        w[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        vis[p]+=x;
    }
    dfs(1,0,0);
    for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 50304
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int M=1010,N=M*(M+1);

vector<int> g[N],gr[N];
bool used[N];
vector<int> order,component;
int dp[N];

void dfs1 (int v) {
	used[v] = true;
	for (size_t i=0; i<g[v].size(); ++i)
		if (!used[ g[v][i] ])
			dfs1 (g[v][i]);
	order.push_back (v);
}

void dfs2 (int v) {
	used[v] = true;
	component.push_back (v);
	for (size_t i=0; i<gr[v].size(); ++i)
		if (!used[ gr[v][i] ])
			dfs2 (gr[v][i]);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int m;
    cin>>m;
    int n=m*(m+1);
    #define hsh(a,b) (a<b?a*m+b:b*m+a)
    for(int i=1;i<=m;i++)
        for(int j=1,p=0;j<=m-1;j++)
        {
            int x;
            cin>>x;
            if(p)
            {
                g[hsh(i,p)].push_back(hsh(i,x));
                gr[hsh(i,x)].push_back(hsh(i,p));
            }
            p=x;
        }
    for(int i=1;i<=n;i++)
        if(!used[i])
            dfs1(i);
    memset(used,0,sizeof(used));
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int v=order[n-1-i];
        if(!used[v])
        {
            dfs2(v);
            if(component.size()>1)
                cout<<"-1",exit(0);
            dp[v]=1;
            for(int before:gr[v])
                dp[v]=max(dp[v],dp[before]+1);
            ans=max(ans,dp[v]);
            component.clear();
        }
    }
    cout<<ans;
}


Measured memory_bytes: 103404
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    while (x) {
      if (x % 10 == 3) {
        printf(" %d", i);
        break;
      }
      x /= 10;
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2084
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    //intとVectorの宣言
    let N: u32 = read();
    let A: Vec<u32> = read_vec();

    //答えの変数を用意し、Aを前の要素から順に割っていく
    let mut ans = 0;
    let mut min_ans = 1000000000;
    for mut a in A {
        ans = 0;
        while a % 2 == 0 {
            a /= 2;
            ans += 1;
        }
        min_ans = std::cmp::min(ans,min_ans);
    }

    println!("{}",min_ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll a, b, c; cin >> a >> b >> c;
    ll l = 4 * a * b;
    ll r = (c - a - b);
    ll r2 = r * r;
    string ans = "Yes";
    if(l >= r2) ans = "No";
    if(r < 0) ans = "No";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        int[][] white = Enumerable.Repeat(0, k).Select(_ => new int[k]).ToArray();
        int[][] black = Enumerable.Repeat(0, k).Select(_ => new int[k]).ToArray();
        var totalWhite = 0;
        var totalBlack = 0;
        for (int i = 0; i < n; i++)
        {
            var xyc = Console.ReadLine().Split();
            var x = int.Parse(xyc[0]);
            var y = int.Parse(xyc[1]);
            var parity = y / k + x / k;
            var c = xyc[2];
            
            if ((c == "W" && parity % 2 == 0) || 
                (c == "B" && parity % 2 == 1)) 
            { white[y % k][x % k]++; totalWhite++; }
            if ((c == "B" && parity % 2 == 0) || 
                (c == "W" && parity % 2 == 1)) 
            { black[y % k][x % k]++; totalBlack++; }
                
        }
        int[][] whiteAccum = Enumerable.Repeat(0, k + 1).Select(_ => new int[k + 1]).ToArray();
        int[][] blackAccum = Enumerable.Repeat(0, k + 1).Select(_ => new int[k + 1]).ToArray();

        for (int i = 1; i <= k; i++)
            for (int j = 1; j <= k; j++)
            {
                whiteAccum[i][j] = white[i - 1][j - 1] + whiteAccum[i][j - 1] + whiteAccum[i - 1][j] - whiteAccum[i - 1][j - 1];
                blackAccum[i][j] = black[i - 1][j - 1] + blackAccum[i][j - 1] + blackAccum[i - 1][j] - blackAccum[i - 1][j - 1];
            }

        var res = 0;
        for (int i = 0; i <= k; i++)
        {
            for (int j = 0; j <= k; j++)
            {
                var whiteCount = whiteAccum[k][j] + whiteAccum[i][k] - whiteAccum[i][j] * 2;
                var blackCount = blackAccum[k][j] + blackAccum[i][k] - blackAccum[i][j] * 2;
                res = Max(res, Max(whiteCount + (totalBlack - blackCount), blackCount + (totalWhite - whiteCount)));
            }
        }

        Console.WriteLine(res);
    }
}


Measured memory_bytes: 36648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

  int neg = 0;
  LL sum = 0;
  LL min_ = 1000000000;
  bool zero = false;

  for(int i=0; i < n; i++) {
    LL tmp;
    cin >> tmp;
    if (tmp < 0) neg ++;
    if (tmp == 0) zero = true;
    sum += abs(tmp);
    min_ = min(abs(tmp), min_);
  }

  if (neg % 2 == 0) cout << sum << endl;
  else if (zero) cout << sum << endl;
  else cout << sum - 2 * min_ << endl;

  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  string s;
  cin >> s;

  //同じ数字が連続して3回並んだ4桁の整数かどうか判定

  if(s[0]==s[1] && s[0]==s[2]){
    cout << "Yes" << endl;
    return 0;
  }else if(s[1]==s[2] && s[1]==s[3]){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int,input().split())
S = [list(map(int,input().split())) for i in range(n)]
D = [int(input()) for i in range(q)]

A = []
for i in range(n):
    s = S[i][0]
    t = S[i][1]
    x = S[i][2]
    A.append([s-x-0.5, x, i, 0])
    A.append([t-x-0.5, x, i, 1])
for i in range(q):
    A.append([D[i], 0, 0, 2])

A.sort()
from heapq import heappop, heappush
Q = []
F = [0] * n
for i in range(len(A)):
    s = A[i][0]
    x = A[i][1]
    j = A[i][2]
    f = A[i][3]
    if f == 0:
        heappush(Q, [x, j])
        F[j] = 1
    elif f == 1:
        F[j] = 0
    elif f == 2:
        while len(Q) > 0 and F[Q[0][1]] == 0:
            heappop(Q)
        if len(Q) > 0:
            print(Q[0][0])
        else:
            print(-1)


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

int n, a, b, c, l[8];

long long dfs(int cur, int x, int y, int z){
  if(cur==n){
    if(min(x,min(y,z))==0) return INT_MAX;
    return abs(a-x)+abs(b-y)+abs(c-z)-3*10;
  }

  return min(dfs(cur+1,x,y,z), min(dfs(cur+1,x+l[cur],y,z)+10, min(dfs(cur+1,x,y+l[cur],z)+10, dfs(cur+1,x,y,z+l[cur])+10)));
}

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

  printf("%lld\n", dfs(0,0,0,0));
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define FREE 0
#define NOT_FREE 1
int col[N],row[N],dpos[15],dneg[15],C[N][N];

void printBoard(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(C[i][j]==1){
	if(row[i]!=j)
	  return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }

}
      
  

void putQueen(int i){
  int j;
  
  if (i==N){
    printBoard();
    return;
  } 
  for(j=0;j<=N-1;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){     
      continue;
    }     
    // put a queen at (i, j)
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    // try the next row   
    putQueen(i+1);    
    // remove the queen at (i, j) for backtracking
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    
  }
}
int main(){
  int i,j,k,r,c;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      C[i][j]=-1;
    } 
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    C[r][c]=1;
  }
  
  putQueen(0);

  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;

const int INF = 3e18;

int x, y, ans = INF;
signed main()
{
  cin >> x >> y;

  if(y - x >= 0){
    ans = min(ans, y - x);
  }
  if(y - (-x) >= 0){
    ans = min(ans, y - (-x) + 1);
  }
  if(-y - x >= 0){
    ans = min(ans, -y - x + 1);
  }
  if(-y - (-x) >= 0){
    ans = min(ans, -y - (-x) + 2);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int last = 0;
  int target = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == target) {
      target++;
    } else {
      ans++;
    }
  }

  if (ans == n) ans = -1;   // 全部砕いた

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
o = gets.chomp.split('')
e = gets.chomp.split('')

l = o.length

if o.length == e.length
  (0...l).each do |i|
    print o[i] + e[i]
  end
  puts
else
  (0..l-1).each do |i|
    if i == l-1
      print o[i]
    else
      print o[i] + e[i]
    end
  end
  puts
end


Measured memory_bytes: 1788