akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import bisect

input = sys.stdin.readline

N, Q = map(int, input().split())

STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])

D = [int(input()) for _ in range(Q)]
ans = [-1] * Q
index = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    now = left
    while now < right:
        if index[now] == -1:  # まだansが更新されていない場合
            ans[now] = x
            index[now] = right
            now += 1
        else:
            now = index[now]
            

for a in ans:
    print(a)

Measured memory_bytes: 109276
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int a, b, c; cin >> a >> b >> c;
	int m = max(max(a, b), c), x;
	if (m % 2 == (a + b + c) % 2) x = m;
	else x = m + 1;
	cout << (3 * x - (a + b + c)) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MAX 100100
#define NIL -1
using namespace std;

typedef struct node{
  int parent, left, right;
}Node;

Node T[MAX];
int depth[MAX];

int seekroot(int id){
  while (T[id].parent != NIL){
    id = T[id].parent;
  }
  return id;
}

void setDepth(int id, int d){
  depth[id] = d;

  if (T[id].right != NIL){
    setDepth(T[id].right, d);
  }
  if (T[id].left != NIL){
    setDepth(T[id].left, d+1);
  }
  return;
}

string type(int id){
  if (T[id].parent == NIL){
    return "root";
  }else if (T[id].left == NIL){
    return "leaf";
  }else{
    return "internal node";
  }
}

string child(int id){
  string ans = "[";

  if (T[id].left != NIL){
    ans.append(to_string(T[id].left));
    id = T[id].left;
  
    while(T[id].right != NIL){
      ans.append(", ");
      ans.append(to_string(T[id].right));
      id = T[id].right;
    }

  }

  ans.append("]");

  return ans;
}

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

  rep(i, n){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
    depth[i] = NIL;
  }
  

  rep(i, n){
    int id;
    int k;
    int c[k+3]; // ループ内で何回も定義し直すとダメだった。node数が4ならできたし，node数が13個の時でも場合によって可能であった。


    cin >> id >> k;
    if(k != 0){
      rep(j, k) cin >> c[j];

      T[id].left = c[0];
      rep(j, k) T[c[j]].parent = id;
      rep(j, k-1) T[c[j]].right = c[j+1];
    }
  }

  int root = seekroot(0);
  setDepth(root, 0);


  rep(i, n){
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "depth = " << depth[i] << ", ";
    cout << type(i) << ", ";
    cout << child(i) << endl;
    // printf("node %d: parent = %d, depth = %d, %s, %s\n", i, T[i].parent, depth(i), type(i), child(i));
  }

  return 0;
}




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

int main() {
  
  string s;
  cin >> s;
  
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <stack>
#include <algorithm>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

typedef struct	_DEC
{
	const char *lpszText;
	int length;
} DEC;

void	Decrypt(std::string &dst, std::string &src)
{
	static DEC decTbl[] =
	{
		{"", 0 + 1},	// +1 for prevent 0-DIV
		{".,!? ", 5}, {"abc", 3}, {"def", 3}, {"ghi", 3},
		{"jkl", 3}, {"mno", 3}, {"pqrs", 4}, {"tuv", 3},
		{"wxyz", 4},
	};
	for(int pos = 0, len = src.size(); pos < len; pos ++)
	{
		int ch, sectlen = pos;
		for(ch = src[pos]; src[pos] != '0'; pos ++);
		sectlen = pos - sectlen - 1;
		if(int idx = ch - '0')
		{	dst += decTbl[idx].lpszText[sectlen % decTbl[idx].length];	}
	}
}

int main()
{
	int tc;
	std::cin >> tc;
	while(tc --)
	{
		std::string decText;
		std::string encText;
		std::cin >> encText;
		::Decrypt(decText, encText);
		std::cout << decText << std::endl;
	}
}

Measured memory_bytes: 1208
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>

#define MAXN 200050
#define mod 10000000

using namespace std;

int n;
char s[MAXN];
int t[MAXN];
int a[2][MAXN];
int cnt[2];

int main()
{
    //freopen("c.txt", "r", stdin);

    while (cin >> n) {
        scanf("%s", s);
        for (int i = 0; i < n; i++)
            if (s[i] == '.')
                t[i] = 0;
            else
                t[i] = 1;
        cnt[0] = cnt[1] = 0;
        memset(a, 0, sizeof(a));

        for (int i = 0; i < n; i++) {
            a[0][i + 1] = a[0][i];
            a[1][i + 1] = a[1][i];
            cnt[t[i]]++;
            a[t[i]][i + 1]++;
        }
        int ans = n;
        for (int i = 0; i <= n; i++) {
            int tmp = a[1][i] + (cnt[0] - a[0][i]);
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll h,w,a,b;
    cin>>h>>w>>a>>b;
  FOR(i,0,h){
    string s;
    FOR(j,0,w){
      if(i<b&&j<a) s+='0';
      else if(i>=b&&j>=a) s+='0';
      else s+='1';
    }
    cout<<s<<endl;
  }
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define inf ((int) 1e9)
#define Linf ((long long) 1e18)

typedef long long ll;
typedef long double ld;

const int N = 123456;
const int M = 1234567;
const int P = 400004;
const int A = 256;

ll ncr(int n, int r){

	if(n < r)
		return 0;

	if(n < 0 || r < 0)
		return 0;

	if(n == r)
		return 1;

	return ncr(n - 1, r - 1) + ncr(n - 1, r);
}


void qsort(auto * a, int i, int j){

	if(i >= j) return;

	int l = i;
	int r = j;

	while(r > l){ 

		while(r > l && a[r] >= a[l]) r--;

		if(a[r] < a[l]){
			swap(a[r], a[l]);
		}

	}	

	qsort(a, i, r - 1);
	qsort(a, r + 1, j);

	return;
}


auto bpow(auto base, auto exp, auto MOD){

	ll ans = 1;
	for(; exp; exp>>=1){
		if(exp & 1)
			ans = (ans * base) % MOD;
		base = (base * 1ll * base) % MOD;
	}

	return ans;
}

int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg1o1
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	

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

	int n;
	cin >> n;

	int a[n + 1];
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}

	sort(a, a + n);

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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(void){
    int n,s[1010],i,b;
    double a=0,h=0;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
         
        for(i=1;i<=n;i++){
            scanf("%d",&s[i]);
        }
        h=0;
        for(i=1;i<=n;i++){
            h+=s[i];
        }
        h=h/(double)n;
        a=0;
        for(i=1;i<=n;i++){
            a+=((double)s[i]-h)*((double)s[i]-h);
        }
        a=a/n;
        a=sqrt(a);
        printf("%f\n",a);
    }
    return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			double m = sc.nextDouble();
			
			double[] aArray = new double[n];
			
			int total = 0;
			for(int i = 0 ; i < n ; i++ ) {
				aArray[i] = sc.nextDouble();
				total += aArray[i];
			}
			
			double th = total / (4*m);
			int count = 0;
			for(int i = 0 ; i < n ; i++ ) {
				if ( aArray[i] >= th) {
					count++;
				}
			}
			
			if ( count >= m ) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
			
		}
	}

}

Measured memory_bytes: 24020
/*Always success does not build on success,success build on failure*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t)
#define lscn(t)      scanf("%lld",&t)
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=1e5+5;
int main()
{
   ll n;
   lscn(n);
   
   ll arr[n][3];
   
   for(ll i=0;i<n;i++)
   {
       lscn(arr[i][0]);
       lscn(arr[i][1]);
       lscn(arr[i][2]);
   }
   
   for(ll i=1;i<n;i++)
   {
       arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
       
       arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
       
       arr[i][2]+=max(arr[i-1][1],arr[i-1][0]);
   }
   
   cout<<max(arr[n-1][0],max(arr[n-1][1],arr[n-1][2]));
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	int n, a, b;
	cin >> n >> a >> b;
	string p;
	cin >> p;
	int x = 0, y = 0;
	for (int i = 0; i < p.size(); i++) {
		if (p[i] == 'c')cout << "No" << endl;
		if (p[i] == 'a') {
			if (x + y < a + b)cout << "Yes" << endl;
			else cout << "No" << endl;
			x++;
		}

		if (p[i] == 'b') {
			if (x + y < a + b) {
				if (y < b) { cout << "Yes" << endl; y++; }
				else cout << "No" << endl;
			}
			else cout << "No" << endl;
			
		}
	}


	return 0;

}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
    int n,x,counter=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if((x%2!=0)&&(i%2!=0))
            counter++;
    }
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class361
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var k = new List<int>[M];
            for(int i = 0; i < M; i++)
            {
                k[i] = new List<int>(Console.ReadLine().Split().Select(int.Parse).ToList());
            }
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;
            for(int i = 0; i < (1 << N); i++)
            {
                int n = 0;
                for(int j = 0; j < M; j++)
                {
                    int count = 0;
                    for(int l = 1; l < k[j].Count; l++)
                    {
                        if ((i & (1 << k[j][l]-1)) > 0) count++;
                    }
                    if (count % 2 == p[j])
                        n |= (1 << j);
                }
                //Console.WriteLine(n);
                if (n == (1<<M)-1) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
#define length(a) (hypot((a).imag() , (a).real()))
#define eps 1e-8
#define vec(a,b) ((b)-(a))
#define dot(a,b) ( (conj(a)*(b)).real() )
#define polar(r,t) ((r)*exp(point(0,(t))))
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define point complex <ld>
#define x real()
#define y imag()
#define pi acos(-1)

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

    int n;
    string s;
    map<string , int> mp;
    cin >> n;
    while(n--)
    {
        cin >> s;
        mp[s]++;
    }

    cout << mp.size() << '\n';

    return 0;
}

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

int main() {
    int r, g, b, num;

    cin >> r >> g >> b;
    num = r*100 + g*10 + b;
    if (num%4 == 0){
        cout << "YES" << endl;
    }

    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	string hoge = "keyence";
	int mae = 0;
	for (int i = 0;mae != hoge.length()&&i < s.length(); ++i) {
		if (s[i] == hoge[mae]) {
			mae++;
		}
		else break;
	}
	int back = hoge.length() - 1;
	for (int i = s.length() - 1;back != -1&&i >= 0; --i) {
		if (s[i] == hoge[back]) {
			back--;
		}
		else break;
	}
	if (mae > back) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

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

const int M = 1e9+7;

int power(int a, int p) {
    if (p == 0) return 1;
    int ans = power(a, p/2);
    ans = (1LL*ans * ans)%M;
    if (p%2)    ans = (1LL*ans*a)%M;
    return ans;
}

const int N = 4e6+7, K = 2005;
int fac[N], invfac[N];
void pre() {
    fac[0] = 1;
    for(int i=1; i<N; i++)  fac[i] = (1LL*i*fac[i-1])%M;
    invfac[N-1] = power(fac[N-1], M-2);
    for (int i=N-2; i>=0; i--)  invfac[i] = (1LL*invfac[i+1]*(i+1))%M;
}

int C(int n, int r) {
    if (r<0 || r>n) return 0;
    int denom = (1LL*invfac[r]*invfac[n-r])%M;
    return (1LL*fac[n]*denom)%M;
}

int dp[K][K];

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

    int n, k;
    cin>>n>>k;

    if (k == 1) {
        cout<<1<<endl;
        return 0;
    }

    dp[n][n] = 1;
    for (int b=n-1; b>=0; b--) {
        for (int a=n; a>=0; a--) {
            if (a < n)      dp[b][a] = dp[b][a+1];
            if (a != b) {
                int rem = n-a + (k-1)*(n-b);
                dp[b][a] = (dp[b][a] + 1LL*C(rem-1, k-2)*dp[b+1][a])%M;
            }
        }
    }
    cout<<(1LL*dp[0][0]*fac[n])%M<<endl;
}


Measured memory_bytes: 50524
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
ll h,w,x,y,i,ans=inf,mx,mn,rh,rw,a[3];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	//freopen("sol.in","r",stdin);
	cin>>h>>w;
	for(i=1,x=(w-1)*(h/2),y=(w-1)*((h/2)+(h%2));i<w;i++,x-=(h/2),y-=((h/2)+(h%2)))
	{
		mx=0,mx=max(x,max(y,h*i)),mn=inf,mn=min(x,min(y,h*i));
		ans=min(ans,mx-mn);
	}
	for(i=1,x=(h-1)*(w/2),y=(h-1)*((w/2)+(w%2));i<h;i++,x-=(w/2),y-=((w/2)+(w%2)))
	{
		mx=0,mx=max(x,max(y,w*i)),mn=inf,mn=min(x,min(y,w*i));
		ans=min(ans,mx-mn);
	}
	if((h/3)>0)
	{
		rh=h%3,a[0]=a[1]=a[2]=h/3;
	    for(i=0;i<rh;i++)a[i]++;
	    for(i=mx=0,mn=inf;i<=2;i++)mx=max(mx,a[i]*w),mn=min(mn,a[i]*w);
	    ans=min(ans,mx-mn);
	}
	if((w/3)>0)
	{
		rw=w%3,a[0]=a[1]=a[2]=w/3;
	    for(i=0;i<rw;i++)a[i]++;
	    for(i=mx=0,mn=inf;i<=2;i++)mx=max(mx,a[i]*h),mn=min(mn,a[i]*h);
	    ans=min(ans,mx-mn);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;


char s[100];
int main(){
	
	scanf("%s", s);
	int len =strlen(s) - 8;
	for (int i=0; i<len; i++) putchar(s[i]);
	
	return 0;
}



Measured memory_bytes: 256
N = input()

score = [[0,0,0] for n in range(N)]

for n in range(N) :
  a, b, c = map(int,raw_input().split())

  if n == 0 : score[0] = [a, b, c]
  else : 
    score[n][0] = a + max(score[n-1][1], score[n-1][2])
    score[n][1] = b + max(score[n-1][0], score[n-1][2])
    score[n][2] = c + max(score[n-1][0], score[n-1][1])
  
print max(score[-1])

Measured memory_bytes: 43036
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        for(long i = N; i < 10000000; i++) {
            if(isPrime(i)) {
                System.out.println(i);
                break;
            }
        }

    }
    public static boolean isPrime(long N) {
        if(N == 1) return false;
        for(long i = 2; i * i <= N; i++) {
            if(N % i == 0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 35908
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) { 
	while (true) {
int n = sc.nextInt();
if (n == 0) { 
	break; 
}
int[] scores = new int[n];
for (int i = 0; i < scores.length; i++) {
scores[i] = sc.nextInt(); 
}
double average = 0, variance = 0;
for (int j=0; j<scores.length; j++){
	average=average+scores[j];
}
average=average/scores.length;
 for (int k=0; k<scores.length; k++){
variance=(scores[k]-average)*(scores[k]-average)+variance;

 }
 variance=variance/scores.length;
System.out.println(Math.sqrt(variance));
} 
}
} 
}


Measured memory_bytes: 31788
from heapq import heappush, heappop

n, m = map(int, input().split())

works = []

for _ in range(n):
    a, b = map(int, input().split())
    works.append((a, b))

works.sort(reverse = True)

hq = []
ans = 0

for i in range(1, m+1):
    while works and works[-1][0] <= i:
        a, b = works.pop()
        heappush(hq, -b)
    if hq:
        b = -heappop(hq)
        ans += b

print(ans)

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

int main(){

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

	int n;cin>>n;
	ll ans=0;
	unordered_map<int,int> umap;
	for(int i=0;i<n;i++){
		int t;cin>>t;
		ans+=t;
		if(umap.find(t)==umap.end()){
			umap[t]=1;
		}
		else{
			umap[t]++;
		}
	}

	int q;cin>>q;
	for(int i=0;i<q;i++){
		int b,c;cin>>b>>c;
		if(umap.find(b)==umap.end()){
			cout<<ans<<endl;
			continue;
		}
		ll tmp=umap[b];
		ans=ans-tmp*b+tmp*c;
		cout<<ans<<endl;

		umap.erase(b);

		if(umap.find(c)==umap.end())
			umap[c]=tmp;
		else
			umap[c]+=tmp;
	}

	return 0;
}

Measured memory_bytes: 6576
n = input()

l = len(n) #nの桁数

if l==1: print(int(n))
elif l==2: print(9)
elif l==3: print(9+int(n)-99)
elif l==4: print(9+900)
elif l==5: print(9+900+int(n)-9999)
elif l==6: print(9+900+90000)

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


int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a<=b&&c<=d)cout<<a+c<<endl;
	else if(a<=b&&c>=d)cout<<a+d<<endl;
	else if(a>=b&&c<=d)cout<<b+c<<endl;
	else if(a>=b&&c>=d)cout<<b+d<<endl;
	return 0;
	}


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

int main(void){
	int N,K;
	cin >> N >> K;
	if(N <= K){
		cout << "0";
		return 0;
	}
	vector<unsigned long long> H;
	string s;
	while(getline(cin, s, ' ')){
		H.push_back(stoi(s));
	}
	sort(H.begin(), H.end(), [&](const auto& l, const auto& r){
		return l > r;
	});
	unsigned long long sum = 0;
	for(int i = K;i < H.size();++i){
		sum += H[i];
	}
	cout << sum;
}


Measured memory_bytes: 2420
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  vector<string>a(n);
  vector<string>b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);
  int itti = m*m;
  vector<vector<char>> s(n, vector<char>(n));//int型の2次元配列(3×4要素の)の宣言
  vector<vector<char>> t(m, vector<char>(m));//int型の2次元配列(3×4要素の)の宣言
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      s.at(i).at(j) = a.at(i).at(j);
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      t.at(i).at(j) = b.at(i).at(j);
    }
  }
/*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << s.at(i).at(j);
    }
    cout << endl;
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      cout << t.at(i).at(j);
    }
    cout << endl;
  }
  */
  int flag=0;
  int count = 0;
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      for(int k=0;k<m;k++){
        for(int p=0;p<m;p++){
          if(s.at(i+k).at(j+p) == t.at(k).at(p)) count++;
        }
      }
      if(count == itti) flag=1;
      count = 0;
    }
  }
  if(flag==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 1つ目の整数
    int a = sc.nextInt();
    // 2つ目の整数
    int b = sc.nextInt();

    int multi = a * b;

    String result;
    if (multi % 2 == 0) {
      result = "Even";
    } else {
      result = "Odd";
    }

    System.out.println(result);
  }
}


Measured memory_bytes: 21588
def main():
    K = int(input())
    from math import gcd
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                d = gcd(a, b)
                ans += gcd(c, d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67764
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool ok(string s) {
    auto l = s.substr(0, s.size() / 2);
    auto r = s.substr(s.size() / 2 + s.size() % 2, s.size() / 2);
    reverse(all(r));
    return l == r;
}
int main() {
    int n;
    cin >> n;
    int ans = INF;
    rep(i, 100005) {
        if (ok(to_string(i))) {
            if (abs(ans - n) > abs(i - n)) {
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int height;
    vector<int> heights;
    while (cin >> height)
	heights.push_back(height);
    sort(heights.begin(), heights.end(), greater<int>());
    for (int i = 0; i < 3; i++)
	cout << heights[i] << endl;
}

Measured memory_bytes: 0
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		HashSet<Character> S_set = new HashSet<Character>();

		for (Character character : S.toCharArray()) {
			S_set.add(character);
		}

		System.out.println(S.length() == S_set.size() ? "yes" : "no");
	}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    if (b <= w + a && a <= w + b) {
        cout << 0 << endl;
    }
    else if (a <= b) {
        cout << b - (a + w) << endl;
    }
    else {
        cout << a - (b + w) << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    if(N==1){
        cout << 1 << endl;
        cout << 0 << endl;
        return 0;
    }
    if(N==2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
        return 0;
    }
    cout << N-1 << endl;
    REP(i,N-1){
        REP(j,i+2){
            if(j==0 || j==i+1){
                cout << 1;
            }else{
                cout << 0;
            }
        }cout << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a = n, b = 0;
  while (0 < a) {
    b += a % 10;
    a /= 10;
  }
  if (n % b == 0) cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
    int n;
    cin >> n;
    int a[n];

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << a[n - 1];
    for (int i = n - 2; i >= 0; --i) {
        cout << ' ' << a[i];
    }

    cout << endl;
    return 0;
}

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

int main(void)
{
   int a, b, s, m;

   scanf("%d %d", &a, &b);

   s=16-(a+b);

   m=abs(a-b);




   if(2*m <= s)
      printf("Yay!\n");

   else if(2*m >= s)
      printf(":(\n");

   return 0;

   }

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

char s[101];

int main (void) {
    int i,n;
    int cnt = 0;
    scanf("%s",s);
    n = strlen(s);
    for(i=0; i<n; i++) {
        if(s[i] != s[n - 1 - i]) cnt++;;
    }

    printf("%d\n",cnt/2);

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair

bool compare(pair<int,pii> a, pair<int,pii> b){
    if(a.first!=b.first)return a.first>b.first;
    return a.second<b.second;
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n,ll k){
    if(n==0)return k;
    if(n%2==0)return modexp((x*x)%mod,n/2,k);
    return (x*modexp((x*x)%mod,n/2,k))%mod;
}

vi g[100000],edges(100000,0);
int main(){
    fastio;
    //clock_t tm = clock();
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;

    int c[M];
    REP(i, M) c[i] = 0;
    REP(i, N) {
        int K;
        cin >> K;
        REP(i, K) {
            int A;
            cin >> A;
            c[A - 1]++;
        }
    }
    int ans = 0;
    REP(i, M) {
        if (c[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

bool pal(string &s, int n) {
	for (int i = 0, j = n - 1; i < j; i++, j--)
		if (s[i] != s[j])
			return false;
	return true;
}

int main() {
	string s; cin >> s;
	int n = s.length();
	cout << (pal(s, n) && pal(s, n / 2) ? "Yes" : "No") << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define pi 3.14159265358979323846
using namespace std;

using ll = long long;

signed main(){
	double a,b,h,m;
    cin >> a >> b >> h >> m;

    double x = (m/60)*360;
    double y = ((h*60+m)*(360))/(60*12);

    //cout << y << "\n";
    double theta = pi*(abs(y-x))/(180);

    double ans = sqrt(pow(a,2)+pow(b,2)-(2*a*b)*(cos(theta)));
    
    printf("%.20lf",ans);
	return 0;
}

Measured memory_bytes: 4144
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        ll k=abs((a-b)/2);
        cout<<max(a,b)-k<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
<?php

$stdins = [];
while($line=fgets(STDIN)){
    $stdins[] = trim($line);
}

foreach($stdins as $stdin){
    $S = $stdin;
    if(strpos($S, "a") !== FALSE && strpos($S, "b") !== FALSE && strpos($S, "c") !== FALSE){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e6+55;
int const inf = 2e16;
int a[N];
int b[N];

void solve(){
    int i,j,l;  
    int x,y;
    cin>>x>>y;
    if(y%2){
        cout<<"No"<<endl;
    }
    else{
        int mn = x*2;
        int mx = x*4;
        if(y >= mn && y <= mx) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}               


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*


*/

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{
    public static void main (String[] args){
        Scanner input = new Scanner(System.in);
        
        while(input.hasNext()){
            int A = input.nextInt();
            int B = input.nextInt();
           
            if(Math.max(A,B) > 8){
                System.out.println(":(");
            } else {
                System.out.println("Yay!");
            }
        }
    }
}
        

Measured memory_bytes: 22732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 5100000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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



int h, w, n;

int main() {

	cin >> h >> w >> n;

	if (h < w)swap(h, w);

	if (n % h != 0)cout << n / h + 1 << endl;
	else cout << n / h << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    int n;
    string s;
    cin >>n>>s;
    int i=0;
    int flag =0;
    while(!flag){
        if (s.substr(i,1)==s.substr(i+1,1)){
             s=s.erase(i,1);
        }else{
            i++;
            if (i==s.size()) flag++;
        }

    }
    cout <<s.size()<<endl;
}

Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    long long x, y;
    cin >> x >> y;

    long long a = x * y;
    long long l = 2 * x + 2 * y;
    printf("%lld %lld\n", a, l);
    return 0;
}


Measured memory_bytes: 3196
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {
	n := ScanInt()
	m := make(map[string]bool)
	for i := 0; i < n; i++ {
      m[ScanWord()]=true
	}
	P(len(m))


	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 14800
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int C,N;

int p[1010][1010];

int wide[1010][1010];
int hei[1010][1010];

int main(){
  cin >> C >> N;
  rep(i,0,N - 1){
    string s;
    cin >> s;
    rep(j,0,N - 1){
      p[i][j] = s[j] == '1';
    }
  }

  rep(i,0,N - 1){
    rep(j,0,N - 1){
      if(j < N / 2)
        wide[i][j] ^= p[i][j];
      else
        wide[i][N - j - 1] ^= p[i][j];
      if(i < N / 2)
        hei[i][j] ^= p[i][j];
      else
        hei[N - i - 1][j] ^= p[i][j];
    }
  }
  int now = 0;
  rep(i,0,N / 2 - 1){
    rep(j,0,N / 2 - 1){
      now += wide[i][j] + hei[i][j];
    }
  }

  int ans = now == 0;
  rep(q,0,C - 2){
    int D;
    cin >> D;
    rep(d,0,D - 1){
      int i,j;
      cin >> i >> j;
      i--;
      j--;
      if(j < N / 2)
        now += (wide[i][j] ^ 1) - wide[i][j];
      else
        now += (wide[i][N - 1 - j] ^ 1) - wide[i][N - 1 - j];
      if(i < N / 2)
        now += (hei[i][j] ^ 1) - hei[i][j];
      else
        now += (hei[N - 1 - i][j] ^ 1) - hei[N - 1 - i][j];
      if(j < N / 2)
        wide[i][j] ^= 1;
      else
        wide[i][N - j - 1] ^= 1;
      if(i < N / 2)
        hei[i][j] ^= 1;
      else
        hei[N - i - 1][j] ^= 1;
    }
    ans += now == 0;
  }
  cout << ans << endl;
}



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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    set<int> div;

    rep2(j, 1, sqrt(i)) {
      if (i % j == 0) {
        div.em(j);
        div.em(i / j);
      }
    }

    if (si(div) == 8) ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N), S(N+1), A;
    vector<vector<ll>> memo(31,vector<ll>(N+1));
    rep(i,N){
        cin >> a[i];
    }
    rep(i,N){
        S[i+1] = S[i] + a[i];
    }
    rep(i,N+1){
        REP(j,i,N+1){
            A.push_back(S[j]-S[i]);
        }
    }
    ll x = 0;
    rep(i,40){
        ll cnt = 0;
        ll tmp = (1LL << (39-i));
        rep(j,N*(N+1)/2){
            if((A[j] & (x+tmp)) == x + tmp){
                cnt++;
            }
        }
        if(cnt >= K){
            x += tmp;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool gudge = true;
  
  vector<int> doc(N);
  for(int i = 0;i < N;i++){
  cin >> doc.at(i);
    if(doc.at(i) % 2 == 0){
      if(doc.at(i) % 3 != 0 && doc.at(i) % 5 != 0){
      gudge = false;
      }
    }
  }
  
  if(gudge){
  cout << "APPROVED" << endl;
  }
  else{
  cout << "DENIED" << endl; 
  }
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[A[i-1]-1]
print(ans)


Measured memory_bytes: 3064
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int k;
map<int,int> vis;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> k;
  queue<int> q;
  for(int i=1;i<=9;i++){
    q.push(i);
  }
  while(!q.empty()){
    int s = q.front();q.pop();
    if(vis[s])continue;
    vis[s]=1;
    k--;
    if(!k){
      cout << s << endl;
      return 0;
    }
    int last = s%10;
    if(last>=1){
      q.push(s*10+last-1);
    }
    q.push(s*10+last);
    if(last<9){
      q.push(s*10+last+1);
    }
  }



return 0;
}
///....


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

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 0, s.size()){
        mp[s[i]]++;
    }
    for(char i = 'a'; i <= 'z'; i++){
        if(mp[i] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}



Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    let mut t: Vec<char> = read::<String>().chars().collect();
    let mut ans = "Yes";
    let mut eq_count = 0;
    s.sort();
    t.sort_by(|x, y| y.cmp(x));


    for i in 0..s.len(){
        if s[i] == t[i]{
            eq_count += 1;
        }else if s[i] < t[i] {
            ans = "Yes";
            break;
        }else{
            ans = "No";
            break;
        }
        if eq_count == t.len() {
            ans = "No";
            break;
        }
    }


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


Measured memory_bytes: 4352