akhauriyash/Code-Regression huggingface dataset:
N = int(input())
h = [list(map(int, input().split())) for _ in range(N)] #1-index

def chmax(a,b):
    if a >= b:
        return a
    else:
        return b
dp = [[0]*(3) for _ in range(N+2)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if (j == k): continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + h[i][k])

print(max(dp[N]))

Measured memory_bytes: 74072
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	string s[n];
	int bucket[n][26]={};
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<s[i].size();j++){
			bucket[i][s[i][j]-'a']++;
		}
	}
	int mini;
	for(int az=0;az<26;az++){
		mini=INF;
		for(int i=0;i<n;i++){
			mini = min(mini,bucket[i][az]);
		}
		for(int i=0;i<mini;i++) cout << (char)('a'+az);
	}
	cout << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

struct vector2D{
  double x;
  double y;
};

vector2D subVector(const vector2D& t1, const vector2D& t2) {
  vector2D ret;
  ret.x = t1.x - t2.x;
  ret.y = t1.y - t2.y;
  return ret;
}

bool hittest(vector2D a, vector2D b, vector2D c, vector2D p) {
  vector2D AB = subVector(b, a);
  vector2D BP = subVector(p, b);

  vector2D BC = subVector(c, b);
  vector2D CP = subVector(p, c);

  vector2D CA = subVector(a, c);
  vector2D AP = subVector(p, a);

  double c1 = AB.x * BP.y - AB.y * BP.x;
  double c2 = BC.x * CP.y - BC.y * CP.x;
  double c3 = CA.x * AP.y - CA.y * AP.x;

  if( ( c1 > 0 && c2 > 0 && c3 > 0 ) || ( c1 < 0 && c2 < 0 && c3 < 0 ) ) {
    return true;
  }

  return false;
}

signed main(void)
{
  vector2D p1, p2, p3, p4;
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y)) {
    if(hittest(p1, p2, p3, p4) || hittest(p1, p2, p4, p3) || hittest(p1, p3, p4, p2) || hittest(p2, p3, p4, p1)) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

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

class Task{
  private:
  long currentNum;
  int addNum;

  public:
  Task(long prevNum, int addNum):currentNum(prevNum * 10 + addNum) ,addNum(addNum){
  }

  void nextTask(queue<Task*>* numQueue){
    for(int i = addNum - 1; i <= addNum + 1; i++){
      if(i >= 0 && i < 10){
        numQueue->push(new Task(currentNum, i));
      }
    }
  }
  
  long getCurrNum(){
    return currentNum;
  }
};

signed main(){
  int k;
  cin >> k;
  queue<Task*>* tasks = new queue<Task*>();
  for(int i = 1; i < 10; i++){
    for(int j = i - 1; j <= i + 1; j++){
      if(j < 10 && j >= 0){
        tasks->push(new Task(i, j));
      }
    }
  }
  if(k < 10){
    cout << k << endl;
    return 0;
  }

  for(int i = 9; i < k - 1; i++){
    tasks->front()->nextTask(tasks);
    tasks->pop();
  }

  cout << tasks->front()->getCurrNum() << endl;
}

Measured memory_bytes: 10880
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			long[] array = new long[n];
			for (int i = 0; i<n; i++) array[i] = sc.nextLong();
			int query = sc.nextInt();
			for (int i = 0; i<query; i++) {
				System.out.println(binarySearch(array,sc.nextLong())? "1":"0");
			}
		}
	}

	static boolean binarySearch(long[] array, long target) {
		int low = 0;
		int high = array.length-1;  //最後
		
		while (low <= high) {
			//System.out.println(low + "    "+ high);
			int mid = (high + low)/2;
			if (array[mid] == target) return true;
			else if (array[mid] < target) low = mid+1;
			else high = mid-1;
		}
		return false;  //最後まで見つからなかったら
	}
}


Measured memory_bytes: 108600
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

const int INF = 10000000;
using namespace std;
typedef long long  ll;
/** Problem0131 : Coctor's Strange Particles **/
// true : 点灯  false : 消灯
bool board[10][10];
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

void flip(int x, int y)
{
	int nx, ny;
	board[x][y] = !board[x][y];
	rep(i, 4) {
		nx = x+dx[i]; ny = y+dy[i];
		if (0 <= nx && nx < 10 && 0 <= ny && ny < 10)
			board[nx][ny] = !board[nx][ny];
	}
}

int main()
{
	int n;
	bool stamp[10][10];
	bool copy[10][10];
	cin >> n;
	while (n-- > 0) {
		rep(j,10) rep(k,10) {
			int c;
			cin >> c;
			board[k][j] = c==1;
			copy[k][j] = board[k][j];
		}
		
		/** Lights-Out Game Mode
		while (1) {
			int x, y;
			cin >> x >> y;
			flip(x, y);
			
			rep(y, 10) {
				if (board[0][y])
					cout << '1';
				else
					cout  << '0';
				REP(x, 1, 10) {
					if (board[x][y])
						cout << ' ' << '1';
					else
						cout << ' ' << '0';
				}
				cout << endl;
			}
		} **/
		
		
		for (int i=0; i<1024; i++) {
			rep(y, 10) rep(x, 10) board[x][y] = copy[x][y];
		
			rep(j, 10) {
				stamp[j][0] = (i>>j&1);
			}
			rep(j, 10) {
				if (stamp[j][0])
					flip(j, 0);
			}
			
			for (int y=1; y<10; y++) {
				for (int x=0; x<10; x++) {
					if (board[x][y-1]) {
						stamp[x][y] = true;
						flip(x, y);
					} else {
						stamp[x][y] = false;
					}
				}
			}
			
			bool flag=true;
			rep(j, 10) {
				if (board[j][9]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				rep(y, 10) {
					if (stamp[0][y])
						cout << '1';
					else
						cout << '0';
					
					REP(x, 1, 10) {
						if (stamp[x][y])
							cout << ' ' << '1';
						else
							cout << ' ' << '0';
					}
					cout << endl;
				}
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1e9+7;
#define fillchar(x,y,z) memset(x,z,y)
int main(){

 ios_base::sync_with_stdio(0);
    cin.tie(0);

ll n,w;
cin>>n>>w;
ll dp[n*1001];
fillchar(dp,sizeof(dp),inf);
ll sum=0,ans=0;
dp[0]=0;
for(ll i=0,W,V;i<n;i++)
{
	
	cin>>W>>V;
	
	for(ll j=sum;j>=0;j--)
	{
		if(W<=w)
		dp[V+j]=min(dp[V+j],dp[j]+W);
		
		if(dp[V+j]<=w)ans=max(ans,V+j);
			
	}
	sum+=V;
	
}


cout<<ans;


return 0;



}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[100010][2][100];
	
int main(){
	string n; cin >> n;
	int nsize = n.l_ength();
	int m; cin >> m;
	dp[0][0][0] = 1;
	for( int i = 0; i < nsize; ++i ){
		for( int less = 0; less <= 1; ++less ){
			for( int k = 0; k < m; ++k ){
				int bound = less ? 9 : n[i] - '0';
				for( int d = 0; d <= bound; ++d ){
					( dp[i+1][ less || ( d != bound ) ][ (k+d)%m ] += dp[i][less][k] ) %= MOD;
				}
			}
		}
	}
	cout << ( dp[nsize][0][0] + dp[nsize][1][0] + 1000000006 ) % MOD << endl;
	return 0;
}

Measured memory_bytes: 16640
// template version 1.11
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#endif
//}}}

int solve(){
  int a,b;cin>>a>>b;
  if (a>=13){
    cout << b << endl;
  }
  else if (6<= a && a<=12){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main(){
  int W,H,N;
  cin >>W>>H>>N;
  int left=0,right=W,up=H,down=0;
  for(int i=0;i<N;i++){
    int a,b,t;
    cin >> a>>b>>t;
    if(t==2) right=min(right,a);
    else if(t==1) left=max(left,a);
    else if(t==4) up=min(up,b);
    else if(t==3) down=max(down,b);
    if(right <= left) {
      cout << 0 <<endl;
      return 0;
    }
     if(up <= down) {
      cout << 0 <<endl;
      return 0;
    }
  }
 
  cout << (up-down)*(right-left) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll x[200000];
int cnt[60][2];
int main(){
	int n;
	ll K;cin>>n>>K;
	rep(i,n){
		scanf("%lld",&x[i]);
		rep(j,60){
			cnt[j][x[i]>>j&1]++;
		}
	}
	ll ans=0;
	for(int i=59;i>=0;i--){
		ll A=(1LL<<i);
		if(cnt[i][1]>=cnt[i][0]){
			ans+=A*cnt[i][1];
		}
		else{
			if(K>=(1LL<<i)){
				K-=(1LL<<i);
				ans+=A*cnt[i][0];
			}
			else{
				ans+=A*cnt[i][1];
			}
		}
		//~ ans+=A*max(cnt[i][0],cnt[i][1]);
		//~ if(cnt[i]==1){
			//~ ans+=(1LL<<i);
		//~ }
		//~ else{
			//~ if(K>=(1LL<<i)){
				//~ K-=(1LL<<i);
				//~ ans+=(1LL<<i);
			//~ }
		//~ }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INFINT = numeric_limits<int>::max();
const ll INFLL = numeric_limits<long long>::max();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;


int main() {
	string s;
	ll k;
	int ichi = 0;

	cin >> s >> k;
	while (s[ichi] == '1') ichi++;
	ichi--;

	if (ichi >= 0 && k - 1 <= ichi) {
		cout << '1' NL;
	} else {
		cout << s[ichi+1] NL;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    ll a, b, x;
    cin >> a >> b >> x;
    ll i = b / x;
    ll j;
    if (a == 0)
        j = -1;
    else
        j = --a / x;
    cout << i - j << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3564
N=int(input())
H=list(map(int,input().split()))
dp=[0]#足場iまでの最小コスト
dp.append(abs(H[1]-H[0]))
for i in range(2,N):
    dp.append(min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2])))
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    int mx = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] =='A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T'){
            cnt++;
            mx = max(mx,cnt);
        }
        else cnt = 0;
    }

    cout << mx << endl;


}

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

ll comb[500][10];
ll ans, dif[10];
ll n,m,l;
ll alpha[3][10];
int use[10];

ll calc(void){
  ll dp[10][70] = {};
  rep(i,m)dp[0][i] = 1;

  rep(i,l-1)rep(j,m){
    if(dif[i]==2){
      for(int k=j+2;k<m;k++)dp[i+1][k] += dp[i][j];
    }else{
      if(j+dif[i]<m)dp[i+1][j+dif[i]] += dp[i][j];
    }
  }
  
  ll res = 0;
  rep(i,m)res += dp[l-1][i];

  int len = 1;
  rep(i,l-1){
    if(dif[i]==0)len++;
    else{
      res *= comb[n][len];
      len = 1;
    }
  }
  res *= comb[n][len];

  return res;
}

bool check(int d){
  if(d==3){
    //rep(i,l)cerr << use[i] << " "; cerr << endl;
    return true;
  }

  int tmpu[10], tmpa[10];
  rep(i,l){
    int cnt = 0;
    rep(j,l)tmpu[j] = use[j];
    rep(j,10){
      tmpa[j] = alpha[d][j];
      cnt += alpha[d][j];
    }

    int p = i, num = 0, sum = 0;
    while(p<l && tmpa[num]){
      while(p<l && tmpa[num]){
	if(!use[p] && sum == num){
	  use[p] = 1;
	  tmpa[num]--;
	  cnt--;
	}
	sum += dif[p];
	p++;
      }
      num++;
    }

    if(cnt==0 && check(d+1))return true;
    rep(j,l)use[j] = tmpu[j];
  }
  return false;
}

void rec(int d){
  if(d == l-1){
    memset(use,0,sizeof(use));
    if(!check(0))return;

    //rep(i,l-1)cerr << dif[i] << " "; cerr << endl;

    ans += calc();
    return;
  }

  rep(i,3){
    dif[d] = i;
    rec(d+1);
  }
}

int main(){
  memset(comb,0,sizeof(comb));
  comb[0][0] = 1;
  rep(i,420){
    comb[i+1][0] = 1;
    rep(j,7)comb[i+1][j+1] = comb[i][j+1] + comb[i][j];
  }

  while(cin >> n >> m >> l, n){
    vector<string> h(l);
    rep(i,l)cin >> h[i];
    memset(alpha,0,sizeof(alpha));
    
    rep(i,l){
      if(h[i] == "*")continue;
      int id = h[i][0]-'a';
      alpha[id][h[i].size()-1]++;
    }
    
    ans = 0;
    rec(0);
    cout << fixed << setprecision(9) << (double)ans/comb[n*m][l] << endl;
  }
}

Measured memory_bytes: 1320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[2000],b[2000],c[2000];
const int maxn=1e6;
const int N=1e7;
long long ans[N];
long long d[maxn];
bool cmp(long long a,long long b){
    return a>b;
}
int main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++)
        cin>>a[i];
    for(int i=0;i<y;i++)
        cin>>b[i];
    for(int i=0;i<z;i++)
        cin>>c[i];
    sort(c,c+z,cmp);
    int cur=0;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            d[cur++]=a[i]+b[j];
        }
    }
    cur=0;
    sort(d,d+x*y,cmp);
    int f=min(3000,x*y);
    for(int i=0;i<f;i++){
        for(int j=0;j<z;j++){
            ans[cur++]=d[i]+c[j];
        }
    }
    cur=f*z;
    sort(ans,ans+cur,cmp);
    for(int i=0;i<k;i++){
        cout<<ans[i]<<endl;
    }
}


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

int main(void) {
	int n, x, q, b, m, e;
	vector<int> v;
	cin >> n;
	while (n--) {
		cin >> x;
		v.push_back(x);
	}
	cin >> q;
	while (q--) {
		cin >> b >> m >> e;
		rotate(v.begin() + b, v.begin() + m, v.begin() + e);
	}
	for (int i = 0; i < v.size(); i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 3164
import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
mod=10**9+7

s=0
for i in range(60):
    bit = np.count_nonzero(a & 1)
    s += bit*(n-bit)*(2**i)
    a >>= 1
print(s % mod)

Measured memory_bytes: 68856
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
# from time import perf_counter


def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = np.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = np.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = np.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = np.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = np.minimum(values[y, :] + 1, values[y - 1, :])

    print(np.max(values))


if __name__ == '__main__':
    # st = perf_counter()
    main()
    # ed = perf_counter()
    # print(ed - st)


Measured memory_bytes: 29020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 1; i <= n; i++){
            map.put(sc.nextInt(),i);
        }
        UnionFindTree uft = new UnionFindTree(n+1);
        for(int i = 0; i < m; i++){
            uft.union(sc.nextInt(),sc.nextInt());
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            if(uft.same(i,map.get(i))) ans++;
        }
        System.out.println(ans);
    }
}

class UnionFindTree {
	int[] parent;
	int[] rank;
	int[] size;
	
	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];
		this.size = new int[size];
		
		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}
	
	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0;
		size[i] = 1;
	}
	
	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);
		
		if (rank[xRoot] > rank[yRoot]) { 
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
			rank[xRoot]++; 
		}
	}
	
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}
	
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}

	public int size(int x) {
		return size[find(x)];
	}
}

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

int main(){
  int N, W, H, S, T, x, y, ans;
  while (cin >> N, N){
    cin >> W >> H;
    int F[W+1][H+1];
    for (int i = 0; i < W+1; ++i){
      for (int j = 0; j < H+1; ++j){
	F[i][j] = 0;
      }
    }
    for (int i = 0; i < N; ++i){
      cin >> x >> y;
      F[x][y] += 1;
    }
    for (int i = 0; i < W; ++i){
      for (int j = 0; j < H; ++j){
	F[i+1][j+1] += F[i][j+1] + F[i+1][j] - F[i][j];
      }
    }
    cin >> S >> T;
    ans = 0;
    for (int i = S; i < W+1; ++i){
      for (int j = T; j < H+1; ++j){
	ans = max(ans, F[i][j] - F[i-S][j] - F[i][j-T] + F[i-S][j-T]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int D;
    cin >> D;
    if(D==24){
        cout << "Christmas Eve" << endl;
    }else if(D==25){
        cout << "Christmas" << endl;
    }else if(D==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve" << endl;
    }
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;


int digit(int n)
{
    int m,res=0;
    while(n){
        m=n%10;
        n/=10;
        res+=m;
    }
    return res;
}


int arr[g_size];



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

	int n,m,T,res,a,b;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>a>>b;

	f(i,1,n){
        k=digit(i);
        if(k>=a && k<=b) count+=i;
	}
	cout<<count<<endl;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
        	while(true) {
        		String line = reader.readLine();
        		String[] num = line.split(" ", -1);
        		int x = Integer.parseInt(num[0]);
        		int y = Integer.parseInt(num[1]);
        		if (x == 0 && y == 0) {
        			break;
        		} else {
        			if (x > y) {
        				System.out.println(y + " " + x);
        			} else {
        				System.out.println(x + " " + y);
        			}
        		}
        	}
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
}

Measured memory_bytes: 26900
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	int ans = 0, r = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'R')
			r++;
		else
			r = 0;
		ans = max(ans, r);
	}
	cout << ans;
	return 0;
}
	


Measured memory_bytes: 3648
#include <stdio.h>

int factorize(long long n, long long p[], int m[])
{
	int k;
	long long i;
	for (i = 2, k = 0; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[k] = i;
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

void merge_sort(long long x[], int n)
{
	static long long y[501] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long K, A[501];
	scanf("%d %lld", &N, &K);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	int j, k, m[100];
	long long sum = 0, p[100];
	for (i = 1; i <= N; i++) sum += A[i];
	k = factorize(sum, p, m);
	
	int l[100] = {1};
	long long ans = 1, tmp = p[0], B[501], max;
	while (l[k] == 0) {
		if (tmp > ans) {
			for (i = 0; i < N; i++) B[i] = A[i+1] % tmp;
			merge_sort(B, N);
			for (i = 0, j = N - 1, sum = 0; i < j; ) {
				if (B[i] < tmp - B[j]) {
					sum += B[i];
					B[j] += B[i];
					B[i++] = 0;
				} else if (B[i] > tmp - B[j]) {
					sum += tmp - B[j];
					B[i] -= tmp - B[j];
					B[j--] = tmp;
				} else {
					sum += B[i];
					B[i++] = 0;
					B[j--] = tmp;
				}
			}
			if (sum <= K) ans = tmp;
		}
		
		for (i = 0; i < k && l[i] == m[i]; i++);
		for (l[i]++, tmp *= p[i--]; i >= 0; l[i--] = 0) {
			for (j = 0; j < l[i]; j++) tmp /= p[i];
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

int main()
{
  ll h, n, sum = 0;
	
  cin >> h >> n;
  for (int i = 0;i < n;i++)
  {
    ll tmp;
    cin >> tmp;
	sum += tmp;
  }
if (sum < h)
  cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
typedef pair<int, int>P;
#define int long long

int a[100000];
int sum[500000];
signed main() {
	int n; scanf("%lld", &n);
	rep(i, n) {
		scanf("%lld", &a[i]);
		sum[a[i]]++;
	}
	int Max = 0;
	for (int i = -1; i <= 200000; i++) {
		int cnt = 0;
		if (i - 1 >= 0)cnt += sum[i - 1];
		if (i >= 0)cnt += sum[i];
		cnt += sum[i + 1];

		Max = max(Max, cnt);
	}
	cout << Max << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll h, w;
	map<char, ll> m;
	std::cin >> h >> w;
	vector<string> a(h);

	rep(i, 0, h) {
		std::cin >> a[i];
		rep(j, 0, w) {
			m[a[i][j]]++;
		}
	}

	ll f = (h / 2) * (w / 2);
	ll t = (w / 2) * (h - 2 * (h / 2)) + (h / 2) * (w - 2 * (w / 2));
	ll o = h * w - 4 * f - 2 * t;

	for (auto itr = m.begin(); itr != m.end(); itr++) {
		ll tmp = min(itr->second / 4, f);
		itr->second -= 4*tmp;
		f-=tmp;

		tmp = min(itr->second / 2, t);
		itr->second -= 2 * tmp;
		t -= tmp;

		if (itr->second == 1 && o == 1) {
			itr->second--;
			o--;
		}

		if (itr->second > 0) {
			outn("No");
			return 0;
		}

	}

	outn("Yes");

	return 0;
}


Measured memory_bytes: 256
/* UserName - ankit_S
  author -Ankit kumar
*/
//https://atcoder.jp/contests/dp/tasks/dp_g
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long 
const ll int MOD=1e9+7;
vector<vector<int>>graph;
vector<bool>vis;
vector<ll int>dist;
void dfs(int node){
    vis[node]=true;
    for(auto i:graph[node]){
        if(!vis[i])dfs(i);
        dist[node]=max(dist[node],1+dist[i]);
    }
    
}
int main()
{
    FAST
    int n,m;
    cin>> n>> m;
    vis=vector<bool>(n,false);
    graph=vector<vector<int>>(n);
    for(int i=0;i<m;i++){
    	int x,y;
        cin>> x>> y;
        x--,y--;
        graph[x].push_back(y);
   	}
    dist= vector<ll int>(n,0);
    for(int i=0;i<n;i++){
        if(!vis[i])
            dfs(i);
    }
    
    
    ll int ans=0;
    for(auto i :dist){
        ans=max(ans,i);
    }
    cout<<ans<<endl;
 
    return 0;
}

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

int A[10000];
int n;

bool solve(int i, int m){
    bool res;
    if(m==0) return true;
    else if(i>=n) return false;
    else{
        res = solve(i+1, m) || solve(i+1,m-A[i]);
    }

    return res;
}

int main(){
    int q,mm;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);
    for(int j=0;j<q;j++){
        scanf("%d", &mm);
        if(solve(0,mm)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n,W;
    cin>>n>>W;
    vector<int> value(n);
    vector<int> weight(n);
    for(int i = 0; i < n; i++) cin>>weight[i]>>value[i];
    int sum_value = 0;
    for(int i = 0; i < n; i++) sum_value += value[i];
    vector<int> dp(sum_value+1,INF);
    dp[0] = 0;
    //dp[i] = the min total weight of items with total value exactly equal to i
    for(int item = 0 ; item < n; item++){
        for(int value_already = sum_value-value[item]; value_already >= 0; value_already--){
            dp[value_already+value[item]] = min(dp[value_already+value[item]],dp[value_already]+weight[item]);
        }
    } 
   int ans = 0;
   for(int i = 0; i <= sum_value; i++){
        if(dp[i] <= W){
            ans = max(ans,i);
        }
   }
   cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    string str;
    int n = 0;
    int count = 0;
    bool out = false;
    cin >> str;
    n = str.size() -1;
    while(n > 1){
        if (n % 2 == 0){
            char front[128];
            char back[128];
            int i = 0;
            for (i = 0; i < n/2; ++i) {
                front[i] = str[i];
            }
            for (int j = 0; j < n/2; ++j) {
                back[j] = str[j+(n /2)];
            }
            for (int k = 0; k < i; ++k) {
                if(front[k] == back[k])count++;
                if(front[k] != back[k])break;
            }
            if(count == i){
                out = true;
                break;
            }
        }
        count = 0;
        n--;
    }
    if (out == true){
        cout << n;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second
#define lowbit(x) (x & -x) 

const int N = 2e5 + 10;
const int M = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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

int n;
int a[2][N], h[2][N];

void updata(int x, int no)
{  
    int lx, i;
    while (x <= n)  
    {  
        h[no][x] = a[no][x];
        lx = lowbit(x);  
        for (i=1; i<lx; i<<=1)
            h[no][x] = min(h[no][x], h[no][x-i]); 
        x += lowbit(x);
    }         
}  
int query(int x, int y, int no)  
{  
    int ans = INF;  
    while (y >= x)  
    {  
        ans = min(a[no][y], ans); 
        y --;  
        for (; y-lowbit(y) >= x; y -= lowbit(y))
            ans = min(h[no][y], ans);  
    }  
    return ans;  
}

struct pp{
	int x, y, l, r;
	
	pp(int x = 0, int y = 0, int l = 0, int r = 0):
		x(x), y(y), l(l), r(r) { }
		
	bool operator < (const pp &A)const{
		return x > A.x || (x == A.x && y > A.y);
	}
};

set<PII> x;
set<PII>::iterator it;
int nt[N], b[N];
priority_queue<pp> q;

void add(int l, int r)
{
	x.insert(MP(l, r));
	vector<int> qt;
	int nd = query(l, r, l&1);
	if(nt[nd] == r){
		if((r&1) == (l&1)) nd = query(l, r-1, l&1);
		else nd = query(l, r-2, l&1);
	}
		
	
	int j = query(nt[nd], r, !(nt[nd] & 1));
//	printf("%d %d %d %d\n", nd, j, l, r);
	q.push(pp(nd, j, l, r));
}

int main()
{
	scanf("%d", &n);
	memset(a, INF, sizeof(a));
	memset(h, INF, sizeof(h));
	for(int i = 1; i <= n; i++){
		int no = i & 1;
		scanf("%d", &a[no][i]);
		updata(i, no);
		nt[a[no][i]] = i;
	}

	add(1, n);
	for(int i = 0; i < n; i += 2){
		pp tm = q.top(); q.pop();
		b[i] = tm.x; b[i+1] = tm.y;
		int ni = nt[tm.x], nj = nt[tm.y];
		x.erase(MP(tm.l, tm.r));
		if(ni - 1 - tm.l > 0)
			add(tm.l, ni-1);
		if(nj - 1 - (ni + 1) > 0)
			add(ni+1, nj-1);
		if(tm.r - (nj + 1) > 0)
			add(nj+1, tm.r);
	}
	
	for(int i = 0; i < n; i++)
		printf("%d%c", b[i], i == n-1 ? '\n' : ' ');
	
	return 0;
}

Measured memory_bytes: 9332
s = input()

res = 0
s
s[::-1]
if s == s[::-1]:
    res += 1

t = int((len(s)-1)/2)
tm = s[:t]
if tm == tm[::-1]:
    res += 1

u = int(((len(s) +3) / 2 )-1)
tm = s[u:]
if tm == tm[::-1]:
    res +=1

if res == 3:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int kohosha, wan;
		kohosha = scn.nextInt();	//候補者数
		wan = scn.nextInt();	//小石数
		while (kohosha != 0 || wan != 0) {
			int[] temoto = new int[kohosha];
			int turn = 0;
			while(true){
				if(wan == 0){
					wan = temoto[turn];
					temoto[turn] = 0;
				}else{
					temoto[turn]++;
					wan--;
				}
				if(wan == 0){
					boolean eflg = true;
					for(int i = 0; i < kohosha; i++) if(i != turn && temoto[i] != 0){eflg = false; break;}
					if(eflg) break;
				}
				turn = Math.min(turn + 1, (turn + 1) % kohosha);
			}
			System.out.println(turn);
			kohosha = scn.nextInt();
			wan = scn.nextInt();
		}
	}
}

Measured memory_bytes: 20264
#include <iostream>

using namespace std;

int main()
{
    int h, n, a, sum = 0;
    cin >> h >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        sum += a;
        if (sum >= h)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			double a1 = sc.nextDouble();
			double b1 = sc.nextDouble();
			double e1 = sc.nextDouble();
			double a2 = sc.nextDouble();
			double b2 = sc.nextDouble();
			double e2 = sc.nextDouble();
			double x = (e1 * b2 - b1 * e2) / (a1 * b2 - b1 * a2);
			double y = (e2 * a1 - e1 * a2) / (a1 * b2 - b1 * a2);
			if (x == 0) x = 0;
			if (y == 0) y = 0;
			System.out.printf("%.3f %.3f\n",  x, y);
		}


	}

}

Measured memory_bytes: 20536
/* ABC141-C
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, first, quiz, *point, answer, i;

    scanf( "%d %d %d" , &number, &first, &quiz);
    point = malloc(sizeof(int) * number);
    for(i=0; i < number; i++){
        point[i] = first - quiz; /* 全問不正解の場合の点数を入力 */
    }

    for(i=0; i < quiz; i++){
        scanf( "%d" , &answer); /* (i+1)問目の正解者を入力 */
        point[answer-1]++; /* 正解者のみ加点 */
    }

    for(i=0; i < number; i++){
        if(point[i]>0){
            printf( "Yes\n" ); /* 勝ち抜け */
        }else{
            printf( "No\n" ); /* 敗退 */
        }
    }
    return 0;
}

Measured memory_bytes: 896
import numpy as np
N, K = map(int, input().split())
Ps = np.array(input().split(), dtype=int)

cumsum = Ps.cumsum()
cumsum = np.concatenate([[0], cumsum])
moving_cumsum = cumsum[K:] - cumsum[:-K]

res = (moving_cumsum.max() + K) / 2
print(res)

Measured memory_bytes: 32328
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n;
    while (cin >> n && n != 0) {
        int sum = 1;
        int top=1, bottom=6, left=4, right=3, front=2, back=5;
        for (int i=0; i<n; ++i) {
            string direction;
            cin >> direction;
            int tmp;
            if (direction == "North") {
                tmp=top;
                top=front; front=bottom; bottom=back; back=tmp;
            } else if (direction == "East") {
                tmp=top;
                top=left; left=bottom; bottom=right; right=tmp;
            } else if (direction == "West") {
                tmp=top;
                top=right; right=bottom; bottom=left; left=tmp;
            } else if (direction == "South") {
                tmp=top;
                top=back; back=bottom; bottom=front; front=tmp;
            } else if (direction == "Right") {
                tmp=front;
                front=right; right=back; back=left; left=tmp;
            } else if (direction == "Left") {
                tmp=front;
                front=left; left=back; back=right; right=tmp;
            }
            sum += top;
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<ll, ll>> z(N);
  for (int i = 0; i < N; i++) cin >> z[i].first >> z[i].second;
  sort(z.begin(),z.end());

  int ans = N+1;
  for(int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      ll p = z[j].first - z[i].first;
      ll q = z[j].second - z[i].second;
      cerr << "p=" << p << " q=" << q << endl;
      int cost = 1;
      for (int k = 0; k < N-1; k++) {
        bool ok = false;
        for (int l = k+1; l < N; l++) {
          if (z[l].first-z[k].first == p && z[l].second-z[k].second == q) {
            ok = true;
            break;            
          }
        }
        cerr << ok << endl;
        if (!ok) cost++;
      }
      cerr << "cost= " << cost << endl;
      ans = min(cost, ans);
    }
  }
  if (N == 1) ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
typedef long long ll;



int main(){
    int cnt = 0;
    string s;
    cin>>s;
    if(s=="RRR")cout<<3;
    else if(s=="SSS")cout<<0;
    else if(s=="RRS"||s=="SRR")cout<<2;
    else cout<<1;

	
} 

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

using namespace std;

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

    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        printf("Possible");
    } else {
        printf("Impossible");
    }

    return 0;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]

a = [0]*3
b = [0]*3

a[0] = 0
for i in range(3):
    b[i] = c[0][i] - a[0]
for i in range(1,3):
    a[i] = c[i][0] - b[0]

good = True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            good = False
            break
    else:
        continue
    break
print('Yes' if good else 'No')




Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main(){
  int n,k,t;
  scanf("%d %d",&n,&k);
  int arr[n],min;
  int dp[n];
  for(int i=0;i<n;i++){
  scanf("%d",&arr[i]);
  }
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++){
    min=INT_MAX;
  for(int j=i-1;j>=i-k&&j>=0;j--){
  t=abs(arr[i]-arr[j])+dp[j];
    if(t<min){
    min=t;
    }
  }
    dp[i]=min;
  }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<int> b(N);
	rep(i,N) cin >> b[i];
	vector<int> ans;
	int t = N;
	while(t--){
		int m = b.size();
		for(int i = m-1; i >= 0; i--){
			if(b[i] == i+1){
				ans.push_back(i+1);
				b.erase(b.begin()+i);
				break;
			}
		}
	}
	if(ans.size() != N) cout << -1 << endl;
	else{
		reverse(ans.begin(),ans.end());
		rep(i,N){
			cout << ans[i] << endl;
		}
	}
}



Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<climits>
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
//4611686018427387903
using namespace std;
void solve(int cnum){	
	int n;
	cin >> n;
	map<string,int>arr;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		arr[s]++;
	}
	cout << "AC x "<<arr["AC"]<<"\n";
	cout << "WA x "<<arr["WA"]<<"\n";
	cout << "TLE x "<<arr["TLE"] <<"\n";
	cout << "RE x "<<arr["RE"]<<"\n";
	
}
int main(){
	
	//ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);
	//initprime();
	int t;
	int count = 1;
	for(t = 1;t--; solve(count),count++);
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    vector<int> A(M + 1);
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int a;
            cin >> a;
            A[a]++;
        }
    }
    int cnt = 0;
    for (int i = 1; i < M + 1; i++) {
        if (A[i] == N) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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 gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int n;cin >> n;
  cout << 1110-n << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}

int main() {
	set<string> s;
	int n; cin >> n;
	rep(i, n) {
		str st; cin >> st;
		s.insert(st);
	}
	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 19068
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < N/2; i++){
        if(S[i] != S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256