akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define B -3
#define V -4
#define N 8
#define M 15
#define free -1
#define Nfree -2
int T[N][N];
int row[N];
int col[N];
int dpos[M];
int dneg[M];

void printBoard(void){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(T[i][j]==B && j!=row[i]) return;
    }
  }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(j==row[i]) printf("Q");
      else printf(".");
      // if(j!=N-1) printf(" ");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  //printf("%d\n",i);
  for(j=0;j<N;j++){
    if(col[j]==Nfree || dpos[i+j]==Nfree || dneg[i-j+N-1]==Nfree) {
      continue;
      printf("a");
    }
    //printf("%d %d\n",i,j);
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=Nfree;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=free;
      }
  
}
int main(){
  int i,j,k,r,c;
  for(i=0;i<M;i++){
    dpos[i]=free;
    dneg[i]=free;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      T[i][j]=V;
    }
  }
  for(i=0;i<8;i++){
    row[i]=0;
    col[i]=free;
    scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    T[r][c]=B;
    //row[r]=c;
    //col[c]=Nfree;
    //dpos[r+c]=Nfree;
    //dneg[r-c+N-1]=Nfree;
    //printf("%d %d %d \n",col[c],dpos[r+c],dneg[r-c+N-1]);
  }
  // for(i=0;i<N;i++){
    putQueen(0);
    //}
    //   for(i=0;i<N;i++){
    // printf("%d ",row[i]);
    //}
  return 0;
  }
}



Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(500000)

N = int(input())
G = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b = map(int, input().split())
    G[a].append((b, i))
    G[b].append((a, i))

color = max(len(g) for g in G)
print(color)

ans = [-1] * (N-1)

def dfs(v=1, p=0, p_col=-1):
    col = 1

    for side, idx in G[v]:
        if side != p:
            if col == p_col:
                col += 1
            ans[idx] = col
            dfs(side, v, col)
            col += 1

dfs()
print("\n".join(map(str, ans)))

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

const ll MAX = 1000000;

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

  int rev = 0;
  char front[MAX];
  char back[MAX];

  int front_cnt = 0, back_cnt = 0;

  for(int i = 0; i < q; i++){
    int t; cin >> t;

    if(t == 1){
      rev = 1 - rev;
    }else{
      int f; char c;
      cin >> f >> c;
      f--;
      if(rev ^ f){
        back[back_cnt++] = c;
      }else{
        front[front_cnt++] = c;
      }
    }
  }

  if(rev){
    for(int i = back_cnt - 1; i >= 0; i--){
      cout << back[i];
    }
    reverse(s.begin(), s.end());
    cout << s;
    for(int i = 0; i < front_cnt; i++){
      cout << front[i];
    }
  }else{
    for(int i = front_cnt - 1; i >= 0; i--){
      cout << front[i];
    }
    cout << s;
    for(int i = 0; i < back_cnt; i++){
      cout << back[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=155;
int n,k,m,_n,_k,v,f[N][N],g[N][N][N];
int main(){
	cin>>n>>k>>m;
	if(~k&1){
		int a=n+1>>1;
		f[0][0]=1;k=k/2+1;
		fo(i,1,a){
			f[i][0]=f[i-1][k-1];
			fo(j,0,k-2)f[i][j+1]=f[i-1][j],f[i][0]=(f[i][0]+f[i-1][j])%m;
		}
		int su1=0,su2=0;
		fo(i,0,k-1)su1=(su1+f[a][i])%m,su2=(su2+f[n-a][i])%m;
		printf("%d",(ll)su1*su2%m);
		return 0;
	}
	f[0][0]=1;_k=(k+1)/2-1;
	fo(i,1,_k)
		fo(j,0,i)f[i][j+1]=f[i-1][j],f[i][0]=(f[i][0]+f[i-1][j])%m;
	_n=(n+1)/2+1;
	fo(j,0,_k)g[0][j][_n]=f[_k][j];
	fo(o,1,(n-k+1)/2)
		fo(i,0,o+_k)
			fo(j,o,_n)
				if(v=g[o-1][i][j]){
					//0 0
					g[o][0][_n]=(g[o][0][_n]+v)%m;
					//0 1
					g[o][i+1][_n]=(g[o][i+1][_n]+v)%m;
					//1 
					if(o<j){
						//1 0
						g[o][0][j]=(g[o][0][j]+v)%m;
						//1 1
						int lim=min(o-i+k,_n);
						if(o<lim)
							g[o][i+1][min(lim,j)]=(g[o][i+1][min(lim,j)]+v)%m;
					}
				}
	memset(f,0,sizeof f);
	fo(j,0,_n)fo(i,0,n/2)f[(n-k+1)/2][j]=(f[(n-k+1)/2][j]+g[(n-k+1)/2][i][j])%m;
	fo(o,(n-k+1)/2+1,(n+1)/2)
		fo(j,0,_n)if(v=f[o-1][j]){
			f[o][_n]=(f[o][_n]+v)%m;
			if(o<j)f[o][j]=(f[o][j]+v)%m;
		}
	cout<<f[(n+1)/2][_n];
}

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

using namespace std;

int main()
{
    vector<int> vs(5);
    int k;
    for (auto& v : vs)
    {
        cin >> v;
    }
    cin >> k;
    sort(vs.begin(), vs.end());
    cout << (vs.back() - vs.front() <= k ? "Yay!" : ":(") << endl;
}

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

int main()
{
    string s;
    cin>>s;
    ll rem,i,n=s.size(),k=2019,val,ans=0,val1=1,c;
    unordered_map<ll,ll> m;
    rem=0;
    
    for(i=n-1;i>=0;i--)
    {
        val=val1%k;
        c=s[i]-'0';
        rem=(rem+c*val)%k;
        m[rem]++;
        val1=(val1%k*10)%k;
    }

    m[0]++;

    for(auto x:m)
    {
        ans+=(x.second*(x.second-1))/2;
    }
    
    cout<<ans;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int MAXN = 1e5+100;
int n;
double mid;
vi A;

bool cmp (int a, int b) {
    return abs(a-mid) < abs(b-mid);
}

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

    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];

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

    int a = A.back(); A.pop_back();
    mid = 0.5 * a;
    sort(A.begin(), A.end(), cmp);
    int b = A[0];

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100100
const ll inf = (ll)1e10;
const ll MOD = (ll)1e9+7;
ll dp[22][1 << 22];
bool chk ( int pos, int mask ) {
	return mask & (1 << pos);
}
int on ( int pos, int mask ) {
	return mask | (1<<pos);
}
int n, done;
int adj[21][21];
ll solve(ll pos , ll mask){
    
    if (pos == n){
        if (mask == done - 1) {
            return 1;
        } else return 0;
    }
    if(dp[pos][mask] != -1) return dp[pos][mask];
    dp[pos][mask] = 0;
    for(int j = 0 ; j < n; j++){
        if ( adj[pos][j] && !chk(j,mask) ) dp[pos][mask] = (dp[pos][mask] + solve ( pos+1, on(j,mask) ) ) %MOD;
    }
    return dp[pos][mask];
}
int main()
{
	#ifdef __APPLE__
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cin >> adj[i][j];
		}
	}
	done = (1<<n);
	memset(dp,-1,sizeof(dp));
	cout << solve(0,0) << endl;
	return 0;
}


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

int main(){
	int m,n,end[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1){
		int day=0,r;
		cin>>m>>n;
		if(m==0) break;
		rep(i,0,m-1) day+=end[i];
		day+=n;
		r=day%7;
		if(r==1) cout<<"Thursday"<<endl;
		else if(r==2) cout<<"Friday"<<endl;
		else if(r==3) cout<<"Saturday"<<endl;
		else if(r==4) cout<<"Sunday"<<endl;
		else if(r==5) cout<<"Monday"<<endl;
		else if(r==6) cout<<"Tuesday"<<endl;
		else if(r==0) cout<<"Wednesday"<<endl;
	}
}

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

long long cmb[61][61];

int main(){
	for(int i = 0; i < 61; ++i){
		cmb[i][0] = 1;
		for(int j = 1; j <= i; ++j){
			cmb[i][j] = cmb[i-1][j] + cmb[i-1][j-1];
		}
	}

	int n;
	long long m;
	while(cin >> n >> m, n){
		int k;
		for(k = 0; cmb[n][k] < m; ++k){
			m -= cmb[n][k];
		}

		for(int i = n; i > 0; --i){
			if(cmb[i-1][k] < m){
				cout << '1';
				m -= cmb[i-1][k];
				--k;
			}
			else{
				cout << '0';
			}
		}
		cout << '\n';
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n, a;
  cin >> n >> a;
  cout << n*n - a << endl;

  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  ll N,D;cin>>N>>D;
  vl X(N),Y(N);
  rep(i,N)cin>>X[i]>>Y[i];
  int cnt =0;
  rep(i,N){
    if((X[i]*X[i] +Y[i]*Y[i]) <=D*D)cnt++;
  }
  cout<<cnt<<endl;
  
}
  


Measured memory_bytes: 6488
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number } => {
  const N = +lines[0]
  const obj = { N }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N } = parseLines(lines)
  if (N < 10) {
    return `${N}`
  } else if (N < 100) {
    return '9'
  } else if (N < 1000) {
    return `${N - 90}`
  } else if (N < 10000) {
    return '909'
  } else if (N < 100000) {
    return `${N - 9000 - 90}`
  } else {
    return '90909'
  }
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int limit=60;
using namespace std;

int main(){
    int n;
    int t=24*3600+59*60+59;
    while(cin>>n&&n){
        vector<int> v(t+1,0);
        rep(i,0,n){
            int hs,ms,ss,he,me,se;
            scanf("%d:%d:%d",&hs,&ms,&ss);
            scanf("%d:%d:%d",&he,&me,&se);
            v[hs*3600+ms*60+ss]++;
            v[he*3600+me*60+se]--;
        }

        int ans=0;
        rep(i,0,t){
            v[i+1]+=v[i];
            /*if(ans<v[i+1]){
                int ii=i;
                cout<<i/3600<<" "<<(i%3600)/60<<" "<<(i%60)<<endl;
            }*/
            ans=max(ans,v[i+1]);
        }
        cout<<ans<<endl;

    }
    
    return 0;
}

/*
111000
011000
001000
000100
000110
000111
*/



Measured memory_bytes: 3496
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define db double
#define ld long double
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define int long long
 
const int N = 1e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;
 
 
signed main() { __
    // freopen("a.in", "r", stdin);
    // freopen("a.out", "w", stdout);
    int n;
    cin>>n;
    int ans = (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int ans=0;
  cin>>s;
  SFOR(i,1,s.size()){
    if(s[i]!=s[i-1]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 512
using System;

public static class Program
{
  static int[] fib = new int[100];
  
  public static void Main(string[] args)
  {
    int input = int.Parse(Console.ReadLine());
    int output = Fib(input);
    
    Console.WriteLine(output);
  }
  
  public static int Fib(int n)
  {
    if(n == 0) return fib[0] = 1;
    if(n == 1) return fib[1] = 1;
    
    if(fib[n] == 0)
    {
      return fib[n] = Fib(n - 2) + Fib(n - 1);
    } 
    else
    {
      return fib[n];
    }
  }
}


Measured memory_bytes: 9164
N,M = map(int,input().split())
L = list(map(int,input().split()))
if N >= M :
    ans = 0
else :
    L = sorted(L)
    A = []
    for i in range(M-1) :
        A.append(L[i+1]-L[i])
    A = sorted(A)
    ans = sum(A[:M-N])
print(ans)


Measured memory_bytes: 13960
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100100;
int a[maxn];
long long sum[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	int ans=0;
	for(int i=n;i>=1;i--){
		if(sum[i]*2>=a[i+1])
			ans++;
		else break;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int gcd(int x, int y) {
  while (x > 0 && y > 0) {
    if (x > y) x %= y;
    else y %= x;
  }
  return x+y;
}


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

  int n;
  cin >> n;
  vector<int> A(n), l(n+1, 0), r(n+1, 0);
  for (auto &a : A) cin >> a;

  for (int i = 1; i <= n; ++i) {
    l[i] = gcd(l[i-1], A[i-1]);
    r[n-i] = gcd(r[n-i+1], A[n-i]);
  }

  int res = 0, tmp;
  for (int i = 0; i < n; ++i) {
    tmp = gcd(l[i], r[i+1]);
    if (tmp > res) res = tmp;
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, x;
  cin >> n >> m >> x;
  V<int> cost(n);
  V<V<int>> A(n, V<int>(m));
  REP(i, n) {
    cin >> cost[i];
    REP(j, m) cin >> A[i][j];
  }
  i64 INF = 1LL << 50;
  i64 ans = INF;
  for (int s = 0; s < (1LL << n); ++s) {
    i64 csum = 0;
    V<int> comp(m);
    REP(i, n) {
      if (s & (1 << i)) {
        csum += cost[i];
        REP(j, m) { comp[j] += A[i][j]; }
      }
    }

    bool ok = true;
    REP(j, m) {
      if (comp[j] < x) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans = min(ans, csum);
    }
  }

  cout << (ans == INF ? -1LL : ans) << endl;
}


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

int main(){
	int data[4][13] = {};
	int n, m, i, j;
	char c;
	cin >> n;
	for (i = 0; i<n; i++){
		cin >> c >> m;
		
		if (c == 'S'){ data [0][m] = 99; }
		else if (c == 'H'){ data[1][m] = 99; }
		else if (c == 'C'){ data[2][m] = 99; }
		else if (c == 'D'){ data[3][m] = 99; }
	}
	for (i = 0; i < 4; i++){
		for (j = 1; j < 14; j++){
			if (data[i][j] != 99){
				if (i == 0){ cout << "S" <<" "<< j << endl; }
				else if (i == 1){
					cout << "H" <<" "<< j << endl;
				}
				else if (i == 2){
					cout << "C" <<" "<< j << endl;
				}
				else if (i == 3){
					cout << "D" <<" "<< j << endl;
				}
			}
		}
	}
	return 0;
}

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

int main(){
 	int n,m,t;
	cin >>n >> m;
	int minimum = 1000000;
	for(int i = 0; i < n; i++) {
		cin >>  t;
      	m-=t;
      	if(minimum > t)
          	minimum = t;
	}
  	
  	cout << n+m/minimum << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string s, t; cin >> s >> t;
    map<char, char> ma, ima;
    bool ok = true;
    rep(i, s.size())
    {
        char c = s[i], f = t[i];
        if (ma.count(c)) if (ma[c] != f) ok = false;
        if (ima.count(f)) if (ima[f] != c) ok = false;
        ma[c] = f, ima[f] = c;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    vector<int> a(26,0),b(26,0);
    int n = s.size();
    rep(i,n) {
        a[s[i]-'a']++;
    }
    rep(i,n) {
        b[t[i]-'a']++;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(a == b) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 776
n = int(input())
S = list(map(int, input().split()))
S = list(set(S))
q = int(input())
T = list(map(int, input().split()))
T = list(set(T))

C = 0
for i in range(len(S)):
    if S[i] in T:
        C += 1
print(C)


Measured memory_bytes: 6548
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1001;
int id[MAXN],p[MAXN], q[MAXN], r[MAXN], c[MAXN];
int lp, lq, lr, lc;

int main()
{
    int n;
    while(cin >> n && n)
    {
        REP(n){cin >>id[i] >> p[i] >> q[i] >> r[i]; c[i] = p[i]*4 + q[i]*9 + r[i]*4;}
        cin >> lp >> lq >> lr >> lc;

        vector<int> ans;
        REP(n)if(lp >= p[i] && lq >= q[i] && lr >= r[i] && lc >= c[i])ans.push_back(id[i]);

        REP(ans.size())cout << ans[i] << endl;

        if(ans.empty()) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 932
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            
            String[] str = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            long max=long.MinValue, min=long.MaxValue, sum=0;

            for(int i =0;i<n;i++){
                a[i] =long.Parse(str[i]);
                sum = sum + a[i];
            }
            for (int i = 0; i < n; i++)
            {
                if (n == 1) {
                    min=a[0];
                    max=a[0];
                    sum=a[0];

                }
                if (max < a[i])
                    {
                     max = a[i];
                  }
                if (min > a[i])
                  {
                       min = a[i];
                  }
                
            }
            Console.WriteLine(min+" "  + max+" " + sum);

           
           




        }
    }
}

Measured memory_bytes: 6428
import sys
from collections import deque, defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        edges = defaultdict(set)
        for _ in range(M):
            a, b = map(int, input().split())
            edges[a].add(b)
            edges[b].add(a)

        deq = deque()
        deq.append((1, 1, {1}))

        ans = 0
        while deq:
            node = deq.popleft()
            node_num = node[0]
            cnt = node[1]
            already = node[2]

            if cnt == N:
                ans += 1
                continue

            already.add(node_num)

            for n in edges[node_num]:
                if n not in already:
                    deq.append((n, cnt + 1, already.copy()))

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 6124
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin (aka white_space)
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
//#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<double,pair<ll,ll> >&a,
               const pair<double,pair<ll,ll> >&b)
{
        if(a.first==b.first) return a.second.first<b.second.first;
       return (a.first > b.first);
}
int main()
{
  //  IOS
    int n,m,x;
    while(cin>>n>>m>>x){
        //vector<pair<ll,ll> > vp[m];
        ll cost[n];
        ll arr[n][m];
        for(int i=0;i<n;i++){
            cin>>cost[i];
            for(int j=0;j<m;j++){
                cin>>arr[i][j];
            }
        }
        ll res=highest(ll);
        for(int bit=0;bit<(1<<n);bit++){
            int temp[m];
            ms(temp);
            ll price=0;
            for(int i=0;i<n;i++){
                if((bit>>i)& 1){
                    price+=cost[i];
                    for(int j=0;j<m;j++){
                        temp[j]+=arr[i][j];
                    }
                }
            }
            bool ok=1;
            for(int i=0;i<m;i++){
                if(temp[i]<x){
                    ok=0;
                    break;
                }
            }
            if(ok)res=min(res,price);
        }
        if(res==highest(ll))cout << "-1\n";
        else cout << res << endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n; cout<<n*n*n<<endl;
}

Measured memory_bytes: 3632
//Not
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int x;
    cin >> x;
    if (x == 0) {
        cout << "1" << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}

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

int main() {
  
  int tate, yoko;
  cin >> tate >> yoko;
  
  vector<string> a(tate);
  
  for (int i =0; i < yoko + 2; i++) {
    cout << "#";
  }
  
  cout << endl;
  
  for (int i = 0; i < tate; i++) {
    cin >> a.at(i);
    cout << "#" << a.at(i) << "#" << endl;
    }
  
  for (int i =0; i < yoko + 2; i++) {
    cout << "#";
  }
 
  cout << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int c1, c2, c3, c4, c5, c6;

int main()
{
	in >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
	auto sum = c1 + c2 * 5 + c3 * 10 + c4 * 50 + c5 * 100 + c6 * 500;
	out << (sum >= 1000 ? 1 : 0) << std::endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    queue<P> q, q_next;
    vector<vector<int>> dist(h, vector<int>(w, -1)), ok(h, vector<int>(w, -1));
    if (s[0][0] == '.') dist[0][0] = 0;
    else dist[0][0] = 1;
    q_next.push(make_pair(0, 0));
    while(!q_next.empty()){
        P pos = q_next.front(); q_next.pop();
        int px = pos.first, py = pos.second;
        if (ok[py][px] == 1) continue;

        char c = s[py][px];
        ok[py][px] = 1;
        q.push(pos);
        while(!q.empty()){
            P p = q.front(); q.pop();
            int sx = p.first, sy = p.second;
            rep(i,2){
                int x = sx+dx[i], y = sy+dy[i];
                if (x >= w || y >= h) continue;
                if (ok[y][x] == 1) continue;
                if (s[y][x] == c){
                    q.push(make_pair(x, y));
                    ok[y][x] = 1;
                    dist[y][x] = dist[sy][sx];
                }else{
                    q_next.push(make_pair(x, y));
                    ok[y][x] = 0;
                    if (c == '.') dist[y][x] = dist[sy][sx] + 1;
                    else dist[y][x] = dist[sy][sx];
                }
            }
        }
    }
    cout << dist[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 3760
using System;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string[,] trump = new string[4, 13];
            bool[,] judge = new bool[4,13];
            int o = int.Parse(n);
            for (int i = 0; i < o; i++)
            {
                String[] input = Console.ReadLine().Split(' ');
                int j = int.Parse(input[1]);

                switch (input[0])
                {
                    case "S":
                        judge[0, j-1] = true;
                        break;
                    case "H":
                        judge[1, j - 1] = true;
                        break;
                    case "C":
                        judge[2, j-1 ]= true;
                        break;
                    case "D":
                        judge[3, j-1 ]= true;
                        break;
                }
            }

            
            string suit = " ";
            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 13; y++)
                {
                    if (judge[x, y] == false)
                    {
                        switch (x)
                        {
                            case 0:
                                suit = "S";
                                break;
                            case 1:
                                suit = "H";
                                break;
                            case 2:
                                suit = "C";
                                break;
                            case 3:
                                suit = "D";
                                break;
                        }
                        trump[x, y] = suit + " " + (y + 1);
                        Console.WriteLine(trump[x, y]);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9192
import math

EPS = 1e-10

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Segment():
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, point):
        # + 演算子での挙動を指定
        return Point(self.x+point.x, self.y+point.y)

    def __sub__(self, point):
        # - 演算子での挙動を指定
        return Point(self.x-point.x, self.y-point.y)

    def __mul__(self, a):
        # * 演算子での挙動を指定
        return Point(a*self.x, a*self.y)

    def __truediv__(self, a):
        # / 演算子での挙動を指定
        return Point(self.x/a, self.y/a)

    def __abs__(self):
        # abs関数での挙動を指定
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2+self.y**2

    def __eq__(self, point):
        # == 演算子での挙動を指定
        return abs(self.x-point.x) < EPS and abs(self.y-point.y) <EPS

def dot(a, b):
    return a.x*b.x+a.y*b.y

def cross(a, b):
    return a.x*b.y - a.y*b.x

def isOrthogonal(a, b):
    return dot(a, b) == 0

def isParallel(a, b):
    return cross(a, b) == 0

def project(s, p):
    #s: Segment(), p: Point()
    base = s.p2 - s.p1
    r = dot(p-s.p1, base)/base.norm()
    return s.p1+base*r

def reflect(s, p):
    return p+(project(s, p)-p)*2

def get_distance(a, b):
    return abs(a-b)

def get_distance_lp(l, p):
    return abs(cross(l.p2-l.p1, p-l.p1)/abs(l.p2-l.p1))

def get_distance_sp(s, p):
    if dot(s.p2-s.p1, p-s.p1) < 0:
        return abs(p-s.p1)
    if dot(s.p1-s.p2, p-s.p2) < 0:
        return abs(p-s.p2)
    return get_distance_lp(s, p)

def intersect(s1, s2):
    return True
    
def get_distance(s1, s2):
    if intersect(s1, s2):
        return 0
    return min([get_distance_sp(s1, s2.p1), get_distance_sp(s1, s2.p2),
                get_distance_sp(s2, s1.p1), get_distance_sp(s2, s1.p2)])

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if cross(a, b) > EPS:
        return COUNTER_CLOCKWISE
    if cross(a, b) < -EPS:
        return CLOCKWISE
    if dot(a, b) < -EPS:
        return ONLINE_BACK
    if a.norm() < b.norm():
        return ONLINE_FRONT
    return ON_SEGMENT

from functools import singledispatch
@singledispatch
def intersect(p1, p2, p3, p4):
    return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0
            and ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0)

@intersect.register(Segment)
def _(s1, s2):
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2)


if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    

    q = int(input())
    for _ in range(q):
        x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
        p0 = Point(x0, y0)
        p1 = Point(x1, y1)
        p2 = Point(x2, y2)
        p3 = Point(x3, y3)
        s1 = Segment(p0, p1)
        s2 = Segment(p2, p3)
        if intersect(s1, s2):
            print(1)
        else:
            print(0)


Measured memory_bytes: 6560
#include <iostream>

using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    --A; --B;

    cout << "100 100" << endl;
    for(int i=0; i<50; i++) {
        for(int j=0; j<100; j++) {
            if(i%2 && j%2 && A) {
                cout << '.';
                --A;
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
    for(int i=0; i<50; i++) {
        for(int j=0; j<100; j++) {
            if(i%2 && j%2 && B) {
                cout << '#';
                --B;
            } else {
                cout << '.';
            }
        }
        cout << endl;
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int K, N;
	cin >> K >> N;

	vector <int> A(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

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

	int maxDist = 0;
	// int maxIdx = -1;
	for (int ii = 0; ii < N-1; ++ii){
		int tmp = A[ii+1] - A[ii];
		if (tmp > maxDist){
			maxDist = tmp;
			// maxIdx = ii;
		}
	}
	int tmp = A[0] + K - A[N-1];
	if (tmp > maxDist){
		maxDist = tmp;
		// maxIdx = ii;
	}

	cout <<  K - maxDist << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EigenFunk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AHitachiString solver = new AHitachiString();
        solver.solve(1, in, out);
        out.close();
    }

    static class AHitachiString {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String hi = in.nextLine();
            boolean itIs = true;
            if (hi.length() % 2 == 1) {
                itIs = false;
            }
            for (int i = 0; i < hi.length() / 2; i++) {
                if (!hi.substring(i * 2, i * 2 + 2).equals("hi")) {
                    itIs = false;
                    break;
                }
            }
            if (itIs) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
# input
n = int(input())
t = list(map(int, input().split()))
s = sum(t)
m = int(input())
for i in range(m):
    o = 0
    p, x = map(int, input().split())
    o = s-t[p-1]+x
    print(o)

Measured memory_bytes: 3060
cnt = [0 for i in range(5)]
for i in range(3):
    temp = list(map(int,input().split()))
    cnt[temp[0]]+=1
    cnt[temp[1]]+=1
flg = 1
for i in range(1,5):
    if cnt[i] > 2:
        flg = 0
if flg == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int64_t b[200000000]={0};
int64_t a[2000000];
int main()
{
   int64_t n;
   scanf("%lld",&n);

   int64_t i;
   int64_t sum=0;
   for(i=1;i<=n;i++)
   {
       scanf("%lld",&a[i]);
       if(a[i]<=i)  b[(i-a[i])]++;
   }
   for(i=1;i<=n;i++)
    if(a[i]+i<2000000) sum=sum+b[a[i]+i];

   cout<<sum<<endl;
    return 0;
}

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

int main() {
  
  vector<int> vec(100);
  int N , M , S ;
  S = 0;
  cin >> N;
  for (int i = 0; i < 10; i++) {
    cin >> vec.at(i);
  }
    if (vec.at(0) < vec.at(1)) 
      M = vec.at(1);
    else M = vec.at(0);
  
  for (int i = 0; i < 10; i++) {
    if (M < vec.at(i+2))
      M=vec.at(i+2);
    else ;
  }
  
  for (int i = 0; i < 10; i++) {
    S = S + vec.at(i);
  }
  if ( 2*M < S ) cout << "Yes" ;
    else cout << "No" ;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class A
{
    static void Main(string[] args)
    {
        int ans;
        while (true)
        {
            ans = 0;
            int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (s[0] == s[1] && s[0] == 0) { break; }
            for (int i = 1; i <= s[0]; i++)
            {
                for (int k = 1; k <= s[0]; k++)
                {
                    for (int m = 1; m <= s[0]; m++)
                    {
                        if (i + k + m == s[1] && i != m && m != k && i != k)
                        {
                            ans++;
                        }
                    }
                }

            }
            Console.WriteLine(ans/6);
        }
    }
}

Measured memory_bytes: 9536
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll n;
  cin >> n;
  vector<ll> v(n);
  reps(i,n){
	  reps(j,n){
		  if(i*j>n)break;
		  else{
			  v[i*j-1]++;
		  }
	  }
  }
  ll ans =0;
  reps(i,n){
	  ans += i*v[i-1];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll X;
ll P[51], sum[51];

ll Solve(int L, ll turn){
  if (turn == sum[L]) return P[L];
  if (turn <= 1) return 0;
  
  if (turn == sum[L-1] + 2) return P[L-1] + 1;
  if (turn > sum[L-1] + 2) return P[L-1] + 1 + Solve(L-1, turn - sum[L-1] - 2);
  return Solve(L-1, turn-1);
}

int main(){
  cin >> N >> X;
  P[0] = 1; sum[0] = 1;
  for (int i = 1; i <= N; i++){
    P[i] = P[i-1] * 2 + 1;
    sum[i] = sum[i-1] * 2 + 3;
  }
  cout << Solve(N, X) << endl;
  
  return 0;
}


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

void fnInput(vector<int>& rvnNum)
{
  for (int& rnElm : rvnNum)
    cin >> rnElm;
}

int fnSameIntTimes(const vector<int>& cnrvnNum)
{
  auto itMaxNum = max_element(begin(cnrvnNum), end(cnrvnNum));

  int  nSum = 0;
  for (int nElm : cnrvnNum)
    nSum += nElm;

  int nSameIntTimes;
  if (*itMaxNum * 3 % 2 == nSum % 2)               // ３数の最大値×３と３数の和のパリティが等しい
    nSameIntTimes = (*itMaxNum * 3 - nSum) / 2;      // ３数の最大値が３数が等しくなる数
  else                                             //  上記以外
    nSameIntTimes = ((*itMaxNum + 1) * 3 - nSum) / 2;// ３数の最大値＋１が３数の等しくなる数

  return nSameIntTimes;
}

int main()
{
  vector<int> vnNum(3);

  fnInput(vnNum);
  cout << fnSameIntTimes(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 256
def read_inputs
  data_sets = []
  loop do
    cards = gets.chomp
    break if cards == "-"
    m = gets.to_i
    shuffle_counts = (1..m).map {gets.to_i}
    data_sets << DataSet.new(cards, shuffle_counts)
  end
  data_sets
end

class DataSet
  def initialize(cards, shuffle_counts)
    @cards = cards
    @shuffle_counts = shuffle_counts
  end

  def shuffle
    @shuffle_counts.reduce(@cards.split("")) {|a, x|
      a.slice(x, a.length) + a.slice(0, x)
    }.join("")
  end
end

data_sets = read_inputs
puts data_sets.map {|ds| ds.shuffle}.join("\n")

Measured memory_bytes: 8720
using System;

namespace AtCoder {
    class Tag {
        public static void Main(string[] args) {
            var parts = Console.ReadLine().Split(' ');
            long A = long.Parse(parts[0]);
            long V = long.Parse(parts[1]);
            parts = Console.ReadLine().Split(' ');
            long B = long.Parse(parts[0]);
            long W = long.Parse(parts[1]);
            long T = long.Parse(Console.ReadLine());

            if (W >= V) {
                Console.WriteLine("NO");
            } else if (Math.Abs(A - B) <= (V - W) * T) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 17772