akhauriyash/Code-Regression huggingface dataset:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil

n = ni()
A = [ni() for i in range(n)]
f=False
for a in A:
    if a%2==1:
        f=True
if f:
    print("first")
else:
    print("second")


Measured memory_bytes: 13232
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = "";
		String pstr = "";
		while(sc.hasNext()){
			str = sc.next();
			if(str.indexOf(".")!=-1)
				str=str.substring(0, str.length()-1);
			if(str.indexOf(",")!=-1)
				str=str.substring(0, str.length()-1);
			if(str.length()<3 || str.length()>6){
				continue;
			}
			else
				pstr+=str+" ";
		}
		pstr=pstr.substring(0,pstr.length()-1);
		System.out.println(pstr);
	}
}

Measured memory_bytes: 17260
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, k = rli()
	A = deque(rli())
	B = deque(rli())
	L = deque()
	p, q = 0, 0
	currsum = 0
	for i, a in enumerate(A):
		if currsum + a <= k:
			currsum += a
			p += 1
		else:
			break
	cnt = p 
	for np in range(p, -1, -1):
		for i in range(q, len(B)):
			add = B[i]
			if add + currsum <= k:
				currsum += add
				q += 1
			else:
				break
		# print(f"At p, q = {np, q}, currsum = {currsum}")
		currsum -= A[np-1] if np > 0 else 0
		cnt = max(cnt, np + q)
	print(cnt)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 104948
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int A,B,C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
}

int main() {
    solve();
    return 0;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
vector<int> ys[maxn];
int main(){
	int h, w, n;
	cin >> h >> w >> n;
	for(int i = 0; i < n; i++){
		int x, y; cin >> x >> y;
		ys[x].push_back(y);
	}
	int ans = h, y = 1;
	for(int i = 2; i <= h; i++){
		sort(ys[i].begin(), ys[i].end());
		bool has = false;
		for(int v : ys[i]){
			if(v <= y) ans = min(ans, i - 1);
			if(v == y + 1) has = true;
		}
		if(!has) y++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
	int n,b,f,r,v;
	int i,j,k;
	int x[4][3][10] = {0};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		x[b-1][f-1][r-1] += v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",x[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3)
		printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<char> ans;
    while(n>0){
      n--;
      ll k = n%26;
      char c = 'a' + k;
      ans.push_back(c);
      n /= 26;
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()){
      cout << ans[i];
    }
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int K;
    cin >> K;
    string s;
    cin >> s;
    if(s.size() <= K) cout << s << endl;
    else {
        for(int i = 0; i < K; ++i) {
            cout << char(s[i]);
        }
        cout << "..." << endl;
    }
    return 0;
}



Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static int lis(int[] a,int n){
		int[] dp=new int[n+1];
		Arrays.fill(dp,Integer.MAX_VALUE);
		dp[0]=-1;
		for(int i=0;i<n;i++){
			int k=Arrays.binarySearch(dp,a[i]);
			if(k<0){
				k=-(k+1);
				dp[k]=Math.min(dp[k],a[i]);
			}
		}
		for(int i=n;i>=0;i--) if(dp[i]<Integer.MAX_VALUE) return i;
		return 0;
	}
	static int lds(int[] A, int N) {
		int[] dp = new int[N + 1];
		Arrays.fill(dp, -1);
		dp[0] = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			int k = bin_search(dp, A[i]);
			if(k < 0) k = -k;
			if(dp[k] == A[i]) {
				k++;
				dp[k] = Math.max(dp[k], A[i]);
			}
			else dp[k] = Math.max(dp[k], A[i]);
		}
		for(int i = N; i >= 0; i--) if(dp[i] >= 0) return i;
		return 0;
	}
	static int bin_search(int[] A, int key) {
		int min = 0, max = A.length - 1;
		while(max - min > 1) {
			int mid = (max + min) / 2;
			if(A[mid] < key) {
				max = mid;
			}else {
				min = mid;
			}
		}
		return (A[max] == key) ? max : -max;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		System.out.println(lds(A, N));
	}
}

Measured memory_bytes: 51004
#include<stdio.h>
int main(){
	int A_wh,B_wh,i,j,k,l,mas=0,ans=0;
	char mapA[50][50],mapB[50][50];
	
	scanf("%d %d ",&A_wh,&B_wh);
	
	for(i=0;i<A_wh;i++){
		for(j=0;j<=A_wh;j++){
			mapA[i][j]=getchar();
		}
	}
	
	for(i=0;i<B_wh;i++){
		for(j=0;j<=B_wh;j++){
			mapB[i][j]=getchar();
		}
	};
	for(k=0;k<A_wh;k++){
		for(l=0;l<A_wh;l++){
			for(i=0;i<B_wh;i++){
				for(j=0;j<B_wh;j++){
					if(mapA[k+i][l+j]!=mapB[i][j]){
						mas=0;
						break;
					}
					else{
						mas++;
					}
				}
			}
			if(mas==B_wh*B_wh){
				ans=1;
				break;
			}
		}
	}
	if(ans==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long


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

    REP(i, s.size() - 1) {
        if(s[i] == 'A' && s[i+1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;

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

  cin>>S;
  map<char,int> cnt;
  rep(i,S.size())cnt[S[i]]++;
  bool ok=true;
  rep(i,S.size())if(cnt[S[i]]!=2)ok=false;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int binarySearch(int *, int);

int n;

int main(void)
{
	int i, S[100000], q, T[50000], c=0;
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for (i=0; i<q; i++) {
		scanf("%d",&T[i]);
	}
	
	for (i=0; i<q; i++) {
		if( binarySearch( S, T[i] ) != -1 ) c++;
	}
	
	printf("%d\n",c);
	
	return 0;
}

int binarySearch(int *S, int key)
{
	int left=0, right=n, mid;
	
	while ( left < right ) {
		mid = ( left + right ) / 2;
		if( S[mid] == key ) {
			return mid;
		} else if( key < S[mid] ) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	return -1;
}

Measured memory_bytes: 1184
N = gets.to_i
H = gets.split.map(&:to_i)
res = true
[*1..(N-1)].reverse.each do |i|
    if H[i-1] > H[i] then
        if H[i-1] - H[i] >= 2 then
            res = false
            break
        else
            H[i-1] -= 1
        end
    end
end
puts res ? "Yes" : "No"

Measured memory_bytes: 11012
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <random>
#include <chrono>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

class simulator{
public:
    static const int L=26;
    int D;
    vector<int> C;
    vector<vector<int>> S;
    int M;
    vector<int> T,Q;

    vector<int> bestAnswer;
    int bestScore;
    set<int> position[L];

    simulator(){}

    void solve(){
        input();
        simulate();
        output();
    }

    void input(){
        cin>>D;
        C.resize(L);
        S.resize(D);
        rep(i,L) cin>>C[i];
        rep(i,D){
            S[i].resize(L);
            rep(j,L) cin>>S[i][j];
        }
        bestAnswer.resize(D);
        rep(i,D) cin>>bestAnswer[i];
        cin>>M;
        T.resize(M);
        Q.resize(M);
        rep(i,M) cin>>T[i]>>Q[i];

        rep(i,M) T[i]--;
        rep(i,M) Q[i]--;
        rep(i,D) bestAnswer[i]--;
        rep(i,D) position[bestAnswer[i]].insert(i);
        rep(i,L){
            position[i].insert(-1);
            position[i].insert(D);
        }
    }

    int evaluate(vector<int> &t){
        int result=0;
        vector<int> last(L,0);
        for(int i=0;i<D;i++){
            int tar=t[i];
            result+=S[i][tar];
            last[tar]=i+1;
            for(int j=0;j<L;j++) result-=C[j]*(i+1-last[j]);
            //cout<<result<<endl;
        }
        return result;
    }

    int diffEvaluate(int d,int q){
        if(bestAnswer[d]==q) return 0;

        int result=S[d][q]-S[d][bestAnswer[d]];
        {
            auto itr=position[bestAnswer[d]].upper_bound(d);
            itr--;
            itr--;
            int l=*(itr);
            itr++;
            itr++;
            int r=*(itr);

            result-=C[bestAnswer[d]]*(d-l)*(r-d);
        }
        {
            auto itr=position[q].upper_bound(d);
            itr--;
            int l=*(itr);
            itr++;
            int r=*(itr);

            result+=C[q]*(d-l)*(r-d);
        }
        return result;
    }

    void simulate(){
        int score=evaluate(bestAnswer);
        rep(i,M){
            int diff=diffEvaluate(T[i],Q[i]);
            score+=diff;

            position[bestAnswer[T[i]]].erase(T[i]);
            position[Q[i]].insert(T[i]);
            bestAnswer[T[i]]=Q[i];
            cout<<score<<"\n";
        }
    }

    void output(){
        //cout<<evaluate(bestAnswer)<<endl;
        evaluate(bestAnswer);
        return;
    }

};

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

  simulator sim;
  sim.solve();

  return 0;
}


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

int di[4] = {-1,-1, 0, 0};
int dj[4] = {-1, 0,-1, 0};

int main(){
    string joi = "JOI";
    int m, n;
    cin >> m >> n;
    vector<vector<char>> mat(m+2, vector<char>(n+2, '.')), flag(2, vector<char>(2));
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            cin >> mat[i][j];
        }
    }
    for(int i = 0; i < 2; i++)  for(int j = 0; j < 2; j++)  cin >> flag[i][j];
    auto f = [&](int i, int j)->bool{
        for(int k = 0; k < 2; k++){
            for(int l = 0; l < 2; l++){
                if(mat[i+k][j+l] != flag[k][l]) return false;
            }
        }
        return true;
    };
    int base = 0;
    for(int i = 1; i <= m-1; i++){
        for(int j = 1; j <= n-1; j++){
            if(f(i,j))  base++;
        }
    }
    int add = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            char c = mat[i][j];
            int def = 0;
            for(int k = 0; k < 4; k++)  if(f(i+di[k],j+dj[k]))  def++;
            for(int k = 0; k < 3; k++){
                mat[i][j] = joi[k];
                int tmp = 0;
                for(int l = 0; l < 4; l++)  if(f(i+di[l],j+dj[l]))  tmp++;
                add = max(add, tmp-def);
            }
            mat[i][j] = c;
        }
    }
    cout << base+add << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    
    if(s == "ABC") cout << "ARC" << endl;

    else 
    {
        cout << "ABC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  double ans=v[0];
  rep(i,n-1) {
    ans=(ans+v[i+1])/2.0;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int N , x , i , Num;
	scanf( "%d%d" , &N , &x );
	V.emplace_back( x );

	for( i = 1 ; i <= N ; ++i ){
		scanf( "%d" , &Num );
		V.emplace_back( Num );
	}

	sort( V.begin() , V.end() );
	int g = 0;

	for( i = 1 ; i < V.size() ; ++i )
		g = __gcd( g , V[i] - V[i - 1] );

	printf( "%d\n" , g );
	return 0;
}

Measured memory_bytes: 892
N,M=map(int,input().split())
p=[]
S=[]
for i in range(M):
    x,y=input().split()
    p.append(int(x)-1)
    S.append(y)
WA=[0 for i in range(N)]
AC=[0 for i in range(N)]
for i in range(M):
    if S[i]=="AC":
        AC[p[i]]=1
    else:
        if AC[p[i]]==0:
            WA[p[i]]+=1
ans1=sum(AC)
ans2=0
for i in range(N):
    if AC[i]==1:
        ans2+=WA[i]
print(ans1,ans2)


Measured memory_bytes: 14920
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if ((n/100)==(n%10)) printf("Yes");else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<char,int>mp;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    mp[s[i]]++;
  }
  for(int i='a';i<='z';i++){
    if(mp[i]%2==1){
      cout<<"No"<<endl;
      return(0);
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n;
    cin >> n;
    if(n%2==1){
        cout<<n/2+1;
    }else{
        cout<<n/2;
    }

    return 0;
}

Measured memory_bytes: 256
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("filed 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 x:u32 = read();
    println!("{}", x.pow(3));
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	string A,B,C;
	cin>>A>>B>>C;
	
	if(A.back()==B.front()&&B.back()==C.front()){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

vector<pair<ll,ll>> fact(ll n){
	vector<pair<ll,ll>> res;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			res.pb({i,0});
			while(n%i==0){
				res[SZ(res)-1].snd++;
				n/=i;
			}
		}
	}
	if(n>1)res.pb({n,1});
	return res;
}

int main(){FIN;
	ll n; cin>>n;
	auto f=fact(n);
	ll res=0;
	for(auto i:f){
		fore(j,1,60){
			if(j*(j+1)/2<=i.snd)res++;
		}
	}
	cout<<res<<"\n";
	
	return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define Swap(a,b) (a+=b,b=a-b,a-=b)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline char GET(void)
{
  static char buf[1<<22],*s1=buf,*s2=buf;
  return s1==s2&&(s2=(s1=buf)+fread(buf,1,1<<22,stdin),s1==s2)?EOF:*s1++;
}
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=GET();while(c<48||c>57){f^=c==45,c=GET();}
  while(c>47&&c<58){x=x*10+c-48,c=GET();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
int work[10006][3],sz=0;
static inline void Add(int x,int y,int v){work[sz][0]=x;work[sz][1]=y;work[sz++][2]=v;}
int main(void)
{
  int N=IN(),A[3*N],dp[N][N],B[N],mx,extra=0;
  rep(i,3*N)A[i]=IN()-1;
  memset(B,-0x3f,sizeof(B));
  memset(dp,-0x3f,sizeof(dp));
  dp[A[0]][A[1]]=dp[A[1]][A[0]]=B[A[0]]=B[A[1]]=mx=0;
  rep(i,N-1)
  {
    int k=3*(i+1);
    if(A[k-1]>A[k])Swap(A[k-1],A[k]);
    if(A[k]>A[k+1])Swap(A[k],A[k+1]);
    if(A[k-1]>A[k])Swap(A[k-1],A[k]);
    int x[3]={A[k-1],A[k],A[k+1]};
    if(x[2]==x[0]){extra++;continue;}
    if(x[0]==x[1])rep(j,N)Add(j,x[2],dp[j][x[0]]+1);
    if(x[1]==x[2])rep(j,N)Add(j,x[0],dp[j][x[1]]+1);
    rep(j,3)Add(x[j==0],x[j==2?1:2],dp[x[j]][x[j]]+1);
    rep(j,3)rep(k,j)Add(x[j],x[k],mx);
    rep(j,N)rep(k,3)Add(j,x[k],B[j]);
    rep(j,sz)if(dp[work[j][0]][work[j][1]]<work[j][2])
      dp[work[j][0]][work[j][1]]=dp[work[j][1]][work[j][0]]=work[j][2],
      B[work[j][0]]=Max(B[work[j][0]],work[j][2]),
      B[work[j][1]]=Max(B[work[j][1]],work[j][2]),mx=Max(mx,work[j][2]);
    sz=0;
  }
  return OUT(Max(mx,dp[A[3*N-1]][A[3*N-1]]+1)+extra),0;
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<bool> v(26);
	for (int i = 0; i < S.size(); i++) {
		char ch = S.at(i);
		int n = (int)ch - 97;
		v.at(n) = 1;
	}

	string ans = "None";
	for (int i = 0; i < 26; i++) {
		if (v.at(i) == 0) {
			ans = (char)i + 97;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3716
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n;
    int a, min, max;
    long long sum;
    
    scanf("%d%d", &n, &a);
    sum = min = max = a;
    while (--n > 0) {
        scanf("%d", &a);
        if (a < min) min = a;
        if (a > max) max = a;
        sum += a;
    }
    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 300010
#define ll long long
int n, m, T[N], q[N];
ll Y[N], sum[N], fl[N], fr[N], f[N], tmp[N];
inline double slope(int x, int y) {
	return 1.0 * (Y[y] - Y[x]) / (y - x);
}
inline void dp(ll* f) {
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + T[i];
	int top = 0; f[0] = 0; q[++top] = 0;
	for (int i = 1; i <= n; ++i) {
		while (top > 1 && slope(q[top - 1], q[top]) <= i) --top;
		f[i] = max(f[i - 1], f[q[top]] + 1ll * (i - q[top]) * (i - q[top] + 1) / 2 - (sum[i] - sum[q[top]]));
		Y[i] = f[i] + sum[i] + 1ll * i * (i - 1) / 2;
		while (top > 1 && slope(q[top - 1], q[top]) <= slope(q[top], i)) --top;
		q[++top] = i;
	}
}
void solve(ll* f1, ll* f2, int l, int r) {
	if (l == r) {
		f[l] = max(f[l], f1[l - 1] + f2[l + 1] - T[l] + 1);
		return;
	}
	int mid = l + r >> 1, top = 0;
	for (int i = l - 1; i < mid; ++i) {
		Y[i] = f1[i] + sum[i] + 1ll * i * (i - 1) / 2;
		while (top > 1 && slope(q[top - 1], q[top]) <= slope(q[top], i)) --top;
		q[++top] = i;
	}
	for (int i = mid; i <= r; ++i) {
		while (top > 1 && slope(q[top - 1], q[top]) <= i) --top;
		tmp[i] = f1[q[top]] + f2[i + 1] + 1ll * (i - q[top]) * (i - q[top] + 1) / 2 - (sum[i] - sum[q[top]]);
	}
	for (int i = r - 1; i >= mid; --i) tmp[i] = max(tmp[i], tmp[i + 1]);
	for (int i = mid; i <= r; ++i) f[i] = max(f[i], tmp[i]);
	solve(f1, f2, l, mid); solve(f1, f2, mid + 1, r);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &T[i]);
	dp(fl); reverse(T + 1, T + n + 1); dp(fr);
	reverse(T + 1, T + n + 1); reverse(fr + 1, fr + n + 1);
	for (int i = 1; i <= n; ++i) f[i] = -T[i], sum[i] = sum[i - 1] + T[i];
	solve(fl, fr, 1, n);
	reverse(T + 1, T + n + 1); reverse(f + 1, f + n + 1); reverse(fl + 1, fl + n + 1); reverse(fr + 1, fr + n + 1);
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + T[i];
	solve(fr, fl, 1, n);
	reverse(T + 1, T + n + 1); reverse(f + 1, f + n + 1); reverse(fl + 1, fl + n + 1); reverse(fr + 1, fr + n + 1);
	scanf("%d", &m);
	for (int i = 1; i <= m; ++i) {
		int x, y; scanf("%d%d", &x, &y);
		printf("%lld\n", max(fl[x - 1] + fr[x + 1], f[x] + T[x] - y));
	}
	return 0;
}

Measured memory_bytes: 18944
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <array>
#include <limits>

const uint32_t D = 365 + 1;
const uint32_t contests = 26 + 1;

int64_t calc_sat(uint32_t contest, int64_t prev_value, uint32_t d,
                const std::array<uint32_t, contests>& last,
                const std::array<std::array<uint32_t, contests>, D>& sat,
                const std::array<uint32_t, contests>& cost){
  int64_t value = prev_value + sat[d][contest];

  int64_t c_sum = 0;
  for (size_t c = 1; c < contests; c++){
    if(c != contest) c_sum += cost[c]*(d-last[c]);
  }
  value -= c_sum;

  return value;
}

int main() {
  {
    uint32_t Dtmp = 0;
    std::cin >> Dtmp;
  }

  std::array<uint32_t, contests> cost;
  for (size_t c = 1; c < contests; c++) std::cin >> cost[c];
  
  std::array<std::array<uint32_t, contests>, D> sat;
  for (size_t d = 1; d < D; d++) for (size_t c = 1; c < contests; c++) std::cin >> sat[d][c];
  
  // solve problem
  std::array<uint32_t, D> test;
  std::array<uint32_t, contests> last;
  last.fill(0);
  int64_t prev_val = 0;
  for (size_t d = 1; d < D; d++)
  {
    int64_t max_val = std::numeric_limits<int64_t>::min();
    uint32_t max_c = 0;
    for (size_t c = 1; c < contests; c++){
      int64_t value = calc_sat(c, prev_val, d, last, sat, cost);
      if(value > max_val) max_val = value, max_c = c;
    }
    test[d] = max_c;

    last[max_c] = d;
    prev_val = max_val;
  }
  
  for(size_t d = 1; d < D; d++) std::cout << test[d] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3680
N = int(input())
M = [0] * (101)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in range(2, N + 1):
  for m in prime_factorize(i):
    M[m] += 1
#print(M[:N+1])

n3, n5, n15, n25, n75 = 0, 0, 0, 0, 0
for i in range(N+1):
  if M[i] >= 2:  n3  += 1
  if M[i] >= 4:  n5  += 1
  if M[i] >= 14: n15 += 1
  if M[i] >= 24: n25 += 1
  if M[i] >= 74: n75 += 1
#print(n3, n5, n15, n25, n75)   

answer = n75 + n25 * (n3 - 1) + n15 * (n5 - 1) + n5 * (n5 - 1) * (n3 - 2) // 2
print(answer)

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

int main()
{
    int n, m;
    cin >> n >> m;
    int guess[3] = {-1, -1, -1};
    rep(i, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if (guess[s] == -1) {
            guess[s] = c;
        } else if (guess[s] != c) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (n > 1) {
        if (guess[0] == 0) {
            cout << -1 << endl;
            return 0;
        } else if (guess[0] == -1) {
            guess[0] = 1;
        }
    }
    int ans = 0;
    rep(i, n) {
        ans *= 10;
        ans += guess[i] == -1 ? 0 : guess[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string s; cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn = 600 + 10;

int n;
char s[maxn][maxn];

int main() {
//	freopen("data.in","r",stdin);
  scanf("%d", &n);
	for(int i = 1;i <= n;i ++) scanf("%s", s[i] + 1);
	for(int i = 1;i <= n;i ++) {
		for(int j = 1;j <= n;j ++) {
			s[i][j + n] = s[i][j];
			s[i + n][j] = s[i][j];
			s[i + n][j + n] = s[i][j];
		}
	}
	int cnt = 0, Ans = 0;
	for(int del = - n + 1;del <= n - 1;del ++) {
		int flag = 0; cnt = 0;
    for(int y = max(1,- del + 1);y <= n && del + y <= n;y ++) {
			int x = del + y;
      if(!flag) {
				for(int i = 1;i <= n;i ++) {
					for(int j = 1;j < i;j ++) {
            if(s[x + i - 1][y + j - 1] != s[x + j - 1][y + i - 1]) cnt ++;
					}
				}
				flag = 1;
			}
			else {
        for(int i = 1;i <= n;i ++) {
					if(s[x - 1][y - 1 + i - 1] != s[x - 1 + i - 1][y - 1]) cnt --;
				}
				for(int i = 1;i <= n;i ++) {
					if(s[x + i - 1][y + n - 1] != s[x + n - 1][y + i - 1]) cnt ++;
				}
			}
			if(!cnt) Ans ++;
		}
	}
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 640
in_data = input().rstrip()
dic = {0:int(in_data[0])}
for i in range(3):
    n_dic = {}
    for item in dic.items():
        n_dic[item[0] + 2**i] = item[1] + int(in_data[i+1])
        n_dic[item[0]] = item[1] - int(in_data[i+1])
    dic = n_dic
    
for item in dic.items():
    if item[1] == 7:
        print(in_data[0], end='')
        num = item[0]
        for i in in_data[1:]:
            num, sign = num // 2, num % 2
            print("%s%s" % ("+" if sign==1 else "-", i), end="")
        break
print("=7")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
int Kpow[30];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K >> N;
  vector<int> ans;
  if (K == 1) {
    rep(i, (N+1)/2) ans.pb(1);
  }
  else if (K % 2 == 0) {
    ans.pb(K/2);
    rep(i, N-1) ans.pb(K);
  }
  else {
    Kpow[0] = 1;
    for (int i=1; i<30; i++) Kpow[i] = min((long long)INF, 1 + 1LL*Kpow[i-1]*K);
    int diff = 0;
    while (N >= 30 || Kpow[N] == INF) {
      ans.pb((K+1)/2);
      N--, diff++;
    }
    int X = Kpow[N]-1;
    X = ((diff+X+1)/2)-diff;
    assert(X >= 0);
    rep(i, N) {
      if (X == 0) break;
      X--;
      int ch = Kpow[N-1-i];
      ans.pb(1+(X/ch));
      X %= ch;
    }
  }
  for (int x : ans) cout << x << " "; cout << "\n";
  return 0;
}


Measured memory_bytes: 5488
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;
const int mod = 1e9+7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    mint sum = 0, sum2 = 0;
    for(int i = 0; i < n; i++){
        //a[i] = i+1;
        cin >> a[i];
        sum += a[i];
        sum2 += a[i]*a[i];
    }
    mint ans = 0;
    ans = (sum*sum - sum2)/2;
    //ans = n*(n+1)*(n-1)*(3*n+2)/24;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


k = input()
n = len(k)
d = int(input())
dp0 = [[0]*(d) for _ in range(n+1)]
dp1 = [[0]*(d) for _ in range(n+1)]
dp1[0][0] = 1
M = 10**9+7
for i in range(1,n+1):
    for j in range(d):
        v = int(k[i-1])
        dp1[i][j] = dp1[i-1][(j-v)%d]
        for vv in range(10):
            if vv<v:
                dp0[i][j] += dp1[i-1][(j-vv)%d]
            dp0[i][j] += dp0[i-1][(j-vv)%d]
        dp1[i][j] %= M
        dp0[i][j] %= M
ans = (dp0[n][0]+dp1[n][0]-1) % M
print(ans)

Measured memory_bytes: 91376
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

long long dp[200009][2], N, A[200009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 0; i <= N; i++) { dp[i][0] = -(1LL << 60); dp[i][1] = -(1LL << 60); }
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		if (dp[i - 1][0] != -(1LL << 60)) {
			dp[i][0] = max(dp[i][0], dp[i - 1][0] + A[i]);
			dp[i][1] = max(dp[i][1], dp[i - 1][0] - A[i]);
		}
		if (dp[i - 1][1] != -(1LL << 60)) {
			dp[i][1] = max(dp[i][1], dp[i - 1][1] + A[i]);
			dp[i][0] = max(dp[i][0], dp[i - 1][1] - A[i]);
		}
	}
	cout << dp[N][0] << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=998244353;
const ll inf=1e15;

template <class T>
T mult(T n,T m){
	if(m==0) return 1;
	if(m==1){
		return n%mod;
	}else if(m%2==0){
		T t=mult(n,m/2);
		return (t*t)%mod;
	}else{
		T t=mult(n,m-1);
		return (t*n)%mod;
	}
}

template <class T>
T mod_pow(T x,T n,T mod){
	T res=1;
	while(n>0){
		if(n & 1){
			res=res*x%mod;
		}
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> cnt(n,0),d(n);
  ll ma=0;
  rep(i,n){
    cin>>d[i];
    ma=max(d[i],ma);
    cnt[d[i]]++;
  }
  if(d[0]!=0){
    cout<<0<<endl;
    return 0;
  }
  ll ans=1;
  ll now=0;
  ll pre=1;
  rep(i,ma+1){
    //cout<<itr.fi<<endl;
    if(cnt[i]==0){
      cout<<0<<endl;
      return 0;
    }
    if(i!=now){
      cout<<0<<endl;
      return 0;
    }
    if(i==0){
      if(cnt[i]!=1){
        cout<<0<<endl;
        return 0;
      }
    }else{
      ans*=((mod_pow(pre,cnt[i],mod))%mod);
      ans%=mod;
      pre=cnt[i];
    }
    now++;
    //cout<<itr.fi<<' '<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <queue>
#include <set>
#include <vector>

using namespace std;

struct State {
  int64_t value_;  // a + b + c
  int l_, m_, n_;

  State(int64_t v, int l, int m, int n) {
    value_ = v;
    l_ = l;
    m_ = m;
    n_ = n;
  }

  bool operator<(const State& other) const { return value_ < other.value_; }
};

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<int64_t> a(x);
  vector<int64_t> b(y);
  vector<int64_t> c(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];
  // sentinels
  auto kMin = (long long)-1e17;
  a.push_back(kMin);
  b.push_back(kMin);
  c.push_back(kMin);

  sort(a.begin(), a.end(), greater<int64_t>());
  sort(b.begin(), b.end(), greater<int64_t>());
  sort(c.begin(), c.end(), greater<int64_t>());

  vector<int64_t> abc;  // a + b + c

  set<int> visited;
  visited.insert(0);
  priority_queue<State> q;
  q.emplace(a[0] + b[0] + c[0], 0, 0, 0);

  auto AppendNext = [&](int l, int m, int n) {
    const int hash = (l << 20) + (m << 10) + n;
    if (visited.find(hash) == visited.end()) {
      visited.insert(hash);
      q.emplace(a[l] + b[m] + c[n], l, m, n);
    }
  };

  while (abc.size() < k) {
    auto state = q.top();
    q.pop();
    abc.push_back(state.value_);
    int l = state.l_;
    int m = state.m_;
    int n = state.n_;
    AppendNext(l + 1, m, n);
    AppendNext(l, m + 1, n);
    AppendNext(l, m, n + 1);
  }
  for (int i = 0; i < k; i++) {
    cout << abc[i] << endl;
  }
  return 0;
}


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

using namespace std;

#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)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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 bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x[3][3];
    rep (i, 3) {
        rep (j, 3) {
            cin >> x[i][j];
        }
    }
    vector<int> a(3), b(3);
    rep (j, 3) {
        b[j] = x[0][j] - a[0];
    }
    rep (i, 3) {
        a[i] = x[i][0] - b[0];
    }
    bool ok = true;
    rep (i, 3) {
        rep (j, 3) {
            if (x[i][j] != a[i] + b[j]) ok = false;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
a = Array.new
b = Array.new
3.times do |i|
    a[i] = gets.split.map(&:to_i)
end
n = gets.to_i
n.times do |i|
    b[i] = gets.to_i
end
if (b.include?(a[0][0]) && b.include?(a[0][1]) && b.include?(a[0][2])) || (b.include?(a[1][0]) && b.include?(a[1][1]) && b.include?(a[1][2])) || (b.include?(a[2][0]) && b.include?(a[2][1]) && b.include?(a[2][2])) || (b.include?(a[0][0]) && b.include?(a[1][0]) && b.include?(a[2][0])) || (b.include?(a[0][1]) && b.include?(a[1][1]) && b.include?(a[2][1])) || (b.include?(a[0][2]) && b.include?(a[1][2]) && b.include?(a[2][2])) || (b.include?(a[0][0]) && b.include?(a[1][1]) && b.include?(a[2][2])) || (b.include?(a[2][0]) && b.include?(a[1][1]) && b.include?(a[0][2])) then
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		long turn = 0;
		
		while(A >= 1 && C >= 1){
		    if(turn == 0){
		        C = C - B;
		        turn = 1;
		    }if(turn == 1){
		        A = A - D;
		        turn = 0;
		    }
		}
		
		if(C <= 0){
		    System.out.println("Yes");
		}else{
		    System.out.println("No");
		}
      
	}
}

Measured memory_bytes: 35856
stack = []
S = input().split()
N = len(S)
for i in range(N):
    if S[i] == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif S[i] == "-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif S[i] == "*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(S[i]))
print(stack[0])
        



Measured memory_bytes: 5604
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }

  int flag=0;
  A[0]--;
  srep(i,1,N){
    if(A[i]<A[i-1]){
      flag=1;
      break;
    }
    else if(A[i]==A[i-1]){
      ;
    }
    else{
      A[i]--;
    }
  }

  if(flag==0){
    printf("Yes\n");
  }
  else if(flag==1){
    printf("No\n");
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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

    vector<long long> lunlun;
    lunlun.reserve(K);
    for (long long i = 0; i < 9; ++i) {
        lunlun.push_back(i + 1);
    }
    for (long long i = 0; i < K; ++i) {
        if (lunlun.size() >= K) {
            break;
        }
        long long root = lunlun[i];
        long long firstDigit = root % 10;
        if (firstDigit == 0) {
            lunlun.push_back(root * 10 + 0);
            lunlun.push_back(root * 10 + 1);
        }
        else if (firstDigit == 9) {
            lunlun.push_back(root * 10 + 8);
            lunlun.push_back(root * 10 + 9);
        }
        else {
            lunlun.push_back(root * 10 + firstDigit - 1);
            lunlun.push_back(root * 10 + firstDigit);
            lunlun.push_back(root * 10 + firstDigit + 1);
        }
    }
    long long ans = lunlun.at(K - 1);

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


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

using namespace std;

long long a, b, n, x, ans;

int main() {
	cin >> a >> b >> n;
	x = min(b - 1, n);
	ans = (a * x / b) - (a * (x / b));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：Organize Your Train part II
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/1142
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）

void solve() {
  unordered_set<string> s;
  string t; // train
  cin >> t;
  for (ll dev = 1; dev < (ll)t.size(); dev++) {
    string l = t.substr(0, dev);
    string r = t.substr(dev);
    string rl = l;
    string rr = r;
    reverse(rl.begin(), rl.end());
    reverse(rr.begin(), rr.end());
    s.insert(l + r);
    s.insert(l + rr);
    s.insert(rl + r);
    s.insert(rl + rr);
    s.insert(r + l);
    s.insert(r + rl);
    s.insert(rr + l);
    s.insert(rr + rl);
  }
  cout << s.size() << endl;
}

int main() {
  ll m;
  cin >> m;
  rep(i, m) { solve(); }
  return 0;
}



Measured memory_bytes: 3220
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

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

  std::vector<ll> v(n);

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

  int dp[n]={0};
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);

  for(int i=2;i<n;i++){

    dp[i] = min( abs(v[i]-v[i-1]) + dp[i-1] , abs(v[i]-v[i-2]) + dp[i-2] );

  }
  cout<<dp[n-1]<<"\n";

}


Measured memory_bytes: 4520
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S;cin >> S;
    map<char,int> m;
    REP(i,S.size()){
        ++m[S[i]];
    }
    if(m['a']==1 && m['b']==1 && m['c']==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = [int(X) for X in input().split()]
A2 = [int(X) for X in input().split()]
CumSumA1 = [A1[0]]*N
CumSumA2 = [A2[(N-1)]]*N
Disp = [0]*N
for T in range(0,N-1):
    CumSumA1[T+1] = CumSumA1[T]+A1[T+1]
    CumSumA2[(N-1)-(T+1)] = CumSumA2[(N-1)-T]+A2[(N-1)-(T+1)]
for T in range(0,N):
    Disp[T] = CumSumA1[T]+CumSumA2[T]
print(max(Disp))

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N;
    int max_a = -1, min_b = 1 << 30;
    for (int i = 0; i < N; i++) {
        cin >> A >> B;
        if (max_a < A) {
            max_a = A;
            min_b = B;
        }
    }
    cout << max_a + min_b << endl;
    return 0;
}

Measured memory_bytes: 256
N, *L = map(int, open(0).read().split())

ls = [0]*N
i = 0
for i,(x,l) in enumerate(zip(*[iter(L)]*2)):
  ls[i] = (x+l,x-l)
ls.sort()
cur = -10**20
ans = 0
for c in ls:
  if c[1]>=cur:
    ans += 1
    cur = c[0]
print(ans)

Measured memory_bytes: 98916
#include<bits/stdc++.h>
const int N = 100000+5;
using namespace std;
int vis[N];
int main() {
    int n;
    scanf("%d",&n);
    deque<pair<int,int> > Q;
    Q.push_front(make_pair(1,1));
    while(!Q.empty()){
        pair<int,int> temp=Q.front();
        Q.pop_front();
        if(!vis[temp.first]){
            vis[temp.first]=true;
            if(temp.first==0){
                printf("%d\n",temp.second);
                break;
            }
            Q.push_front(make_pair((temp.first*10)%n,temp.second));
            Q.push_back(make_pair((temp.first+1)%n,temp.second+1));
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main ()

{
	long long a,b,x;
	
	cin>>a>>b>>x;
	
	if(a>0)
	{
		
		cout<<(b/x)-(a-1)/x ;	
		
	}
	else 
	{
		
		cout<<(b/x)+1 ;
		
	}
	
	
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <math.h>
#include <string.h>
 
using namespace std;
 
int main(){

 string s;
  cin>>s;

  string res = "";

  for(int i=0;i<s.length();i++){

    if(s[i] == '0')
        res.append("0");
    else if(s[i] == '1')
        res.append("1");
    else if(s[i] == 'B' && !res.empty())
        res.erase(res.size()-1);
  }

  cout<<res<<endl;


return 0;
}



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

int main() {
  map<string, int> cnt;

  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    cnt[s[i]]++;
  }
  int m;
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
    cnt[t[i]]--;
  }

  int res = 0;
  for (auto kv:cnt) {
    int v = kv.second;
    res = max(res, v);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a = 0 , b = 0, pass = 0;
      int ans = 0;
      cin >> a >> b;
      pass = (a + b) % 2;
      ans = (a + b) / 2;
      cout << ans + pass;
    }

Measured memory_bytes: 256