akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

vector<int>ch;
void solve()
{
    ll x,k,d;cin>>x>>k>>d;
    x=abs(x);
    ll y=x%d;
    ll z=x/d;
    if(k<z){
        ll a=x-k*d;
        print(a)
        return;
    }
    ll t=k-z;
    if(t&1){
        print(d-y)
    }
    else{
        print(y)
    }

}

int main()
{
  //  fastio();
   // test
    solve();
}


Measured memory_bytes: 3552
#include <stdio.h>

int main(void){
	int a,b,answer,br=0;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		switch(op){
		case '+':
			answer = a + b;
			break;
		case '-':
			answer = a - b;
			break;
		case '*':
			answer = a * b;
			break;
		case '/':
			answer = a / b;
			break;
		case '?':
			br = 1;
			break;
		}
		
		if(br != 1){
			printf("%d\n",answer);
		}else{
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
string s;
llint a[6][250005], b[6][250005];
map<vector<llint>, llint> mp;
const llint p[] = {2, 1145143, 998244353, 101, 640099, 2172113};
llint invp[6];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	cin >> n >> s;
	reverse(s.begin(), s.end());
	s = "#" + s;
	
	for(int i = 0; i < 6; i++){
		invp[i] = modpow(p[i], mod-2);
		a[i][0] = 1, b[i][0] = 0;
	}
	for(int z = 0; z < 6; z++){
		for(int i = 1; i <= n; i++){
			a[z][i] = a[z][i-1], b[z][i] = b[z][i-1];
			if(s[i] == '+') b[z][i]++, b[z][i] %= mod;
			if(s[i] == '-') b[z][i] += mod-1, b[z][i] %= mod;
			if(s[i] == '<'){
				a[z][i] *= p[z], a[z][i] %= mod;
				b[z][i] *= p[z], b[z][i] %= mod;
			}
			if(s[i] == '>'){
				a[z][i] *= invp[z], a[z][i] %= mod;
				b[z][i] *= invp[z], b[z][i] %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		vector<llint> vec;
		for(int j = 0; j < 6; j++){
			llint tmp = (b[j][i]-b[j][n]+mod) % mod;
			tmp *= modpow(a[j][i], mod-2), tmp %= mod;
			vec.push_back(tmp);
		}
		ans += mp[vec];
		vec.clear();
		for(int j = 0; j < 6; j++) vec.push_back(b[j][i] * modpow(a[j][i], mod-2) % mod);
		mp[vec]++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 94220
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int len = s.length();
	bool ans = true;
	if(((s[0]==s[len-1])&&(len%2==1))||((s[0]!=s[len-1])&&(len%2==0))) ans = false;
	if(ans) cout << "First\n";
	else cout << "Second\n";
	return 0;
}

Measured memory_bytes: 512
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);

  auto c = new int[](26);
  foreach (si; s) c[si-'a']++;
  writeln(c.all!"a <= 1" ? "yes" : "no");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

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

    int ans = 0;
    for(int i = 1;i < n-1;i++) {
        vector<int> P;
        P.push_back(p[i-1]);
        P.push_back(p[i]);
        P.push_back(p[i+1]);
        sort(P.begin(),P.end());
        if(P[1] == p[i]) {
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}





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

int main()
{
  int X;
  int Y;
  cin>>X>>Y;
  
  int max;
  int min;
  max=X*4;
  min=X*2;
  if(Y>max || Y<min ||Y%2!=0)
    cout<<"No";
  else
    cout<<"Yes";
  
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int res=0;
	int now=0;
	for(char c:s){
		if(c=='R')now++;
		else now--;
		if(now%4==0){
			if(now==4)res++;
			now=0;
		}
	}
	printf("%d\n",res );
}


Measured memory_bytes: 3388
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <ctime>
#include <cctype>
using namespace std;
const int maxn=1210;
const long long mo=998244353;

int n,ans;
bool bz[maxn];
char s[200010];
long long f[200010][3][3][2];

//__attribute__((optimize("-O3")))
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	ans=1;
	bool pd1=true;
	for (int i=1;i<=n-1;i++)
	{
		if (s[i]==s[i+1]) ans=0;
		if (s[i]!=s[i+1]) pd1=false;
	}
	if (pd1==true)
	{
		printf("1\n");
		return 0;
	}
	if (n==1)
	{
		printf("1\n");return 0;
	}
	else
	if (n==2)
	{
		if (s[1]!=s[2]) printf("2\n");
		else printf("1\n");
		return 0;
	}
	else
	if (n==3)
	{
		if (s[1]==s[2] && s[2]==s[3]) printf("1\n");
		else if ((s[1]==s[2] && s[2]!=s[3]) || (s[2]==s[3] && s[1]!=s[2])) printf("6\n");
		else if (s[1]==s[3] && s[2]!=s[1]) printf("7\n");
		else if (s[1]!=s[2] && s[2]!=s[3] && s[3]!=s[1]) printf("3\n");
		return 0;
	}
	int up=0;
	for (int i=1;i<=n;i++)
	{
		if (s[i]=='b') up++;
		if (s[i]=='c') up+=2;
	}
	up=up%3;
	f[1][0][0][0]=1;
	f[1][1][1][0]=1;
	f[1][2][2][0]=1;
	for (int i=1;i<=n-1;i++)
	{
		for (int a=0;a<=2;a++)
		{
			for (int b=0;b<=2;b++)
			{
				for (int c=0;c<=2;c++)
				{
					int now=0;
					if (b==c)
					{
						now=1;
					}
					for (int hf=0;hf<=1;hf++)
					{
						f[i+1][(a+b)%3][b][max(hf,now)]=(f[i+1][(a+b)%3][b][max(hf,now)]+f[i][a][c][hf])%mo;
					}
				}
			}
		}
	}
	for (int i=0;i<=2;i++)
	{
		ans=(ans+f[n][up][i][1])%mo;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 28544
from sys import stdin
from itertools import groupby

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()

mi = 10**10
for i in range(n-k+1):
    mi = min(mi,li[i+k-1]-li[i])

print(mi)

Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if (a==b){
    cout << c << endl;
  }else if (a == c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}



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

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

	vector<int>sumw(n + 1), sumb(n + 1);
	sumw[0] = 0;
	sumb[0] = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.') {
			sumw[i + 1] = sumw[i] + 1;
			sumb[i + 1] = sumb[i];
		}
		else {
			sumw[i + 1] = sumw[i];
			sumb[i + 1] = sumb[i] + 1;
		}
	}

	int ans = 10000000;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, sumb[i] + sumw[n] - sumw[i]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2180
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int w,n,a,b,i,tmp;
		w=s.nextInt();//ツ縦
		n=s.nextInt();//ツ可。
		int k[]=new int[w+1];
		for(i=1;i<=w;i++){
			k[i]=i;
		}
		for(i=0;i<n;i++){
			String[] str=s.next().split(",");
			a=Integer.parseInt(str[0]);
			b=Integer.parseInt(str[1]);
			tmp=k[a];
			k[a]=k[b];
			k[b]=tmp;
		}
		for(i=1;i<=w;i++){
			System.out.println(k[i]);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int mi[222222];
int ma[222222];
int work[222222];

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

	ll n, k, c;cin >> n >> k >> c;
	string str;cin >> str;

	int now = 0;
	int rest = 0;
	REP(i, n){
		if(rest == 0 && str[i] == 'o'){
			work[i]++;
			now++;
			rest = c;
		}
		else {
			rest = max(0, rest - 1);
		}
		ma[i] = now;
	}

	now = k;
	rest = 0;
	REV(i, n){
		mi[i] = now;
		if(rest == 0 && str[i] == 'o'){
			work[i]++;
			now--;
			rest = c;
		}
		else {
			rest = max(0, rest - 1);
		}
	}

	SHOW1d(mi, n);
	SHOW1d(ma, n);
	SHOW1d(work, n);
	REP(i, n){
		if(work[i] == 2 && mi[i] == ma[i]){
			cout << i + 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4244
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int N;
  cin >> N;
  lli a[N];
  lli sum = 0;
  F(i, N){
    cin >> a[i];
    sum += a[i];
  }
  lli prev = 0;
  F(i, N){
    lli result = sum;
    int idx = (i+1)%N;
    if(i == 0){
      F(j, (N-1)/2){
        result -= 2*a[idx];
        idx = (idx+2)%N;
      }
    }
    else{
      result = 2*a[i-1] - prev;
    }
    cout << result;
    if(i != N-1){
      cout << " ";
    }
    prev = result;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2048
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
M=sum(v)
dp=[[float('inf')]*(M+1) for i in range(N+1)]
dp[0][0]=0

for i in range(N):
  for j in range(M+1):
    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]
ans=0
for i in range(M+1):
  if dp[N][i]<=W:
    ans=max(ans,i)
    
print(ans)
    

Measured memory_bytes: 308168
#include <bits/stdc++.h>
 
using namespace std;
int main(void){
    int H,A;
    cin >> H >> A;
  if (H % A != 0)
  {
    cout << (H / A + 1);
  }
  else {
    cout << H / A;
  }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    P,Q,R = map(int,input().split())
    X = list()
    XX = 9999999
    X.append(P+Q)
    X.append(P+R)
    X.append(Q+R)
    #print(X)
    for i in X:
        if XX > i:
            XX = i
    print(XX)
if __name__ == '__main__':
    main()

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

using namespace std;
double  a [ 999999 ] , n ;
double k , t ,q ;
int main()
{
	cin >> n ;
	t = 1 ;
	for ( int i = 1 ; i<= n ; i ++ )
	{
		cin >> a [i] ;
	}
	for ( int i = 1 ; i <= n ; i ++ )
	{
		q += 1 / a [i] ;
	}
	cout << t / q ;
}


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

const ll MAX = 4000010;
const ll MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
 
 
void COMinit() {
 fac[0] = fac[1] = 1;
 finv[0] = finv[1] = 1;
 inv[1] = 1;
  for (ll i = 2; i < MAX; i++){
  fac[i] = fac[i - 1] * i % MOD;
  inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
        }
      }
 
   long long COM(ll n, ll k){
  if (n < k){ return 0;}
  if (n < 0 || k < 0) {return 0;}
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
     }
 


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

  ll res = 0;
  
  for(ll n = 1; n <= 2*1e6; n++){ 
    
    if( x+y == 3*n && n <= x && x <= 2*n ){
      
      res = COM(n,x-n);
    }
    
  }
  
  cout << res << endl; return 0;
}
  

Measured memory_bytes: 93952
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const ll INF = (ll)1e18 + 1;

int main(){
  ll N; cin >> N;

  ll ans = INF;
  for (ll a = 1; a * a <= N; ++a){
    if (N % a == 0){
      ll b = N / a;
      ans = min(ans, a + b - 2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N;
    cin >> N;
    cout << (N/2 + N%2) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;

map<string ,int>ans;

int main(){
	int a;
	char che;
	string str;
	while(cin>>a>>che>>str ){
		ans[str]++;
	}
	cout<<ans["A"]<<endl;
	cout<<ans["B"]<<endl;
	cout<<ans["AB"]<<endl;
	cout<<ans["O"]<<endl;
	
	
}

Measured memory_bytes: 1216
import math
a,b,x=map(int,input().split())

import numpy as np
from numpy import linalg as LA

if a*a*b<=2*x:
  sanMenseki=(a*a*b-x)/a
  takasa=sanMenseki*2/a
  u = np.array([a,0])
  v = np.array([a,takasa])
  i = np.inner(u, v)
  n = LA.norm(u) * LA.norm(v)

  c = i / n
  a = np.rad2deg(np.arccos(np.clip(c, -1.0, 1.0)))

  print(a)
else:
  sanMenseki=x/a
  takasa=sanMenseki*2/b
  u = np.array([b,0])
  v = np.array([b,takasa])
  i = np.inner(u, v)
  n = LA.norm(u) * LA.norm(v)

  c = i / n
  a = np.rad2deg(np.arccos(np.clip(c, -1.0, 1.0)))

  print(90-a)



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

int main(){
int a,b,x,y,g;
cin>>a>>b;
x=a/b;
y=a%b;
g=y*1000000/b;
cout<<x<<" "<<y<<" "<<x<<"."<<g<<endl;
return 0;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'


vector<int> food;
  vector<int> arr;

// 1 2 4
// 3 2 1
// mid = 2;

int check(int mid, int k) {

  int n = arr.size();
  for(int i = 0; i < arr.size(); i++) {
    int goal = mid / food[i];
    k -= max(0ll, arr[i] - goal);
  }

  return (k >= 0);

}

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, k;

  cin >> n >> k;

  arr.resize(n);
  food.resize(n);

  for(int &x: arr) cin >> x;
  for(int &x: food) cin >> x;

  sort(arr.begin(), arr.end());
  sort(food.begin(), food.end(), greater<int>());

  int l = 0, r = (int)1e18;
  int ans = -1;

  while(l <= r) {

    int mid = (l + r) / 2;

    if(check(mid, k)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch);
long long getKey(char str[]);
int h1(int key);
int h2(int key);
int find(char str[]);
int insert(char str[]);

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


// transform char to int 
int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

// transfrorm char to int for generating a key
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M -1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0 ) return 0;
    }
    return 0;
}
    
int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0 ) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 16996
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 505;

string col = "YRGB";

int n, m, d;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int x = ((i + j) % (2 * d) + (2 * d)) % (2 * d) / d;
			int y = ((i - j) % (2 * d) + (2 * d)) % (2 * d) / d;
			cout << col[2 * x + y];
		}
		cout << "\n";
	}
	return 0;
}


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

int main() {
	while (true) {
		string tmp1;
		cin >> tmp1;
		if (tmp1 == "-") break;
		int m;
		cin >> m;
		for (int i = 0; i < m; ++i) {
			int h;
			cin >> h;
			string tmp2 = tmp1.substr(0, h);
			tmp1.erase(tmp1.begin(), tmp1.begin() + h);
			tmp1 += tmp2;
		}
		cout << tmp1 << endl;
	}
}


Measured memory_bytes: 3196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,*A = map(int,read().split())

dp = [0]*(K+K+1) # bitset
for n in range(K):
    if not dp[n]:
        for a in A:
            dp[n+a]=1

answer = 'First' if dp[K] else 'Second'
print(answer)

Measured memory_bytes: 4596
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 10000001;
    for (int i = 0; i < n-1; i++) {
      ans = min(ans, a[i + 1] - a[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N = I()
A = LI()
A.sort()
cnt = collections.Counter(A)
MAX = A[-1] + 1
# end = A[-1] ** 0.5

for a in A:
    if cnt[a] >= 2:
        del cnt[a]
    for i in range(a * 2, MAX, a):
        del cnt[i]

print(sum(cnt.values()))


Measured memory_bytes: 37196
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, res; cin >> n, n; cout << res << endl){
        res = 0;

        vector< vector<bool> > know(n, vector<bool>(n, false));
        rep(i, n){
            int m; cin >> m;
            rep(j, m){
                int p; cin >> p;
                p--;
                know[i][p] = true;
            }
        }

        vector<bool> possible(n, true);
        int k; cin >> k;
        rep(i, k){
            int l; cin >> l;
            l--;

            rep(j, n){
                if(!know[j][l]){
                    possible[j] = false;
                }
            }
        }

        rep(i, n){
            if(possible[i]){
                if(res == 0){
                    res = i + 1;
                }
                else res = -1;
            }
        }
        if(res == 0) res = -1;
    }

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans=0,now=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='R'){
      now++;
    }else{
      ans=max(ans,now);
      now=0;
    }
  }
  ans=max(ans,now);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
n=int(input())
r=[]
for _ in range(n):
    s,t=map(int,input().split())

    r.append([s-t,s+t])

r=sorted(r,key=lambda x: x[1])


ans=[r[0]]
for i in range(1,n):
    if r[i][0]>=ans[-1][1]:
        ans.append(r[i])

        


print(len(ans))

Measured memory_bytes: 26236
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	vvi cnt(2,vi(n,0));
	REP(i,n){
		if(i-a[i]>=0) cnt[0][i-a[i]]++;
		if(i+a[i]<n) cnt[1][i+a[i]]++;
	}
	
	llong ans=0;
	REP(i,n){
		ans+=(llong)cnt[0][i]*cnt[1][i];
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 6428
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  std::string s;
  std::cin>>s;

  int a=std::stoi(s.substr(0,2));
  int b=std::stoi(s.substr(2,2));

  if(a==0||a>12){
    if(b==0||b>12){
      std::cout<<"NA\n";
    }else{
      std::cout<<"YYMM\n";
    }
  }else{
    if(b==0||b>12){
      std::cout<<"MMYY\n";
    }else{
      std::cout<<"AMBIGUOUS\n";
    }
  }

  return 0;
}


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

valid = [1] * 10
for d in dd:
    valid[d] = 0
digits = [i for i,v in enumerate(valid) if v]
num_digit = len(str(N))

from itertools import product
from sys import exit
for ans_digit in [num_digit, num_digit+1]:
    for x in product(digits, repeat=ans_digit):
        x = int(''.join(map(str, x)))
        if x >= N:
            print(x)
            exit()

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

int N;

int main() {
  
  cin >> N;
  vector<long> A(N+2);
  vector<long> B(N);
  for (int i = 0; i <= N; i++){
  cin >> A.at(i);
  }
  for (int i = 0; i <= N - 1 ;i++){
  cin >> B.at(i);
  }
  
  long C = 0;

  for (int i = 0; i < N; i++){
    
    //勇者の体力がない時は次に回す
    if(B.at(i) == 0) continue;
    
    //iのモンスターを倒しきれない
    if(B.at(i) <= A.at(i)){
    C += B.at(i);
      continue;
    }
    
    //iを倒しきれるがi+1を倒しきれない
    if(B.at(i) <= A.at(i) + A.at(i+1)){
    C += B.at(i) ;
      A.at(i+1) -= (B.at(i) - A.at(i));
      continue;
    }
    
    //iもi+1も倒しきれる
    if(B.at(i) > A.at(i) + A.at(i+1)){
    C +=A.at(i) + A.at(i+1);
      A.at(i) = A.at(i+1) = 0;
      continue;
    }
    
  }
  cout << C << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int dataset = 4;
		double data = 0.0;


		while(stdin.hasNext()) {
			data = stdin.nextDouble();

			if(data <= 48.00) {
				System.out.println("light fly");
			} else if(data <=51.00){
				System.out.println("fly");
			} else if(data > 51.00 && data <=54.00){
				System.out.println("bantam");
			} else if(data > 54.00 && data <=57.00){
				System.out.println("feather");
			} else if(data > 57.00 && data <=60.00){
				System.out.println("light");
			} else if(data > 60.00 && data <=64.00){
				System.out.println("light welter");
			} else if(data > 64.00 && data <=69.00){
				System.out.println("welter");
			} else if(data > 69.00 && data <=75.00){
				System.out.println("light middle");
			} else if(data > 75.00 && data <=81.00){
				System.out.println("middle");
			} else if(data > 81.00 && data <=91.00){
				System.out.println("light heavy");
			} else {
				System.out.println("heavy");
			}
		}


	}

}

Measured memory_bytes: 27816
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
//const int N = 
int main(){
//	freopen("1.txt","r",stdin);
	int a;
	cin>>a;
	if(a==0) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>

int main(){
	boost::multiprecision::cpp_dec_float_100 a,b,c;
	std::cin >> a >> b >> c;

	boost::multiprecision::cpp_dec_float_100 x = boost::multiprecision::sqrt(a)+boost::multiprecision::sqrt(b);
	boost::multiprecision::cpp_dec_float_100 y = boost::multiprecision::sqrt(c);

	if(x<y)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, A, B;
	cin >> N >> A >> B;

	cout << min(A * N, B) << endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) throws 

java.io.IOException{
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if ( a > b ){
			System.out.println("a > b");
		}else if ( a < b ){
			System.out.println("a < b");
		} else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17160
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline
MOD = 10**9+7
# @njit
def solve(n,a):
  # ～段目と対応
  stairs = [1]*(n+10)
  for x in a:
    stairs[x] = 0

  dp = [1] + [0] * (n+1)
  dp[1] = stairs[1]
  for i in range(n):
    dp[i+2] = (dp[i] + dp[i+1]) * stairs[i+2]
    dp[i+2] %= MOD

  return dp[n]



def main():
  N,M = map(int,input().split())
  a = [int(input()) for _ in range(M)]
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 15272
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int N;
int pattern[10];
vector<vector<int>> F, P;
int ans = -(int)(1e9);

void dfs(int k) {
	if (k < 0) {
		int t = 0;
		for (int i = 0; i < 10; i++)t += pattern[i];
		if (t == 0) return;

		vector<int> cnt(N, 0);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 10; j++)
			{
				if (pattern[j]) cnt[i] += F[i][j];
			}
		}

		int rem = 0;
		for (int i = 0; i < N; i++)
			rem += P[i][cnt[i]];
		ans = max(ans, rem);
	}
	else {
		pattern[k] = 0;
		dfs(k - 1);
		pattern[k] = 1;
		dfs(k - 1);
	}
}


int main() {

	cin >> N;

	F.resize(N, vector<int>(10, 0));
	P.resize(N, vector<int>(11, 0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++)
		{
			cin >> F[i][j];
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			cin >> P[i][j];
		}
	}

	dfs(9);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
int a[4],n;
int main(){
	int Min1,Min2;
	REP(i,0,3)cin>>a[i];
	cin>>n;
	a[0]*=4,a[1]*=2;
	sort(a,a+3);
	Min1=a[0];
	REP(i,0,2)a[i]<<=1;
	sort(a,a+4);
	Min2=a[0];
	printf("%lld\n",1ll*Min1*(n&1)+1ll*Min2*(n>>1));
	return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self,u,s,e,w,n,d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d
    
    def rot(self,way):
        # vertically
        if way == 0:
            c = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = c
        #rotate
        if way == 1:
            c = self.e
            self.e = self.n
            self.n = self.w
            self.w = self.s
            self.s = c
        #holizantally
        if way == 2:
            c = self.w
            self.w = self.d
            self.d = self.e
            self.e = self.u
            self.u = c

u,s,e,w,n,d = map(int,input().split())
dice1 = Dice(u,s,e,w,n,d)
uu,ss,ee,ww,nn,dd = map(int,input().split())
dice2 = Dice(uu,ss,ee,ww,nn,dd)

count = 0
flag = 0
while True:
    if dice1.u == dice2.u:
        for s in range(5):
            if dice1.s == dice2.s and dice1.e == dice2.e and dice1.w == dice2.w and dice1.n == dice2.n:
                if dice1.d == dice2.d:
                    flag = 1
                    print('Yes')
                break
            else:
                dice2.rot(1)
        if not flag:
            if dice1.d == dice2.s and dice1.u == dice2.n:
                print('Yes')
                
            elif dice1.d == dice2.e and dice1.u == dice2.w:
                print('Yes')
                
            elif dice1.d == dice2.w and dice1.u == dice2.e:
                print('Yes')
                
            elif dice1.d == dice2.n and dice1.u == dice2.s:
                print('Yes')
            else:
                print('No')
        break
    elif count < 5:
        dice2.rot(0)
        count += 1
    elif count == 5:
        dice2.rot(1)
        count = 0


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define Set(a, v) memset(a, v, sizeof(a))
#define For(i, l, r) for(int i = (l); i <= (int)(r); ++i)
#define Fordown(i, r, l) for(int i = (r); i >= (int)(l); --i)
using namespace std;

inline int read(){
	int x = 0, fh = 1; char ch;
	for(; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1) + (x<<3) + (ch^'0');
	return x * fh;
}
const int N = 200010;
int to[N<<1], Head[N], Next[N<<1], e = 0;
void add_edge (int u, int v) {
	to[++e] = v;
	Next[e] = Head[u];
	Head[u] = e;
}

bool inq[N];
int dis[N];
int m, n;
bool spfa () {
	Set(dis, 0x3f);
	queue<int> Q;
	Q.push(1);
	dis[1] = 1;
	while (!Q.empty() ) {
		int now = Q.front(); Q.pop();
		inq[now] = false;
		for (int i = Head[now]; i; i = Next[i]) {
			int v = to[i];
			if (dis[v] > dis[now] + 1) {
				dis[v] = dis[now] + 1;
				if (!inq[v]) {
					inq[v] = true;
					Q.push(v);
				}
			}
		}
	}
	if (!dis[n]) return false;
	if (dis[n] <= 3) return true;
	return false;
}

int main (){
    n = read(); m = read();
	For (i, 1, m) {
		int u = read(), v = read();
		add_edge (u, v);
		add_edge (v, u);
	}
	puts (spfa() ? "POSSIBLE" : "IMPOSSIBLE");
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

ll filt = 1000000007;
ll combination(ll n, ll r);

ll dp[2009][2009];

int main(void){
    int N, K;
    cin >> N >> K;
    dp[0][0] = 1;
    rep(i, N+2){
        rep(j, i+2){
            if(j == 0) dp[i+1][j] = 1;
            else dp[i+1][j] = (dp[i][j] + dp[i][j-1])%filt;
        }
    }
    
    rep(j, K){
        cout << (dp[N-K+1][j+1]*dp[K-1][j])%filt <<  endl;
    }
    return 0;
}

/*ll combination(ll n, ll r){
    if(r * 2 > n) r = n-r;
    ll dividend = 1;
    ll divisor = 1;
    rep(i, r){
        dividend *= (n-i+1);
        divisor *= i;
    }
    cout << dividend << " " << divisor << " "<< dividend/divisor << endl;
    return (dividend / divisor)%filt;
}*/


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

int main() {
  int n, k;
  std::cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2) {
    puts("-1");
    return 0;
  }
  std::vector< std::pair<int, int> > ans;
  int cur = (n - 1) * (n - 2) / 2;
  for (int i = 2; i <= n; ++i)
    ans.emplace_back(1, i);
  if (cur > k) {
    for (int i = 2; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        ans.emplace_back(i, j);
        if (--cur == k) break;
      }
      if (cur == k) break;
    }
  }
  std::cout << ans.size() << std::endl;
  for (auto e : ans)
    std::cout << e.first << " " << e.second << "\n";
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> dp(n + 1);
	dp[0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 3; j <= i; j++) {
			dp[i] += dp[i - j] % mod;
			dp[i] %= mod;
		}
	}

	cout << dp[n] << endl;
}

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/*
 * LOOK DUDE ... IT AINT DEFINETELY EASY BUT YOU AINT THAT WEAK EITHER
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int ans=a*b*c/(2*max(a,max(b,c)));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key = lambda x:x[2],reverse = True)
for cx in range(101):
    for cy in range(101):
        H =xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for idx in range(1,N):
            if xyh[idx][2] != max(0,H-(abs(xyh[idx][0] - cx) + abs(xyh[idx][1] - cy))):
                break
        else:
            print(cx,cy,H)
            sys.exit()
    

Measured memory_bytes: 3064
def types(st1, st2):
    ret = 0
    for i in range(26):
        j = chr(i + 97)
        if j in st1 and j in st2:
            ret += 1
    return ret

n = int(input())
s = input()

ans = 0
for i in range(n-1):
    ans = max(ans, types(s[:i], s[i:]))
print(ans)


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

int main() {
  long n;
  string ans="";
  cin >> n;
  vector<vector<long>> a(26,vector<long>(n));
  vector<string> s(n);
  for(long i=0;i<n;i++) cin >> s[i];
  for(long i=0;i<n;i++) {
    for(long j=0;j<s[i].size();j++) {
      a[s[i][j]-'a'][i]++;
    }
  }
  for(char i='a';i<='z';i++) {
    sort(a[i-'a'].begin(),a[i-'a'].end());
    for(long j=0;j<a[i-'a'][0];j++) ans=ans+i;
  }
  cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> H(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> H[i];
    ll inf = 1e18;
    vector<ll> dp(N+1, inf);
    dp[1] = 0;
    dp[2] = abs(H[2]-H[1]);
    for (int i = 3; i <= N; i++) {
        dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]));
    }
    cout << dp[N] << endl;
    return 0;
}

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

#define OBOE(head, ...) head

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector< pair<int, int> > > v(n);
  for (int i = 0; i < n; ++i) {
    int m;
    cin >> m;
    v[i].resize(m);
    for (int j = 0; j < m; ++j) {
      cin >> v[i][j].first >> v[i][j].second;
      --v[i][j].first;
    }
  }
  int res = 0;
  for (int S = 0; S < 1 << n; ++S) {
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (S >> i & 1) {
        for (auto e : v[i]) {
          if ((     ~S     >> e.first & 1)      ==      e.second) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      res = max(res, __builtin_popcount(S));
    }
  }
  cout << res << '\n';
}


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

using namespace std;

int main()
{
  int h, w; cin >> h >> w;
    vector <vector <int>> a(h, vector <int> (w));

  int c1 = 0, c2 = -1;
  int d = 1;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    while (k > 0) {
      if (d == 1) {
        if (c2 == w - 1 || a[c1][c2 + 1])
        d = 2;
      }
      else if (d == 2) {
        if (c1 == h - 1 || a[c1 + 1][c2])
        d = 3;
      }
      else if (d == 3) {
        if (c2 == 0 || a[c1][c2 - 1])
        d = 4;
      }
      else if (d == 4) {
        if (c1 == 0 || a[c1 - 1][c2])
        d = 1;
      }
      switch (d) {
        case 1: ++c2; break;
        case 2: ++c1; break;
        case 3: --c2; break;
        case 4: --c1; break;
      }
      a[c1][c2] = i + 1;
      --k;
    }
  }

  for (auto elem : a) {
  for (auto elem1 : elem)
  cout << elem1 << " ";
  cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, t, i, a, b;
	cin >> num >> t;
	vector<pair<int, int>> d(num);
	for (i = 0; i < num; i++) {
		scanf("%d%d", &a, &b);
		d[i] = make_pair(a, b);
	}
	sort(d.begin(), d.end());
	for (i = 0; i < num; i++) {
		if (d[i].second <= t) {
			printf("%d\n", d[i].first);
			break;
		}
	}
	if (i == num)
		printf("TLE\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c >> d;
    fp((abs(a - c) <= d)||((abs(a - b) <= d)&&(abs(b - c) <= d)));
    return 0;
}

Measured memory_bytes: 256