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

using namespace std;

typedef long long ll;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	ll A, B;
	ll cnt = 1, axor = 0, bxor = 0;
	cin >> A >> B;
	if (B == 0){
		cout << 0 << '\n';
		return 0;
	}
	A--;
	if (A > 0){
		(A%4 == 2 || A%4 == 3) ? axor = 1 : axor = 0;
		for (int i = 1; i < 60; ++i){
			ll k = A%(2*cnt), l = A/(2*cnt);
			if (k >= cnt){
				axor ^= ((k-cnt+1)%2)*(cnt);
			}
			cnt <<= 1;
		}
	}
	(B%4 == 2 || B%4 == 3) ? bxor = 1 : bxor = 0;
	cnt = 1;
	for (int i = 1; i < 60; ++i){
		ll k = B%(2*cnt), l = B/(2*cnt);
		if (k >= cnt){
			bxor ^= ((k-cnt+1)%2)*(cnt);
		}
		cnt <<= 1;
	}
	cout << (bxor ^ axor) << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
	
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void){
	int hit, blow, a[4], b[4], i, j;
	while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]) != EOF){
		hit = blow = 0;
		for(i = 0;i < 4;i++){
			scanf("%d",&b[i]);
		}
		for(i = 0;i < 4;i++){
			for(j = 0;j < 4;j++){
				if(a[i] == b[j] && i == j){
					hit++;
				}else if(a[i] == b[j]){
					blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
ll GCD(ll p,ll q){
  if(p<q)swap(p,q);
  if(q==0)return p;
  return GCD(q,p%q);
}
ll LCM(ll p,ll q){
  return (p/GCD(p,q))*(q/GCD(p,q))*GCD(p,q);
}
int main(){
  int n;cin>>n;
  ll ans=1;
  rep(i,n){
    ll t;cin>>t;
    ans=LCM(ans,t);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10][19];
main(){
    int h, w,  k;
    cin >> h >>w >> k;
    for(int i = 0; i < h; i++)
    for(int j= 0; j < w; j++){
        char x;
        cin>>x;
        if(x == '#') a[i][j]=  1;

    }
    int ans= 0;
    for(int bi = 0; bi < (1<<h); bi++){
        for(int bj = 0; bj < (1<<w); bj++){
            int K= 0;
            for(int i = 0; i < h; i++)
            for(int j = 0; j < w; j++){
                if(((1<<i)&bi) && ((1<<j) &bj) && a[i][j])
                    K++;
            }
            if(k==K) ans++;

        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int x;
  scanf("%d",&x);
  if (400<=x&&x<=599) printf("8\n");
  if (600<=x&&x<=799) printf("7\n");
  if (800<=x&&x<=999) printf("6\n");
  if (1000<=x&&x<=1199) printf("5\n");
  if (1200<=x&&x<=1399) printf("4\n");
  if (1400<=x&&x<=1599) printf("3\n");
  if (1600<=x&&x<=1799) printf("2\n");
  if (1800<=x&&x<=1999) printf("1\n");
  return 0;
}

Measured memory_bytes: 1660
#python3

def f(x):
    return (x+1)/2

def main():
    n, k = map(int, input().split())
    fp = [f(int(i)) for i in input().split()]
    n = len(fp)
    v = sum(fp[0:k])
    i = 0
    ans = v
    while i+k <= n-1:
        v = v-fp[i]+fp[i+k] 
        ans = max(ans, v)
        i+=1

    a = "{0:.12f}".format(ans)
    print(a)

main()


Measured memory_bytes: 23588
R, G, B, N = map(int, input().split())

ans = 0

for g in range(N//G+1):
    for b in range(N//B+1):
        s = N-g*G-b*B
        if s < 0:
            break
        if s%R == 0:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if (H==0&&W==0)break;
        for (int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

bool cmp(ii a, ii b)
{
	if(a.fi!=b.fi) return a.fi>b.fi;
	else return a.se>b.se;
}

vector<ii> vec;
ll ans[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vec.resize(n);
	ll sum = 0;
	for(int i = 0; i < n; i++)
	{
		ll x; cin>>x;
		vec[i].fi=x;vec[i].se=i;
		sum+=x;
	}
	sort(vec.begin(),vec.end(),cmp);
	ll weight = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		ll cnt = vec[i].fi; ll idx = vec[i].se;
		if(i+1<vec.size()&&vec[i+1].fi==vec[i].fi)
		{
			weight++;
			continue;
		}
		if(i==int(vec.size()) - 1)
		{
			ans[idx]+=cnt*(weight+1);
			break;
		}
		int ptr = i + 1;
		int nxtval = vec[ptr].fi;
		int ext = 1;
		while(ptr<n&&vec[ptr].fi==nxtval)
		{
			ext++;
			ptr++;
		}
		ptr--;
		ext--;
		if(vec[ptr].se<idx)
		{
			ans[idx]+=(cnt-(nxtval+1))*(weight+1)+1+weight;
			weight++;
			continue;
		}
		ans[idx]+=(cnt-nxtval)*(weight+1);
		vec[ptr].se=idx;
		i=ptr-1;
		weight+=ext;
		continue;
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 3456
a = str(input())
l = len(a)
let5 = ['dream','erase']


while l >= 5:
  lb = len(a)
  if a[-5:] in let5:
    a = a[:-5]
    l -= 5
  if a[-6:] == 'eraser':
    a = a[:-6]
    l -= 6
  if a[-7:] == 'dreamer':
    a = a[:-7]
    l -= 7
  if l == 0:
    print('YES')
    break
  if l == lb:
    print('NO')
    break
else:
  print('NO')


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> d(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int temp;
            cin >> temp;
            d[i][j] = abs(temp - a[i][j]);
        }
    }
    const int offset = 12800;
    vector<vector<bitset<offset * 2>>> dp(h, vector<bitset<offset * 2>>(w, 0));
    dp[0][0][offset + d[0][0]] = dp[0][0][offset - d[0][0]] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i + 1 < h) {
                int diff = d[i + 1][j];
                dp[i + 1][j] |= dp[i][j] << diff;
                dp[i + 1][j] |= dp[i][j] >> diff;
            }
            if (j + 1 < w) {
                int diff = d[i][j + 1];
                dp[i][j + 1] |= dp[i][j] << diff;
                dp[i][j + 1] |= dp[i][j] >> diff;
            }
        }
    }
    for (int i = 0; i < 12800; i++) {
        if (dp[h - 1][w - 1][offset + i] || dp[h - 1][w - 1][offset + i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 20736
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l,r;
    for(int i=0;i<m;i++){
        int s,t;
        cin >> s >> t;
        l.push_back(s);
        r.push_back(t);
    }

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

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

    int ans = r.at(0)-l.at(0)+1;

    if(ans<0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 4260
#include<iostream>
#include<string>
#include<stack>
#include<cstdlib>


int main(){

  std::stack<int> st;
  std::string str;
  int a,b;
  while(std::cin>>str){
    
   if(str=="+"){
     a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(a+b);
    }else if(str=="-"){
      a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(b-a);
    }else if(str=="*"){
      a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(a*b);
   }else{
     st.push(atoi(str.c_str())); 
   }
   }
     std::cout<<st.top()<<std::endl;
   
   }



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, A, B;
    cin >> N >> A >> B;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else if (N == 2) {
        cout << (A + B) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int d;
	int ans = 0;
	while(scanf("%d", &d) != 0){
		if(d == 0) break;
		while(d != 1){
			if(d % 2 == 0){
				d /= 2;
			}else{
				d = d * 3 + 1;
			}
			ans++;
		}
		printf("%d\n", ans);
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long long dfs(long long n)
{
	if(n==1)
	return 1;
	else
	return dfs(n/2)*2+1;
}
int main()
{
	long long n;
	cin>>n;
	cout<<dfs(n);
	return 0;
 } 

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

const int SPACE = 0;
const int BLACK = 1;
const int WHITE = 2;

const int MAXN = 8;

int N, M, P;
int G[MAXN][MAXN][MAXN];

int count(int x, int y, int z, int dx, int dy, int dz) {
  int c = G[z][y][x];
  int res;
  res = 1;
  for(int i = 0; i < 2; ++i) {
    int nx, ny, nz;
    nx = x;
    ny = y;
    nz = z;
    while(1) {
      nx += dx;
      ny += dy;
      nz += dz;
      if(nx < 0 || nx >= N) break;
      if(ny < 0 || ny >= N) break;
      if(nz < 0 || nz >= N) break;
      if(G[nz][ny][nx] != c) break;
      ++res;
    }
    dx *= -1;
    dy *= -1;
    dz *= -1;
  }
  return res;
}

int tryPut(int x, int y, int c) {
  int z;
  for(z = 0; z < N && G[z][y][x] != SPACE; ++z);
  if(z == N) return SPACE;
  G[z][y][x] = c;
  for(int dx = -1; dx <= 1; ++dx) {
    for(int dy = -1; dy <= 1; ++dy) {
      for(int dz = -1; dz <= 1; ++dz) {
	if(dx == 0 && dy == 0 && dz == 0) continue;
	if(count(x,y,z,dx,dy,dz) >= M) return c;
      }
    }
  }
  return SPACE;
}


int main() {
  while(cin >> N >> M >> P && (N|M|P)) {
    fill(G[0][0], G[MAXN][0], SPACE);
    int winner = SPACE;
    int res = 0;
    for(int move = 0; move < P; ++move) {
      int x, y;
      cin >> x >> y;
      --x; --y;
      if(winner == SPACE) {
	winner = tryPut(x, y, move%2 == 0 ? BLACK : WHITE);
	res = move+1;
      }
    }
    if(winner == SPACE)
      cout << "Draw" << endl;
    else if(winner == BLACK)
      cout << "Black " << res << endl;
    else if(winner == WHITE)
      cout << "White " << res << endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int main() {
	int N;
	cin >> N;
	V<int64_t> A(N);
	READALL(A);
	sort(A.begin(), A.end());
	int64_t running = 0, right = -1, ans = 0;
	for (int i = 0; i < N; ++i) {
		if (right == N-1) {
			++ans;
			continue;
		}
		if (right >= i)
			continue;
		// cout << i << endl;
		running += A[i];
		++right;
		assert(right == i);
		while (right+1 < N && A[right+1] <= 2*running) {
			running += A[right+1];
			++right;
		}
		// cout << right << endl;
		if (right == N-1)
			++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
N,Y=gets.split.map(&:to_i)
x,y,z=-1,-1,-1
(N+1).times{|i|(N+1-i).times{|j|x,y,z=i,j,N-i-j if i*10000+j*5000+(N-i-j)*1000 == Y}}
puts "#{x} #{y} #{z}"

Measured memory_bytes: 1788
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int h,w;
  cin >> h >> w;

  vector<string> grid(h);
  for(int i = 0;i < h;i++){
    cin >> grid[i];
  }

  vector<pair<pair<int,int>,pair<int,int>>> sg;
  for(int i = 0;i < w;i++){
    for(int j = 0;j < h;j++){
      int sx = i;
      int sy = j;
      for(int k = 0;k < w;k++){
        for(int l = 0;l < h;l++){
          int gx = k;
          int gy = l;
          if(grid[sy][sx] == '.' && grid[gy][gx] == '.')sg.push_back(make_pair(make_pair(sy,sx),make_pair(gy,gx)));
        }
      }
    }
  }

  int ans = 0;

  for(auto p:sg){
    queue<pair<int,pair<int,int>>> que;

    vector<vector<int>> dist(h,vector<int>(w,-1));

    int sy = p.first.first;
    int sx = p.first.second;
    int gy = p.second.first;
    int gx = p.second.second;

    int cnt = 0;
    que.push(make_pair(0,make_pair(sy,sx)));
    dist[sy][sx] = 0;

    while(que.size()){
      pair<int,pair<int,int>> now = que.front();
      que.pop();

      int d = now.first;
      int now_y = now.second.first;
      int now_x = now.second.second;

      if(now_x == gx && now_y == gy){
        ans = max(ans,d);
        break;
      }

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

      for(int i = 0;i < 4;i++){
        int ny = now_y + dy[i];
        int nx = now_x + dx[i];

        if(0 <= nx && nx < w && 0 <= ny && ny < h && dist[ny][nx] == -1 && grid[ny][nx] == '.'){
          que.push(make_pair(d+1,make_pair(ny,nx)));
          dist[ny][nx] = d+1;
        }
      }
    }
  }

  cout << ans << endl;
}


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

int main() {
    int N,count = 0;
    cin >> N;
    vector<int> next(N),flag(N),hist(N+1);
    flag.at(0) = 1;
    hist.at(0) = 1;
    

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

    for (int i = 0; i < N; ++i){
        hist.at(i + 1) = next.at(hist.at(i) - 1);
        
        if (flag.at(hist.at(i+1)-1) == 1){
            cout << -1 << endl;
            break;
        }
        else{
            ++count;
            if (hist.at(i+1) == 2){
                cout << count << endl;
                break;
            }
            flag.at(hist.at(i) - 1) = 1;
        }
    }
}


Measured memory_bytes: 1408
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

h, w = nm()
if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()
minn = 10 ** 9
for i in range(1, w):
    if h % 2 == 0:
        minn = min(minn, max(i * h, (w - i) * h // 2)
                - min(i * h, (w - i) * h // 2))
    else:
        minn = min(minn, max(i * h, (w - i) * (h // 2), (w - i) * (h // 2 + 1))
                - min(i * h, (w - i) * (h // 2), (w - i) * (h // 2 + 1)))
for i in range(1, h):
    if w % 2 == 0:
        minn = min(minn, max(i * w, (h - i) * w // 2)
                - min(i * w, (h - i) * w // 2))
    else:
        minn = min(minn, max(i * w, (h - i) * (w // 2), (h - i) * (w // 2 + 1))
                - min(i * w, (h - i) * (w // 2), (h - i) * (w // 2 + 1)))
minn = min(minn, (h // 3 + 1) * w - (h // 3) * w, (w // 3 + 1) * h - (w // 3) * h)
print(minn)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;

int main(){
  ll X;
  cin>>X;
  ll N = X;
  ll sum = 0;
  while(X!=0){
    sum+=X%10;
    X/=10;
    }
  if(N%sum==0)
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import heapq

######## Wrapper for Max Heap ############
class MaxHeap:
    def __init__(self, H = []):
        self.heapify(H)

    def heapify(self, H):
        self._neg_heap = [ -a for a in H ] # マイナスをかける
        heapq.heapify( self._neg_heap )

    def push(self, value):
        heapq.heappush(self._neg_heap, -value)

    def pop(self):
        return (-1) * heapq.heappop(self._neg_heap)

    def __len__(self):
        return len(self._neg_heap)

# 入力を取得
N, M = [int(x) for x in input().split()]
AB = [None] * N  # AB[i] = [報酬までの日数, 報酬]
for i in range(N):
    AB[i] = [int(x) for x in input().split()]

AB.sort(key = lambda x: x[0]) # 報酬までの日数でソート

heap = MaxHeap() # 報酬額のMax heap
total = 0
j = 0  # 仕事を指すindex

for i in range(1, M + 1):
    while j < N and (AB[j][0]) <= i:  # i日後までに報酬が得られる仕事について
        heap.push(AB[j][1]) # 報酬額をpush
        j += 1
    if len(heap) > 0:
        total += heap.pop() # 最高額をpop

print(total)


Measured memory_bytes: 82392
#include <stdio.h>

int main(void)
{
  int H, W;
  int i, j;

  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) break;

    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {

        if (i % 2 == j % 2) {
          putchar('#');
        } else {
          putchar('.');
        }

      }
      putchar('\n');
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 572
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5+ 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
int x[] = {1,1,1,-1,-1,-1,0,0};
int y[] = {0,1,-1,0,-1,1,1,-1};
int main() {
    int N , T ;
    cin >> N >> T ;
    int mx = MAX ;
    for(int i=0;i<N;i++){
        int t , c ;
        cin >> t >> c ;
        if(c <=T) mx=min(mx,t) ;
    }
    if(mx==MAX){
        cout<<"TLE\n" ;
    }
    else
        cout<<mx<<endl;
    
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    char c;
    cin >> c;
    c++;
    cout << c << endl;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s_list = gets_nsp_list

puts s_list.size == s_list.uniq.size ? "yes" : "no"

Measured memory_bytes: 2428
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
#include<random>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
bool solve(string str,vector<bool>&spl){
	int i,n=str.size(),gen=-1;
	vector<int> su(n+1);su[0]=-1;
	for(i=0;i<n;i++){
		while(gen>=0&&str[i]!=str[gen]){gen=su[gen];}
		gen++;
		su[i+1]=gen;
	}
	for(i=1;i<n;i++){if(su[i]!=0&&i%(i-su[i])==0){spl[i-1]=true;}}
	return su[n]!=0&&n%(n-su[n])==0;
}
int main(void){
	int n,i;
	string str;cin>>str;n=str.size();
	//string rts;
	int ddd=1;
	for(i=1;i<n;i++){if(str[i]!=str[i-1]){ddd=0;break;}}
	if(ddd==1){cout<<n<<endl<<1<<endl;return 0;}
	vector<bool> spl(n-1);
	if(!solve(str,spl)){cout<<1<<endl<<1<<endl;return 0;}
	reverse(str.begin(),str.end());
	reverse(spl.begin(),spl.end());
	if(!solve(str,spl)){cout<<1<<endl<<1<<endl;return 0;}
	int ans=0;
	for(i=0;i<n-1;i++){if(!spl[i]){ans++;}}
	cout<<2<<endl<<ans<<endl;
	return 0;
}

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


int main() {
  string s;
  cin >> s;
  int total = 700;
  int cnt = 0;
  if (s[0] == 'o') cnt++;
  if (s[1] == 'o') cnt++; 
  if (s[2] == 'o') cnt++;
  cout << total + 100 * cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<pair<lli, lli> > g[N];
lli col[N];


void dfs(lli u, lli p = -1, lli dis = 0) {

    if(dis % 2 == 0) {
        col[u] = 1;
    }
    for(auto it : g[u]) {
        lli v = it.ff;
        lli d = it.ss;
        if(p != v) {
            dfs(v, u, dis + d);
        }
    }

}

void solve()
{

    lli n;
    cin>>n;
    for(int i = 0; i < n - 1; i ++) {
        lli a, b, c;
        cin>>a>>b>>c;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    dfs(1);
    for(int i = 1; i <= n; i ++) {
        cout<<col[i]<<'\n';
    }
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 15232
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int h,w;
  cin >> h >> w;

  char e[h+2][w+2];

  int c=0;

  for(int i=0;i<w+2;i++){
    e[0][i]='#';
    e[h+1][i]='#';
  }
  for(int i=1;i<h+1;i++){
    e[i][0]='#';
    for(int j=1;j<w+1;j++){
      cin >> e[i][j];
      if(e[i][j]=='#')c++;
    }
    e[i][w+1]='#';
  }

  int dist[h+2][w+2];
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      dist[i][j]=-1;
    }
  }

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

  queue<vector<int>> que;

  dist[1][1]=0;
  que.push({1,1});

  while(!que.empty()){
    vector<int> v=que.front();
    que.pop();

    for(int i=0;i<4;i++){
      if(dist[v[0]+dy[i]][v[1]+dx[i]]==-1 && e[v[0]+dy[i]][v[1]+dx[i]]=='.'){
        dist[v[0]+dy[i]][v[1]+dx[i]]=dist[v[0]][v[1]]+1;
        que.push({v[0]+dy[i],v[1]+dx[i]});
      }
    }
  }

  if(dist[h][w]!=-1)cout << w*h-c-dist[h][w]-1 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
ceildiv a b = div (a + b - 1) b

main = do
    n <- readLn :: IO Int
    x <- map read . words <$> getLine :: IO [Int]
    let sum_x = sum x
    let p0 = div sum_x n
    let p1 = ceildiv sum_x n
    let cost0 = sum [(x0 - p0) ^ 2 | x0 <- x]
    let cost1 = sum [(x0 - p1) ^ 2 | x0 <- x]
    print $ min cost0 cost1


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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    ll x, ans;
    cin >> x;

    ans = x / 11 * 2;
    x %= 11;

    if (x > 0 && x <= 6)
        ++ans;
    else if (x > 6 && x <= 10)
        ans += 2;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import queue
n,m=map(int,input().split())
l=[[] for i in range(n)]

for _ in range(m):
    tempa,tempb=map(int,input().split())
    tempa-=1
    tempb-=1
    l[tempa].append(tempb)
    l[tempb].append(tempa)
que=queue.Queue()
dist=[-1]*n

dist[0]=0
que.put(0)
ans=[0]*n

while not que.empty():
    v=que.get()

    for nv in l[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        que.put(nv)
        ans[nv]=v
if -1 in dist:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(ans[i]+1)


Measured memory_bytes: 35240
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, 0, s.size()){
		s[i] = 'x';
	}
	cout << s << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	vector<pii> a(n);
	int at;
	rep(i,n) {
		cin >> at; 
		a[i] = pii(at, i+1);
	}
	sort(a.begin(), a.end());
	rep(i,n) {
		cout << a[i].se;
		if(i == n-1) cout << endl;
		else cout << " ";
	}



  return 0;
}


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

int main(){
  int age; cin>>age;
  if(age==3||age==5||age==7)cout<<"YES";
  else{cout<<"NO";}
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int va;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int va) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->va = va;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* search(int va) {
    struct Node *x = note->next;
    while(x != note && x->va != va ) {
        x = x-> next;
    }
    return x;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}
 void deleteva(int va) {
    deleteNode(search(va));
}  
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
   
void print() {
    struct Node *x;
    x = note->next;
    int i = 0;
    while(1) {
        if (x == note) break;
    	if(i++ > 0) printf(" ");
        printf("%d", x->va);
        x = x->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int va, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &va);
        if(order[0] == 'i') {
            insert(va);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( strlen(order) > 10) {
                    deleteFirst();
                }else if( strlen(order) > 9) {
                    deleteLast();
                }
            }else {
                deleteva(va);
            }
        }
    }
    print();
    return 0;
}

Measured memory_bytes: 36128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int N;
ll x[100100];
int M;
ll K;
int A[100100];
vi mul(vi a,vi b){
	vi ret(a.size());
	for(int i=0;i<a.size();i++){
		ret[i] = b[a[i]];
	}
	return ret;
}
vi pow(vi a,ll y){
	vi ret;
	for(int i=0;i<a.size();i++){
		ret.pb(i);
	}
	while(y){
		if(y%2ll==1ll)ret = mul(ret,a);
		y /= 2ll;
		a = mul(a,a);
	}
	return ret;
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	vll y;
	for(int i=1;i<N;i++){
		y.pb(x[i]-x[i-1]);
	}
	cin >> M >> K;
	vi sig;
	for(int i=0;i<N-1;i++)sig.pb(i);
	for(int i=0;i<M;i++){
		cin >> A[i];
		A[i]--;
		swap(sig[A[i]],sig[A[i]-1]);	
	}
	// dump(sig);
	sig = pow(sig,K);
	// dump(sig);
	vll z(N-1);
	for(int i=0;i<N-1;i++){
		z[i] = y[sig[i]];
	}
	// dump(y);
	// dump(z);
	vll ans(N);
	ans[0] = x[0];
	for(int i=0;i<N-1;i++){
		ans[i+1] = ans[i]+z[i];
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define SIZE 5005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll way[SIZE];
ll way2[SIZE];
ll way3[SIZE];
ll dp[SIZE][2];

int main()
{
	int n,A,B;
	scanf("%d %d %d",&n,&A,&B);
	if(A>B) swap(A,B);
	for(int i=1;i<B;i++)
	{
		way[i]=1;
		for(int j=1;j+A+1<=i;j++)
		{
			ll vl=way[j]*(ll) (i-j-A)%MOD;
			way[i]+=vl;
			if(way[i]>=MOD) way[i]-=MOD;
		}
	}
	for(int i=1;i<B;i++)
	{
		way3[i]=0;
		for(int j=A;j<i;j++)
		{
			way3[i]+=way[i-j];
			if(way3[i]>=MOD) way3[i]-=MOD;
		}
	}
	way2[0]=1;
	for(int i=1;i<B;i++)
	{
		way2[i]=0;
		for(int j=0;j+A+1<=i;j++)
		{
			ll vl=way2[j]*(ll) (i-j-A)%MOD;
			way2[i]+=vl;
			if(way2[i]>=MOD) way2[i]-=MOD;
		}
	}
	dp[0][0]=1;
	for(int i=0;i<B;i++) dp[i][1]=way2[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(j-i<B)
			{
				dp[j][1]+=dp[i][0]*way[j-i]%MOD;
				if(dp[j][1]>=MOD) dp[j][1]-=MOD;
			}
			if(j-i<A)
			{
				dp[j][0]+=dp[i][1];
				if(dp[j][0]>=MOD) dp[j][0]-=MOD;
			}
		}
	}
	ll ret=(dp[n][0]+dp[n][1])%MOD;
	for(int i=A;i<n;i++)
	{
		ret+=dp[n-i][0]*way3[i]%MOD;
		if(ret>=MOD) ret-=MOD;
	}
	ll all=1;
	for(int i=0;i<n;i++) all=all*2LL%MOD;
	printf("%lld\n",(all-ret+MOD)%MOD);
}

Measured memory_bytes: 3952
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        
        String c11 = a.substring(0,1);
        String c12 = a.substring(1,2);
        String c13 = a.substring(2,3);
        String c21 = b.substring(0,1);
        String c22 = b.substring(1,2);
        String c23 = b.substring(2,3);
        if (c11.equals(c23) && c12.equals(c22) && c13.equals(c21)){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

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

int main() {
	
	int n;
	
	while(cin >> n){
		int ans = 0;
		for(int a = 0; a < 10; a++){
			for(int b = 0; b < 10; b++){
				for(int c = 0; c < 10; c++){
					int d = n - a - b- c;
					if(0 <= d && d <= 9) ans++;
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var x int64
	fmt.Scan(&x)
	ret := int64(100)
	result := 0
	for {
		result++
		ret += int64(float64(ret) * 0.01)
		if ret >= x {
			break
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 1756
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == 'I') {
                cnt++;
                if (ans < cnt) {
                    ans = cnt;
                }
            } else {
                cnt--;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23764
N,K = map(int,input().split())

h = [input() for i in range(N)]
H = [int(s) for s in h]
H.sort()
d = 10000000000
for i in range(N-K+1):
    if d > (H[i+K-1] - H[i]):
        d = H[i+K-1] - H[i]

print(d)
    


Measured memory_bytes: 14608
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	ll a,b,c,k; cin>>a>>b>>c>>k;
	if(k<=a+b) cout<<min(a,k)<<endl;
	else cout<<a-(k-(a+b))<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define N 200005
#define mod 1000000007
typedef long long int ll;
typedef long int li;

int n,h[N],b[N];
ll dp[N],tree[4*N+4],ans;

void update(int i,int s,int e,int id,ll val) {
    if(s == e) { tree[i] = val;  dp[id] = val; }
    else {
        int mid = (s+e)/2;
        if(s <= id && id <= mid)  update(2*i,s,mid,id,val);
        else update(2*i+1,mid+1,e,id,val);
        tree[i] = max(tree[2*i],tree[2*i+1]);
    }
}

ll query(int i, int s, int e, int l, int r) {
    if(r < s || e < l) return 0;
    if(l <= s && e <= r) return tree[i];
    int mid = (s+e)/2;
    return max(query(2*i,s,mid,l,r),query(2*i+1,mid+1,e,l,r));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++) cin>>b[i];
    
    for(int i=0;i<n;i++) {
        ll max_s = query(1,1,n,1,h[i]-1);
        update(1,1,n,h[i],b[i]+max_s);
    }
    for(int i=1;i<=n;i++) ans = max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  ll ans=0;
  rep(i,1,n+1){
    if(i%3!=0 && i%5!=0) ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin >> n;
	long long int dp[112345][3];
	// int dp[n][n];
	for(int i=0;i<n;i++)
	{
		int a,b,c;cin >> a >> b >> c;
		if(i==0){
			dp[i][0] = a;
			dp[i][1] = b;
			dp[i][2] = c;
		}
		else{
			dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
			dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
			dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c;
		}
	}
	cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1;
	int dy = y2 - y1;

	int x3 = x2 - dy;
	int y3 = y2 + dx;

	int x4 = x3 - dx;
	int y4 = y3 - dy;

	printf("%d %d %d %d\n", x3, y3, x4, y4);
	

	return 0;
}

Measured memory_bytes: 3700
#n=int(input())
n,k=map(int,input().split())
l=list(map(int,input().split()))
mul=1
for i in range(k):
  mul=mul+l[i]
z=mul
j=0
for i in range(k,n):
  z=z-l[j]
  z=z+l[i]
  if z>mul:
    print('Yes')
  else:
    print('No')
  j+=1
  mul=z

Measured memory_bytes: 31544
#include <stdio.h>

#define MAX 45

int func(int );

int main()
{
  int n;
  scanf("%d", &n);
  printf("%d\n", func(n));

  return 0;
}

int func(int n)
{
  int i;
  int a[MAX];

  if(n == 0 || n == 1) return 1;

  a[0] = 1;
  a[1] = 1;
  for(i=2; i<=n; i++) {
  a[i] = a[i-2] + a[i-1];
  }
  return a[n];
}



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


int main()
{
	long long n, x;
	long long max = -1000000;
	long long min = 1000000;
	long long sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if (max<x)
		{
			max = x;
		}
		if (x < min)
		{
			min = x;
		}
		sum = sum + x;
	}
	
	cout << min << ' ' << max << ' ' << sum << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>

int dp[50];

int fib(int n) {
  if(dp[n] != -1) return dp[n];
  if(n == 0) return 1;
  if(n == 1) return 1;

  return dp[n] = fib(n-1) + fib(n-2);
}

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

  for(int i=0; i<50; ++i) {
    dp[i] = -1;
  }
  dp[0] = 1;
  dp[1] = 1;

  int fb = fib(n);
  std::cout << fb << std::endl;

}


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

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long K,S;
	cin >> K >> S;

	long long ans = 0 ;

	for(long long i=0;i<=K;i++){

		for(long long j=0;j<=K;j++){

			long long x = S - i - j;
			if(x >= 0 && x <= K){

				ans = ans + 1;
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if ((0<=x-r && x+r<=w) && (0<=y-r && y+r<=h)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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


using namespace std;

main(){

    int mask = 0;
    char s[110];
    scanf("%s" , s);

    for(int i = 0 ; s[i] ; i ++){
        mask ^= 1 << (int(s[i] - 'a'));
    }

    printf("%s\n" , mask == 0 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 384
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys



mod = 10**9+7
sys.setrecursionlimit(mod)

N = int(input())
graph = [set() for i in range(N+1)]

for i in range(N-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    w = w % 2
    graph[u].add((v,w))
    graph[v].add((u,w))


res = [None for i in range(N+1)]

# v は今見ている頂点，p はｖの親
def dfs(node,p,color): # Depth First Serch
    res[node] = color
    for new_node,w in graph[node]:
        if new_node == p:
            pass
        else:
            if w == 1:dfs(new_node,node,1-color)
            else:dfs(new_node,node,color)
#tree 探索　
# vは頂点，ｐは親
dfs(0,-1,0)

for i in range(N):
    print(res[i])


Measured memory_bytes: 90444
#include <iostream>
    #include <limits>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <queue>
     
    using namespace std;
     
    int main()
    {
     
    	long long num_count;
    	cin >> num_count;
     
    	vector<long long> nums( num_count*3 );
     
    	for( long long i = 0; i < nums.size(); ++i )
    		cin >> nums[i];
     
    	long long answer = numeric_limits<long long>::min();
     
    	map< int,long long > plus_total, minus_total;
    	priority_queue< long long, vector<long long>, greater<long long> > q_plus;
    	priority_queue< long long, vector<long long>, less<long long> > q_minus;
     
    	long long total = 0;
     
    	for( long long i = 0; i < num_count; ++i )
    	{
    		q_plus.push( nums[i] );
    		total += nums[i];
    	}
     
    	plus_total[0] = total;
     
    	for( long long k = 0; k < num_count; ++k )
    	{
     
    		total += nums[k+num_count];
    		q_plus.push(nums[k+num_count]);
    		total -= q_plus.top();
    		q_plus.pop();
     
    		plus_total[k+1] = total;
     
    	}
    	
    	total = 0;
    	for( long long i = 2*num_count; i < 3*num_count; ++i )
    	{
    		q_minus.push(nums[i]);
    		total += nums[i];
    	}
     
    	minus_total[num_count] = total;
     
    	for( long long k = num_count-1; k >= 0; --k )
    	{
    		total += nums[k+num_count];
    		q_minus.push(nums[k+num_count]);
    		total -= q_minus.top();
    		q_minus.pop();
    		minus_total[k] = total;
    	}
     
    	for( long long i = 0; i <= num_count; ++i )
    	{
    		answer = max( answer, plus_total[i] - minus_total[i] );
    	}
     
    	cout << answer << endl;
     
    	return 0;	
     
    }

Measured memory_bytes: 16628
#include <iostream>
#include <vector>
//#include <algorightm>
#include <map>
#include <tuple>
//#include <cstudio>

int main() {
    int N;
    std::cin >> N;
    char c;
    int count = 0;
    while (N > 0 ){
        std::cin >> c;
        if (c == 'Y'){
            count++;
        }
        N--;
    }
    if (count > 0 )std::cout << "Four" <<std::endl;
    if (count == 0 )std::cout << "Three" <<std::endl;

}


Measured memory_bytes: 256
N=int(input())
s=list(input())
for i in range(N-1):
    ss=[]
    t=list(input())
    for j in range(len(s)):
        if s[j] in t:
            ss.append(s[j])
            t.remove(s[j])
    s=ss
print("".join(sorted(s)))
    
        
    
    

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  ll cur = 0;
  rep(i, N) { cur = A[i] * 2 - cur; }

  if (cur != 0) cur /= 2;

  rep(i, N) {
    cout << cur << ' ';
    cur = A[i] * 2 - cur;
  }
  cout << endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}

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


Measured memory_bytes: 256