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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int num=0;
	REP(i,3){
		if(S[i]=='1') num++;
	}
	
	out(num);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,m;
	while(scanf("%d%d",&n,&m)==2 && (n|m)!=0) {
		int i;
		int nowa;
		int mina,mintime;
		int tantou;
		mina=10000;mintime=10000;
		tantou=n-1;
		for(i=0;i<n;i++) {
			int sinsei;
			scanf("%d",&nowa);
			sinsei=mintime;
			if(mintime%nowa!=0)sinsei+=nowa-mintime%nowa;
			if(sinsei==mintime && (nowa<mina || (nowa==mina && i==n-1))) {
				sinsei+=nowa;
			}
			if(sinsei>m)sinsei=m-m%nowa;

			if(sinsei<mintime) {
				mintime=sinsei;
				mina=nowa;
				tantou=i;
			} else if(sinsei==mintime) {
				if(nowa<mina) {
					mintime=sinsei;
					mina=nowa;
					tantou=i;
				} else if(nowa==mina) {
					tantou=n-1;
				}
			}
		}
		printf("%d\n",tantou+1);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll A[100000];
ll s[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N) cin>>A[i];
    sort(A,A+N);
    rep(i,0,N) s[i+1]=s[i]+A[i];
    ll ans=0;
    rer(i,N,0){
        if(A[i]<=2*s[i]) ans++;
        else break;
    }
    cout <<ans+1<<"\n";
}

Measured memory_bytes: 1792
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a,b):
    g = gcd(a,b)
    return  a*b//g

def lcm_n(arr):
    l = arr[0]
    for i in range(len(arr)-1):
        l = lcm(l,arr[i+1])
    return l

N = int(input())
arr = list(map(int,input().split()))

g = lcm_n(arr)-1
out = 0


for i in arr:
    out += g%i

print(out)

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, cnt = 0;
    scanf("%d", &n);
    while(n>0){
        if(n % 10 == 2){
            cnt++;
        }
        n /= 10;
    }
    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define MIN(x,y)	((x)<(y)?(x):(y))
#define ABS(x)		((x)<0 ? -(x):(x))
int main(){
  int n,min=999;
  char s[10+1]={0};
  scanf("%s",s);
  n = strlen(s);
  for(int i=0; i<n-2; i++){
    int tmp=0;
    for(int j=0; j<3; j++){
      tmp = tmp*10 + (s[i+j]-'0');
    }
    min = MIN( min, ABS(tmp-753) );
  }
  printf("%d",min);
  return 0;
}

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

int main(){
    vector<int> num(3);
    for(int i = 0; i < 3; i++){
        cin >> num[i];
    }
    sort(num.begin(), num.end());
    cout << num[0] * num[1] * 0.5 << endl;
    return 0;
}

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

int n;
int v[110], w[110];

int memo[110][11000];

int solve(int i, int ww){
  if(i == n){
    return 0;
  }

  if(memo[i][ww] != -1){
    return memo[i][ww];
  }

  int ans = solve(i+1, ww);

  if(ww-w[i] >= 0){
    ans = max(ans, solve(i,ww-w[i])+v[i]);
  }

  return memo[i][ww] = ans;
}

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

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

  memset(memo, -1, sizeof(memo));

  cout << solve(0, ww) << endl;

  return 0;
}


Measured memory_bytes: 8188
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,k; string s; cin >>n >>k >>s;
  s[k-1]+=32;
  cout <<s;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

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

int main() {
  string S, T, U; cin >> S >> T >> U;
  char dif = 'A' - 'a';
  printf("%c%c%c\n", S[0] + dif, T[0] + dif, U[0] + dif);
  return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c,d,e,f = inpl()
water = set()
sugar = set()
for i in range(f//(a*100)+10):
    for j in range(f//(b*100)+10):
        w = a*100*i + b*100*j
        if w > f:
            break
        water.add(w)
for i in range(f//c+10):
    for j in range(f//d+10):
        s = c*i + d*j
        if s > f:
            break
        sugar.add(s)
water = sorted(list(water))
sugar = sorted(list(sugar))
# print(water)
# print(sugar)

max_cons = 0
res_to = a*100
res_s = 0
for w in water:
    for s in sugar:
        if w+s > f:
            break
        if w == 0 and s == 0:
            continue
        cons = s/(w+s)
        # print(w,s)
        if cons > e/(100+e):
            continue
        if cons > max_cons:
            res_to = w+s
            res_s = s
            max_cons = cons
print(res_to,res_s) 


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

#define endl '\n'

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

    int n,k; cin >> n >> k;
    int ans = 0;
    while(n){
        ans++;
        n /= k;
    }
    cout << ans << endl;
}

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

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int a,b,c ;
    cin >> a >> b >> c ;
    int na,nb,nc ;
    int ans = 0 ;
    while (1)
    {
        if (a%2 != 0 || b%2 != 0 || c%2 != 0)
        {
            cout << ans << endl ;
            return 0 ;
        }
        na = b/2 + c/2 ;
        nb = c/2 + a/2 ;
        nc = a/2 + b/2 ;
        if (a == na && b == nb && c == nc )
        {
            cout << -1 << endl ;
            return 0 ;
        }else
        {
            ans ++ ;
            a = na ;
            b = nb ;
            c = nc ;
        }
        
        
    }
        
}

Measured memory_bytes: 256
N = int(input())
numbers = [x for x in map(int, input().split())]
count = 0
on = True
while on:
  val = [x % 2 == 0 for x in numbers]
  if False in val:
    print(count)
    break
  else:
    numbers = [x//2 for x in numbers]
    count += 1

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int cnt[26] = {};
    char str[100];
    bool res = true;

    scanf("%s", str);
    for(char* i=str; *i != '\0'; i++){
        cnt[*i - 'a'] += 1;
        if(cnt[*i - 'a'] > 1){
            res = false;
        }
    }

    if(res){
        printf("yes\n");
    }else{
        printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N = readline()
A = list(map(int,readline().split()))

setA = len(set(A))


        
if setA == len(A):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 76292
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 1000009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
     ll n,k,i,j;
     cin>>n>>k;
     double a,b,s=0,r;
     f(i,n)
     {
        cin>>a>>b;


        r=sqrt(a*a+b*b);

        if(r<=k)
            s++;
     }
     cout<<s<<endl;

}













Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	double count = n*(n-1)/2.0;
	int point[n] = {0}, temp[n], temp2[n], temp3[n], x = 1, y = 0;
	for (int i = 0; i <count; i++){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if (c == d){
			point[a-1]++;
			point[b-1]++;
		}else if (c > d){
			point[a-1] += 3;
		}else {
			point[b-1] += 3;
		}
	}
	for (int i = 0; i < n; i++){
		temp[i] = point[i];
	}
	sort(temp, temp+n);
	for (int i = 0; i < n; i++){
		temp2[i] = temp[n-1-i];
	}
	for (int i = 0; i < n; i++){
		temp[i] = temp2[i];
	}
	for (int i = 0; i < n; i++){
		if (temp[i] == temp[i+1]){
			temp2[i] = x;
			y++;
		}else {
			x += y;
			y = 0;
			temp2[i] = x;
			x++;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (point[i] == temp[j]){
				temp3[i] = temp2[j];
				break;
			}
		}
	}
	for (int i = 0; i < n; i++)
		printf("%d\n",temp3[i]);
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >>S;
	int count[4]{ 0,0,0,0 };
	for (int i = 0;i < 4;i++) {
		for (int ii = 0;ii <= S.length();ii++) {
			if (S[i] == S[ii]) {
				count[i]++;
			}
		}
	}


	for (int i = 0;i < 4;i++)
	{
		if (count[i] != 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double PI = 3.14159265358979;
  double beta = m / 60 * 2 * PI;
  double alpha = (h * 60 + m) / 720 * 2 * PI;
  double theta = abs(alpha - beta);

  // ANS(alpha);
  // ANS(beta);
  // ANS(theta);

  double c2 = a * a + b * b - 2 * a * b * cos(theta);
  cout << fixed << setprecision(12) << sqrt(c2) << endl;

  return 0;
}


Measured memory_bytes: 4212
#include <stdio.h>
#include <stdlib.h>

struct Node {
    int key;
    Node *parent;
    Node *left;
    Node *right;
};
Node *root;
Node *NIL;
int m;

void insert( int key ) {
    Node *p_x = root;
    Node *p_y = NIL;
    Node *p_z = (Node *)malloc( sizeof(Node) );
    p_z->parent = p_z->left = p_z->right = NIL;
    p_z->key = key;

    while ( p_x != NIL ) {
	p_y = p_x;
	if ( p_z->key < p_x->key ) p_x = p_x->left;
	else p_x = p_x->right;
    }

    p_z->parent = p_y;
    if ( p_y == NIL ) root = p_z;
    else if ( p_z->key < p_y->key ) p_y->left = p_z;
    else p_y->right = p_z;
}

Node* find( int key ) {
    Node *x = root;
    
    while ( x != NIL && key != x->key ) {
	if ( key < x->key ) x = x->left;
	else x = x->right;
    }
    
    return x;
}

void preOrder(Node *p_cur) {
    if ( p_cur == NIL ) return;

    printf( " %d", p_cur->key );
    preOrder( p_cur->left );
    preOrder( p_cur->right );

    return;
}



void inOrder(Node *p_cur) {
    if ( p_cur == NIL ) return;
    inOrder( p_cur->left );
    printf( " %d", p_cur->key );
    inOrder( p_cur->right );

    return;
}

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

    for ( int i = 0; i < m; i++ ) {
	char str[100];

	scanf(" %s", str);

	if ( str[0] == 'i' ) {
	    int d;

	    Node *p_z = (Node *)malloc( sizeof(Node) );
	    scanf("%d", &d);

	    insert( d );
	}
	else if ( str[0] == 'f' ) {
	    int d;
	    scanf("%d", &d);
	    if ( find( d ) == NIL ) printf("no\n");
	    else printf("yes\n");
	}
	else {
	    inOrder(root);
	    printf("\n");
	    preOrder(root);
	    printf("\n");
	}
    }

    return 0;
}

Measured memory_bytes: 38544
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;

vector<vector<int>> combi(int n,int r){
  vector<vector<int>> ret;
  vector<int> tmp;
  int ii,jj;
  int cnt;

  for(ii=0;ii<pow(2,n);ii++){

    cnt = 0;
    tmp.clear();
    for(jj=0;jj<n;jj++){

      if( ((ii >> jj) & 1) == 1){
        cnt++;
        tmp.push_back(jj);
      }
      else{

      }
    }
    if(cnt == r){
      ret.push_back(tmp);
    }
  }
  return ret;
  
}
bool check(vector<lll>* c,int k){
  lll ii,prev;
  lll cnt = 0;

  for(ii=0;ii<c->size();ii++){
    if(ii==0){
      prev = c->at(0);
      cnt++;
    }
    else{
      if(c->at(ii) > prev){
        prev = c->at(ii);
        cnt++;
      }
      
    }
  }

  if(cnt>=k){
    return true;
  }
  else{
    return false;
  }

}

int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n,k;
  vector<lll> a;
  vector<lll> aft;
  cin >> n >> k;
  a.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }

  vector<vector<int>> target;
  target = combi(n,k);
  lll min = LONG_LONG_MAX;
  lll sum;
  lll prev;
  lll up;
  up = 0;

  for(vector<int> t : target){
    sum = 0;
    up = 0;
    aft = a;
    for(ii=0;ii<t.size();ii++){
      
      if(ii != 0){

        if(a[t[ii]] <= prev){

          up = prev - a[t[ii]] +1;
          sum += prev - a[t[ii]] +1;
          
          //a[t[ii]] += prev - a[t[ii]] +1;
          

        }
        else{
          up = 0;
        }
      }

      prev = a[t[ii]] + up;
      aft[t[ii]] = prev;

      //cout << "a[" << t[ii] << "]" << a[t[ii]] << "prev" << prev <<  "up:" << up << endl;
    }
    //cout << "sum:" << sum << endl;
    
    if(sum < min && check(&aft,k)){
      min = sum;
    }
    //for(auto val : aft){
    //  cout << val << "\t" ;
    //}
    //cout << endl;
  }

  cout << min << endl;
  
  return 0;
  
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int m1=in(),d1=in(),m2=in(),d2=in();
    int ans=0;
    if(m1+1==m2)ans=1;
    cout<<ans<<endl;
}


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

const int MOD = 1000000007;
const int64_t INF = 1LL << 60;

int main()
{
    int cnt = 0;
    int K, S;
    cin >> K >> S;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u') {
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


// || 'e' || 'i' || 'o' || 'u'

Measured memory_bytes: 3552
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;

pii a[1005];
int anslist[10005];
int main(){
    int h,n;
    cin >> h >> n;
    rep(i,n){
        int atmp,btmp;
        cin >> atmp >> btmp;
        a[i] = mp(atmp,btmp);
    }

    rep(i,h+1) anslist[i] = 100000000;
    anslist[0] = 0;

    rep(i,h+1){
        rep(j,n){
            anslist[min(i+a[j].F,h)] = min(anslist[min(i+a[j].F,h)],anslist[i]+a[j].S);
        }
    }

    // rep(i,h+1){
    //     prints(anslist[i]);
    // }

    prints(anslist[h]);




    return 0;
}


Measured memory_bytes: 256
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll x; cin >> x;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	ll ans = 0;
	for(int i = 1; i <= n - 1; i++)
	{
		ll z = x - a[i-1];
		if(z<0)
		{
			ans += a[i-1]-x;
			a[i-1] = x;
			ans+=a[i];
			a[i]=0;
			continue;
		}
		ll tmp = max(0LL, a[i] - z);
		a[i] -= tmp;
		ans+=tmp;
		/*
		ll tmp = min(x-a[i-1],x-a[i+1]);
		if(tmp>=0)
		{
			//a[i] -> tmp
			ans += max(a[i]-tmp,0LL);
			a[i] = min(a[i],tmp);
			continue;
		}
		ans+=a[i];
		a[i] = 0;
		tmp = min(a[i-1],x);
		ans += a[i-1]-tmp;
		a[i-1] = tmp;
		*/
	}
	/*
	ll tmp = x-a[n-2];
	ll change = max(0LL, a[n-1]-tmp);
	ans+=change;
	*/
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var r = o.a();
  var d = o.a();
  var x = o.a();

  for (var i = 1; i <= 10; i++) {
    console.log(r * x - d);
    x = r * x - d;
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21320
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    long s[n],t[m];
    rep(i,n){
        cin >> s[i];
    }
    rep(i,m){
        cin >> t[i];
    }
    long long dp[n+2][m+2];
    rep(i,n+2){
        rep(j,m+2){
            dp[i][j] = 0;
        }
    }
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=1+dp[i+1][j]+dp[i][j+1];
                dp[i+1][j+1]%=MOD;
            }
            else{
                dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1]-dp[i][j]; 
                dp[i+1][j+1]%=MOD;
            }
        }
    }
    dp[n][m]+=1;
    dp[n][m]%=MOD;
    if(dp[n][m]<0) dp[n][m]+=MOD;
    cout << dp[n][m] << endl;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll ans_i = -1;
  ll ans_j = -1;
  ll ans_k = -1;
  for (ll i = 0; i <= n; ++i) {
    for (ll j = 0; j <= n; ++j) {
      ll k = n - (i + j);
      if (k < 0) continue;
      ll x = i*10000 + j*5000 + k*1000;
      if (x == y) {
        ans_i = i;
        ans_j = j;
        ans_k = k;
        break;
      }
    }
    if (ans_i >= 0) break;
  }

  cout << ans_i << " " << ans_j << " " << ans_k << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> A = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      A.add(sc.nextInt());
    }
    while (true) {
      Collections.sort(A);
      int ch = 0;
      while (A.remove((Integer) 0)) {
      }
      for (int i = 1; i < A.size(); i++) {
        A.set(i, A.get(i) % A.get(0));
        ch += A.get(i);
      }
      if (ch == 0) {
        System.out.println(A.get(0));
        return;
      }
      if (A.get(0) == 1) {
        System.out.println(1);
      }
    }
  }
}

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

using namespace std;

int main(void) {
  int N; long long ans = 0;
  cin >> N;
  
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
typedef long long int ll;

int main(void){

    int n, *list;
    int p = 0, q = 0;
    ll k, ps = 0, qs = 0;

    scanf("%d %lld", &n, &k);

    list = malloc(sizeof(int) * n);

    for(int i = 0; i < n; i++){
        scanf("%d", list+i);
    }
    
    //一つ目
    for(int i = 0; i < n;i++){
        for(int j = i; j < n;j++){
            if(list[i] > list[j]){
                ps += k;
            }
        }
    }

    //二つ目
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n;j++){
            if(list[i] > list[j]){
                qs += (k * (k - 1)) / 2;
                qs %= MOD;
            }
        }
    }

    printf("%ld", (ps+qs) % MOD);

    free(list);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
using namespace std;

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

    for(int i=0; i<3; i++){
        if(s[i]-'0' == 7){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            continue;

        }
    }
    cout << "No" << endl;


    return 0;
}


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

n_list = [111, 222, 333, 444, 555, 666, 777, 888, 999]

if n in n_list:
  print(n)

for i in range(len(n_list)):
  if i == 0 and n < n_list[0]:
    print(n_list[0])
  if n_list[i-1] < n < n_list[i]:
    print(n_list[i])

Measured memory_bytes: 3060
#include <stdio.h>

int main ()
{
	int i, N, v, A[100], j;
	
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf ("%d", &A[i]);
	}
	printf ("%d", A[0]);
	for (i = 1; i < N; i++) {
		printf (" %d", A[i]);
	}
	putchar ('\n');
	
	for (i = 1; i <= N - 1; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		
		printf ("%d", A[0]);
		for(j = 1; j < N; j++) {
			printf (" %d", A[j]);
		}
		putchar ('\n');
	}
	
	return 0;
}


Measured memory_bytes: 1928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			out.println("" + s.charAt(0) + (s.length() - 2) + s.charAt(s.length() - 1));
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 22228
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]

last=[0]*26

for d in range(1,D+1):
    choice=0
    cost=c[0]*(d-last[0])
    for i in range(1,26):
        if c[i]*(d-last[i])>cost:
            choice=i
            cost=c[i]*(d-last[i])
    last[choice]=d
    print(choice+1)

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

int main(){
    string s,t; cin >> s >> t;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3624
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      a: [i64; n]
   }
   let mut b = vec![0; n];
   b[0] = a[0];
   for i in 1..n {
      b[i] = b[i - 1] + a[i];
   }
   let mut ans = 1e15 as i64;
   for i in 0..n - 1 {
      ans = std::cmp::min(ans, (b[n - 1] - 2 * b[i]).abs());
   }
   println!("{}", ans);
}


Measured memory_bytes: 8444
N = int(input())
*A, = map(int, input().split())
flag = 1
cnt = 0
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            flag = 1
            cnt += 1
print(*A)
print(cnt)


Measured memory_bytes: 5604
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
ansx = 0
ansy = 0
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res <= 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)


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

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

    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j) cin >> a[i][j];
    }
    
    vector<pair<int, int>> snaked;
    for(int i = 0; i < h; ++i){
        if(i%2 == 0){
            for(int j = 0; j < w; ++j){
                snaked.push_back(make_pair(i+1, j+1));
            }
        }
        else{
            for(int j = w-1; j >= 0; --j){
                snaked.push_back(make_pair(i+1, j+1));
            }
        }
    }

    vector<vector<int>> res;
    pair<int, int> prev = make_pair(-1, -1);
    for(int i = 0; i < snaked.size(); ++i){
        int y = snaked[i].first - 1;
        int x = snaked[i].second - 1;

        if(prev.first == -1){
            if(a[y][x] % 2 == 1){
                prev = make_pair(y+1, x+1);
            }
        }
        else{
            res.push_back({prev.first, prev.second, y+1, x+1});
            if(a[y][x] % 2 == 1) prev = make_pair(-1, -1);
            else prev = make_pair(y+1, x+1);
        }

    }

    cout << res.size() << endl;

    for(int i = 0; i < res.size(); ++i){
        for(int j = 0; j < 3; ++j) cout << res[i][j] << " ";
        cout << res[i].back() << endl;
    }
}

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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

double solve(int n, vi adj[], int blk)
{
    int i, j;
    double e[n];
    F(i, 0, n)
        e[i] = 1e9;
    e[n - 1] = 0;
    for(i = n - 2; i >= 0; i--)
    {
        int num = adj[i].size();
        double sum = 0;
        double maxi = 0;
        for(auto j: adj[i])
        {
            sum += e[j];
            maxi = max(maxi, e[j]);
        }
        if(i == blk && num >= 2)
        {
            --num;
            sum -= maxi;
        }
        if(num == 0)
            continue;
        e[i] = (sum / num) + 1;
    }
    return e[0];
}


int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j, n, m;
    DI(n, m);
    vi adj[n];
    vii edges;
    F(i, 0, m)
    {
        int u, v;
        DI(u, v);
        --u; --v;
        edges.pb(mp(u, v));
        adj[u].pb(v);
    }
    double ans = solve(n, adj, -1);
    F(i, 0, n - 1)
        ans = min(ans, solve(n, adj, i));
    cout << setprecision(10) << ans << "\n";
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}


Measured memory_bytes: 7792
#include<iostream>
#include<cstdio>

using namespace std;

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

    int lun[2] = {0,0},din[2] = {0,0},mid[2] = {0,0};
    for(int i = 0; i < n; i++){
      int h,m,M;
      scanf("%d:%d %d",&h,&m,&M);
      int t = M-m;
      if(t < 0) t += 60;
      if(11<= h && h < 15){
	lun[0]++;
	if(t <= 8) lun[1]++;
      }else if(18 <= h && h < 21){
	din[0]++;
	if(t <= 8) din[1]++;
      }else if(21 <= h || 0 <= h && h < 2){
	mid[0]++;
	if(t <= 8) mid[1]++;
      }
     }
     
    cout << "lunch ";
    if(lun[0]) cout << 100*lun[1]/lun[0] << endl;
    else cout << "no guest" << endl;
    cout << "dinner ";
    if(din[0]) cout <<  100*din[1]/din[0] << endl;
    else cout << "no guest" << endl;
    cout << "midnight ";
    if(mid[0]) cout << 100*mid[1]/mid[0] << endl;
    else cout << "no guest" << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
n=gets.chomp.to_i
f=Array.new
p=Array.new
for m in 0..n-1
  f[m]=gets.to_s.split(" ").map{|s| s.to_i}
end
for m in 0..n-1
  p[m]=gets.to_s.split(" ").map{|s| s.to_i}
end

benm=-10**9
for b in 1..2**10-1
  count=Array.new
  ben=0

  for i in 0..n-1
    count[i]=0
  end

  for k in 0..9
    if b&2**k==2**k
      for i in 0..n-1
         count[i]+=f[i][k]
      end
    end
  end

  for i in 0..n-1
    ben+=p[i][count[i]]
  end

  if ben>benm
    benm=ben
  end

end

print benm


Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define N 2005
using namespace std;
vector<int> E[N],F[N];
int n,m,cnt,G[N][N],a[N],vis[N];
int gcd(int x,int y){ return x ? gcd(y%x,x) : y;}
void dfs(int t)
{
	int i; vis[t]=1;
	for(i=1;i<=n;i++)
		if(G[t][i]&&!vis[i])
			E[t].push_back(i),dfs(i);
}
void sol(int t)
{
	int i,p;
	if(t<=n) F[t].push_back(t);
	for(i=0;i<E[t].size();i++)
		sol(E[t][i]),reverse(F[E[t][i]].begin(),F[E[t][i]].end());
	while(1){
		p=0;
		for(i=0;i<E[t].size();i++){
			if(!F[E[t][i]].size()) continue;
			if(!p||F[E[t][i]][F[E[t][i]].size()-1]>F[p][F[p].size()-1]) p=E[t][i];
		  }
		if(!p) break;
		F[t].push_back(F[p][F[p].size()-1]);
		F[p].pop_back();
	  }
}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(gcd(a[i],a[j])!=1) G[i][j]=1;
	for(i=1;i<=n;i++){
		if(vis[i]) continue;
		E[n+1].push_back(i),dfs(i);
	  }
	sol(n+1);
	for(i=0;i<F[n+1].size();i++)
		printf("%d ",a[F[n+1][i]]);
	return 0;
}


Measured memory_bytes: 26752
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int D[31][31];
int c[501][501];
int cnt[3][31];

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

  int N, C;
  cin >> N >> C;
  REP(i, C) REP(j, C) cin >> D[i][j];
  REP(i, N) REP(j, N) cin >> c[i][j];

  REP(i, N) REP(j, N) cnt[(i+j+2)%3][c[i][j]-1]++;

  //cout << cnt[0] << " vs " << cnt[1] << " vs " << cnt[2] << endl;

  int ans = 1 << 30;  
  REP(i, C) REP(j, C) if(i != j) REP(k, C) if(i != k && j != k) {
      int tmp = 0;
      REP(l, C) tmp += D[l][i] * cnt[0][l];
      REP(l, C) tmp += D[l][j] * cnt[1][l];
      REP(l, C) tmp += D[l][k] * cnt[2][l];
      if(tmp < ans) ans=tmp;
    }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
int main() {
  int N = 1;
  int output;
  int ave = 0;
  vector<int> X;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int input = 0;
    cin >> input;
    X.push_back(input);
    ave += input;
  }
  ave = round(ave * 1.0f / N);
  output = 0;
  for(int i = 0; i < N; i++) {
    output += (X[i] - ave) * (X[i] - ave);
  }
  cout << output << endl;
  return 0;
}

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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    int N;
    cin >> N;
    bool ans = false;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2)
            cnt++;
        else
            cnt = 0;

        if (cnt == 3)
        {
            ans = true;
        }
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
def solve(word1, word2):
	n1, n2 = len(word1), len(word2)
	res = []
	
	for i in range(n1 - n2 + 1):
		cur_s = word1[i : i + n2]
		res.append(sum(cur_s[j] != word2[j] for j in range(len(cur_s))))
	
	return min(res)
  
s = input()
p = input()
print(solve(s, p))

Measured memory_bytes: 73328
class SegTreeMin:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        self.n = n
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = min(x, self.tree[i ^ 1])
            i >>= 1

    def get_min(self, a, b):
        """
        [a, b)の最小値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        # (k, l, r)
        # k   : 現在調べている区間のtree内index
        # l, r: kが表す区間の左右端index [l, r)
        q = [(1, 0, self.n2)]

        while q:
            k, l, r = q.pop()

            if a <= l and r <= b:
                result = min(result, self.tree[k])
                continue

            m = (l + r) // 2
            k <<= 1
            if a < m and l < b:
                q.append((k, l, m))
            if a < r and l < m:
                q.append((k + 1, m, r))

        return result

N,M = map(int,input().split())
edges = [list(map(int,input().split())) for i in range(M)]
edges.sort()

ST = SegTreeMin(N+1,10**15)
ST.update(0,0)

for i in range(M):
    min_ = ST.get_min(edges[i][0]-1,edges[i][1]-1)
    if min_+edges[i][2] < ST.get_min(edges[i][1]-1,edges[i][1]):
        ST.update(edges[i][1]-1,min_+edges[i][2])
if ST.get_min(N-1,N)!=10**15:
    print(ST.get_min(N-1,N))
else:print(-1)

Measured memory_bytes: 71512
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; string s, t, u; cin >> s >> t >> u;
	if (s[0] == 'a') { cout << 'A'; }
	if (s[0] == 'b') { cout << 'B'; }
	if (s[0] == 'c') { cout << 'C'; }
	if (s[0] == 'd') { cout << 'D'; }
	if (s[0] == 'e') { cout << 'E'; }
	if (s[0] == 'f') { cout << 'F'; }
	if (s[0] == 'g') { cout << 'G'; }
	if (s[0] == 'h') { cout << 'H'; }
	if (s[0] == 'i') { cout << 'I'; }
	if (s[0] == 'j') { cout << 'J'; }
	if (s[0] == 'k') { cout << 'K'; }
	if (s[0] == 'l') { cout << 'L'; }
	if (s[0] == 'm') { cout << 'M'; }
	if (s[0] == 'n') { cout << 'N'; }
	if (s[0] == 'o') { cout << 'O'; }
	if (s[0] == 'p') { cout << 'P'; }
	if (s[0] == 'q') { cout << 'Q'; }
	if (s[0] == 'r') { cout << 'R'; }
	if (s[0] == 's') { cout << 'S'; }
	if (s[0] == 't') { cout << 'T'; }
	if (s[0] == 'u') { cout << 'U'; }
	if (s[0] == 'v') { cout << 'V'; }
	if (s[0] == 'w') { cout << 'W'; }
	if (s[0] == 'x') { cout << 'X'; }
	if (s[0] == 'y') { cout << 'Y'; }
	if (s[0] == 'z') { cout << 'Z'; }
	if (t[0] == 'a') { cout << 'A'; }
	if (t[0] == 'b') { cout << 'B'; }
	if (t[0] == 'c') { cout << 'C'; }
	if (t[0] == 'd') { cout << 'D'; }
	if (t[0] == 'e') { cout << 'E'; }
	if (t[0] == 'f') { cout << 'F'; }
	if (t[0] == 'g') { cout << 'G'; }
	if (t[0] == 'h') { cout << 'H'; }
	if (t[0] == 'i') { cout << 'I'; }
	if (t[0] == 'j') { cout << 'J'; }
	if (t[0] == 'k') { cout << 'K'; }
	if (t[0] == 'l') { cout << 'L'; }
	if (t[0] == 'm') { cout << 'M'; }
	if (t[0] == 'n') { cout << 'N'; }
	if (t[0] == 'o') { cout << 'O'; }
	if (t[0] == 'p') { cout << 'P'; }
	if (t[0] == 'q') { cout << 'Q'; }
	if (t[0] == 'r') { cout << 'R'; }
	if (t[0] == 's') { cout << 'S'; }
	if (t[0] == 't') { cout << 'T'; }
	if (t[0] == 'u') { cout << 'U'; }
	if (t[0] == 'v') { cout << 'V'; }
	if (t[0] == 'w') { cout << 'W'; }
	if (t[0] == 'x') { cout << 'X'; }
	if (t[0] == 'y') { cout << 'Y'; }
	if (t[0] == 'z') { cout << 'Z'; }
	if (u[0] == 'a') { cout << 'A' << endl; }
	if (u[0] == 'b') { cout << 'B' << endl; }
	if (u[0] == 'c') { cout << 'C' << endl; }
	if (u[0] == 'd') { cout << 'D' << endl; }
	if (u[0] == 'e') { cout << 'E' << endl; }
	if (u[0] == 'f') { cout << 'F' << endl; }
	if (u[0] == 'g') { cout << 'G' << endl; }
	if (u[0] == 'h') { cout << 'H' << endl; }
	if (u[0] == 'i') { cout << 'I' << endl; }
	if (u[0] == 'j') { cout << 'J' << endl; }
	if (u[0] == 'k') { cout << 'K' << endl; }
	if (u[0] == 'l') { cout << 'L' << endl; }
	if (u[0] == 'm') { cout << 'M' << endl; }
	if (u[0] == 'n') { cout << 'N' << endl; }
	if (u[0] == 'o') { cout << 'O' << endl; }
	if (u[0] == 'p') { cout << 'P' << endl; }
	if (u[0] == 'q') { cout << 'Q' << endl; }
	if (u[0] == 'r') { cout << 'R' << endl; }
	if (u[0] == 's') { cout << 'S' << endl; }
	if (u[0] == 't') { cout << 'T' << endl; }
	if (u[0] == 'u') { cout << 'U' << endl; }
	if (u[0] == 'v') { cout << 'V' << endl; }
	if (u[0] == 'w') { cout << 'W' << endl; }
	if (u[0] == 'x') { cout << 'X' << endl; }
	if (u[0] == 'y') { cout << 'Y' << endl; }
	if (u[0] == 'z') { cout << 'Z' << endl; }
	cin >> n;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;
//Yesがなる条件はすべて∧で表示できる
if(r<=x&&(W-x)>=r&&r<=y&&(H-y)>=r){cout << "Yes" << endl;}
else{cout << "No" << endl;}
return 0;
}


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

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string n; cin >> n;
    for (auto c : n) {
        if (c == '1') cout << '9';
        else if (c == '9') cout << '1';
        else cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
void read(long long &x){
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=5e5+10;
char a[maxn];int ans,n,s[maxn],w[10];
int main(){
	scanf("%s",a+1);n=strlen(a+1);
	for(rg int i=1;i<=n;i++)s[i]=a[i]-'0';
	int k=0;
	for(rg int i=1;i<=n;i++){
		int las=n,d=i;
		if(s[k+1]>=s[k])k=0;
		for(rg int j=d+1;j<=n;j++){
			if(s[j]<s[j-1]){las=j-1;break;}
			if(k>=j&&s[j]==s[j-1]){las=j-1;break;}
		}
		if(las==n){ans++;break;}
		if(s[las]==s[las-1]){
			k=las;
			for(rg int j=las;j;j--)if(s[j]!=s[j-1]){las=j;break;}
		}
		ans++,s[n]++;
		int now=n;s[i]=s[las]=0;
		while(now&&s[now]>=10)s[now-1]+=s[now]/10,s[now]%=10,now--;
	    i=las;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a, b, c;
llong x;
llong ans;

int main() {
    cin >> a >> b >> c;
    cin >> x;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (i * 500 + j * 100 + k * 50 == x) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define INF 1e9

using namespace std;

int main() {
    int n, l = INF, r = 0, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        l = min(l, a);
        r = max(r, a);
    }
    cout << r - l << endl;
    return 0;
}


Measured memory_bytes: 256