akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

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

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

map<string,int> prefix;

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >>setprecision(30) >> t;
}

void add_zero(string &s) {
    string zero="";
    rep(i,30) zero+="0";
    s=zero+s+zero;
}

void split(string line,string &s1,string &s2,string &s3) {
    int i;
    for(i=0;i<line.size();i++) {
        if(line[i]==' ') break;
        s1+=line[i];
    }
    i++;
    for(;i<line.size();i++) {
        if(line[i]==' ') break;
        if(line[i]=='\n') break;
        s2+=line[i];
    }
    if(i!=line.size()-1) {
        i++;
        for(;i<line.size();i++) {
            if(line[i]=='\n') break;
            s3+=line[i];
        }
    }
}

void solve() {
    int zero_cnt=0;
    string line;
    getline(cin,line);
    string s1,s2,s3;
    split(line,s1,s2,s3);
    if(s3=="") {
        s3=s2;
        s2="";
    }

    if(s1.find('.')==-1) s1+=".";
    else {
        for(int i=s1.size()-1;i>=0;i--) {
            if(s1[i]!='0') break;
            zero_cnt++;
        }
        while(s1[s1.size()-1]=='0') s1.erase(s1.size()-1,1);
    }
    int cnt=0;

    int pos=s1.find('.');
    if(s1[0]=='0') {
        for(int i=pos;i<s1.size()-1;i++) {
            cnt--;
            swap(s1[i],s1[i+1]);
        }
    }
    else {
        for(int i=pos;i>=2;i--) {
            cnt++;
            swap(s1[i],s1[i-1]);
        }
    }
    while(s1[0]=='0') s1.erase(0,1);
    if(s1[s1.size()-1]=='.') {
        if(s1.size()>zero_cnt+2) {
            cnt++;
            int t=s1.size()-1;
            swap(s1[t],s1[t-1]);
        }
        else s1.erase(s1.size()-1,1);
    }
    if(zero_cnt) {
        if(s1.find('.')==-1) s1+=".";
        rep(i,zero_cnt) s1+="0";
    }
    cout<<s1<<" * 10^"<<cnt+prefix[s2]<<" "<<s3<<endl;


}

int main() {
    prefix["yotta"] = 24;
    prefix["zetta"] = 21;
    prefix["exa"] = 18;
    prefix["peta"] = 15;
    prefix["tera"] = 12;
    prefix["giga"] = 9;
    prefix["mega"] = 6;
    prefix["kilo"] = 3;
    prefix["hecto"] = 2;
    prefix["deca"] = 1;
    prefix[""] = 0;
    prefix["deci"] = -1;
    prefix["centi"] = -2;
    prefix["milli"] = -3;
    prefix["micro"] = -6;
    prefix["nano"] = -9;
    prefix["pico"] = -12;
    prefix["femto"] = -15;
    prefix["ato"] = -18;
    prefix["zepto"] = -21;
    prefix["yocto"] = -24;
    int t;
    cin>>t;
    cin.ignore();
    while(t-->0) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			if (c >= a && c <= b) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} finally {
			sc.close();
		}
	}
}

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

ll f(ll n){
    if(n%4==0) return n;
    if(n%4==1) return 1;
    if(n%4==2) return 1^n;
    if(n%4==3) return 0;
    
}
int main(){
    ll A,B;
    cin >> A >> B;
    if(A==0) cout<< f(B) << endl;
    else cout << (f(A-1)^f(B)) << endl;

}

Measured memory_bytes: 256
store = "ABCDE"

while True:
  s1, s2 = map(int, input().split())
  if s1 == 0 and s2 == 0:
    break
    
  s = store[0]
  ans = s1 + s2
  
  for i in range(4):
    s1, s2 = map(int, input().split())
    if s1 + s2 > ans:
      s, ans = store[i+1], s1 + s2
      
  print(s, ans)


Measured memory_bytes: 5600
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

s = input()
q = int(input())
# print(s,q)
head = True
right = ''
left = ''
for i in range(q):
    query = input().split(' ')
    # print(query)
    if query[0]=='1':
        head = not head
    else:
        if query[1]=='1':
            if head:
                left += query[2]
            else:
                right += query[2]
        else:
            if head:
                right += query[2]
            else:
                left += query[2]
    # print(left,  right)
s = left[::-1]+s+right
if head:
    print(s)
else:
    print(s[::-1])

Measured memory_bytes: 4596
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

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

using namespace std;

#define ll long long

const int N=1e6+5;

int n,a[N],b[N],x,cnt[N];

ll ans;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    for(int i=0;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<n;i++){
        if (a[i]>0){
            int x=min(b[i],a[i]);
            a[i]-=x;
            b[i]-=x;
            ans+=x;
        }
        if (a[i+1]>0){
            int x=min(b[i],a[i+1]);
            a[i+1]-=x;
            b[i]-=x;
            ans+=x;
        }
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;

int main(){
    fastio;
    string s;
    cin>>s;
    cout<<s<<((s[s.size()-1]=='s')?"es":"s")<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

signed main(){
    CIN(h,w,k);
    if(w==1)EN(1);
    vector<V> dp(h+1, V(w, 0));
    dp[0][0] = 1;
    REP(i,h){
        REP(j,w){
            if(!dp[i][j])continue;
            REP(k, 1<<(w-1)){
                
                if(k&(k<<1))
                    continue;
                bool r = j ? (k & (1 << (j - 1))) : 0;
                bool l = j != w - 1 ? (k & (1 << j)) : 0;

                dp[i + 1][j - r + l] += dp[i][j];
                dp[i + 1][j - r + l] %= MOD;
            }
        }
    }
    COUT(dp[h][k-1]);

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
int main(){
	int n,m;
	cin>>n>>m;
	vvi cost(n,vi(n,inf));
	rep(i,n)cost[i][i]=0;
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		cost[a][b]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)
		cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	bool h=true;
	rep(i,n)if(cost[i][i]!=0)h=false;
	if(!h)cout<<"NEGATIVE CYCLE"<<endl;
	else{
		rep(i,n){
			rep(j,n){
				if(j)cout<<" ";
				if(cost[i][j]<1e13)cout<<cost[i][j];
				else cout<<"INF";
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1292
# -*- coding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A =[]
for i in range(N):
  kk = list(map(int, input().split()))
  A.append(kk[1:])

count = np.zeros(M, dtype=int)
for i in range(N):
  for ind in A[i]:
    count[ind-1] += 1

sum = 0
for j in range(M):
  if(count[j] == N):
    sum += 1

print(sum)


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

using namespace std;

char t[100005];

int a[100005];

int main()
{
    int n,k,r,s,p,ans=0,i;
    cin>>n>>k>>r>>s>>p>>(t+1);
    for(i=1; i<=strlen(t+1); i++)
    {
        if(t[i]=='r')
        {
            if(i-k<=0||t[i-k]!=1)
            {
                ans+=p;
                t[i]=1;
            }
        }
        else if(t[i]=='s')
        {
            if(i-k<=0||t[i-k]!=2)
            {
                ans+=r;
                t[i]=2;
            }
        }
        else
        {
            if(i-k<=0||t[i-k]!=3)
            {
                ans+=s;
                t[i]=3;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

    def lower_bound(self, x):
        s = 0
        pos = 0
        depth = self.n.bit_length()
        v = 1 << depth
        for i in range(depth, -1, -1):
            k = pos + v
            if k <= self.n and s + self.bit[k] < x:
                    s += self.bit[k]
                    pos += v
            v >>= 1
        return pos

import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, q = map(int, input().split())
A = list(map(int, input().split()))
bit = BIT(n)
bit.init(A)
for i in range(q):
    t, a, b = map(int, input().split())
    if t == 0:
        bit.add(a, b)
    else:
        print(bit.sum(a, b))


Measured memory_bytes: 69656
#include <iostream>

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

    int num1, num2, num3;
  
  	std::cin >> num1 >> num2 >> num3;
  
    int max = 21;

    std::string answer = max >= (num1 + num2 + num3) ? "win" : "bust";
    std::cout << answer;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

four_num = 0
two_num = 0
odd_num = 0
for _ in a:
    if _%4==0:
        four_num+=1
    elif _%2==0:
        two_num+=1
    else:
        odd_num+=1

if odd_num>four_num and two_num>0:
    print("No")
elif odd_num>four_num+1 and two_num==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int N, K;
bool D[10];
bool solve(int x)
{
    if(x==0) return true;
    if(D[x%10]) return false;
    return solve(x/10);
}
int main()
{
    scanf("%d%d", &N, &K);
    for(int i=0; i<K; ++i)
    {
        int t; scanf("%d", &t);
        D[t] = true;
    }
    while(true)
    {
        if(solve(N))
        {
            printf("%d\n", N);
            return 0;
        }
        ++N;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a>b)
    {
        printf(">\n");
    }
    else if(a<b)
    {
        printf("<\n");
    }
    else
    {
        printf("=\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	if (A1 + A2 + A3 >= 22)cout << "bust";
	else cout << "win";
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



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

int dfs(int N, int cnt) {
  if (cnt == 11) return N;
  int base = cnt % 2 == 0 ? 6 : 9, ans = N;
  for (int i = 0; i < cnt / 2; i++) base *= (cnt % 2 == 0 ? 6 : 9);
  for (int i = 0; i <= 5; i++) {
    if (N - base * i >= 0) {
      ans = min(ans, i + dfs(N - base * i, cnt + 1));
    }
  }
  return ans;
}

int main() {
  int N, ans = 0;
  cin >> N;
  cout << dfs(N, 0) << endl;
}


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

using namespace std;
typedef long long LL;

int main(){
  int N;
  LL W;
  LL w[110];
  int v[110];
  LL vsum=0;
  LL INF=1LL<<35;
  LL ans=0;
  cin >> N >> W;
  for(int i=0; i<N; i++) cin >> w[i] >> v[i];
  for(int i=0; i<N; i++) vsum+=v[i];
  LL dp[110][100010];
  for(int i=0; i<N; i++){
    for(int j=0; j<=vsum; j++) dp[i][j]=INF;
  }
  dp[0][0]=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<=vsum; j++){
      if(j>=v[i]) dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  for(LL i=0; i<=vsum; i++){
    if(dp[N][i]<=W) ans=max(ans, i);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 81152
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, x, mod = map(int, input().split())

    seen = [0] * mod
    ans = 0
    A = []
    ii = -1
    for i in range(N):
        if seen[x] == 0:
            seen[x] = 1
        elif seen[x] == 1:
            A.append(x)
            seen[x] = 2
        elif seen[x] == 2:
            ii = i
            break
        ans += x
        x = (x * x) % mod
    if ii == -1:
        print(ans)
    else:
        rem = N - ii
        ans += sum(A) * (rem // len(A))
        rem %= len(A)
        for j in range(rem):
            ans += A[j]
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71316
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n = int(stdin.readline().rstrip())
a = [x for x in stdin.readline().rstrip().split()]

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = 1
    else:
        d[a[i]] += 1

m = sum([v*(v-1) // 2 for v in list(d.values())])

for i in range(n):
    v = d[a[i]]
    print(m + 1 - v)




Measured memory_bytes: 33156
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];


    vector<int> cs;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#') cs.push_back(j);
        }
    }

    sort(cs.begin(),cs.end());
    cs.erase(unique(cs.begin(),cs.end()),cs.end());

    vector<vector<int>> ans(h,vector<int>(w,-1));
    int l=0;
    int v=0;
    for(int ii=0;ii<cs.size();ii++){
        int r=cs[ii]+1;
        if(ii+1==cs.size()) r=w;
        int u=0;
        for(int i=0;i<h;i++){
            if(s[i][cs[ii]]=='#'){
                for(int x=u;x<=i;x++){
                    for(int j=l;j<r;j++) ans[x][j]=v;
                }
                u=i+1;
                v++;
            }
        }
        for(int i=u;i<h;i++){
            for(int j=l;j<r;j++){
                ans[i][j]=v-1;
            }
        }
        l=r;
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j]+1<<" ";
        }
        cout<<endl;
    }
    

    
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> K >> S;
  N=S.size();
  if(K>=N)Out(S);
  else Out(S.substr(0,K)+"...");
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n,count=0;
  cin>>w>>h>>n;
  int x[n],y[n];
  int xx[1],yy[1];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  xx[0]=x[0];
  yy[0]=y[0];
  for(int a=1;a<n;a++){
    while(xx[0]!=x[a]||yy[0]!=y[a]){
      if(xx[0]<x[a]&&yy[0]<y[a]){
	xx[0]++;
	yy[0]++;
	count++;
      }
      else if(xx[0]>x[a]&&yy[0]>y[a]){
	xx[0]--;
	yy[0]--;
	count++;
      }
      else if(xx[0]<x[a]){
	xx[0]++;
	count++;
      }
      else if(yy[0]<y[a]){
	yy[0]++;
	count++;
      }
      else if(xx[0]>x[a]){
	xx[0]--;
	count++;
      }
      else if(yy[0]>y[a]){
	yy[0]--;
	count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

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

bool comp(P a, P b) {
    if (a.first.first != b.first.first) {
        return a.first.first < b.first.first;
    } else {
        return a.first.second > b.first.second;
    }
}

int main() {
    int n;
    cin >> n;
    vector<P> r(n);
    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        r[i].first = make_pair(s, p);
        r[i].second = i+1;
    }

    sort(r.begin(), r.end(), comp);

    for (auto a: r) cout << a.second << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1<<17, mlg = 17, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void generate(int &n, string &s) {
	n = 20;
	for(int i = 0; i < n; i += 2) s += "ab";
	shuffle(all(s), rng);
}
string brute(string s) {
	int n = s.size()/2;
	string ans = "";
	for(int msk = 0; msk < 1<<n; msk++) {
		int ca = 0, cb = 0;
		string cur;
		for(auto i : s) {
			if(i == 'b') swap(ca, cb);
			if((msk>>ca)&1) cur += i;
			ca++;
			if(i == 'b') swap(ca, cb);
		}
		ans = max(ans, cur);
	}
	return ans;
}

string process(string s) {
	string ans;
	//cout << s << '\n';
	if(s[0] == 'a') {
		char p = '0';
		set<int> rem;
		int ca = 0, cb = 0;
		for(auto i : s) {
			if(i == 'a') {
				if(ans.empty() || ans.back() != i) ans += i;
				else rem.insert(ca);
				ca++;
			} else {
				if(!rem.count(cb)) ans += i;
				cb++;
			}
		}
		return ans;
	}
//	cout << s.size()/2 << " dsjfkas\n";
	for(int i = 0; i < s.size()/2; i++) {
		string cur;
		int ca = 0, cb = 0;
		for(auto c : s) {
			if((c == 'a' ? ca++ : cb++) >= i) cur.pb(c);
		}
		//cout << i << " to " << cur << '\n';
		ans = max(ans, cur);
	}
	return ans;
}
bool better(string a, string b) {
	int n = min(a.size(), b.size());
	a = a.substr(0, n);
	b = b.substr(0, n);
	return a < b;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	string _s, _cur;
	vector<string> blocks;
	cin >> n >> _s;
	//generate(n, _s);
	int ca = 0, cb = 0;
	for(auto i : _s) {
		(i == 'a' ? ca : cb)++;
		_cur.pb(i);
		if(ca == cb) blocks.pb(_cur), _cur = "";
	}
	vector<string> ans;
	for(int i = 0; i < blocks.size(); i++) {
		string r = process(blocks[i]);
		//cout << blocks[i] << " => " << r << '\n';
		while(!ans.empty() && better(ans.back(), r)) ans.pop_back();
		ans.pb(r);
	}
	string rans;
	for(auto i : ans) rans += i;
	cout << rans << '\n';
	
	//string v = brute(_s);
	//if(rans != v) {
	//	cout << v << '\n';
	//	cout << "WA: " << _s << '\n';
	//}
}


Measured memory_bytes: 640
<?php

class LowLinks {
    private $edges, $root, $ord, $low, $cnt, $bridges, $articulations, $par;

    function __construct($edges, $v, $root=0) {
        $this->edges = $edges;
        $this->root = $root;
        $this->ord = array_fill(0, $v, null);
        $this->low = array_fill(0, $v, null);
        $this->cnt = 0;
        $this->bridges = [];
        $this->articulations = [];
        $this->par = array_fill(0, $v, null);
    }

    function getArticulations() {
        return $this->articulations;
    }

    function getBridges() {
        return $this->bridges;
    }

    function build() {
        $this->search($this->root);
    }

    function search($node) {
        $this->ord[$node] = $this->cnt;
        $this->low[$node] = $this->cnt;
        $this->cnt++;
        $dim = 0;
        foreach($this->edges[$node] as $to) {
            if ($to === $this->par[$node]) continue;
            if ($this->ord[$to] === null) {
                $this->par[$to] = $node;
                $this->search($to);
                $dim++;
                $this->low[$node] = min($this->low[$node], $this->low[$to]);
                if ($node != $this->root and $this->ord[$node] <= $this->low[$to]) {
                    $this->articulations[] = $node;
                }
            } else {
                $this->low[$node] = min($this->low[$node], $this->ord[$to]);
            }

            if ($node == $this->root and $dim > 1) {
                $this->articulations[] = $node;
            }

            if ($this->ord[$node] < $this->low[$to]) {
                $this->bridges[] = [$node, $to];
            }
        }
    }
}

function compBridge($bridge1, $bridge2) {
    $u1 = min($bridge1);
    $v1 = max($bridge1);
    $u2 = min($bridge2);
    $v2 = max($bridge2);
    if ($u1 < $u2) {
        return -1;
    } elseif ($u1 > $u2) {
        return 1;
    } else {
        if ($v1 < $v2) {
            return -1;
        } elseif ($v1 > $v2) {
            return 1;
        } else {
            return 0;
        }
    }
}

list($v, $e) = explode(" ", trim(fgets(STDIN)));
$edges = array_fill(0, $v, []);
for ($i = 0; $i < $e; $i++) {
    list($s, $t) = explode(" ", trim(fgets(STDIN)));
    $edges[(int)$s][] = (int)$t;
    $edges[(int)$t][] = (int)$s;
}

$lowlinks = new LowLinks($edges, $v, 0);
$lowlinks->build();

/*** print articulations ***/
$articulations = array_unique($lowlinks->getArticulations());
sort($articulations);
foreach($articulations as $art) {
    echo $art . "\n";
}


/*** print bridges
$bridges = $lowlinks->getBridges();
usort($bridges, "compBridge");
foreach($bridges as $bridge) {
    echo min($bridge) . " " . max($bridge) . "\n";
}
*/



Measured memory_bytes: 50640
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,x,*a=map(int,open(0).read().split());c=0\n"
"for t in sorted(a):\n"
"  x-=t\n"
"  if x<0:break\n"
"  c+=1\n"
"print(c-(x>0))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 
vector<string> a;
ll dp[1001][1001];
int h,w;

ll calc(int i,int j)
{
    if(i==0&&j==0)
    {
        return 1;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    if(a[i][j]=='#')
    {
        return 0;
    }
    dp[i][j] = 0;
    if(i>0)
    {
        dp[i][j]+=calc(i-1,j)%MOD;
    }
    if(j>0)
    {
        dp[i][j]+=calc(i,j-1)%MOD;
    }
    return dp[i][j]%MOD;
}

int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        string l;
        cin>>l;
        a.pb(l);
    }
    mset(dp,-1);
    cout<<calc(h-1,w-1);
   
    
    return 0;
}

Measured memory_bytes: 9216
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
//using namespace std;
 //Compiler version g++ 6.3.0

using namespace std;

 int main()
 {
 	long _max,_min,total=0;
 	bool mx=false,mn=false;
 	int len;
 	cin>>len;
 	for(int n=0;n<len;n++){
 		long v;
 		cin>>v;
 		//cout<<v<<endl;
 		if(!mx){
 			_max=v;
 			mx=true;
 		}
 		else{
 			_max=max(_max,v);
 		}
 		if(!mn){
 			_min=v;
 			mn=true;
 		}
 		else{
 			_min=min(_min,v);
 		}
 		total+=v;
 	}
    cout<<_min<<" "<<_max<<" "<<total<<endl;
 	return 0;
 }
    


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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> S(H);
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }

  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if(S[h][w] == '#') continue;
      S[h][w] = '0'
          + (h && w         && S[h-1][w-1] == '#')
          + (h              && S[h-1][w] == '#')
          + (h && W-w-1     && S[h-1][w+1] == '#')
          + (     w         && S[h][w-1] == '#')
          + (     W-w-1     && S[h][w+1] == '#')
          + (H-h-1 && w     && S[h+1][w-1] == '#')
          + (H-h-1          && S[h+1][w] == '#')
          + (H-h-1 && W-w-1 && S[h+1][w+1] == '#');
    }
    cout << S[h] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const long long mod=998244353;
const int N=3010;
int n,s;
int a[N];
long long dp[N][N][3];//dp[i][s][t],从前i个里选，总和为s，状态为t
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=s;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= s){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    

    cout<<dp[n][s][2]<<endl;
    return 0;
}



Measured memory_bytes: 211968
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		String w = sc.next();
		switch (w) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

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

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

    while(1) {
        string str = to_string(n);

        if (str[0] == str[1] && str[1] == str[2])
            break;
        n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    unsigned long long int K;
    cin>>s;
    cin>>K;
    for(int i=0;i<s.length()-1;i++){
        if(s[i]=='a')continue;
        if('a'+26-s[i]<=K){
            K-=('a'+26-s[i]);
            s[i]='a';
        }
    }
    s[s.length()-1]=(s[s.length()-1]-'a'+K)%26+'a';
    cout<<s;
}


Measured memory_bytes: 512
n = gets.to_i
numbers = gets.split.map(&:to_i)
count = Hash.new(0)
numbers.each do |number|
  count[number] += 1
end
sum = 0
count.each do |key, value|
  if key <= value
    sum += value - key
  else
    sum += value
  end
end
puts sum


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s;
    cin>>s;
    set<int> st;
    int i=1;
    while(st.find(s)==st.end()){
        st.insert(s);
        if(s%2==0)
        s/=2;
        else
        s=3*s+1;

        i++;
    }
    cout<<i;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  char S[3];
  
  scanf("%s", S);
  
  if(S[0] == 'a'){
    if(S[1] == 'b'){
      if(S[2] == 'c') printf("Yes\n");
      else printf("No\n");
    }
    else if(S[1] == 'c'){
      if(S[2] == 'b') printf("Yes\n");
      else printf("No\n");
    }
    else printf("No\n");
  }
    
  if(S[0] == 'b'){
    if(S[1] == 'a'){
      if(S[2] == 'c') printf("Yes\n");
      else printf("No\n");
    }
    else if(S[1] == 'c'){
      if(S[2] == 'a') printf("Yes\n");
      else printf("No\n");
    }
    else printf("No\n");
  }
  
  if(S[0] == 'c'){
    if(S[1] == 'a'){
      if(S[2] == 'b') printf("Yes\n");
      else printf("No\n");
    }
    else if(S[1] == 'b'){
      if(S[2] == 'a') printf("Yes\n");
      else printf("No\n");
    }
    else printf("No\n");
  }  
  
  return 0;
}


Measured memory_bytes: 128
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int h1,h2,m1,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int e = h2*60+m2;
	//cout << e<<endl;

	cout << e-k-h1*60-m1<<endl;

	return 0;
}


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

int main()
{
    int a, b;
    string op;
    while(op != "?")
    {
        cin >> a >> op >> b;
        if(op == "+") cout << a+b << endl;
        else if(op == "-") cout << a-b << endl;
        else if(op == "*") cout << a*b << endl;
        else if(op == "/") cout << a/b << endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
const int c[]={0,2,5,5,4,5,6,3,7,6};
string stmax(string a, string b)
{
  if(a.size() > b.size())
  {
    return a;
  }
  else if(a.size() < b.size())
  {
      return b;
  }
  else{
  	if(a>=b)return a;
    else return b;
  }
}
    
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(m);
  for(int i=0; i<m; i++){
    cin>>a[i];
  }
  vector<string>dp(10101,"");
  for(int i=0; i<=n; i++){
    for(int j=0; j<a.size(); j++){
      if(i==0||dp[i]!=""){			//
      	if(i+c[a[j]]>n)continue;
        dp[i+c[a[j]]]=stmax(dp[i]+to_string(a[j]),dp[i+c[a[j]]]);
      }
    }
  }
  cout<<dp[n]<<endl;
}
    
  
   


Measured memory_bytes: 33024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	string s;
	getline(cin,s);

	transform (s.begin(),s.end(),s.begin(),::toupper);

	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  string abc = "abcdefghijklmnopqrstuvwxyz";
  
  vector<bool> A(26, false);
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 26; j++)
    {
      if (S.at(i) == abc.at(j)) A.at(j) = true;
    }
  }
  
  for (int i = 0; i < 26; i++)
  {
    if (!A.at(i))
    {
      cout << abc.at(i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

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

using namespace std;

int main(void){
    int n;
    vector<int> l;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        l.push_back(a);
    }

    sort(l.begin(), l.end());

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


    if(sum <= l[n-1]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
import collections as c

N = int(input())
S = sorted(["".join(sorted(input())) for _ in range(N)])

D = c.Counter(S)

D_value = []

for a in D.values():
	D_value.append(a)

ans = 0

for i in D_value:
	if i == 0:
		continue
	ans += (i * (i-1)) // 2

print(ans)


Measured memory_bytes: 19808
from collections import Counter


if __name__ == "__main__":
    C = Counter()
    N = int(input())
    for c in [chr(n) for n in range(ord("a"), ord("z")+1)]:
        C[c] = 10**8
    for _ in range(N):
        cs = Counter(input())
        C &= cs
    for k, v in C.items():
        print(k*v, end="")
    print()


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

typedef long long int lli;
typedef long double lld;
typedef long long ll;
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf 1e13
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)

using namespace std;
class Solution{
  public:
    lli knapsack1(lli w[], lli v[], lli N, lli W){
      lli i, j, res = 0, V = 0;
      loops(i, 1, N){
          V+= v[i];
      }
      lli dp[V+1];
      loop(i, V+1){
          dp[i] = inf;
      }
      dp[0] = 0;
      loops(i, 1, N){
          lli w1 = w[i], v1 = v[i];
          looprev(j, V, v1){
              dp[j] = min(dp[j], (dp[j-v1]+w1));
          }
      }
      /*loop(i, V+1){
          cout<<dp[i]<<endl;
      }*/
      looprev(i, V, 0){
          if(dp[i] <= W){
              res = i;
              break;
          }
      }
      return res;
    }
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    Solution s;
    lli i, j, k, N, W;
    cin>>N>>W;
    lli w[N+1] = {0}, v[N+1] = {0};
    loop(i, N){
        cin>>w[i+1]>>v[i+1];
    }
    lli res = s.knapsack1(w, v, N, W);
    cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <cmath>


using namespace std;
int main()
{
	int K, S, z;
	int cnt = 0;
	cin >> K >> S;

	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			z = S - x - y;
			if (z >= 0 && z <= K) cnt++;
			
		}
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
let () =
  let a = Array.make 101 false in
  a.(0) <- true;
  for i = 1 to 100 do
    if i >= 4 then a.(i) <- a.(i) || a.(i-4);
    if i >= 7 then a.(i) <- a.(i) || a.(i-7);
  done;
  print_endline @@ Scanf.scanf "%d" @@ fun n -> if a.(n) then "Yes" else "No"

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int A,B,f[4]={};
    cin>>A>>B;

    f[A]+=1;
    f[B]+=1;

    for(int i=1;i<=3;i++){
        if(f[i]!=1){
            cout << i<<endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);

	int A, B, M;
	cin >> A >> B >> M;
	vector <int> a, b, ma, mb, mc;
	a.resize(A);
	b.resize(B);
	ma.resize(M);
	mb.resize(M);
	mc.resize(M);

	int reca = 100000;
	int recb = 100000;
	for (int i = 0; i < A; ++i) {
		cin >> a[i];
		if (a[i] < reca) {
			reca = a[i];
		}
	}
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
		if (b[i] < recb) {
			recb = b[i];
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> ma[i] >> mb[i] >> mc[i];
	}
	int mini = reca + recb;
	for (int i = 0; i < M; ++i) {
		if (a[ma[i] - 1] + b[mb[i] - 1] - mc[i] < mini) {
			mini = a[ma[i] - 1] + b[mb[i] - 1] - mc[i];
		}
	}

	cout << mini << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <map>
using namespace std;
int main(){
    int N;
    int T;
    int c,t;
    int ans;
    cin >> N;
    cin >> T;
    ans = 9999999;
    for(int i = 0; i < N; ++i){
        cin >> c >> t;
        if(t <= T && c < ans){
            ans = c;
        }
    }
    if(ans == 9999999){
            cout << "TLE" << endl;
        }else{
            cout << ans << endl;
        }
    
        
    }
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

char buf[100000+10];

int main(void) {
  scanf("%s", buf);
  int n = strlen(buf);
  int res = 1e9;
  REP(t, 2) {
    int cur = 0;
    REP(i, n) {
      if((buf[i] == '0') != (i%2 == t)) {
        ++cur;
      }
    }
    res = min(res, cur);
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 504
#include <cstdio>
#include <algorithm>

int main()
{
	long long h, w;
	scanf("%lld%lld", &h, &w);
	if (h == 1 || w == 1)
	{
		puts("1");
	}
	else
	{
		if (h % 2 == 0 || w % 2 == 0)
		{
			printf("%lld\n", h * w / 2);
		}
		else
		{
			printf("%lld\n", h * (w / 2) + (h + 1) / 2);
		}
	}
	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

vector<bool> search(vector<bool> check, string s, int N) {
	FOR(i, 2, N+2) {
		bool p;
		if (check[i - 1]) {
			p = s[(i - 1) % N] == 'o' ? check[i - 2] : !check[i - 2];
		}
		else {
			p = s[(i - 1) % N] == 'o' ? !check[i - 2] : check[i - 2];
		}
		check.push_back(p);
	}
	return check;
}
string filter(vector<bool> vec) {
	string s = "";
	FOR(i, 0, vec.size() - 2) {
		s += vec[i] ? "S" : "W";
	}
	return s;
}

int main() {
	int N;
	string s;
	cin >> N >> s;
	bool pattern[4][2]{ {true,true},
						{true,false},
						{false,true},
						{false,false}
	};
	REP(i, 4) {
		vector<bool> check;
		check.push_back(pattern[i][0]);
		check.push_back(pattern[i][1]);
		check = search(check, s, N);
		IfOut(check[0]==check[N]&&check[1]==check[N+1], filter(check));
	}
	out("-1");
	return 0;
}



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

typedef long long LL;

const int N=200,C=62;

int n;
char s[N+9];
LL a[N+9];
int id[C+9];

bool Insert(int x){
  for (int i=C-1;i>=0;--i)
	if (a[x]>>i&1){
	  if (!id[i]) {id[i]=x;return 1;}
	  a[x]^=a[id[i]];
	}
  return 0;
}

void work(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
  scanf("%s",s+1);
  for (int i=0;i<C;++i) id[i]=0;
  for (int i=n;i>=1;--i)
    if (Insert(i)&&s[i]-'0') {puts("1");return;}
  puts("0");
}

int main(){
  int T;
  scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll left = 0;
    ll right = INF;
    rep(i, m) {
        ll L, R;
        cin >> L >> R;
        chmax(left, L);
        chmin(right, R);
    }

    out(max(0LL, right - left + 1));
    re0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
one = []
goal = []
for i in range(M):
    A,B = map(int,input().split())

    if A == 1 :
        one.append(B)
    elif B == 1:
        one.append(A)

    if A == N or B == N:
        goal.append(A)
        goal.append(B)

if set(goal) & set(one):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 25796