akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int main(){
    int n,w;
    cin >> w >> n;
    int a[100];
    rep(i,w) a[i] = i+1;
    rep(i,n){
        int x,y;
        char c;
        cin >> x >> c >> y;
        swap(a[x-1],a[y-1]);
    }
    rep(i,w) cout << a[i] << endl;
}

Measured memory_bytes: 1160
s = input()
t = input()

cnt = []
for i in range(len(s) - len(t) + 1):
    cnt1 = 0
    for k in range(len(t)):
        if t[k] == s[i: i + len(t)][k]:
            cnt1 += 1
            cnt.append(cnt1)
            #print(t[i:k], s[i:], k-i)
    else:
        cnt.append(0)
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))


Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define int long long
#define pb       push_back
#define io    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(a)      (a).begin(),(a).end()
#define endl        '\n'
#define F    first
#define S second
#define mod 1000000007 
#define N 3005
#define pii pair<int,int>
using namespace std;
int n,m;
int dp[N][N];
string s,t;

int  fun(int i,int j)
{
    if(i==0 || j==0)
        return 0;
        
    if(dp[i][j] != -1)
        return dp[i][j];
        
    if(s[i-1] != t[j-1])
        dp[i][j]=max(fun(i-1,j),fun(i,j-1));
    else
        dp[i][j]=fun(i-1,j-1)+1;
        
    return dp[i][j];
}
void solve()
{
    cin>>s>>t;
    n=s.length(),m=t.length();
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            dp[i][j]=-1;
            
    int x=fun(n,m);
    int i=n,j=m;
    
    string ans="";
    while(i && j)
    {
        if(s[i-1]==t[j-1])
            ans=s[i-1]+ans,i--,j--;
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    
    cout<<ans;
}

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

Measured memory_bytes: 71040
N,M=map(int,input().split())
t=[0]*(N+1)
e=[0]*(N+1)
for i in range(M):
  p,s=input().split()
  if t[int(p)]==0 and s=="WA":
    e[int(p)]+=1
  if t[int(p)]==0 and s=="AC":
    t[int(p)]=1
for i in range(N+1):
  if t[i]==0:
    e[i]=0
print(sum(t),sum(e))

Measured memory_bytes: 4596
def main():

    N, K = map(int, input().split())
    have = set()
    for _ in range(K):
        d = input()
        have |= set(list(map(int, input().split())))

    ans = 0
    for i in range(1, N+1):
        if i not in have:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"

signed main()
{
	int n;
	cin>>n;
	int dp[n][6];
	int a,b,c;
	cin>>a>>b>>c;
	dp[0][0]=a; dp[0][1]=b;dp[0][2]=c;//dp[0][3]=b;dp[0][4]=c;dp[0][5]=c;
	REP(i,1,n-1)
	{
		cin>>a>>b>>c;
		dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    return 0;
}


Measured memory_bytes: 4992
import bisect
import sys
input=lambda : sys.stdin.readline().rstrip()
a,b,q=map(int,input().split())
s=sorted([int(input()) for i in range(a)])
t=sorted([int(input()) for i in range(b)])
for i in range(q):
    ans=999999999999
    x=int(input())
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))
    print(ans)

Measured memory_bytes: 79068
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,m,a[N][N],sum[N][N];
int sqr(int x){return x*x;}
signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int res=0;
			for(int k=1;k<=m;k++)res+=sqr(a[i][k]-a[j][k]);
			int t=(int)(sqrt(res+1e-8));
			if(t*t==res)ans++;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
E,Y = map(int,input().split())

if E ==0:
    if 1912>Y:
        print("M"+str(Y-1867))
    elif 1926>Y:
        print("T"+str(Y-1911))
    elif 1989>Y:
        print("S"+str(Y-1925))
    else:
        print("H"+str(Y-1988))
elif E==1:
    print(1867+Y)
elif E==2:
    print(1911+Y)
elif E==3:
    print(1925+Y)
else:
    print(1988+Y)



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(a>0&&c>0){
    c -= b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 220000
#define offset 
const ll MOD= 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> colas[tam],g[tam];
ordered_set s;
int resp[tam],v[tam];
int lstuniv=0;
void dfs(int num,int pa)
{
    int delta=0;
    int p=-1,ant;
    
    if (lstuniv==0 || colas[lstuniv].back()<v[num])
    {
        delta=1;
        p=++lstuniv;

        colas[lstuniv].push_back(v[num]);
        s.insert(v[num]);
    }
    else
    {
        if (s.find(v[num])==s.end())
        {
            int aux=*s.upper_bound(v[num]);
            p=s.order_of_key(aux+1);
            ant=colas[p].back();
            s.erase(ant);
            colas[p].push_back(v[num]);
            s.insert(v[num]);
        }
    }
    //cout<<num<<": "<<pa<<endl;
    /*for(auto ite=s.begin();ite!=s.end();ite++)
        cout<<*ite<<' ';
    cout<<endl;*/
    resp[num]=s.size();
    for(int v:g[num])
    {
        if (v==pa)continue;
        dfs(v,num);
    }
    if (p!=-1)
    {
        lstuniv-=delta;
        int aux=colas[p].back();
        s.erase(aux);
        colas[p].pop_back();
        if (!colas[p].empty())
            s.insert(colas[p].back());
    }
}
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    forr(i,1,n+1)
        cin>>v[i];  
    int iz,der;
    forr(i,0,n-1)
    {
        cin>>iz>>der;
        g[iz].pb(der);
        g[der].pb(iz);
    }
    dfs(1,1);
    forr(i,1,n+1)
        cout<<resp[i]<<endl;
}
// PLUS ULTRA!
    


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

int main()
{
    int a,b;
    cin>>a>>b;
    int sum = 0;
    for(int i=0; i<b; i++){
    	int yo;
    	cin>>yo;
    	sum+=yo;
    }
    if((a-sum)>=0){
    	cout<<a-sum;
    }
    else{
    	cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
int main() {

 int n,i,j,k,l,m,o,p,q;
 int b,c;
 char a[2][150];
char d;
 scanf("%d",&n);
scanf("%c",&d);

i=0;
j = 0;
k=0;
b =0;
c=0;
o=0;

 while(1){    

if(k == n) {
  break;
}


scanf("%c", &a[j][i]);
i++;

//printf("??\????¢???????a[%d][%d] = %c\n" , j,i-1,a[j][i-1]);

if(a[j][i-1] == ' ') {
  j = 1;
  l=i-1;
  i = 0;
//printf("????????§j=%d\n",j);
} else if (a[j][i-1] == '\n') {
  j = 0;
  m = i-1;
  i= 0;
  k++;
//printf("????????§k=%d?????????\n",k);
  
//printf("????????§j=%d\n",j);
}


if(l-m < 0) {
  q = m;
} else {
  q = l;
}


if(a[1][m] == '\n') {
  for(p=0; p<q;p++) {
//printf("a[0][%d]???%c a[1][%d]???%c ????????????\n",p,a[0][p],p,a[1][p]);
    if(a[0][p] > a[1][p]) {
      b = b +3;
//printf("b+3=%d\n",b);
break;
    } else if( a[0][p] == a[1][p]) {
      c++;
if(c == q) {
b = b+1; o=o+1;
//printf("b+1=%d o+1=%d\n",b,o);
break;
}

} else if(a[0][p] < a[1][p]) {
o = o+3;
//printf("o+3=%d\n",o);
break;
}
}
m=0;
c=0;
}



 }

printf("%d %d\n" ,b,o);


return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int parent(int a )
{
  return a/2;
}

int right(int a)
{
  return a*2+1;
}

int left(int a)
{
  return a*2;
}

int main(){
  int A[200001],n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  for(i=0;i<n;i++){
    printf("node %d: key = %d, ",i+1,A[i+1]);
  
  
    if(parent(i+1)>=1){
      printf("parent key = %d, ",A[parent(i+1)]);
    }
     if(left(i+1)<=n){
      printf("left key = %d, ",A[left(i+1)]);
    }
    if(right(i+1)<=n){
      printf("right key = %d, ",A[right(i+1)]);
    }


      printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2044
n = int(input())

if n == 0:
    print(n)
    exit(0)

t   = 0
idx = 0
max = 0

if n > 0 :
    while True:
        max = idx
        t   += 2**idx
        idx  = idx + 2
        #print(t)
        if t >= n :
            break
else:
    idx = 1
    while True:
        max = idx
        t   += -2**idx
        idx  = idx + 2
        #print(t)
        if t <= n :
            break

#print(t,max)

ans = ''
s   = 0
for i in range(max+1):
    idx = 0

    sidx = (i-1)//2
    t = 1

    if i > 0 :
        start = 1
        for j in range(sidx):
            t *= 4
            start += t
    else:
        start = 0
    
    t = (n - start)/(2**i)

    if t - (n - start)//(2**i)  > 0 :
        t = (n - start)//(2**i) + 1
    else :
        t = (n - start)//(2**i)   

    if t % 2 == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans

        if i % 2 == 0 :
            s += 2**i
        else:
            s -= 2**i

print(ans)

# +) 1 4 16  64 258 1024
# -) 2 8 32 128 512 2048

Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    for(int i=0;i<k;i++) ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

if( arr[0] >= 6 && ( arr[0] <= 12 ) ) {
  arr[1] = arr[1] / 2
} else if( arr[0] < 6 ) {
  arr[1] = 0
}
  
print( arr[1] )
  

Measured memory_bytes: 4208
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
int main()
{
	//fast;
	
	ll tc,x,sum=0,n;
	cin>>tc;
	n=tc;
	while(tc--)
	{
		cin>>x;
		sum+=x;
	}
	cout<<sum-n<<endl;
}

Measured memory_bytes: 3612
from collections import Counter
n = int(input())
s = input()

ans = 0
for i in range(1,n-1):
    a = Counter(s[:i])
    b = Counter(s[i:])
    cnt = 0
    for k in a.keys():
        if k in b:
            cnt += 1
    if cnt > ans:
        ans = cnt
print(ans)

Measured memory_bytes: 3444
H, W = map(int, input().split())
map = [input() for _ in range(H)]

white = 0
for d in map:
    white += d.count('.')

memory = [(0,0)]
data = [[0] * W for _ in range(H)]
data[0][0] = 1
direction = [(0,1), (0,-1), (1,0), (-1,0)]
while True:
    if len(memory) == 0:
        print(-1)
        exit()
    x, y = memory.pop(0)
    for dx, dy in direction:

        if x + dx == H - 1 and y + dy == W-1:
            print(white - (data[x][y] + 1))
            exit()
        if 0 <= x + dx < H and 0 <= y + dy < W:
            if map[x+dx][y+dy] == '.' and data[x+dx][y+dy] == 0:
                data[x+dx][y+dy] = data[x][y] + 1
                memory.append((x+dx, y+dy))







Measured memory_bytes: 3064
#include <stdio.h>
int search(int S[], int n, int key)
{
    int i = 0;
    S[n] = key;
    while (S[i] != key)
        i++;
    return i != n;
}
int main()
{
    int n;
    scanf("%d", &n);
    int S[n + 1];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &S[i]);
    }
    int q;
    scanf("%d", &q);
    int ans = 0;
    int key;
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if (search(S, n, key))
        {
            ans++;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 2716
# include <cstdio>
# include <iostream>
# include <algorithm>
# include <queue>
# include <map>
# include <vector>
# include <cmath>
# include <cstring>
# define R register int
# define ll long long

using namespace std;

const int N=22;
const int Q=(1<<21)+10;
int n,k,f[N][Q];
char s[Q];

int main()
{
    scanf("%d%d",&n,&k);
    for (R i=0;i<=n;++i)
    {
        scanf("%s",s);
        for (R j=0;j<(1<<i);++j)
            if(s[j]=='1') f[i][j+(1<<i)]=1; 
        //这里为什么要+(1<<i)呢？是为了用这个标记S+T的长度，否则遇到带前导0的串就分不清了
    }
    for (R i=n;i>0;--i)
        for (R j=i;j<=n;++j)
        {
            int u=1<<j;
            for (R k=0;k<u;++k)
            {
                int x=f[i][k+u],p=-1,q=-1;
                if(x==0) continue;
                //p,q:最前的0/1；
                for(R t=i-1;t>=0;--t)
                    if((k&(1<<t))==0) { p=t; break; }
                for(R t=i-1;t>=0;--t)
                    if(k&(1<<t)) { q=t; break; }
                f[0][(k+u)>>i]+=x;
                if(p!=-1)
                    f[p][ ( k&((1<<p)-1) )+( ((k>>i)*2)<<p )+(u>>(i-p-1)) ]+=x;
                if(q!=-1)
                    f[q][ ( k&((1<<q)-1) )+( ((k>>i)*2+1)<<q )+(u>>(i-q-1)) ]+=x;
            }
        }
    for(R i=n;i>=0;--i)
        for (R j=(1<<i);j<(2<<i);++j)
        {
            if(f[0][j]>=k)
            {
                for (R t=i-1;t>=0;--t)
                    printf("%d",(j>>t)&1);
                return 0;
            }
        }
    return 0;
}

Measured memory_bytes: 173312
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int A,B;
	cin>>A>>B;
	
	int ans=0;
	for(int i=A;i<=B;i++){
		int i0,i1,i2,i3,i4,t=i;
		i0=t%10;
		t=(t-i0)/10;
		i1=t%10;
		t=(t-i1)/10;
		i2=t%10;
		t=(t-i2)/10;
		i3=t%10;
		t=(t-i3)/10;
		i4=t;
		
		if(i4==i0 && i3==i1) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool is_prime(int num){
	if(num <= 1) return false;
	if(num == 2) return true;
	if(num % 2 == 0) return false;
	for(int i = 3; i * i <= num; i++){
		if(num % i == 0) return false;
	}
	return true;
}
int main(){
	for(;;){
		int N;
		cin >> N;
		if(N == 0) break;
		int cnt = 0;
		for(int i = 2; i <= N / 2; i++){
			if(is_prime(i) && is_prime(N - i)){
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

int main() {
  vector<int> a(4);
  rep(i, 4) cin >> a[i];
  sort(a.begin(), a.end());
  if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
string s[11];

signed main()
{
  int h, w, k;
  cin >> h >> w >> k;
  rep(i, h) cin >> s[i];

  lli ret = 1e18;
  rep(i, 1 << (h - 1))
  {
    int cnt = __builtin_popcount(i);
    vector<int> Sep;
    int cur = 0;
    rep(j, (h - 1))
    {
      if ((i >> j) & 1)
        Sep.push_back(j + 1);
    }
    vector<int> L, R;
    {
      int l = 0;
      rep(j, Sep.size())
      {
        L.push_back(l);
        R.push_back(Sep[j]);
        l = Sep[j];
      }
      L.push_back(l);
      R.push_back(h);
      // rep(j, L.size())
      // {
      //   cout << L[j] << " " << R[j] << endl;
      // }
      //cout << endl;
    }
    vector<int> dom(h);
    rep(l, h)
    {
      rep(j, L.size())
      {
        if (L[j] <= l && l < R[j])
          dom[l] = j;
      }
    }
    vector<int> VV(L.size());
    int ans = cnt;
    bool dame = false;
    rep(j, w)
    {

      vector<int> TMP(L.size());
      rep(l, h)
      {

        if (s[l][j] == '1')
          TMP[dom[l]]++;
      }

      bool ok = true;

      rep(l, L.size())
      {
        if (TMP[l] > k)
          dame = true;
        if (TMP[l] + VV[l] > k)
          ok = false;
      }
      if (!ok)
      {
        VV = TMP;
        ans++;
      }
      else
      {
        rep(l, TMP.size()) VV[l] += TMP[l];
      }
    }
    if (!dame)
      chmin(ret, ans);
  }
  cout << ret << endl;
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan  2 22:46:48 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	v, _ := strconv.Atoi(strconv.Itoa(a) + strconv.Itoa(b))

	for i := 1; i*i <= v; i++ {
		if i*i == v {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(All(a));
    for(int i=0;i<n;i++){
        cout<<a[i].second<<endl;
    }
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

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

int main()
{
  int n;
  cin >> n;
  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << n * 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int h, w, ch, cw, dh, dw, a; cin >> h >> w >> ch >> cw >> dh >> dw;
  vector<string> v(h); rep(i, h) cin >> v[i];
  ch--; cw--; dh--; dw--;
  v2i ans(h, v1i(w, 1e9));
  pii tmp = {ch * w + cw, 0};
  deque<pii> d, e;
  d.push_back(tmp);
  while(!d.empty() || !e.empty()){
    if(!d.empty()){
      tmp = d.front(); d.pop_front();
    }
    else{
      tmp = e.front(); e.pop_front();
    }
    int th = tmp.fi/w, tw = tmp.fi%w, tc = tmp.se;
    if(ans[th][tw] < tc) continue;
    rep(i, 5){
      int thi = th-2+i;
      if(thi < 0 || thi >= h) continue;
      rep(j, 5){
        int twj = tw-2+j;
        if(i == 2 & j == 2) continue;
        if(twj < 0 || twj >= w) continue;
        if(v[thi][twj] == '#') continue;
        if((i == 1 && j == 2) || (i == 2 && j == 1) || (i == 2 && j == 3) || (i == 3 && j == 2)){
          if(tc < ans[thi][twj]){
            d.push_back({thi*w+twj, tc}); ans[thi][twj] = tc;
          }
        }
        else{
          if(tc+1 < ans[thi][twj]){
            e.push_back({thi*w+twj, tc+1}); ans[thi][twj] = tc+1;
          }
        }
      }
    }
  }
  if(ans[dh][dw] == 1e9) a = -1;
  else a = ans[dh][dw];
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 9432
n, w = map(int, input().split())
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
ws, vs = [], []
for _ in range(n):
    wi, vi = map(int, input().split())
    ws.append(wi)
    vs.append(vi)
for i in range(n):
    for j in range(1, w+1):
        if j - ws[i] >= 0:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - ws[i]] + vs[i])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

Measured memory_bytes: 171400
#include <stdio.h>

int main(){
  int A[101][101], i, j, n, u, k, v;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u, &k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      A[u-1][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      printf("%d",A[i][j]);
      if(j < n - 1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
public class Main {
			
				
		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int x;
		int i = 0;
		while(true){
		x = scan.nextInt();
		i+= 1;
			if(1<=x && x<= 10000){
			System.out.println("Case "+i+": "+x);
			
			}
		if(x == 0){
			break;
		}
		}
		}
					
					
					
		}

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

int main()
{    
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<bool> hash(pow(10,9)+1, false);

    for(ll data : a)
    {
        if(hash[data] != false)
        {
            cout << "NO" <<endl;
            return 0;
        }
        hash[data] = true;
    }
    cout << "YES" << endl;

}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint l[99]={2,1};
	rep(i,97) l[i+2]=l[i]+l[i+1];

	int n; cin>>n;
	cout<<l[n]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll n,sum=0;
	cin >> n;
	vector<ll>a(n), b(n), c(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> b[i];
		sum += b[i];
	}
	for (ll i = 0; i < n-1; i++) {
		cin >> c[i];
	}
	for (ll i = 0; i < n-1; i++) {
		if (a[i] + 1 == a[i + 1]) {
			sum += c[a[i] - 1];
		}
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vi64 a(n);
    forn(i, n) cin >> a[i];
    i64 ans = 0, S = 0;
    forn(i, n) {
        if (a[i]) S += a[i];
        else ans += S / 2, S = 0;
    }
    ans += S / 2;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a;
  a=0;
  cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
   sort(vec.begin(), vec.end());
  for(int j=0;j<N-1;j++){
    a+=vec.at(j);
  }
  if(a>vec.at(N-1)){
    cout<<"Yes"<<endl;
  }
     else{
       cout<<"No"<<endl;
     }
     }

Measured memory_bytes: 256
s=input()

length=len(s)

keta=len(s)

gross=0

for i in s:
    i=int(i)
    
    gross+=2**(len(s)-keta)*i*(2**(keta-4)*(5**(keta-1)-1)+10**(keta-1))
    
    keta-=1
    
print(int(gross))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f,a+b+c+d+e+f){
    ll ans=100;
    ans-=(f-(e+a*5+b*3))*3;
    ans-=(a*5+b*3)*2;
    ans+=(a*15+b*15+(a*5+b*3)*15+(c)*7+d*2);
    cout<<ans<<endl;
  }
  return 0;
}



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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

LL INF=1e15+7;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<PLL> p(n),q(m);
    REP(i,n)
    {
        LL a,b;
        cin>>a>>b;
        p[i]=PLL(a,b);
    }
    REP(i,m)
    {
        LL a,b;
        cin>>a>>b;
        q[i]=PLL(a,b);
    }

    REP(i,n)
    {
        int ans=0;
        LL mdis=INF,dis;
        REP(j,m)
        {
            dis=abs(p[i].first-q[j].first) + abs(p[i].second - q[j].second);
            if(dis<mdis)
            {
                mdis=dis;
                ans=j;
            }
        }
        cout<<ans+1<<endl;

    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int w;
	string S;
	cin>>S>>w;
	REP(i,ceil(S.length()/(double)w)) printf("%c",S[i*w]);
	print();
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int a[200000];
	rep(i, n) {
		int x; cin >> x; x--; a[x] = i;
	}
	int cnt = 1; int out = 0;
	rep(i, n - 1) {
		if (a[i] < a[i + 1]) {
			cnt++;
		}
		else {
			out = max(out, cnt); cnt = 1;
		}
	}
	out = max(out, cnt);
	cout << n - out << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php

  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $sum = array_sum($a);

  $x=0;
  for($i=0;$i<$n;$i++){
    if(1/(4*$m) <= $a[$i]/$sum){
       $x++;
    }
  }

  if($m <= $x){
    echo "Yes";
  }else{
    echo "No";
  }


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

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

  for (int i = 0; i < s.length(); i++)
  {
    if (i % w == 0)
      cout << s[i];
  }
  cout << endl;
}


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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1e9
#define mod 132021913
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
ll power(ll b,ll p) {ll res=1,x=b; while(p > 0){if(p&1ll)res=res*x;x=x*x;p >>= 1;} return res;}

#define MX 200005
ll arr1[MX], arr2[MX], cm1[MX], cm2[MX];

int main()
{
	ll n, m, k;
	cin>>n>>m>>k;

	for(int i = 1; i <= n; i++) cin>>arr1[i];
	for(int i = 1; i <= m; i++) cin>>arr2[i];

	for(int i = 1; i <= n; i++) cm1[i] = cm1[i-1] + arr1[i];
	for(int i = 1; i <= m; i++) cm2[i] = cm2[i-1] + arr2[i];

	ll ans = 0, x;
	for(int i = 0; i <= n && cm1[i] <= k; i++) {
		x = upper_bound(cm2, cm2+m+1, k-cm1[i]) - cm2 - 1;
		x = i + x;
		ans = max(ans, x);
	}

	cout<<ans<<endl;
}















Measured memory_bytes: 9860
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vvi edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<bool> used(n, false);
    function<void(int, int)> dfs = [&](int c, int p) {
        for (auto &v : edges[c]) {
            if (v == p)
                continue;
            dfs(v, c);
        }
        if (!used[c] && p != -1 && !used[p]) {
            used[c] = used[p] = true;
        }
    };
    dfs(0, -1);
    bool match = true;
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            match = false;
            break;
        }
    }
    if (match) {
        cout << "Second"
             << "\n";
    } else {
        cout << "First"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 5888
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let vs: Vec<u64> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();
    let k = vs[0];
    let a = vs[1];
    let b = vs[2];

    if b <= a + 2 {
        println!("{}", k + 1);
        return;
    }

    let mut n:u64 = 1;
    let mut yen:u64 = 0;
    // シミュレーション方針
    for i in (0..k).rev() {
        // println!("{}", i);
        if i <= yen {
            if yen > 0 {
                n += b;
                yen -= 1;
                // println!("  yen to n n:{}, yen:{}", n, yen);
            } else {
                n += 1;
                // println!("  n++ n:{}, yen:{}", n, yen);
            }
        } else if n >= a {
            n -= a;
            yen += 1;
            // println!("  n to yen n:{}, yen:{}", n, yen);
        } else if yen > 0 {
            n += b;
            yen -= 1;
            // println!("  yen to n n:{}, yen:{}", n, yen);
        } else {
            n += 1;
            // println!("  n++ n:{}, yen:{}", n, yen);
        }
    }
    println!("{}", n);
}


Measured memory_bytes: 4352
import std.stdio, std.string, std.algorithm, std.range;

void main() {
    auto S = readln.chomp;
    auto s = 0, e = S.length-1;
    while (S[s] != 'A') {
        s++;
    }
    while (S[e] != 'Z') {
        e--;
    }
    writeln(e - s + 1);
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

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

	char s[200000];
	int cnt[200001] = { 0 };
	REP(i, n) {
		cnt[i + 1] += cnt[i];
		scanf("%c ", &s[i]);
		if (s[i] == '.') {
			cnt[i + 1]++;
		}
	}

	int ans = 200001;
	REP(i, n + 1) {
		ans = Min(ans, (i - (cnt[i] - cnt[0])) + (cnt[n] - cnt[i]));
	}
	PRINTD(ans);
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b; 
}
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {
	
	ran(); fast();
	
	int n, k;
	cin >> n >> k;
	int arr[n];
	bool alln = true;
	for (int i=0; i<n; i++) {
		cin >> arr[i];
		if (arr[i] != n) alln = false;
	}
	
	for (int i=0; i<k; i++) {
		if (alln) continue;
		vector<pair<int, int> > events;
		for (int j=0; j<n; j++) {
			events.push_back(make_pair(j - arr[j], 1));
			events.push_back(make_pair(j + arr[j] + 1, -1));
		}
		
		sort(events.begin(), events.end());
		
		int at = 0;
		int cur = 0;
		for (int j=0; j<n; j++) {
			while (at < events.size() && events[at].first <= j) {
				cur += events[at].second;
				at++;
			}
			arr[j] = cur;
		}
		
		alln = true;
		for (int j=0; j<n; j++) {
			// cout << arr[j] << ' ';
			if (arr[j] != n) alln = false;
		}
		// cout << endl;
		
	}
	
	for (int i=0; i<n; i++) {
		cout << arr[i] << ' ';
	}
	cout << endl;
	
}


Measured memory_bytes: 19300
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

long dp[2000][2000];

int main(){
	int n;
	long x;
	long ans = LLONG_MAX;
	
	cin >> n >> x;
	rep(i,n){
		cin >> dp[0][i];
	}
	
	for(int iy=1; iy<n; iy++){
		for(int ix=0; ix<n; ix++){
			int k;
			if(iy > ix){
				k = n - (iy - ix);
			}else{
				k = ix - iy;
			}
			
			dp[iy][ix] = min(dp[iy-1][ix], dp[0][k]);
		}
	}
	
	for(int iy=0; iy<n; iy++){
		ans = min(ans, accumulate(dp[iy], dp[iy]+n, (long)0) + x * iy);
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>
int main(void){
    char S[1001];
    int i = 0;
    scanf("%s",S);
    while(S[i] != '\0'){
        i ++;
    }
    if(S[i-1] == 's'){
        S[i] = 'e';
        S[i+1] = 's';
        S[i+2] = '\0';
    }else{
        S[i] = 's';
        S[i+1] = '\0';
    }
    printf("%s\n",S);
    return 0;
}


Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n;
  map<int,int> m;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    if( m[tmp] == 0)  m[tmp]++;
    else m[tmp]--;
  }
  ll ans=0;
  for (auto w:m){
    if (w.second == 1) ans++;
  }
  cout << ans << endl;
   return 0;
}



Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))

money = 1000
kabu = 0
for i in range(N-1):
    if kabu > 0:
        money += kabu*A[i]
        kabu = 0
    if A[i] < A[i+1]:
        kabu = money//A[i]
        money -= kabu*A[i]
if kabu > 0:
    money += kabu*A[-1]

print(money)


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define MP(a, b) make_pair(a, b)

long long N, num[5];
char name[5] = {'M', 'A', 'R', 'C', 'H'};

long long culc(long long numm, int ind)
{
	if (ind == 0) return 1;
	ind--;
	long long res = 0;
	rep(i, numm) {
		res += num[i] * culc(i, ind);
	}
	return res;
}

int main()
{
	cin >> N;
	while (N--) {
		string s;
		cin >> s;
		rep(i, 5) if (s[0] == name[i]) num[i]++;
	}
	cout << culc(5, 3) << endl;
	return 0;
}


Measured memory_bytes: 384
<?php
class main {
    var $map = array();
    var $h;
    var $w;
 
    function run() {
        fscanf(STDIN, "%d %d", $h, $w);
        $this->h = $h;
        $this->w = $w;
        $this->map = array();
        $sum = 0;
        for ($i = 0; $i < $h; $i++) {
            $line = trim(fgets(STDIN));
            $this->map[] = str_split($line);
            $tmp = array_count_values($this->map[$i]);
            $sum += isset($tmp['#'])?$tmp['#']:0;
        }
 
        if ($sum != ($this->h + $this->w - 1)) {
            echo "Impossible";
        } else {
            echo "Possible";
        }
    }
}
$object = new main();
$object->run();

Measured memory_bytes: 3576
(let ((n (parse-integer (read-line)))
      (s nil)
      (s10 0))
  (loop :for line = (read-line t nil nil)
        :while line
        :for n = (parse-integer line)
        :do (if (zerop (mod n 10))
                (incf s10 n)
                (push n s)))
  (setf s (sort s #'<))
  (let ((sum (apply #'+ s)))
    (format t "~d~%"
            (cond
              ((zerop sum) 0)
              ((zerop (mod sum 10)) (+ s10 (- sum (car s))))
              (t (+ s10 sum))))))


Measured memory_bytes: 6884
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int K, S, ans=0;
  cin >> K >> S;
  
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(S - i - j <= K && S - i - j >= 0) ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(c+1):
    for j in range(b+1):
        for k in range(a+1):
            if k*500+j*100+i*50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060