akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int n, k ;
  cin >> n >> k ;
  cout << n-k+1 <<endl ;


  return 0 ;
}




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


int main(){
  int N;
  cin >> N;
  vector<int> H(N, 0);
  int ans = 0;
  for(auto& h : H){
    cin >> h;
    if(*max_element(H.begin(), H.end()) == h) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n, k;
    cin >> n >> k;
 
    double ans = 0;
 
    for (int i = 1; i <= n; i++) {
        double d = 1.0;
        if (i < k) {
            int point = i;
            while (point < k) {
                point *= 2;
                d /= 2;
            }
        }
        d /= n;
        ans += d;
    }
 
    cout << fixed << setprecision(12) << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 100001
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int main()
{
	fast;
	int n,x,y,z;
	cin>>n;
    int c[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>x>>y>>z;
        if(i==0)
        {
            c[i][0]=x;
            c[i][1]=y;
            c[i][2]=z;
        }
        else
        {
            c[i][0]=x+max(c[i-1][1],c[i-1][2]);
            c[i][1]=y+max(c[i-1][0],c[i-1][2]);
            c[i][2]=z+max(c[i-1][1],c[i-1][0]);
        }
    }
    int res=c[n-1][0];
    for(int i=1;i<3;i++)
    {
        if(res<c[n-1][i])
            res=c[n-1][i];
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

struct UF{
    vl par;
    UF(ll N):par(N){
        rep(i,N)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    void unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
};

int main() {
ll L;
  cin >>L;
  if(L%3==0) {
    ll a=L/3;
    cout<<a*a*a<<endl;
    return 0;
  }

  
  else {
long double b=(long double)L/(long double)3;
    long double c=b*b*b;
    CST(8);
    cout<<c<<endl;
  }
  
  
}
  
  

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

using namespace std;
using ll = long long;
const int MAXN = 2.01e5;
vector<int> g[MAXN];
int a[MAXN];
int res[MAXN];
vector<int> L;
int pos;

void dfs(int u, int p) {
  auto it = lower_bound(L.begin(), L.begin() + pos, a[u]);
  if(it == L.begin() + pos) {
    L[pos++] = a[u];
    res[u] = pos;
    for(int x: g[u]) if(x != p) dfs(x, u);
    L[pos--] = 0;
  } else {
    auto f = *it;
    *it = a[u];
    res[u] = pos;
    for(int x: g[u]) if(x != p) dfs(x, u);
    *it = f;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  L.resize(n);
  pos = 1;
  for(int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  L[0] = a[0];
  res[0] = 1;
  dfs(0, -1);
  for(int i = 0; i < n; ++i) {
    cout << res[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 27992
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;
#define int ll
const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 105;
const int K = 400005;
int ar[N] , dp[N][K + 10];

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    int n , k;
    cin >> n >> k;
    fo(i , n) cin >> ar[i];
    
    dp[0][0] = 1;

    fo(i , n){
        fo(j , K){
            //if(dp[i][j] == 0) break;
            
            dp[i + 1][j] = ((dp[i + 1][j] % MOD + dp[i][j] % MOD) + MOD) % MOD;
            if(j + ar[i] + 1 > K)
                continue;
            dp[i + 1][j + ar[i] + 1] = ((dp[i + 1][j + ar[i] + 1] % MOD - dp[i][j] % MOD) + MOD) % MOD; 
        }
        fo(j , K)
            if(j)
                dp[i + 1][j] = ((dp[i + 1][j] % MOD +  dp[i + 1][j - 1] % MOD) + MOD ) % MOD; 
    }

//    fo(i , n + 1){
//        fo(j , k + 10)
//            cout << dp[i][j] << " " ;
//        cout << '\n';
//    }
//
    cout << dp[n][k] << '\n';;

    return 0;

}



Measured memory_bytes: 316140
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int field[64][64];
bool done[64][64];
int w, h;

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

void dfs(int y, int x) {
    done[y][x] = true;
    for (int i = 0; i < 8; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] == 1 && done[ny][nx] == false) {
            dfs(ny, nx);
        }
    }
}

int main(void) {
    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
                done[i][j] = false;
            }
        }
        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (field[i][j] == 1 && done[i][j] == false) {
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int64_t X;
  cin >> X;
  int64_t Y = 100;
  int count = 0;
  while( Y < X ){
  	Y = Y + floor(Y*0.01);
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
// Problem : A - The Number of Even Pairs
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
const int N = 1e6 + 1;

int n, m;

void baka() {
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

int main() { cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	// cin >> t;
	while (t--) {
		baka();
	}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int num_C0 = C / B;
    if (C%B !=0)
        ++num_C0;
    int num_A0 = A / D;
    if (A%D !=0)
        ++num_A0;
        
    if (num_A0 < num_C0){
        cout << "No" << endl;
    } else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
// 2011/01/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		// üÍi³ÒÌj
		int n;
		cin >> n;
		if(n==0)
			break;

		// üÍi³ÒÌîñjÆZ
		int p_max = 0;			// Å·Ì³ÒÌÔiúlÍ0j
		int d_max = -1;			// Å·Ìà¢½£iúlÍ-1j
		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;
			if(d_max<d1+d2){	// àµà¢½£ª·©Á½ç
				p_max = p;
				d_max = d1+d2;
			}
		}

		// oÍ
		cout << p_max << ' ' << d_max << endl;
	}

	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ 
	cin.sync_with_stdio(0);
	
	int a;
	string s;

	cin >> a >> s;

	if (!(a < 3200)) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

} //cin.tie(0) bei schnellem Wechseln

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

int main(){
  long long N;
  cin>>N;
  if (N==0) {cout<<"0"<<endl; return 0;}
  string base="";
while(N){
//  cout<<(N%-2)<<","<<N<<endl;
    if(abs(N%-2)==1){base+="1";}
    else{base+="0";}
    N-=abs(N%-2);
    N/=-2;
  }
    reverse(base.begin(),base.end());
    cout<<base<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int r = 0;
    int g = 0;
    int b = 0;
    rep(i,0,n-1){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ll ans = (ll)r*g*b;

    rep(i,0,n-1){
        for(int d=1;i+2*d<n;d++){
            int j = i + d;
            int k = j + d;
            if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]) ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
import sys

n = int(input())
INF = 10**20
a_ls = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n)] for i in range(n)]
for _ in range(1,n):
    for i in range(n-_):
        j = i + _
        sum_ij = sum(a_ls[i:j+1])
        memo_ls[i][j] = sum_ij
        res = INF if j - i > 1 else 0
        for k in range(i,j):
            res = min(memo_ls[i][k] + memo_ls[k+1][j], res)
        memo_ls[i][j] += res
for i in range(n):
    memo_ls[i][i] = a_ls[i]
print(memo_ls[0][-1])

Measured memory_bytes: 46172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    int N;
    string s;
    cin >> N >> s;
    vector<int> a(N);
    if(s[0]=='.') a.at(0) = 1;
    else a.at(0) = 0;
    for(int i=1;i<N;i++){
        if(s[i]=='.') a.at(i) = a.at(i-1) + 1;
        else a.at(i) = a.at(i-1);
    }
    int w = N - a.at(N-1);
    int b = a.at(N-1);
    int wb = N;
    for(int k=0;k<N;k++){
        if((k+1-a.at(k)) + (a.at(N-1)-a.at(k))<wb){
            wb = (k+1-a.at(k)) + (a.at(N-1)-a.at(k));
        }
    }
    int ans = w;
    if(ans>b) ans = b;
    if(ans>wb) ans = wb;
    cout << ans << endl;
    return 0;
}

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


def solve(S: int):
    upper = int(S/100)
    lower = S%100
    
    if upper > 0 and upper < 13:
        if lower > 0 and lower < 13:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    elif lower > 0 and lower < 13:
        print('YYMM')
    else:
        print('NA')
        
    return


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

if __name__ == '__main__':
    main()


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

int main() {
	ll N,D;
	cin>>N>>D;
	
	ll X[N],Y[N];
	
	ll MAX=2e5 + 5;
	
	unordered_set<ll> st;
	
	ll item=1;
	while(item*item<=MAX){
	    st.insert(item*item);
	    item++;
	}
	int ans=0;
	
	for(ll i=0;i<N;i++){
	    cin>>X[i]>>Y[i];
	    ll sum=(X[i]*X[i])+(Y[i]*Y[i]);
	    
	    if(sum<=(D*D)){
	        ans++;
	    }
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < (n); i++)

int main(void) 
{
    int h, w;
    while(1) {
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        REP(i, h) {
            REP(j, w) {
                if(i == 0 || j == 0 || i == h - 1 || j == w - 1) {
                    cout << "#" ;
                } else {
                    cout << "." ;
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int num = sc.nextInt();
			int array[] = new int[num];
			
			for(int i = 0; i < num; i++) {
				array[i] = sc.nextInt();
			}
			
			for(int i = num-1;i >= 0; i--) {
				System.out.printf("%d", array[i]);
				if(i != 0) {
					System.out.printf(" ");
				}
			}
			System.out.printf("\n");
			sc.close();
			
		}
}


Measured memory_bytes: 26468
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define true 1
#define false 0



int main(void){
	int a,b,h;
	scanf("%d%d%d",&a,&b,&h);
	printf("%d\n", (a+b)*h/2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,D;
    int count=0;
    cin>>N>>D;
    int X[N][D];
    REP(i,N){
        REP(j,D){
            cin>>X[i][j];
        }
    }
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int l=0;
            REP(k,D){
                l+=pow((X[i][k]-X[j][k]),2);
            }
            int d=sqrt(l);
            double e=sqrt(l);
            if(d==e) count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    vector<string> weeks = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    string s;
    cin >> s;
    for (int i=0; i<7; i++) {
        if (s == weeks[i]) cout << i+1 << endl;
    }
}


Measured memory_bytes: 256
s = str(input())
if s[0] == s[1] == s[2] == s[3]:
    print('No')
    exit()
if (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[3] and s[2] == s[1]) or (s[0] == s[2] and s[1] == s[3]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import string
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
X,Y,Z = nums()
X_copy = X
A = X
B = Y
C = Z
A = B
B = X_copy
C_copy = C
C = A
A = C_copy
print(A,B,C)

Measured memory_bytes: 4088
import Foundation

func main() {
    let s = readLine()!
    var count = s.numberOfOccurrences(of: "R")
    if count == 3 || count == 1 || count == 0 {
        print(count)
    } else {
        count = s.numberOfOccurrences(of: "RR")
        if count == 1 {
            print(2)
        } else {
            print(1)
        }
    }
    
}

main()

extension String {
    func numberOfOccurrences(of word: String) -> Int {
        var count = 0
        var nextRange = self.startIndex..<self.endIndex
        while let range = self.range(of: word, options: .caseInsensitive, range: nextRange) {
            count += 1
            nextRange = range.upperBound..<self.endIndex
        }
        return count
    }
}


Measured memory_bytes: 13988
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll x,y,z;
  cin>>x>>y>>z;

  cout<<(x-z)/(z+y)<<endl;
  return 0;
}


Measured memory_bytes: 3528
n = int(input())
arr = list(map(int,input().split(" ")))

count = 0
s = 1000000000
add = 0
for num in arr:
  if num < 0:
    count += 1
  s = min(s, abs(num))
  add += abs(num)

print(add-(count%2)*abs(s)*2)

Measured memory_bytes: 14284
#include<bits/stdc++.h>
using namespace std;
map<char,int> m;
int main(){
	string s;
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++){
		m[s[i]]=1;
	}
	if(m['E']&&!m['W']){
		cout<<"No";
		return 0;
	}
	if(m['W']&&!m['E']){
		cout<<"No";
		return 0;
	}
	if(m['S']&&!m['N']){
		cout<<"No";
		return 0;
	}
	if(m['N']&&!m['S']){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	int n;
	cin >> n;
	vector<ll>a(n);
	input(a);
	ll all = 0;
	for (auto to : a)
		all ^= to;
	for (int i = 0; i < n; i++)
		cout << (a[i] ^ all) << ' ';

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("luigi.in", "r", stdin);
	//freopen("luigi.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 4784
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s;
    ll d[5];
    int f[10]={0,0,0,0,0,0,1,1,1,2};
    int x[10]={1,1,1,2,2,3,2,2,3,3};
    int t[10]={2,3,4,3,4,4,3,4,4,4};
    int m=0,a=0,c = 0,r=0,h=0;
    ll answer=0;

    REP(i,n){
        cin >> s;
        if(s[0]=='M')m++;
        else if(s[0]=='A')a++;
        else if(s[0]=='R')r++;
        else if(s[0]=='C')c++;
        else if(s[0]=='H')h++;
    }
    d[0]=m;
    d[1]=a;
    d[2]=r;
    d[3]=c;
    d[4]=h;
    
    //REP(i,5)cout << d[i] << endl;
    REP(i,10)answer+=d[f[i]]*d[x[i]]*d[t[i]];
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A==B && A==C) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int H,W,i;
	
	while(cin>>H>>W)
	{
		if(H==0||W==0)
		{
			break;
		}

	for(int i=0;i<H;i++)
	{
		for(int n=0;n<W;n++)
		{
			cout<<"#";
		}
	cout<<endl;
	
	}
	cout<<endl;
	
	}


	
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    int i, ans=0;
    cin >> s >> t;
    for(i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans <<endl;

    return 0;
}



Measured memory_bytes: 3912
N = int(input())
a = [0] + list(map(int, input().split()))
box = [0] * (N+1)

def find_baisu(a, N):
    j = 2
    ret = []
    while(a*j <= N):
        ret.append(a*j)
        j += 1
    return ret
    
for i in range(N):
    num = N-i
    baisu = find_baisu(num, N)
    baisu_box_sum = 0
    for j in range(len(baisu)):
        baisu_box_sum += box[baisu[j]]
    if(baisu_box_sum % 2 == a[num]):
        box[num] = 0
    else:
        box[num] = 1

M = 0
ans = ''
for i in range(N+1):
    if(box[i] == 1):
        M += 1
        ans += str(i) + ' '

print(M)
print(ans)


Measured memory_bytes: 19516
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    if (n % 2 == 0) {
      println(0.5)
    } else {
      println((n / 2 + 1) * 1.0 / n)
    }
  }
}

Measured memory_bytes: 25648
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(1, N+1):
  t = abs(A*1000 - (T*1000 - H[i-1] * 6))
  if ans == 0 or tmp > t:
    ans = i
    tmp = t

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main (void)
{
	long long int n,i,min,k,a[2100000],count=0,temp=0;
scanf("%lld",&n);
for(i=0;i<n;i++){
  scanf("%lld",&a[i]);
  temp+=a[i];
}  
  temp=temp%1000000007;
    for(i=0;i<n;i++){
    temp-=a[i];
      if(temp<0){
        temp+=1000000007;
      }
      count+=temp*a[i];
      count=count%1000000007;
  }
      if(count<0){
        count+=1000000007;
      }
  printf("%lld\n",count);
return 0;
    
}


Measured memory_bytes: 3284
alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n=int(input())
ans=""
while n>0:
 n-=1
 a=n%26
 ans+=alp[a] 
 n=int(n//26)
 
print(ans[::-1])

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int i=a+b+c+d;
	int h=i/60;
	int s=i-60*h;
	printf("%d\n%d\n",h,s);
	}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int s1[N],s2[N],a[N];
int find(int x,int *s){
	return x==s[x]?x:s[x]=find(s[x],s); 
}
int main(){
	int n,k,l;
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;i++) s1[i]=s2[i]=i,a[i]=1;
	for(int i=1;i<=k;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		int fu=find(u,s1),fv=find(v,s1);
		if(fu!=fv) s1[fu]=fv;
	}
	for(int i=1;i<=l;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		int fu=find(u,s2),fv=find(v,s2);
		if(fu!=fv) s2[fu]=fv;
	}
	map<PII,int>mp; 
	for(int i=1;i<=n;i++){
		mp[make_pair(find(i,s1),find(i,s2))]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d ",mp[make_pair(s1[i],s2[i])]);
	return 0;
}


Measured memory_bytes: 17360
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll calc(ll a,ll b){
    //cout <<a << " " << b << endl;
    if(a<b){
        return 0;
    }
    ll c = a/b;
    if(c==1){
        if((a-b)%2==0)return 1;
        else return 0;
    }
    c++;
    if(a%b==0){
        return c-1;
    }
    if((a-(c-1)*b)%c==0){
        return c-1;
    }else{
        ll k = (a-(c-1)*b)/c;
        calc(a-(k+1)*c,b);
    }

}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),k(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> k[i];
    }
    ll tmp = 0;
    for(int i=0;i<n;i++){
        tmp ^= calc(a[i],k[i]);
    }
    if(tmp==0){
        cout << "Aoki" << endl;
    }else{
        cout << "Takahashi" << endl;
    }
    return 0;
}

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

const int MAX = 1000000;
int notp[MAX + 1];

void prime(){
	notp[0] = 1;
	notp[1] = 1;
	
	for(int i = 2; i <= MAX; ++i){
		int j = i * 2;
		while(j <= MAX){
			notp[j] = 1;
			j += i;
		}
	}
}

int main(){
	int n, c;
	prime();
	
	while(c = 0, cin >> n, n){
		for(int i = 3; i <= n / 2; ++i){
			if(notp[i] == 0 && notp[n - i] == 0) ++c;
		}
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5064
#include <cstdio>
#include <vector>
#define MAXN 100000

using namespace std;

int N, M;
long long K;
int x[MAXN];
int a[MAXN];

bool used[MAXN];
long long diff[MAXN];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &x[i]);
    scanf("%d%lld", &M, &K);
    for (int j = 0; j < M; j++)
        scanf("%d", &a[j]);

    vector <int> p(N - 1);
    for (int i = 0; i < N - 1; i++)
        p[i] = i;
    for (int j = 0; j < M; j++) {
        int i = a[j] - 1;
        swap(p[i - 1], p[i]);
    }

    for (int i : p) {
        if (used[i])
            continue;

        vector <int> cycle;
        int j = i;
        while (p[j] != i) {
            cycle.push_back(j);
            used[j] = true;
            j = p[j];
        }
        cycle.push_back(j);

        int l = K % cycle.size();
        for (int k = 0; k < cycle.size(); k++) {
            int idx = cycle[(k + l) % cycle.size()];
            diff[cycle[k]] = x[idx + 1] - x[idx];
        }
    }

    long long cur = x[0];
    for (int i = 0; i < N; i++) {
        printf("%lld.0\n", cur);
        if (i + 1 < N)
            cur += diff[i];
    }
}


Measured memory_bytes: 3556
/**
 * At Boss's Expense
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

public class Main {

	static boolean[] primes = new boolean[1000001];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		//
		Arrays.fill(primes, true);
		for (int i = 2; i * i <= 1000000; i++) {
			if (primes[i]) {
				for (int j = 2 * i; j <= 1000000; j += i) {
					primes[j] = false;
				}
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int x = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | x) == 0) break;

			int max = 0;
			int[] dp = new int[x + 1];
			int[] c = new int[n];

			for (int i = 0; i < n; i++) c[i] = parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				for (int j = c[i]; j <= x; j++) {
					dp[j] = Math.max(dp[j], dp[j - c[i]] + c[i]);
					if (primes[dp[j]]) max = Math.max(max, dp[j]);
				}
			}
			System.out.println(max != 0 ? max : "NA");
		}//end while
	}//end main
}

Measured memory_bytes: 94860
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

vector<ll> memo(100);

ll fib(ll n){
    if(memo[n] == -1) {
        memo[n] = fib(n - 1) + fib(n - 2);
    }
    return memo[n];
}

int main(){
    for(int i=0;i<100;i++){
        memo[i] = -1;
    }
    memo[0] = 2;
    memo[1] = 1;

    ll n;
    cin >> n;
    cout << fib(n) << endl;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
vector<int> al[200005];
int w[200005];
void dfs(int i,int p){
    for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
        if (*it==p) continue;
        w[*it]=w[i]+1;
        dfs(*it,i);
    }
}
int main(){
    scanf("%d",&n);
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }

    w[1]=0;
    dfs(1,-1);

    int best=1;

    for (int x=1;x<=n;x++){
        if (w[best]<w[x]) best=x;
    }

    w[best]=0;
    dfs(best,-1);

    int diam=0;
    for (int x=1;x<=n;x++) diam=max(diam,w[x]);

    printf((diam-1)%3?"First":"Second");
}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  ll lim=n*(n-1)/2-(n-1);
  if(lim<k) {
    cout << -1 << endl;
    return 0;
  }
  cout << lim-k+n-1 << endl;
  for(ll i=2;i<=n;i++) {
    cout << 1 << " " << i << endl;
  }
  ll i=2,j=3;
  ll cnt=lim-k;
  while(cnt--) {
    cout << i << " " << j << endl;
    if(j<n) j++;
    else i++,j=i+1;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  string ans = "YES";
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < n - 1; i++) {
    if(vec.at(i) == vec.at(i+1)){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
a = []
for i in range(0, 5):
    a.append(int(input()))

k = int(input())
f = True

for i in range(0, 5):
    for j in range(i + 1, 5):
        if f and a[j] - a[i] > k:
            f = False
            print(":(")

if f:
    print("Yay!")

Measured memory_bytes: 3060
'use strict';
(function(stdin) {
  var lines = stdin.toString().split('\n')[0];
  var result = (function(data) {
    var deg = data[2] * (Math.PI / 180);
    var a = data[0];
    var b = data[1];
    var c = Math.sqrt((Math.pow(a,2) + Math.pow(b,2)) - ((2 * (a * b)) * Math.cos(deg)));
    return [
      a * b / 2 * Math.sin(deg)
      , a + b + c
      , b * Math.sin(deg)
    ].join('\n')

  }(
    lines.split(' ').map(parseFloat)
  ));

  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7648
#include <cstdio>
using namespace std;

typedef long long ll;

const int MAXN = 100005;

int N;
ll a[MAXN], b[MAXN];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    scanf("%lld%lld", a + i, b + i);
   
  ll sol = 0;
  for (int i = N - 1; i >= 0; i--) {
    a[i] += sol;
    sol += (b[i] - a[i] % b[i]) % b[i];
  }    
  
  printf("%lld\n", sol);
  
  return 0;
}

Measured memory_bytes: 1664
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

inf=10**18

import bisect

def main():
	a,b,q=map(int,input().split())
	s=[-inf]+[int(input()) for _ in range(a)]+[inf]
	t=[-inf]+[int(input()) for _ in range(b)]+[inf]
	x=[int(input()) for _ in range(q)]
	
	
	for i in x:
		si=bisect.bisect_left(s,i)
		ti=bisect.bisect_left(t,i)
		
		ans=inf
		for S in [s[si-1],s[si]]:
			for T in [t[ti-1],t[ti]]:
				ans=min(ans,abs(S-i)+abs(S-T),abs(T-i)+abs(S-T))
		print(ans)
		
		
		
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 16244
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    int group[13]={-1,1,3,1,2,1,2,1,1,2,1,2,1};
    
    int x,y;
    scanf("%d%d",&x,&y);
    if(group[x]==group[y]) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  long w,h,n, m;
  cin >> w >> h>>n ;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);

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

  int xlb,xub,ylb,yub;
  xlb=0;
  ylb=0;
  xub=w;
  yub=h;


  for (int i = 0; i < n; ++i){
    cerr << a[i] <<endl;
    if (a[i]==1)if (xlb < x[i])xlb = x[i];
    if (a[i]==2)if (xub > x[i])xub = x[i];
    if (a[i]==3)if (ylb < y[i])ylb = y[i];
    if (a[i]==4)if (yub > y[i])yub = y[i];

  }

  // cerr <<xlb << " " <<xub <<endl;
  // cerr <<ylb << " " <<yub <<endl;

  cout << max((xub-xlb),0)*max((yub-ylb),0)   <<endl;


  return 0;
}






Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if not directed:
            pt[t[i]-1].append(s[i]-1)
    return pt

def euler_tour(pt,N,root):
    S = [(~root,-1),(root,-1)]
    tour = [None]*(2*N)  #ツアー順（2*N-1要素）
    F = [None]*N         #最初の到達時刻
    depth = [0]*N
    count = -1
    while(S):
        v,p = S.pop()
        count += 1
        if v >= 0:
            tour[count] = v
            if not F[v]:
                F[v] = count
            for nv in pt[v][::-1]:
                if nv == p:
                    continue
                depth[nv] = depth[v]+1
                S.append((~nv,v))
                S.append((nv,v))
        else:
            tour[count] = p
    tour.pop()
    return tour

N = I()
a = LI()
u,v = LIR(N-1,2)

pt = edges_to_pt(u,v,N)
tour = euler_tour(pt,N,0)

inf = 10**9+1
dp = [inf]*N
record = []
visited = [False]*N
ans = [0]*N
for v in tour:
    if visited[v]:
        r = record.pop()
        dp[r[0]] = r[1]
    else:
        p = bisect_left(dp,a[v])
        record.append((p,dp[p]))
        dp[p] = a[v]
        pinf = bisect_left(dp,inf)
        ans[v] = pinf
        visited[v] = True

for a in ans:
    print(a)

Measured memory_bytes: 182284
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n,k;
    cin>>n>>k;

    vi v(n);
    for(int &x:v) cin>>x;
        sort(rall(v));

    int count = 0;
    for(int i=0;i<n;i++){
        if(v[i] < k) break;
        count++;
    }

    cout<<count;
} 

Measured memory_bytes: 1024
//Problem link - https://atcoder.jp/contests/dp/tasks/dp_c

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define mod 1000000007

ll arr[(int)1e5+5][3];
ll dp[(int)1e5+5][3];

ll f(ll idx, ll i)
{
    if(idx==0)
        return arr[idx][i];
    if(dp[idx][i]!=-1)
        return dp[idx][i];
    ll a=arr[idx][i];
    if(i==0)
        a+=max(f(idx-1,1),f(idx-1,2));
    else if(i==1)
        a+=max(f(idx-1,0),f(idx-1,2));
    else
        a+=max(f(idx-1,0),f(idx-1,1));
    return dp[idx][i]=a;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		for(ll j=0;j<3;j++)
			cin>>arr[i][j];
	memset(dp,-1,sizeof(dp));
	cout<<max({f(n-1,0),f(n-1,1),f(n-1,2)});
	return 0;
}

Measured memory_bytes: 9600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  string S;
  cin >> S;

  int ans = 0;
  bool pre1 = false;
  int pos = 0;
  char last = '1';
  while(pos < S.length()){
    if(!pre1){
      last = S[pos];
      pre1 = true;
      pos++;
      ans++;
    } else {
      if(last != S[pos]){
        last = S[pos];
        pre1 = true;
        pos++;
        ans++;
      } else {
        if(pos + 1 >= S.length()){
          break;
        } else {
          last = S[pos+1];
          pre1 = false;
          pos+=2;
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

#define SIZE 250
#define NUM 801

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i < N; i++) if (A[i] >= A[i+1]) break;
	if (i == N) {
		printf("1\n");
		fflush(stdout);
		return 0;
	}
	
	int j, k, l = 2, r = N, m, n, count[200001], block[NUM], tmp;
	while (l < r) {
		m = (l + r) / 2;
		n = N / (m - 1) + 1;
		for (i = 0; i < n; i++) count[i] = 0;
		for (i = 0; i < (n - 1) / SIZE; i++) block[i] = 0;
		if (A[1] < n) {
			tmp = (A[1] - 1) / SIZE;
			for (i = 0; i < tmp; i++) block[i] = 1;
			for (j = tmp * SIZE; j < A[1]; j++) count[j] = 1;
			k = A[1];
		} else {
			tmp = (n - 1) / SIZE;
			for (i = 0; i < tmp; i++) block[i] = 1;
			for (j = tmp * SIZE; j < n; j++) count[j] = 1;
			k = n;
		}
		for (i = 2; i <= N; i++) {
			if (A[i] > n) continue;
			else if (A[i] > k) {
				for (j = k, tmp = k / SIZE + 1; j < tmp * SIZE && j < A[i]; j++) count[j] = 1;
				if (j < A[i]) {
					for (; tmp < (A[i] - 1) / SIZE; tmp++) block[tmp] = 1;
					for (j = tmp * SIZE; j < A[i]; j++) count[j] = 1;
					for (; j < (tmp + 1) * SIZE && j < n; j++) count[j] = 0;
				}
				k = A[i];
			} else {
				tmp = (A[i] - 1) / SIZE;
				if (block[tmp] == 1) {
					block[tmp] = 0;
					for (j = tmp * SIZE; j < (tmp + 1) * SIZE; j++) count[j] = 1;
				}
				for (j = A[i] - 1; j >= tmp * SIZE && count[j] == m; j--);
				if (j < 0) break;
				else if (j < tmp * SIZE) {
					while (--tmp >= 0 && block[tmp] == 0) {
						for (; j >= tmp * SIZE && count[j] == m; j--);
						if (j >= tmp * SIZE) break;
					}
					if (tmp < 0) break;
					else if (block[tmp] == 1) {
						block[tmp] = 0;
						for (j = tmp * SIZE; j < (tmp + 1) * SIZE; j++) count[j] = 1;
						j--;
					}
				}
				for (count[j++]++; j < A[i]; count[j++] = 1);
				for (tmp = (A[i] - 1) / SIZE, j = A[i]; j < (tmp + 1) * SIZE && j < n; j++) count[j] = 0;
				k = A[i];
			}
		}
		if (i <= N) l = m + 1;
		else r = m;
	}
	printf("%d\n", l);
	fflush(stdout);
	return 0;
}

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

using namespace std;

#define INF 210000000
#define int long long

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

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



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;pair<int,int> bars[100000];int x[1000], y[1000];int main(){int n, m, h, k, a, b, i;for(;scanf("%d%d%d%d", &n, &m, &h, &k), n;){for( i = 0; i < n; scanf("%d", y + i++ ) )x[i] = i;for( i = m; i--; bars[i] = make_pair( b, a ) )scanf("%d%d", &a, &b );sort( bars, bars + m );for( i = m ; i--; )swap( x[ bars[i].second - 1], x[ bars[i].second ] );for( i = 0; i < n; i++ ){a = y[ x[i] ];y[ x[i] ] = i;x[i] = a;}b = 0;for( i = m; i--; ){a = bars[i].second;if( ( y[a-1] < k ) != ( y[a] < k ) ){b = max( b,y[a] < k ?x[y[a]] - x[y[a-1]] :x[y[a-1]] - x[y[a]] );}swap( y[a-1], y[a] );}a = 0;for(; k--; ) a += x[k];printf("%d\n", a - b );}}

Measured memory_bytes: 0
I = lambda: map(int, input().rstrip().split())
n, m = I()
a = []
b = []
for i in range(n):
    a += [input()]
for i in range(m):
    b += [input()]
flag = 0
for i in range(n - m + 1):
    if flag == 1:
        break
    for j in range(n - m + 1):
        temp = 1
        for k in range(m):
            if temp == 0:
                break
            for l in range(m):
                if a[k + i][l + j] != b[k][l]:
                    temp = 0
                    break
        if temp:
            flag = 1
            break
if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

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

  int n;
  cin >> n;
  long long mod = 1e9+7;
  long long res = 1;
  for (long long i = 2; i <= n; ++i) {
    res = (res * i)%mod;
  }
  cout << res << endl;

  return 0;
}



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

int main(){
    int N; cin>>N;
    int num = 0;
    REP(i,N){
        int x; cin>>x;
        if(x==num+1){ ++num; }
    }
    if(num==0){ cout << "-1\n"; }
    else{ cout << N-num << "\n"; }
}

Measured memory_bytes: 256