akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int n;
vector<vector<int>> mat;
vector<int> color;
vector<vector<int>> parts;
vector<pair<int, int>> ps;

bool dfs(int u, int c) {
    color[u] = c;
    parts[c].emplace_back(u);
    for (int v = 0; v < n; v++) if (v != u && mat[u][v]) {
        if (~color[v]) {
            if (color[v] == color[u]) return false;
        } else {
            if (!dfs(v, c ^ 1)) return false;
        }
    }
    return true;
}

bool is_bipartite() {
    color.assign(n, -1);
    parts.assign(2, vector<int>());
    for (int u = 0; u < n; u++) if (color[u] == -1) {
        if (!dfs(u, 0)) return false;
        ps.emplace_back(parts[0].size(), parts[1].size());
        parts.assign(2, vector<int>());
    }
    return true;
}

int main() {
    int m; cin >> n >> m;
    mat.assign(n, vector<int>(n, 1));
    while (m--) {
        int a, b; cin >> a >> b; a--; b--;
        mat[a][b] = mat[b][a] = 0;
    }
    if (!is_bipartite()) return !(cout << -1 << endl);
    vector<bool> dp(n * 2 + 1);
    dp[0] = true;
    for (auto &p: ps) {
        for (int i = n; i >= 0; i--) if (dp[i]) {
            dp[i] = false;
            dp[i + p.first] = dp[i + p.second] = true;
        }
    }
    int idx = -1;
    for (int i = 0; i <= n; i++) if (dp[i]) {
        if (abs(idx - n / 2) > abs(i - n / 2)) idx = i;
    }
    int a = idx, b = n - idx;
    int res = a * (a - 1) / 2 + b * (b - 1) / 2;
    cout << res << endl;
    return 0;
}


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

int main()
{
  vector<vector<int> > A;
  vector<int> v;
  for (int i = 0; i < 3; i++)
  {
    A.push_back(v);
    for (int j = 0; j < 3; j++)
    {
      int x;
      cin >> x;
      A[i].push_back(x);
    }
  }

  ll n;
  cin >> n;

  for (ll i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if(A[j][k]==x) A[j][k] = -1;
      }
    }
  }

  string ans = "No";

  int i,j;
  // 縦
  for ( i = 0; i < 3; i++)
  {
    if( A[i][0]==-1 && A[i][1]==-1 && A[i][2]==-1 ) ans = "Yes";
  }
  
  // 横
  for (i = 0; i < 3; i++)
  {
    if( A[0][i]==-1 && A[1][i]==-1 && A[2][i]==-1 ) ans = "Yes";
  }
  
  //ななめ
  if( A[0][0]==-1 && A[1][1]==-1 && A[2][2]==-1 ) ans = "Yes";
  if( A[0][2]==-1 && A[1][1]==-1 && A[2][0]==-1 ) ans = "Yes";

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

Measured memory_bytes: 256
def mapt(fn, *args):
    return list(map(fn, *args))

def Array(listseq):
    return mapt(Vector, listseq)

def Vector(line):
    return mapt(Atom, line.split(" "))

def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment


def parse_second(rest):
    first, end, strings = rest[0], rest[1], rest[-1]
    return first, end+1, strings


def main(word, orders):
    parsed =Array(orders)
    word = list(word)
    for cmd, *rest in parsed:
        first, end, strings = parse_second(rest)

        if    cmd == "replace": word[first:end] = strings
        elif  cmd == "reverse": word[first:end] = reversed(word[first:end])
        else: print("".join(word[first:end]))



word = input()
times = int(input())
orders = [input() for _ in range(times)]
main(word, orders)


Measured memory_bytes: 5692
function Main(input){

      input = parseInt(input,10);
  　input = Math.abs(25 - input);
  	
  
  
  
   process.stdout.write('Christmas');
  for(var i=0;i<input;i++){
    process.stdout.write(' Eve');
  }
  
  
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7244
S = input()
T = input()

min_dist = 10**10
for i in range(len(S) - len(T) + 1):
    for k in range(len(T)):
        dist = 0
        for s, t in zip(S[i:i + len(T)], T):
            if s != t:
                dist += 1
            if dist >= min_dist:
                break

        min_dist = min(dist, min_dist)
        if min_dist == 0:
            print(0)
            exit()

print(min_dist)


Measured memory_bytes: 74296
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#define ll long long
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'a'||__c>'z') __c=getc();
        while(__c>='a'&&__c<='z') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(long double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            long double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y+1e-9);if(__c==10) __c--;
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int n,T,m,N;
ll s[100010],f[100010],ans[100010],tmp;
int main(){
	read(n);read(T);int i;ll remain,now,k;
	while(T--){
		read(tmp);
		while(m&&s[m]>=tmp) s[m--]=0;
		s[++m]=tmp;
	}
	if(m&&s[1]<n){
		N=n;n=s[1];
		for(i=1;i<m;i++) s[i]=s[i+1];m--;
	}
	s[0]=n;f[m]=1;
	for(i=m;i>=0;i--){
		remain=s[i];now=i-1;
		while(remain>n){
			k=remain/s[now];
			f[now]+=f[i]*k;remain-=s[now]*k;
			now=upper_bound(s,s+now,remain)-s-1;
		}
		ans[1]+=f[i];ans[remain+1]-=f[i];
	}
	for(i=1;i<=n;i++) ans[i]+=ans[i-1],print(ans[i]),el();
	while(n<N) n++,print(0),el();
	flush();
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		String weather = sc.next();

		if (weather.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (weather.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}


	}}

Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,k,n,tmp,ans=0,flag=0,a[1010]={};
    scanf("%d %d",&n,&k);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    do{ flag=0;
        for(i=0; i<n-1; i++){
            if(a[i]>a[i+1]){
                tmp=a[i];
                a[i]=a[i+1];
                a[i+1]=tmp;
                flag=1;
            }
        }
    }while(flag==1);
    for(i=0; i<k; i++){
        ans+=a[i];
    }
    printf("%d",ans);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u; n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size(){ return n; }
	int size(int u){ return -p[find(u)]; }
};

int main(){
	int n; cin>>n;
	vector<int> a(n),b(n);
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];

	vector<pair<int,int>> a2(n),b2(n);
	rep(i,n){
		a2[i]={a[i],i};
		b2[i]={b[i],i};
	}
	sort(a2.begin(),a2.end());
	sort(b2.begin(),b2.end());

	bool ok=true;
	vector<int> to(n);
	rep(i,n){
		if(a2[i].first>b2[i].first) ok=false;
		to[a2[i].second]=b2[i].second;
	}
	if(!ok){
		cout<<"No\n";
		return 0;
	}

	// 行き先が 2 ヶ所以上ある a の要素があれば Yes
	ok=false;
	for(int i=n-1;i>0;i--) if(a2[i]<=b2[i-1]) ok=true;
	if(ok){
		cout<<"Yes\n";
		return 0;
	}

	// 行き先を伝って全体で 1 つのループになっていれば No, そうでなければ Yes
	union_find U(n);
	rep(i,n) U.unite(i,to[i]);
	cout<<(U.size()==1?"No":"Yes")<<'\n';

	return 0;
}


Measured memory_bytes: 3328
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
p = LIST()
q = LIST()
count = 0
for x in permutations(range(1, n+1), n):
    count += 1
    if all( x[j] == p[j] for j in range(n)):
        a = count
    if all( x[j] == q[j] for j in range(n)):
        b = count
print(abs(a-b))

Measured memory_bytes: 10096
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int inf = 1e9;
using namespace std;

int N,M,X;
int a[15][15];
int judge(int ch){
	int money = 0;
	vector<int> ve(M+1,0);
	for(int i = 0;i<N;i++){
		if((ch>>i) & 1){
			money += a[i+1][0];
			for(int j = 1;j<=M;j++){
				ve[j] += a[i+1][j];
			}
		}
	}
	for(int j = 1;j<=M;j++){
		if(ve[j] < X) return inf;
	}
	return money;
}

int main(){
	// debug;
	ios;
	cin>>N>>M>>X;
	for(int i = 1;i<=N;i++) for(int j = 0;j<=M;j++) cin>>a[i][j];
	int ans = inf;
	for(int i = 0;i<(1<<N);i++){
		ans = min(ans,judge(i));
	}
	cout<<((ans == inf)?-1:ans)<<'\n';
	
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    string buf;
    cin >> buf;
    int count = 0;
    rep(i,4){
        rep(j,4){
            if(buf.at(i) == buf.at(j)){
                count++;
            }
        }
    }

    if(count==8){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=INT_MAX;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int Need(int size){
	size--;
	rep(i,5) size|=size>>(1<<i);
	return size+1;
}

struct SegTree{
	int size;
	vi data;
	SegTree(int s):size(Need(s)),data(size*2,INFTY){}
	void Update(int i,int x){
		for(i+=size;i;i>>=1)
			data[i]=min(data[i],x);
	}
	int Query(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return INFTY;
		if(a<=l && r<=b) return data[i];
		int res=INFTY,m=(l+r)/2;
		if(a<m) res=min(res,Query(a,b,i*2+0,l,m));
		if(m<b) res=min(res,Query(a,b,i*2+1,m,r));
		return res;
	}
	int Query(int a,int b){
		return Query(a,b,1,0,size);
	}
};

struct SegTree2D{
	int size;
	vector<SegTree> data;
	SegTree2D(int h,int w):size(Need(h)),data(size*2,SegTree(w)){}
	void Update(int i,int j,int x){
		for(i+=size;i;i>>=1)
			data[i].Update(j,x);
	}
	int Query(int a,int b,int c,int d,int i,int to,int bo){
		if(c<=to || bo<=a) return INFTY;
		if(a<=to && bo<=c) return data[i].Query(b,d);
		int res=INFTY,m=(to+bo)/2;
		if(a<m) res=min(res,Query(a,b,c,d,i*2+0,to,m));
		if(m<c) res=min(res,Query(a,b,c,d,i*2+1,m,bo));
		return res;
	}
	int Query(int a,int b,int c,int d){
		return Query(a,b,c,d,1,0,size);
	}
};

int main()
{
	for(int r,c,q;scanf("%d%d%d",&r,&c,&q),r|c|q;){
		vvi grid(min(r,c),vi(max(r,c)));
		if(r<=c) rep(i,r) rep(j,c) scanf("%d",&grid[i][j]);
		else     rep(j,r) rep(i,c) scanf("%d",&grid[i][j]);
		
		vi r1(q),c1(q),r2(q),c2(q);
		rep(i,q) scanf("%d%d%d%d",&r1[i],&c1[i],&r2[i],&c2[i]);
		
		if(r>c){
			swap(r,c);
			swap(r1,c1);
			swap(r2,c2);
		}
		
		SegTree2D st(r,c);
		rep(i,r) rep(j,c)
			st.Update(i,j,grid[i][j]);
		
		rep(i,q)
			printf("%d\n",st.Query(r1[i],c1[i],r2[i]+1,c2[i]+1));
	}
	
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 5e6 + 5;

int ans;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> s;
	REP(i, sz(s) / 2) {
		if (s[i] != s[sz(s) - i - 1]) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
n,ma,mb=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
suma=0;sumb=0
for i in range(n):
  suma+=l[i][0]
  sumb+=l[i][1]
dp=[[[float('inf') for i in range(sumb+1)] for i in range(suma+1)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
  for j in range(suma):
    for k in range(sumb):
      dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
      if j+l[i][0]<=suma and k+l[i][1]<=sumb:
        dp[i+1][j+l[i][0]][k+l[i][1]]=min(dp[i+1][j+l[i][0]][k+l[i][1]],dp[i][j][k]+l[i][2])
ans=[]
for j in range(suma+1):
  for k in range(sumb+1):
    if j*mb==k*ma and j*j!=0:
      ans.append(dp[n][j][k])
if min(ans)==float('inf'):
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 102620
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n, W;
    cin >> n >> W;
    vector<ll> dp(100001, INT_MAX); //dp[i] min weight at value = i
    dp[0]=  0;
    for(int i = 0; i < n; i++) {
        int weights, value;
        cin >> weights >> value;

        for(int j = 100001 - value; j >= 0; j--) 
            dp[j + value] = min(dp[j + value], dp[j] + weights); 
    }

    int ans = 0;
    for(int i = 0; i < 100001; i++)
        if(dp[i] <= W)
			ans = max(ans, i);

    cout << ans;

}


Measured memory_bytes: 4044
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val (a,b,c,d,e) = f.readLine().split(" ").map{it.toInt()}
	if(a == 0) println(1)
	if(b == 0) println(2)
	if(c == 0) println(3)
	if(d == 0) println(4)
	if(e == 0) println(5)
}


Measured memory_bytes: 36328
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi x, y, t;
    x = y = t = {0};
    rep(i, n){
        int xx, yy, tt; cin >> tt >> xx >> yy;
        x.emplace_back(xx);
        y.emplace_back(yy);
        t.emplace_back(tt);
    }

    bool ok = true;
    rep(i, n){
        int d = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        int rt = t[i + 1] - t[i] - d;
        if(rt < 0) ok = false;
        else if(rt % 2 == 1) ok = false;
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 1644
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    ret, _, _ = ext_euc(a, mod)
    return ret % mod


def main():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split(' ')))
    comb = [1 for _ in range(N + 1)]  # N_C_k
    perm_1 = [1 for _ in range(N + 1)]  # M_P_k
    perm_2 = [1 for _ in range(N + 1)]  # (M-k)_P_(N-k)
    for k in range(1, N + 1):
        c = comb[k - 1] * (N - k + 1) * mod_inv(k, MOD)
        c %= MOD
        comb[k] = c
        p = perm_1[k - 1] * (M - k + 1)
        p %= MOD
        perm_1[k] = p
        p = perm_2[k - 1] * (M - N + k)
        p %= MOD
        perm_2[k] = p
    perm_2.reverse()
    ans = 0
    for k in range(N + 1):
        v = (-1) ** (k % 2)
        v *= comb[k]
        v %= MOD
        v *= perm_1[k]
        v %= MOD
        v *= perm_2[k]
        v %= MOD
        v *= perm_2[k]
        v %= MOD
        ans += v
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 190032
import sys
import math
#import random
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()
ara=inara()

xor=0
for num in ara:
	xor^=num

xor^=ara[n-1]

ans=[0]*n
ans[n-1]=xor

for i in range(n-2,-1,-1):
	xor^=ara[i]^ara[i+1]
	ans[i]=xor

print(*ans)


Measured memory_bytes: 96612
s=int(input())
sqr=int((s-1)**(1/2))+1
sa=sqr**2-s
if(sqr>10**9):
    sa=10**18-s
    print(0,0,10**9,1,sa,10**9)
else:
 	print(0,0,sqr,1,sa,sqr)

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

pair<int,int> beto(int x) {
    string s = to_string(x);
    
    return pair<int,int> (s.front(), s.back());
}

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

    map<pair<int,int>, int> m;
    for(int i = 1; i <= n; i++) {
        pair<int,int> p = beto(i);
        m[p]++;
    }
    
    long int cnt = 0;
    for(int i = 1; i <= n; i++) {
        pair<int,int> pa = beto(i);
        pair<int,int> pb(pa.second, pa.first);
        
        //cout << pa.first << endl;
        //cout << m[pa] << " " << m[pb] << endl;
        cnt += m[pb];
    }
    
    cout << cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 3660
k,x = map(int,input().split())
if(x-k+1>=-1000000) :
	if(x+k+1<=1000000):
		for i in range(x-k+1, x+k):
			print(i," ",end="")
	else :
		for i in range(x-k+1, 1000001) :
			print(i," ",end="")
else :
	if(x+k+1<=1000000):
		for i in range(-1000000, x+k):
			print(i," ",end="")
	else :
		for i in range(-1000000, 1000001) :
			print(i," ",end="")

Measured memory_bytes: 3064
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		boolean flg = false;

		BigDecimal S = BigDecimal.valueOf(W);
		S = S.multiply(BigDecimal.valueOf(H));
		S = S.divide(BigDecimal.valueOf(2), 10,RoundingMode.HALF_UP);
		if(2*x==W&&2*y==H) {
			flg = true;
		}
		System.out.print(S+" ");
		if(flg) {
			System.out.println("1");
		} else {
			System.out.println("0");
		}
	}
}

Measured memory_bytes: 27284
#include<iostream>
using namespace std;
//--------------------

int main() {
	long res[400009];
	long n; cin >> n;
	long a[200009]; for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) res[i] = a[n - i + 1];
	for (int i = n + 1; i <= 2 * n; i++) res[i] = a[i - n];

	for (int i = 1; i <= 2 * n; i = i + 2) cout << res[i] << " ";
    cout << endl;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int a[3], k;
    scanf("%d %d %d\n%d",&a[0],&a[1],&a[2],&k);
    sort(a,a+3);
    cout<<a[0]+a[1]+(a[2]<<k)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

a = [0] * (n + 1)
b = [0] * (n + 1)

for i in range(n):
    #先頭からi番目までの#の数
    if s[i] == '#':
        a[i + 1] = 1
    #末尾からi番目までの.の数
    if s[n - i - 1] == '.':
        b[n - i - 1] = 1
    #累積和をとる
    a[i + 1] += a[i]
    b[n - i - 1] += b[n - i]

ans = 100100100

for i in range(n):
    #i番目を境に分けた時に入れ替える数の最小値
    ans = min(ans, a[i] + b[i + 1])

print(ans)

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

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

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

  int cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] != a[i - 1])
      continue;
    a[i] = -1;
    ++cnt;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;

}
int KH[300001], KW[300001];
int h[300001], w[300001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), W = getint(), M = getint();

	rep(i, M) {
		KH[h[i] = getint()]++;
		KW[w[i] = getint()]++;
	}

	int saidaih = -1, hh = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			hh = 1;
		}
		else if (saidaih == KH[i]) hh++;
	}
	int saidaiw = -1, ww = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			ww = 1;
		}
		else if (saidaiw == KW[i]) ww++;
	}

	ll are = ll(hh) * ww;

	int kazu = 0;
	rep(i, M) {
		kazu += (KH[h[i]] == saidaih && KW[w[i]] == saidaiw);
	}

	printf("%d\n", saidaih + saidaiw - (kazu == are));

	Would you please return 0;
}

Measured memory_bytes: 6412
#include <iostream>

int main() {
    char c;
    std::cin >> c;

    switch(c) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            std::cout << "vowel" << std::endl;
            break;
        default:
            std::cout << "consonant" << std::endl;
            break;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int a,b; cin >> a >> b;
    int ans = 123;
    if(a==1 || b==1) ans-=100;
    if(a==2 || b==2) ans-=20;
    if(a==3 || b==3) ans-=3;
    
    if(ans==3) cout << 3 << endl;
    if(ans==20) cout << 2 << endl;
    if(ans ==100) cout << 1 << endl;
 
}

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

int main(){
  int n,q;
  string t,s = " ";
  cin >> n >> q >> t;
  s += t;
  vi cnt(n+1);
  for(int i=1; i<n; i++){
    if(s[i] == 'A' && s[i+1] == 'C'){
      cnt[i]++;
      cnt[i+1]++;
    }
  }
  rep(i,n-1) cnt[i+2] += cnt[i+1];
  //rep(i,n+1) cout << cnt[i] << endl;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    int ans = cnt[r]-cnt[l] +1;
    if(cnt[l]%2 == 0) ans--;
    ans /= 2;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3788
# AOJ 0090 Overlaps of Seals

$EPS = 1e-9

class CircleR1
  attr_reader :center

  def initialize(center)
    @center = center
  end

  def to_s
    "#<CircleR1 (#{@center.real},#{@center.imag})>"
  end

  def include?(point)
    (point - @center).abs2 <= 1 + $EPS
  end

  def overlaps?(other)
    (other.center - @center).abs2 <= 4
  end

  def intersection_points(other)
    return [] unless overlaps?(other)

    d = (other.center - @center).abs
    e1 = (other.center - @center) / d
    e2 = e1 * Complex(0, 1)
    l1 = 0.5 * d
    l2 = Math.sqrt(1 - l1 * l1)

    p1 = @center + l1 * e1 + l2 * e2
    p2 = @center + l1 * e1 - l2 * e2

    l2 < $EPS ? [p1] : [p1, p2]
  end
end

while line = gets
  n = line.to_i
  break if n.zero?

  circles = []
  intersection_points = []
  n.times do
    x, y = gets.split(",").map(&:to_f)
    c1 = CircleR1.new(Complex(x, y))

    # これまでにある円との交点を求め、交点の配列に追加する
    circles.each do |c2|
      intersection_points += c1.intersection_points(c2)
    end

    circles << c1
  end

  max_overlaps = 1
  intersection_points.each do |point|
    overlaps = circles.select {|circle| circle.include?(point)}.length
    max_overlaps = [overlaps, max_overlaps].max
  end

  puts max_overlaps
end

Measured memory_bytes: 13736
#include<stdio.h>
  
int main(){
  int s1,s2,s3;
  //s1,s2,s3は0又は1から良い
  scanf("%d",&s1);
  s2 = s1%100;
  s1 = s1/100;
  s3 = s2%10;
  s2 = s2/10;
  printf("%d", s1+s2+s3);
  return 0;

}

Measured memory_bytes: 128
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ote(x) cout<<(x)<<endl

int main(){
	string S; cin>>S;
	string T = "ACGT";
	vector<bool> A(S.size(),false);
	rp(i,S.size()){
		rp(j,4) if(S[i]==T[j])A[i] = true;
	}
	ll maxi = 0;
	ll now = 0;
	rp(i,A.size()){
		if(A[i]) ++now;
		else{
			maxi = max(maxi,now);
			now = 0;
		}
	}
	maxi = max(maxi,now);
	ote(maxi);
}


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

constexpr int INF = 1 << 30;

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::string> ss(n);
    for (auto& s : ss) std::cin >> s;

    // (x, y)から(t ? 縦 : 横)に取れるか判定
    auto judge = [&](int x, int y, int t) {
        if (t == 0) {
            for (int dx = 0; dx < 3; ++dx) {
                int nx = x + dx,
                    ny = y;
                if (nx < 0 || n <= nx || ny < 0 || m <= ny ||
                    ss[nx][ny] != "RGW"[dx]) return false;
            }
        } else {
            for (int dy = 0; dy < 3; ++dy) {
                int nx = x,
                    ny = y + dy;
                if (nx < 0 || n <= nx || ny < 0 || m <= ny ||
                    ss[nx][ny] != "RGW"[dy]) return false;
            }
        }
        return true;
    };

    int ans = 0;
    auto dp = vec(2, vec(2, 0));
    auto ndp = dp;

    // (sx, 0)から斜め上に見る
    for (int sx = 0; sx < n + m; ++sx) {
        for (int t1 = 0; t1 <= 1; ++t1) {
            for (int t2 = 0; t2 <= 1; ++t2) {
                dp[t1][t2] = -INF;
            }
        }
        dp[0][0] = 0;

        for (int y = 0; y <= m + 1; ++y) {
            int x = sx - y;

            for (int t1 = 0; t1 <= 1; ++t1) {
                for (int t2 = 0; t2 <= 1; ++t2) {
                    ndp[t1][t2] = -INF;
                }
            }

            for (int t1 = 0; t1 <= 1; ++t1) {
                for (int t2 = 0; t2 <= 1; ++t2) {
                    // ブロックを取らない
                    ndp[t2][0] = std::max(ndp[t2][0], dp[t1][t2]);

                    // 縦に取る
                    if (!t1 && !t2 && judge(x, y, 0)) {
                        ndp[t2][0] = std::max(ndp[t2][0], dp[t1][t2] + 1);
                    }

                    // 横に取る
                    if (judge(x, y, 1)) {
                        ndp[t2][1] = std::max(ndp[t2][1], dp[t1][t2] + 1);
                    }
                }
            }
            std::swap(dp, ndp);
        }
        ans += dp[0][0];  // yを2だけ余分にカウントすることでdp[0][0]に集約している
    }
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



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

int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,t,a;
  cin>>n>>t>>a;
  int h[n];
  rep(i,n) cin >> h[i];
  double min_tmp = abs(t-(h[0]*0.006) - a);
  int itr = 0;
  rep(i,n){
    if(abs(t-(h[i]*0.006) - a) < min_tmp) {
      min_tmp = abs(t-(h[i]*0.006) - a);
      itr = i;
    }
  }
  cout << itr+1 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
LIMIT = 10 ** 18
n=int(input())
#a=(int,read.split())
a=[int(i) for i in input().split()]
if 0 in a:
	print(0)
	exit()

ans = 1
for i in a:
	ans *= i
	if ans > 10**18 and i != 0:
		print(-1)
		exit()
print(ans)
	

Measured memory_bytes: 21708
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin >> n;
    int days[n][3], dp[n][3];
    for (int i=0 ; i<n ; i++)
        cin >> days[i][0] >> days[i][1] >> days[i][2];
    dp[0][0]=days[0][0], dp[0][1]=days[0][1], dp[0][2]=days[0][2];
    for (int i=1 ; i<n ; i++)
    {
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+days[i][0];
        dp[i][1]=max(dp[i-1][0], dp[i-1][2])+days[i][1];
        dp[i][2]=max(dp[i-1][1], dp[i-1][0])+days[i][2];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+10,MAXM=2e6+10;
const int INF=INT_MAX,MOD=1e9+7;
const ll llINF=~(1ll<<63);

int a[4],n,ans;
char s[MAXN];

bool check()
{
    int p=1;
    for(int i=1;i<=n;i++)
    {
        if(s[i]==a[p]+'0')p++;
        if(p==4)return true;
    }
    return false;
}

int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++)
            for(int k=0;k<=9;k++)
        {
            a[1]=i;
            a[2]=j;
            a[3]=k;
            ans+=check();
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#define INF -1000000
#define F first
#define S second
using namespace std;

int N,imap[100010],MINE;
int dp[100010];
bool Init(){
  cin >> N;
  if(N == 0)return false;
  for(int i=0;i<N;i++){
    cin >> imap[i];
    dp[i] = 1<<29;
  }
  for(int i=N;i<N+10;i++)dp[i] = 1<<29;
  MINE = 1<<29;
  return true;
}

int main(){
  //while(true){
  //if(!Init())break;
  Init();

  deque<int> que;
  que.push_front(0);
  dp[0] = 0;

  while(!que.empty()){
    int p = que.front();que.pop_front();
   
    if(p >= N-1){
      cout << dp[p] << endl;
      break;
    }
    if(imap[p] != 0){
      int np = p + imap[p];
      if(dp[np] <= dp[p])continue;
      dp[np] = dp[p];
      que.push_front(np);//飛ばされてきた場合を優先する
      continue;
    }
    for(int i=1;i<=6;i++){
      int np = p+i;
      if(dp[np] <= dp[p]+1)continue;
      dp[np] = dp[p]+1;
      que.push_back(np);
    }
  }
  //for(int i=1;i<N;i++)cout << "dp["<< i << "] = "  << dp[i] << endl;


  
  //}
  return 0;
}

Measured memory_bytes: 2000
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Integer[] len = new Integer[n];
		for ( int i = 0; i < n; i++ ) {
			len[i] = in.nextInt()*2; // 2倍して（偶数にして）受け取る
		}
		Arrays.sort(len);

		int cnt = 0;		
		for ( int e1 = 0; e1 < n - 2; e1++ ) {
			for ( int e2 = e1 + 1; e2 < n - 1; e2++ ) {				
				// LowerBoundを取りたい // 奇数は存在しないので一意な値が返ってくる
				int d = len[e1] + len[e2] - 1;				
				int i = ~Arrays.binarySearch(len, d);
				cnt += i - (e2 + 1);
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 44484
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a); i < (b); i += (s))
#define down(i, a, b, s) for (int i = (a); (b) < i; i -= (s))

const int maxn = 1e5 + 1;

int n, m, a[maxn];

struct _info {
  int b, c;

  bool operator<(_info rhs) const { return c > rhs.c; }
} info[maxn];

int main(int argc, char const *argv[]) {
  // freopen("D.txt", "r", stdin);

  while (cin >> n >> m) {
    range(i, 0, n, 1) cin >> a[i];
    sort(a, a + n);
    // range(i, 0, n, 1) { cout << a[i] << " "; }
    // cout << endl;
    range(i, 0, m, 1) { cin >> info[i].b >> info[i].c; }
    sort(info, info + m);
    int s = 0, o = n;
    long long ans = 0;
    range(i, 0, m, 1) {
      // TODO upper?
      int k =
          lower_bound(a + s, a + s + min(o, info[i].b), info[i].c) - (a + s);
      s += k;
      o -= k;
      // cout << info[i].b << " @ " << info[i].c << " -> " << k << endl;
      ans += (long long)k * (long long)info[i].c;
      // cout << "ans!" << ans << endl;
      if (o == 0) break;
      // cout << k << endl;
    }
    range(i, s, n, 1) { ans += a[i]; }
    // range(i, 0, n, 1) { cout << a[i] << " "; }
    // cout << endl;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

const int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int solve(vector<int> a,int n){
    int m;
    cin >>m;
    rep(i,(1<<n)){
        int sum = 0;
        rep(j,n){
            if(i &(1<<j)){
                sum += a[j];
            }
        }
        if(sum==m){
            return 1;
        }
    }
    return 0;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int q;
    cin >> q;
    vector<int> m(2010);
    rep(bit,(1<<n)){
        int sum = 0;
        rep(i,n){
            if(bit & (1<<i)){
                sum += a[i];
            }
        }
        if(sum<2010){
            m[sum]++;
        }
    }
    rep(_,q){
        int x;
        cin >> x;
        if(m[x]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL


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

const ll mod1 = 1000000007;
const ll mod2 = 1000000009;
const ll seica1 = 114514;
const ll seica2 = 1919810;

#define NODE 555555
pair<ll,ll> f[2][NODE];
ll mod[] = {1000000007,1000000009};
ll kake[] = {114514,1919810};
int n;
string str;
map<pair<ll,ll>,ll> mp;

ll m_pow(ll a,ll b,ll p){
	ll ret = 1;
	ll tmp = a;
	for(ll i = 0LL;i < 60;i++){
		if(b & (1LL << i)){
			ret *= tmp;
			ret %= p;
		}
		tmp *= tmp;
		tmp %= p;
	}
	return ret;
}

ll m_inv(ll a,ll p){
	return m_pow(a,p-2,p);
}

void get_f(int num,int type){
	pair<ll,ll> now = MP(1,0);
	pair<ll,ll> prev;
	if(num == n-1){
		prev = MP(1,0);
	}
	else{
		prev = f[type][num+1];
	}
	
	if(str[num] == '<'){
		now.FI = kake[type];
	}
	else if(str[num] == '>'){
		now.FI = m_inv(kake[type],mod[type]);
	}
	else if(str[num] == '+'){
		now.SE = mod[type] - 1;
	}
	else{
		now.SE++;
	}
	
	ll fir = now.FI * prev.FI % mod[type];
	ll sec = (now.SE * prev.FI % mod[type] + prev.SE) % mod[type];
	f[type][num] = MP(fir,sec);
}

pair<ll,ll> dfs(int num,int type){
	pair<ll,ll> now = MP(1,0);
	pair<ll,ll> prev;
	if(num == 0){
		prev = MP(1,0);
	}
	else{
		prev = dfs(num-1,type);
	}
	
	if(str[num] == '>'){
		now.FI = kake[type];
	}
	else if(str[num] == '<'){
		now.FI = m_inv(kake[type],mod[type]);
	}
	else if(str[num] == '-'){
		now.SE = mod[type] - 1;
	}
	else{
		now.SE++;
	}
	
	ll fir = now.FI * prev.FI % mod[type];
	ll sec = (now.SE * prev.FI % mod[type] + prev.SE) % mod[type];
	return MP(fir,sec);
}

ll get_x(ll x,ll num,ll type){
	return (f[type][num].FI * x % mod[type] + f[type][num].SE) % mod[type];
}

int main(){
	cin >> n >> str;
	for(int i = str.size()-1;i >= 0;i--){
		get_f(i,0);
		get_f(i,1);
	}
	
	ll c[2] = {dfs(n-1,0).SE,dfs(n-1,1).SE};
	
	ll ans = 0;
	mp[{0,0}]++;
	for(int i = str.size()-1;i >= 0;i--){
		ans += mp[{get_x(c[0],i,0),get_x(c[1],i,1)}];
		mp[{get_x(0,i,0),get_x(0,i,1)}]++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 53636
#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 digitSum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = Inf;
    FOR (i, 1, n) {
        int tmp = digitSum(i) + digitSum(n - i);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    
    return 0;
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	vector<int> a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	int ans = 0 ;
	rep(i,n){
		//どこで下に降りるか
		int tmp = 0 ;
		for(int j = 0 ; j < n ; j++){
			//i以上になったら下を＋
			if(j <= i){
				tmp += a[j];
			}
			if(j >= i ){
				tmp += b[j] ;
			}
		}
		chmax(ans,tmp);
		tmp = 0 ;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 long long

int n;
int t[233333];
int a[233333];
int b[233333];

int main(void){
    // Your code here!
    cin>>n;
    rep(i,n)cin>>t[i];
    int t1=-1,t2=-1;
    rep(i,n){
        t1=max(t1,t[i]);
        a[i]=t1;
    }
    for(int i=n-1;i>=0;i--){
        t2=max(t2,t[i]);
        b[i]=t2;
    }
    
    rep(i,n){
        if(i==0){
            cout<<b[i+1]<<endl;
        }
        else if(i==n-1){
            cout<<a[i-1]<<endl;
        }
        else{
            cout<<max(a[i-1],b[i+1])<<endl;
        }
    }
    
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  cout.precision(12);
  while(true){
    double x,h;
    cin>>x>>h;
    if(x==0 && h==0)break;
    double s;
    double po = x*sqrt(2.0)/2.0;
    double bo = sqrt(h*h + po*po);
    double co = x/2.0/bo;
    double si = sqrt(1.0-co*co);
    double ho = si*bo;
    s = ho*x/2.0;
    s *= 4.0;
    s += x*x;
    cout<<fixed<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
import collections
N = int(input())
List = [str(input()) for i in range(N)]
c = collections.Counter(List)
#print(c.most_common()[0])
#print(c.most_common()[1])
#print(c.most_common())

most=[]
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)

Measured memory_bytes: 45040
#include<cstdio>
typedef long long ll;
const int N=1000002;
ll n,a,b,x[N],i,ans;
ll min(ll x,ll y){
	return x<y?x:y;
}
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	for(i=1;i<=n;i++)
		scanf("%lld",x+i);
	for(i=1;i<n;i++)
		ans+=min(b,(x[i+1]-x[i])*a);
	printf("%lld",ans);
}

Measured memory_bytes: 896
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: x,i

    read*, x

    do i=1,100000
        if (((i-1)*i)/2 + 1 <= x .and. x <= (i*(i+1))/2) then
            print'(i0)', i
            stop
        end if
    end do
end program name

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

typedef long long ll;

ll man(ll, ll, ll, ll);
int main(){
  int n, m; cin >> n >> m;
  ll a[n+1], b[n+1], c[m+1], d[m+1];
  for(int i=1; i<=n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i=1; i<=m; i++){
    cin >> c[i] >> d[i];
  }

  for(int i=1; i<=n; i++){
    int ans;
    ll dis = LLONG_MAX;
    for(int j=1; j<=m; j++){
      if(man(a[i], b[i], c[j], d[j])<dis){
        dis = man(a[i], b[i], c[j], d[j]);
        ans = j;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

ll man(ll x1, ll y1, ll x2, ll y2){
  return abs(x1-x2)+abs(y1-y2);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[100 + 1];
    int k = 0;

    scanf("%s", &s);
    int n = strlen(s); 
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] == s[n - 1 - i])
        {
        }
        else
        {
          s[n -1] = s[n];
            k++ ;
        }
    }
    printf("%d\n",k);

    return 0;
}


Measured memory_bytes: 128