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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N; char S[MAX_N];
int Cnt[26][MAX_N];
int Dy[1<<26], Ans[MAX_N];


int main() {
	scanf("%s", S+1);
	N = strlen(S+1);
	
	for(int i=1; i<=N; i++) {
		for(int k=0; k<26; k++) Cnt[k][i] = Cnt[k][i-1];
		int k = S[i] - 'a';
		Cnt[k][i] = 1 - Cnt[k][i];
	}
	
	for(int s=0; s<(1<<26); s++) Dy[s] = INF;
	for(int i=1; i<=N; i++) Ans[i] = INF;
	Ans[0] = 0; Dy[0] = 0;
	for(int i=1; i<=N; i++) {
		int s = 0;
		for(int k=0; k<26; k++) {
			s += Cnt[k][i] << k;
		}
		Ans[i] = min(Ans[i], Dy[s]+1);

		for(int ch=0; ch<26; ch++) {
			int ns = s ^ (1<<ch);
			Ans[i] = min(Ans[i], Dy[ns] + 1);
		}
		Dy[s] = min(Dy[s], Ans[i]);
	}
	printf("%d\n", Ans[N]);
	return 0;
}


Measured memory_bytes: 283648
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long int

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int l, r;
    l = (N - 1) / 2;
    r = (N + 3) / 2;
    string s2, s3;
    for(int i = 0; i < l; i++){
        s2 += s[i];
    }
    for(int i = r - 1; i < N; i++){
        s3 += s[i];
    }
    if(s2 == s3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

using matrix = vector<vector<ll>>;
ll N;

inline matrix mul(matrix &A,matrix &B){
    matrix C(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i){
        for(ll j=0;j<N;++j){
            ll s=0;
            for(ll k=0;k<N;++k){s+=A[i][k]*B[k][j];s%=MOD;}
            C[i][j]=s;
        }
    }
    return C;
}

inline matrix pow(matrix &A, ll n){
    matrix origin(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i)origin[i][i]=1;
    matrix K=A;
    while(n){
        if(n&1LL){
            origin=mul(origin,K);
        }
        K=mul(K,K);
        n>>=1;
    }
    return origin;
}



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin >> N;
    ll K;
    cin >> K;
    vector<vector<ll>> A(N, vector<ll>(N, 0));
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)cin>>A[i][j];
    matrix ANS=pow(A,K);
    ll ans=0;
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)ans+=ANS[i][j];


    prt(ans%MOD)fl
    


    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
bool j=true;
int n;
int c=1;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++){
    cin>>a.at(i);
}
sort(a.begin(),a.end());
if(n%2==1){
    if(a.at(0)!=0){
        j=false;
    }
    for(int i=2;i<n;i+=2){
        if(a.at(i)!=i||a.at(i-1)!=i){
            j=false;
        }
    }
}
else
{
    for(int i=0;i<n;i+=2){
        if(a.at(i)!=i+1||a.at(i+1)!=i+1){
            j=false;
        }
    }
}
for(int i=0;i<n/2;i++){
    c=(c*2)%mod;
}

if(j==true){
cout<<c<<endl;
}
else
{
    cout<<"0"<<endl;
}
}







Measured memory_bytes: 640
N, K = map(int, input().split())
tele = list(map(int, input().split()))
times = [0] * N
t = 0
pos = 0
looped = False
while K > 0:
    t += 1
    K -= 1
    if times[pos] == 0:
        times[pos] = t
    elif not looped:
        K %= t - times[pos]
        looped = True
    pos = tele[pos] - 1
print(pos + 1)


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

int main(){
  int N, M;
  cin >>N>>M;
  vector<int> A(M);
  vector<bool> row(N+1,1);
  for (int i=0;i<M;i++){
    cin >> A[i];
    row[A[i]] = 0;
  }
  
  vector<long long> ans(N+1,1);
  for (long long i=N-2;i>=0;i--){
    ans[i] = row[i+1]*ans[i+1] + row[i+2]*ans[i+2];
    ans[i] %= 1000000007;
  }
  cout << ans[0] << endl;
}

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

long long n,w;
long long dp[2][110000],W[110],V[110];

int main(){
cin >>n>>w;
for (int i=0;i<n;i++){
  cin >> W[i]>>V[i];
}

for (long long i=0;i<=100000;i++){
  dp[0][i]=0;
  dp[1][i]=0;
}

for (int i=0;i<n;i++){
  int k=i%2;
  for (long long j=1;j<=100000;j++){
    if (V[i]>=j){
      dp[k][j]=W[i];
    } else if (dp[!k][j-V[i]]){
      dp[k][j]=W[i]+dp[!k][j-V[i]];
    }
    if (dp[!k][j]){
      dp[k][j]=min(dp[k][j],dp[!k][j]);
    }
  }

}
long long j=1;
while (dp[(n-1)%2][j]<=w && dp[(n-1)%2][j]!=0){
  j++;
}
cout << j-1<<endl;

return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
  return 0;
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

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

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[MAX];
  scanf("%s", s);

  printf("2018%s", s + 4);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int four = 0;
		int two = 0;
		for (int i = 0; i < N; i++) {
			int tmp = sc.nextInt();
			if (tmp % 4 == 0) {
				four++;
			} else if (tmp % 2 == 0) {
				two++;
			}
		}
		int num = 0;
		if (two > 1) {
			num += two - 1;
		}
		num += four * 2;
		if (num < N - 1) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 48496
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		sc.fill(a);

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i == j) {
					continue;
				}
				for (int k = 0; k < 3; k++) {
					if (i == k || j == k) {
						continue;
					}

					debug(a[i], a[j], a[k], Math.abs(a[i] - a[j]) + Math.abs(a[j] - a[k]));

					min = Math.min(min, Math.abs(a[i] - a[j]) + Math.abs(a[j] - a[k]));
				}
			}
		}

		System.out.println(min);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

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

    int a[4];
    a[0] = n % 10;
    a[1] = (n / 10) % 10;
    a[2] = (n / 100) % 10;
    a[3] = (n / 1000) % 10;

    bool good = (a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]);
    cout << (good ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long cnt = 0 ;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			for(int k=1; k<=n; k++)
			{
				cnt += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << cnt;
	return 0; 
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    S.erase(S.begin(), S.begin() + 4);

    cout << "2018" << S << endl;
    return 0;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Count[MX1+1];

lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli a,b;
    cin>>a>>b;
    
    if(abs(a-b)<=1)
    {
        cout<<"Brown";
    }
    else
    {
        cout<<"Alice";
    }
    
    
    
    
    
 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,sum,maxn;
char s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>s;
		if(s=='I') sum++;
		if(s=='D') sum--;
		if(maxn<sum) maxn=sum;
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]
    return i + 1


n = int(input())
A = [int(x) for x in input().split()]

p = partition(A, 0, n-1)

for i in range(n):
    if i:
        print(" ", end = "")
    if i == p:
        print("[", end="")
    print(A[i], end="")
    if i == p:
        print("]", end="")
print()



Measured memory_bytes: 16368
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<list>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#define rep(i,k,n) for(int i=(k);i<=(n);i++)
#define red(i,k,n) for(int i=(k);i>=(n);i--)
#define sqr(x) ((x)*(x))
#define clr(x,y) memset((x),(y),sizeof(x))
#define mod 1000000007
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)>(b)?(b):(a))
//const int maxn = ;

int n,m;
int skl[110][110];
int skr[110][110];
int in[110];
bool vis[110];
vector<int> e[110];
queue<int> q;

char s[10];

bool solve()
{
    int kk,num,p,v;
    rep(i,1,n)rep(j,1,m)skl[i][j]=0,skr[i][j]=100;
    bool flag=false;
    rep(i,1,n)
    {
        scanf("%d",&kk);
        rep(j,1,kk)
        {
            scanf("%d%s%d",&num,s,&p);
            if(s[0]=='>')
            {
                if(skl[i][num]<p)
                {
                    if(skr[i][num]<p) flag=true;
                    else skl[i][num]=p;
                }
            }
            else if(s[0]=='<')
            {
                if(skr[i][num]>p)
                {
                    if(skl[i][num]>p) flag=true;
                    else skr[i][num]=p;
                }
            }
        }
        e[i].clear();
    }

    if(flag)return 0;

    clr(in,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            bool flag=false;
            rep(k,1,m)
            {
                if(skr[i][k]<skl[j][k]){flag=true;break;}
            }
            if(flag)
            {
                e[j].push_back(i);
                in[i]++;
            }
        }
    }

    clr(vis,0);
    int cnt=0;
    rep(i,1,n)if(in[i]==0)
    {
        q.push(i);
        vis[i]=1;
        cnt++;
    }
    while(!q.empty())
    {
        int p=q.front();q.pop();
        if(!e[p].empty())rep(i,0,e[p].size()-1)
        {
            v=e[p][i];
            if(vis[v])continue;
            if(--in[v]==0)
            {
                q.push(v);
                vis[v]=1;
                cnt++;
            }
        }
    }

    return cnt==n;
}

int main()
{
//#define LOCAL
#ifdef LOCAL
    freopen("e:\\read.txt","r",stdin);
    //freopen("e:\\write.txt","w",stdout);
#endif
    while(cin>>n>>m)
    {
        if(solve())puts("Yes");
        else puts("No");
    }


    return 0;
}

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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

const int N=1e5+7;
vector<int> gp[N];
vector<int> vis(N);

void dfs(int u){
    vis[u]=1;
    for(auto x:gp[u]){
        if(vis[x])continue;
        dfs(x);
    }
}

int main(){
    nimble
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int u,v;
        cin>>u>>v;
        gp[u].pb(v);
        gp[v].pb(u);
    }
    dfs(1);
    rep(i,1,n+1){
        if(!vis[i]){
            cout<<-1<<nl;
            return 0;
        }
    }
    vector<int> d(N);
    rep(i,0,N)d[i]=inf;
    d[1]=0;
    deque<int> q;q.push_back(1);
    while(_sz(q)){
        int u=q.front();q.pop_front();
        for(int j=0;j<_sz(gp[u]);j++){
            int v=gp[u][j];
            if(d[v]==inf){
                d[v]=d[u]+1;
                q.push_back(v);
            }
        }
    }
    map<int,vector<int>> mp;
    mp[0].pb(1);
    for(int i=2;i<=n;i++){
        mp[d[i]].pb(i);
    }
    map<int,int> as;
    int f=1;
    int xx=0;
    for(auto x:mp){
        if(f){
            f=0;
            continue;
        }
        vector<int> t=x.Y;
        for(int i=0;i<_sz(t);i++){
            as[t[i]]=mp[x.X-1][0];
        }
    }
    cout<<"Yes"<<nl;
    for(int i=2;i<=n;i++)cout<<as[i]<<nl;
    return 0;
}


Measured memory_bytes: 28180
N,W=map(int,input().split())
w=[]
v=[]

for i in range(N):
    x,y=map(int,input().split())
    w.append(x)
    v.append(y)

S=sum(v)

DP=[[1000000000000]*(S+1) for i in range(N+1)]
for i in range(N+1):
    DP[i][0]=0



for i in range(N):
    for v1 in range(S+1):
        DP[i+1][v1]=min(DP[i][v1-v[i]]+w[i],DP[i][v1])

for i in range(S,0,-1):
    if DP[N][i]<=W:
        print(i)
        exit()

Measured memory_bytes: 120028
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int x = (a + b- 1) / b;
        
        System.out.println(c * x);
    }
}


Measured memory_bytes: 35612
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdlib>
#define ll long long
using namespace std;
int a[100005];
int b[100005];
int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+N);
    for(int i=0;i<N-K+1;i++)
    {
       b[i]=a[i+K-1]-a[i];
    }
    sort(b,b+N-K+1);
    printf("%d\n",b[0]);
    return 0;
}


Measured memory_bytes: 1024
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = GettingStarted.XCubic();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class GettingStarted
    {
        public static string XCubic()
        {
            var input = Console.ReadLine();
            return Math.Pow(double.Parse(input), 3).ToString("#");
        }

        public static string HelloWorld()
        {
            return "Hello World";
        }
    }
}

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

int main()
{
   int n;
   cin >>n;
   vector<int> p(n);
   for(int t=0;t<n;t++){
       cin >>p.at(t);
   }
   //以上入力
   int ans = 0;
   for(int t = 1;t<n-1;t++){
        if(p.at(t)<p.at(t-1)){
            if(p.at(t)>=p.at(t+1)){
                ans++;
            }
        }
        if(p.at(t)<p.at(t+1)){
            if(p.at(t)>=p.at(t-1)){
                ans++;
            }
        }
   }
   cout <<ans <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int main()
{
	int K;
	scanf("%d",&K);
	printf("%d\n",a[K-1]);
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int sa = a.size(), sb = b.size();
    if (sa < sb) {
        cout << "LESS" << endl;
    }
    else if (sa > sb)
        cout << "GREATER" << endl;
    else {
        if (a == b)
            cout << "EQUAL" << endl;
        else {
            cout << (a > b ? "GREATER" : "LESS") << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for l in range(330, 366):
  last = [0] * 26
  run(l)
  #print(last)
  zmx = -float("inf")
  zmxz = 0
  for z in range(26):
    t[l - 1] = z

    for d in range(l + 1, D + 1):
      mx = -float("inf")
      mxx = t[d - 1]
      for x in range(26):
        t[d - 1] = x
        res = score(d, 0) + s[d - 1][x]
        if mx < res:
          mx = res
          mxx = x
      t[d - 1] = mxx
      last[mxx] = d
    zres = run(D)
    if zres > zmx:
      zmx = zres
      zmxz = z
  t[l - 1] = zmxz

for x in t: print(x + 1)

Measured memory_bytes: 86180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_5_a
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = new string[2];
                str = Console.ReadLine().Split(' ');

                int i = int.Parse(str[0]);
                int n = int.Parse(str[1]);
                if (i == 0 && n == 0 )
                {
                    break;
                }

                for (int a = 0; a < i; a++)
                {
                    for (int b = 0; b < n; b++)
                    {
                        Console.Write('#');
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }
}



Measured memory_bytes: 17832
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	ll n, k;
	cin >> n >> k;
	vector <ll> arr(n);
	FOR(i,0,n) {
		cin >> arr[i];
	}
	vector <ll> table(n);
	table[0] = 0;
	table[1] = abs(arr[1] - arr[0]);
	FOR(i,2,n) {
		table[i] = table[i-1] + abs(arr[i] - arr[i-1]);
		FOR(j,2,k+1) {
			if (i-j < 0) {
				break;
			}
			table[i] = min(table[i], table[i-j] + abs(arr[i] - arr[i-j]));
		}
	}
	cout << table[n-1] << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

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

int n;
ll dp[110][64]; // [i][j] # of valid string when we read till ith character and
                // last 3 characters are j.
vector<string> candidate = {"A", "C", "G", "T"};
vector<string> invalid = {"AGC", "ACG", "GAC"};

bool valid(string pre, string tmp) {
  return find(invalid.begin(), invalid.end(), tmp) == invalid.end() &&
         pre + tmp.substr(1, 2) != "AGC" &&
         pre + tmp.substr(0, 1) + tmp.substr(2, 1) != "AGC";
}

void solve() {
  map<string, int> m;
  int index = 0;
  for (auto c1 : candidate) {
    for (auto c2 : candidate) {
      for (auto c3 : candidate) {
        string tmp = c1 + c2 + c3;
        if (valid("", tmp)) {
          dp[2][index] = 1;
        }
        m[tmp] = index++;
      }
    }
  }

  for (int i = 2; i < n; i++) {
    for (auto x : m) {
      for (auto c : candidate) {
        string tmp = x.first.substr(1, 2) + c;
        if (valid(x.first.substr(0, 1), tmp)) {
          dp[i + 1][m[tmp]] += dp[i][m[x.first]];
          dp[i + 1][m[tmp]] %= MOD;
        }
      }
    }
  }
  ll sum = 0;
  for (auto x : m) {
    sum = (sum + dp[n - 1][x.second]) % MOD;
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 256
#include <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;
int INF=1<<28;
int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
	    int d;cin >> d;if(d==0)break;
	    int n;cin >> n;
	    int m;cin >> m;
	    vector<int> ds(n);
	    FOR(i,1,n) cin >> ds[i];
	    vector<int> ks(m);
	    REP(i,m) cin >> ks[i];

	    sort(ALL(ds));
	    vector<int> dbds(2*n);
	    REP(i,n){
		dbds[i]=ds[i];
		dbds[n+i]=d+ds[i];
	    }
	    
	    int res=0;
	    REP(i,m){
		int v=INF;
		v=min(v,abs(ks[i] - dbds[lower_bound(ALL(dbds),ks[i])-dbds.begin()]));
		v=min(v,abs(ks[i] - dbds[lower_bound(ALL(dbds),ks[i])-dbds.begin()-1]));
		res+=v;
	    }
	    cout << res <<endl;
	}

 	return 0;
 }

Measured memory_bytes: 2388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    //X未満の数がK個未満かどうか
    auto check = [&](ll X){
        ll res = 0;
        vector<ll> cnt(N, 0);
        rep(i,N){
            //左側を数える
            if(A[i]>0){
                //indexの二分探索
                int ok = -1;
                int ng = N;
                while(ng - ok > 1){
                    int mid = (ok + ng) / 2;
                    if(A[i] * A[mid] < X)ok = mid;
                    else ng = mid;
                }
                //0-indexedなので
                cnt[i] = ok + 1;
                if(A[i] * A[i] < X)cnt[i]--;
            }
            //右側を数える
            else if(A[i]<0){
                //indexの二分探索
                int ng = -1;
                int ok = N;
                while(ok - ng > 1){
                    int mid = (ok + ng) / 2;
                    if(A[i] * A[mid] < X)ok = mid;
                    else ng = mid;
                }
                cnt[i] = N - ok;
                if(A[i] * A[i] < X)cnt[i]--;
            }
            //A[i] == 0
            else{
                if(X > 0){
                    cnt[i] = N - 1;
                }
            }
            res += cnt[i];
        }
        //print(cnt);
        //cerr<<X<<": "<<res/2<<" 個"<<endl;
        return res/2 < K;
    };

    ll ok = - INFLL -1;
    ll ng = INFLL + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 3428
#include <iostream>
#include <set>
using namespace std;
set <long long> s1,s2;
int main(int argc, char** argv) {
	int a,b,q;
	cin >> a >> b >> q;
	s1.insert(-1e18),s1.insert(1e18);
	s2.insert(-1e18),s2.insert(1e18);
	for(int i=1;i<=a;i++)
	{
		long long x;
		cin >> x;
		s1.insert(x);
	}
	for(int i=1;i<=b;i++)
	{
		long long x;
		cin >> x;
		s2.insert(x);
	}
	while(q--)
	{
		long long x;
		cin >> x;
		long long l1,l2,r1,r2;
		l1=x-(*(--s1.upper_bound(x)));
		l2=x-(*(--s2.upper_bound(x)));
		r1=(*s1.lower_bound(x))-x;
		r2=(*s2.lower_bound(x))-x;
		cout << min(max(r1,r2),min(max(l1,l2),min(min(l1,r2)*2+max(l1,r2),min(l2,r1)*2+max(l2,r1)))) << "\n";
	}
	return 0;
}

Measured memory_bytes: 10752
import math
N,P = map(int,input().split(" "))

i = 2
plimes = []

if N == 1:
    print(P)
else:
    while(i <= math.sqrt(P)):
        if P % i == 0:
            P = P // i
            plimes.append(i)
        elif i == 2:
            i += 1
        else:
            i += 2
    plimes.append(P)


    resalt = 1
    j = 0

    while(len(plimes) > j):
        k =plimes.count(plimes[j])
        if k // N >= 1:
            resalt = resalt * plimes[j] **(k//N)
        j = j + k
    print(resalt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 
#define ll long long int 
using namespace std;

int main(){
	
		//freopen("A.in", "r", stdin);
		
	int x, y, n;
	cin >> x >> y >> n;
	cout << ((n - 1) / max(x, y) + 1);
	return 0;
}

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

typedef long long ll;

ll dfs(int n, ll x){
    if(n == 0 && x == 1)  return 1;
    if(x <= 1)  return 0;

    ll len = (1ll<<(n+2))-3;
    ll center = len/2+1;
    
    // 区間を完全に覆ってしまった時点で枝刈りをしないとdfsの呼び出しが指数的に爆発して死ぬ
    if(x == len)    return 1 + 2ll*dfs(n-1, center-2);
    
    if(x < center)  return dfs(n-1, x-1);
    else            return 1 + dfs(n-1, center-2) + dfs(n-1, x-1-center+1);
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    cout << dfs(n, x) << endl;
    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, m;
  string s;
  vector<vector<int>> g;
  vector<vector<int>> cnt;
  unordered_set<int> idx;
  vector<int> rem;
  Solver2(LL n, LL m) : n(n), m(m), g(n), cnt(n, vector<int>(2)), rem(n, 1){};

  void solve() {
    cin >> s;
    vector<pair<int, int>> edges;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      edges.emplace_back(min(a, b), max(a, b));
    }
    sort(edges.begin(), edges.end());
    edges.erase(unique(edges.begin(), edges.end()), edges.end());
    for (auto p : edges) {
      if (p.first == p.second) {
        g[p.first].push_back(p.first);
        cnt[p.first][s[p.first] - 'A']++;
      } else {
        g[p.first].push_back(p.second);
        g[p.second].push_back(p.first);
        cnt[p.second][s[p.first] - 'A']++;
        cnt[p.first][s[p.second] - 'A']++;
      }
    }
    for (int i = 0; i < n; ++i) {
      idx.insert(i);
    }
    DBG(cnt)
    // while (1) {
    bool ok = true;
    vector<int> del;
    queue<int> check;
    for (int v : idx) {
      if ((cnt[v][0] == 0 || cnt[v][1] == 0) && rem[v] == 1) {
        DBG(v)
        ok = false;
        del.push_back(v);
        rem[v] = 0;
        for (auto to : g[v]) {
          cnt[to][s[v] - 'A']--;
          if ((cnt[to][0] == 0 || cnt[to][1] == 0) && rem[to] == 1) {
            check.push(to);
            rem[to] = 0;
          }
        }
      }
    }
    for (int v : del) {
      idx.erase(v);
    }
    DBG(cnt)
    del.clear();
    DBG(idx.size())
    if (idx.empty()) {
      cout << "No" << endl;
      return;
    }
    while (!check.empty()) {
      int v = check.front();
      DBG(v)
      check.pop();
      for (auto to : g[v]) {
        cnt[to][s[v] - 'A']--;
        if ((cnt[to][0] == 0 || cnt[to][1] == 0) && rem[to] == 1) {
          check.push(to);
          rem[to] = 0;
        }
      }
      idx.erase(v);
      if (idx.empty()) {
        cout << "No" << endl;
        return;
      }
    }
    //if (ok) break;
    DBG(cnt)
    //}
    cout << "Yes" << endl;
  }
};  // namespace Problem
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define pb push_back
#define ll long long
const int maxn=2e5+10;
const int mod=1e9+7;
const double pi=-acos(-1);

int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



signed main() {
	int n, m, a, t=0;
	cin >> n >> m;
	priority_queue<int>pq;
	rep(i, n) {
		cin >> a;
		pq.push(a);
	}
	rep(i, m) {
		pq.push(pq.top() / 2);
		pq.pop();
	}
	rep(i, n) {
		t += pq.top();
		pq.pop();
	}
	cout << t << endl;
}



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

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

    int n;
    cin >> n;

    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    rep(i, n){
        cin >> a[i];
        rep(j, a[i]) {
            int xt, yt;
            cin >> xt >> yt;
            --xt;
            x[i].push_back(xt);
            y[i].push_back(yt);
        }
    }

    int res = 0;
    rep(i, (1<<n)){
        vector<int> honest(n, 0);
        int sm = 0;
        rep(j, n){
            if(i & (1<<j)){
                honest[j] = 1;
                ++sm;
            }
        }

        bool is_correct = true;
        rep(j, n){
            if(honest[j] == 1){
                rep(k, a[j]){
                    if(y[j][k] == 0 && honest[x[j][k]] == 1) is_correct = false;
                    if(y[j][k] == 1 && honest[x[j][k]] == 0) is_correct = false;
                }
            }
        }

        if(is_correct) res = max(res, sm);

        // if(is_correct){
        //     rep(j, n) cout << honest[j] << " ";
        //     cout << endl;
        // }

    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


int main(){
	set <llint> hon, pon, bon;
	hon.insert({2, 4, 5, 7, 9});
	pon.insert({0, 1, 6, 8});
	bon.insert(3);
	llint n;
	cin>>n;
	if(bon.find(n%10) != bon.end()) cout<<"bon";
	else if(pon.find(n%10) != pon.end()) cout<<"pon";
	else cout<<"hon";
	return 0;
}


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

#define ARRMAX 100001
int cnt[ARRMAX][2] = {0};
int maxcnt[2] = {0}; 
int maxcntnum[2] = {0};
int max2ndcnt[2] = {0};
int max2ndcntnum[2] = {0};

vector<int> even,odd;

void lanking(){
    for (int i = 0; i < ARRMAX; i++){
        
        for(int j = 0; j < 2; j++)
        {
            //printf("cnt%d %d %d num:%d %d\n",cnt[i][j],maxcnt[0],maxcnt[1],maxcntnum[0],maxcntnum[1]);
            if (cnt[i][j] > maxcnt[j]){
                max2ndcnt[j] = maxcnt[j];
                max2ndcntnum[j] = i;
                maxcnt[j] = cnt[i][j];
                maxcntnum[j] = i;
            } else if (cnt[i][j] > max2ndcnt[j]){
                max2ndcnt[j] = cnt[i][j];
                max2ndcntnum[j] = i;
            }
        }       
    }
    //printf("%d %d num:%d %d",maxcnt[0],maxcnt[1],maxcntnum[0],maxcntnum[1]);
    return;
}


int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        cnt[tmp][i%2]++;
    
    }

    lanking();
    int ans;
    if (maxcntnum[0] != maxcntnum[1]){
        ans = N - (maxcnt[0] + maxcnt[1]);
    } else {
        if (maxcnt[0] + max2ndcnt[1] < maxcnt[1] + max2ndcnt[0]){
            ans = N - (maxcnt[1] + max2ndcnt[0]);
        } else {
            ans = N - (maxcnt[0] + max2ndcnt[1]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <utility>
#define ll long long
using namespace std;
int a[100010];
map<int,ll> mp;
int main() {
    int n,m,s=0;
    ll res=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
        s%=m;
        mp[s]++;
    }
    for(auto c:mp){
        res+=(c.second*(c.second-1))/2;
        //cout<<c.first;
    }
    res+=mp[0];
    printf("%lld",res);
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int A, B;
	string S;
	cin >> A >> B >> S;
	
	bool ng = false;
	if (count(ALL(S), '-') != 1) ng = true;
	else {
		int p = find(ALL(S), '-') - S.begin();
		if (p != A) ng = true;
		
		REP(i, p) if (!isdigit(S[i])) ng = true;
		FOR(i, p + 1, S.size()) if (!isdigit(S[i])) ng = true;
	}
	
	puts(ng ? "No" : "Yes");
	
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  string s;
  cin >> s;
  if(s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
	int a;
	cin>>a;
	string b;
	for (int i=1;i<=a;i++){
	b=to_string(i);
		if (i%3==0)cout<<" "<<i;
		else {
			for (int j=0;j<b.length();j++){
				if (b[j]=='3'){
				cout<<" "<<i;
				break;}
			}
		}
	}
	cout<<endl;
}


Measured memory_bytes: 3260
my ($X,$Y,$n,$x,$y)=+<<get.words;$x=$y=0;
map {m:g/\d+/;('$x max=+$0','$X min=+$0','$y max=+$1','$Y min=+$1')[$2-1].EVAL},lines;
say ($X-$x max 0)*($Y-$y max 0)

Measured memory_bytes: 108688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi a(3);
	rep(i,3)cin>>a[i];
	sort(all(a));
	cout<<a[0]*a[1]/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
long long MOD = 1000000007;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    if(a[0]==a[1] && a[0]==a[2]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,X[100],i,j,hp,answer;
  answer=10000000;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&X[i]);
  for(i=0;i<=100;i++){
    hp=0;
    for(j=0;j<N;j++)
      hp=hp+(X[j]-i)*(X[j]-i);
    if(answer>hp)
      answer=hp;
  }
  printf("%d\n",answer);
  return 0;
}
      

Measured memory_bytes: 128