akhauriyash/Code-Regression huggingface dataset:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < * ((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

typedef struct {
    size_t B;
    size_t C;
} _pair;

static size_t A[100000];
static _pair pair[100000];

int compare_p(const void* a, const void* b) {
    const _pair* aP = (_pair*)a;
    const _pair* bP = (_pair*)b;

    return aP->C > bP->C ? -1 : 1;
}

int main(void) {
    size_t N, M;

    scanf("%zu %zu\n", &N, &M);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(A[i]));
        scanf(i < N - 1 ? " " : "\n");
    }
    for (size_t i = 0; i < M; i++) {
        scanf("%zu %zu", &(pair[i].B), &(pair[i].C));
        if (i < M - 1) {
            scanf("\n");
        }
    }

    qsort(A, N, sizeof(size_t), compare_sz_asc);
    qsort(pair, M, sizeof(_pair), compare_p);

    size_t ofs = 0;
    bool cont = true;

    for (size_t i = 0; i < M && cont; i++) {
        for (size_t j = 0; j < pair[i].B && cont; j++) {
            if (A[ofs] < pair[i].C) {
                A[ofs] = pair[i].C;
            }
            else {
                cont = false;
            }
            ofs++;
        }
    }

    uint64_t sum = 0;

    for (size_t i = 0; i < N; i++) {
        sum += (uint64_t)(A[i]);
    }

    printf("%"PRIu64"\n", sum);

    return 0;
}


Measured memory_bytes: 4076
prime_sieve=[1 for i in range(200000)]

prime_sieve[0]=0
prime_sieve[1]=0

X=int(input())
for i in range(2,200000):
  if prime_sieve[i]==1:
    if i>=X:
      print(i)
      break
    else:
      for j in range(2,200000//i):
        prime_sieve[i*j]=0

Measured memory_bytes: 53104
while 1:
    s1 = input().split('"')
    l1 = len(s1)
    if s1[0] == ".": break
    s2 = input().split('"')
    l2 = len(s2)
    if l1 != l2:
        print("DIFFERENT")
        continue
    i = 0
    cnt = 0
    while 1:
        if s1[i] != s2[i]:
            print("DIFFERENT")
            break
        if i > l1-2:
            if cnt == 1:
                print("CLOSE")
                break
            else:
                print("IDENTICAL")
                break
        if s1[i+1] != s2[i+1]:
            if cnt == 1:
                print("DIFFERENT")
                break
            else: cnt = 1
        i += 2



Measured memory_bytes: 5576
import java.util.Scanner;
 
class Main {
 	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[ \t\n,]");

    public static void main(String[] args){

    double x = 0;
    double y = 0;
    int ang = 90;
    for(;;){
        int d = scan.nextInt();
        int a = scan.nextInt();
        if(d == 0 && a == 0)  break;
        x += d * Math.cos(Math.toRadians((double) ang));
        y += d * Math.sin(Math.toRadians((double) ang));
        ang -= a;
    }
    System.out.println((int)(x));
        System.out.println((int)(y));
     
    }
}

Measured memory_bytes: 25936
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  cout<<(n+1)/2<<endl;
}

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

from collections import Counter

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
A = np.array(read().split(),np.int32)

counter = np.bincount(A)
x = np.argmax(counter)
I,J = np.where(A == x)[0]

L = I
M = J - I - 1
R = N - J

# 長さ k での重複は、(L+R)C(k-1)

def cumprod(A, MOD = MOD):
    L = len(A); Lsq = int(L**.5+1)
    A = np.resize(A, Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        A[:,n] *= A[:,n-1]; A[:,n] %= MOD
    for n in range(1,Lsq):
        A[n] *= A[n-1,-1]; A[n] %= MOD
    return A.ravel()[:L]
def make_fact(U, MOD = MOD):
    x = np.arange(U, dtype = np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact,fact_inv

fact, fact_inv = make_fact(10 ** 5 + 100)

answer = fact[N+1] * fact_inv[:N+2] % MOD * fact_inv[:N+2][::-1] % MOD
LR = L + R
x = fact[LR] * fact_inv[:LR+1] % MOD * fact_inv[:LR+1][::-1] % MOD
answer[1:LR+2] -= x

answer = answer[1:]
answer %= MOD
print('\n'.join(answer.astype(str)))

Measured memory_bytes: 49408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		// split??§????????????????´?
		String[] strArray = str.split("");
		//String[] strArray = new String[str.length()]; 
		
		for (int i = 0; i < strArray.length; i++) {
			if(Character.isUpperCase(str.charAt(i))){
				//??§???????????¨???
				strArray[i] = strArray[i].toLowerCase();
			}else{
				strArray[i] = strArray[i].toUpperCase();
			}
		    System.out.print(strArray[i]);
		}
		System.out.println();
	}
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl; 
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int c[4] = {25, 10, 5, 1};
  int ans = 0;
  REP(i, 4) {
    int t = n / c[i];
    ans += t;
    n -= c[i] * t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3100
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
#include<queue>
using namespace std;


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

const int INF = 1001001001;
vector<int> to[100005];
int main()
{
    int n, m;
    cin >> n >> m;
    int s, t;
    for (int i = 0; i <m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int>pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF)continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if (i == 0)continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 10284
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,m,a,b;
vpi war;

signed main(){
    I(n); I(m);
    REP(i,m){
        I(a); I(b);
        a--; b--;
        war.eb(b,a);
    }
    sort(all(war), greater<pi>() );
    
    int ret = 0;
    int l = 0;
    int idx = 0;
    int ctr = 0;
    REPNS(i,n-1){
        if (l == i) {
            ret++;
            l = 0;
            ctr = 0;

        }
        for(; idx<m && war[idx].first == i; idx++){
            l = max(l,war[idx].second);
            ctr++;
        }
    }
    if (ctr) {
        ret++;
    }
    cout << ret << endl;
}

Measured memory_bytes: 2420
s = int(input())
a = s
l = [s]
for i in range(1000000):
    if a % 2 == 1:
        a = a * 3 + 1
    else:
        a = a / 2
    if a in l:
        print(i+2)
        break
    else:
        l.append(a)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int k, x;
    cin >> k >> x;
    k--;
    for (int i = -k; i <= k; i++) {
        cout << i + x << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {
    LL pw10 = 1, pw9 = 1, pw8 = 1;
    int n;
    cin >> n;
    for (int i=0;i<n;++i) {
        pw10 = (pw10 * 10) % MOD;
        pw9 = (pw9 * 9) % MOD;
        pw8 = (pw8 * 8) % MOD;
    }
    LL ans = (pw10 - 2 * pw9 + pw8) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
}

int main() {
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<math.h>
#include<iomanip>
#define PI 3.141592653589
using namespace std;
struct point{
    double x;
    double y=0.0;
};
int koch(int n,point p1,point p2);

int main(){
    vector<point> points;
    int n;
    cin>>n;
    point p1;
    p1.x=0.0;
    point p2;
    p2.x=100.0;
    printf("%.6f %.6f\n",p1.x,p1.y);
    // cout<<p1.x<<" "<<p1.y<<"\n";
    if(koch(n,p1,p2)==1){
        printf("%.6f %.6f\n",p2.x,p2.y );
    }
    
    // cout<<p2.x<<" "<<p2.y<<"\n";
}
int koch(int n, point p1, point p2){
    if (n==0){
        return 1;
    }
    point s,t,u;
    s.x=(2*p1.x+1*p2.x)/3.0;
    s.y=(2*p1.y+1*p2.y)/3.0;
    t.x=(1*p1.x+2*p2.x)/3.0;
    t.y=(1*p1.y+2*p2.y)/3.0;
    u.x=(t.x-s.x)*cos(60*PI/180)-(t.y-s.y)*sin(60*PI/180)+s.x;
    u.y=(t.x-s.x)*sin(60*PI/180)+(t.y-s.y)*cos(60*PI/180)+s.y;
    koch(n-1, p1, s);
    printf("%.6f %.6f\n",s.x,s.y);
    koch(n-1, s, u);
    // cout<<u.x<<" "<<u.y<<"\n";
    printf("%.6f %.6f\n",u.x,u.y);
    koch(n-1, u, t);
    // cout<<t.x<<" "<<t.y<<"\n";
    printf("%.6f %.6f\n",t.x,t.y);
    koch(n-1, t, p2);
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+5;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/
int dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


Measured memory_bytes: 87040
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n);
  x.sort((a,b)=>a[0]>b[0]?1:a[0]<b[0]?-1:a[1]-b[1]);
  var ans = n;
  for(var i = 0; i < n; i++){
    for(var j = i+1; j < n; j++){
      var a = xArray(0,n);
      var s = 0;
      var p = x[j][0]-x[i][0];
      var q = x[j][1]-x[i][1];
      for(var k = 0; k < n; k++){
        if(a[k])continue;
        s++;
        var tx = x[k][0];
        var ty = x[k][1];
        for(var l = k+1; l < n; l++){
          if(a[l])continue;
          if(x[l][0]-tx===p && x[l][1]-ty===q){
            a[l] = 1;
            tx = x[l][0], ty = x[l][1];
          }
        }
      }
      if(s < ans)ans = s;
    }
  }
  return ans;
}

Measured memory_bytes: 21192
#include <cstdio>
const int MAXN = 2e5+5;
int A[MAXN]{ };
int B[MAXN]{ };
int M, N;

int count_up(int i) {
  int sum = 0;
  for (int j = i; j <= N; j += i) {
    if (B[j]) sum ^= 1;
  }
  return sum;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
  }
  M = 0;
  for (int i = N; i >= 1; --i) {
    if (count_up(i) != A[i]) {
      B[i] = 1;
      ++M;
    }
  }
  printf("%d\n", M);
  for (int i = 1; i <= N; ++i) {
    if (B[i]) printf("%d ", i);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[2002];
ll dp[2002][2002][2];
int n;
ll dfs(int l,int r,bool t){
    if(l==r) return dp[l][r][t]=(t?0:a[l]);
    if(dp[l][r][t]!=-1) return dp[l][r][t];
    if(t){
        if(a[l]>a[r]) return dp[l][r][t]=dfs((l-1+n)%n,r,0);
        else return dp[l][r][t]=dfs(l,(r+1)%n,0);
    }
    else return dp[l][r][t]=max(dfs((l-1+n)%n,r,1)+a[l],dfs(l,(r+1)%n,1)+a[r]);
}
int main(){
    cin>>n;
    rep(i,n) cin>>a[i];
    memset(dp,-1,sizeof(dp));
    ll mx=0;
    rep(i,n){
        mx=max(mx,dfs((i-1+n)%n,(i+1)%n,1)+a[i]);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 65844
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] text = sc.next().toCharArray();

        char[] removedText = new char[text.length];
        Arrays.fill(removedText, ' ');
        int index = 0;
        int destIndex = -1;
        for (int i = 0; i < text.length; i++) {
            if (destIndex < 0 || text[i] == removedText[destIndex]) {
                removedText[++destIndex] = text[i];
            } else {
                removedText[destIndex--] = ' ';
            }
        }

        System.out.println(new String(text).length() - new String(removedText).trim().length());
    }
}

Measured memory_bytes: 27688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


int l[10];
int N,A,B,C;
int ans = 1000000;

int dfs(int cur,int a, int b, int c){
  if(cur == N){
    if(a*b*c == 0) return inf;
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }
  int ret1 = dfs(cur + 1,a+l[cur],b,c) + 10;
  int ret2 = dfs(cur + 1,a,b+l[cur],c) + 10;
  int ret3 = dfs(cur + 1,a,b,c+l[cur]) + 10;
  int ret4 = dfs(cur + 1,a,b,c);
  return min(min(ret1, ret2) ,min(ret3, ret4));
}
  



int main(){
  cin >> N >> A >> B >> C;
  rep(i,N) cin >> l[i];
  cout << dfs(0,0,0,0) << endl;
}


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

#define mp make_pair
#define pb push_back
#define mod (int)1e9+7
using namespace std;

set<int> s;
void func(int x,int lst,int n){
    s.insert(x);
    if(n >= 11) return;
    if(lst == 9){
        func(x*10+9,9,n+1);
        func(x*10+8,8,n+1);
        return;
    }
    if(lst == 0){
        func(x*10+0,0,n+1);
        func(x*10+1,1,n+1);
        return;
    }
    func(x*10+lst,lst,n+1);
    func(x*10+lst-1,lst-1,n+1);
    func(x*10+lst+1,1+lst,n+1);
    return;
}

signed main(){
    int n;
    cin >> n;
    for(int i =1;i<10;i++) func(i,i,1);
    n--;
    while(n--){
        s.erase(s.begin());
    }
    cout << *s.begin();
}


Measured memory_bytes: 30864
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  string s;
  cin >> s;
  s += s;
  string p;
  cin >> p;
  cout << (s.find(p) != string::npos ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3196
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int cnt [MAXN];
bool kek[MAXN];

int main() {
    int n = readInt(), m = readInt();
    for (int i = 1; i <= n; i++) {
        cnt[i] = 1;
    }
    kek[1] = 1;
    for (int i = 1; i <= m; i++) {
        int x = readInt(), y = readInt();
        kek[y] |= kek[x];
        if (cnt[x] == 1) {
            kek[x] = 0;
        }
        cnt[x]--;
        cnt[y]++;
    }
    int sum = 0;
    for (int i = 1; i <= n ;i++) {
        sum+=kek[i];
    }
    cout << sum;
}


Measured memory_bytes: 768
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def wszystkie_mozliwosci(N):
    if N==0:
        return [[]]
    poprzedni = wszystkie_mozliwosci(N-1)
    wynik = []
    for przyp in poprzedni:
        wynik.append(przyp + [False])
        wynik.append(przyp + [True])
    return wynik

def C():
    N = wczytaj_liste()[0]
    zeznania = []
    odp = 0
    for i in range(N):
        A = wczytaj_liste()[0]
        zeznania.append([])
        for j in range(A):
            x, y = wczytaj_liste()
            zeznania[-1].append((x-1,y))
    
    for czy_szczery in wszystkie_mozliwosci(N):
        dasie = True
        for i in range(N):
            if czy_szczery[i]:
                for x,y in zeznania[i]: 
                    if y == 1 and not czy_szczery[x]:
                        dasie = False
                    if y == 0 and czy_szczery[x]:
                        dasie = False
        if dasie:
            ile_szczerych = sum(czy_szczery)
            if ile_szczerych > odp:
                odp = ile_szczerych

    print(odp)
C()

Measured memory_bytes: 59100
N = int(input())
gA, sA, bA = map(int, input().split())
gB, sB, bB = map(int, input().split())

ans = 0

if gB > gA and sB > sA and bB > bA:
    for g in range(N // gA + 1):
        n = N - g * gA
        for s in range(n // sA + 1):
            m = n - s * sA
            b = m // bA
            m = m % bA
            ans = max(ans, g * gB + s * sB + b * bB + m)
elif gB > gA and sB > sA and bB <= bA:
    for g in range(N // gA + 1):
        n = N - g * gA
        for s in range(n // sA + 1):
            m = n - s * sA
            m = g * gB + s * sB + m
            b = m // bB
            m = m % bB
            ans = max(ans, b * bA + m)
elif gB > gA and sB <= sA and bB > bA:
    for g in range(N // gA + 1):
        n = N - g * gA
        for b in range(n // bA + 1):
            m = n - b * bA
            m = g * gB + b * bB + m
            s = m // sB
            m = m % sB
            ans = max(ans, s * sA + m)
elif gB <= gA and sB > sA and bB > bA:
    for s in range(N // sA + 1):
        n = N - s * sA
        for b in range(n // bA + 1):
            m = n - b * bA
            m = s * sB + b * bB + m
            g = m // gB
            m = m % gB
            ans = max(ans, g * gA + m)
elif gB > gA and sB <= sA and bB <= bA:
    g = N // gA
    n = N % gA
    n = g * gB + n
    for s in range(n // sB + 1):
        m = n - s * sB
        b = m // bB
        m = m % bB
        ans = max(ans, s * sA + b * bA + m)
elif gB <= gA and sB > sA and bB <= bA:
    s = N // sA
    n = N % sA
    n = s * sB + n
    for g in range(n // gB + 1):
        m = n - g * gB
        b = m // bB
        m = m % bB
        ans = max(ans, g * gA + b * bA + m)
elif gB <= gA and sB <= sA and bB > bA:
    b = N // bA
    n = N % bA
    n = b * bB + n
    for s in range(n // sB + 1):
        m = n - s * sB
        g = m // gB
        m = m % gB
        ans = max(ans, g * gA + s * sA + m)
else:
    for g in range(N // gB + 1):
        n = N - g * gB
        for s in range(n // sB + 1):
            m = n - s * sB
            b = m // bB
            m = m % bB
            ans = max(ans, g * gA + s * sA + b * bA + m)

print(ans)


Measured memory_bytes: 42684
fun main(args: Array<String>) {
     readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var map = mutableMapOf<Int, Int>()

    a.forEach {
        map[it] = (map[it] ?: 0) + 1
    }
    var sum = a.map { it.toLong() }.sum()

    val q = readLine()!!.toInt()
    repeat(q){
        val (b, c) = readLine()!!.split(" ").map { it.toInt() }
        val count = map[b] ?: 0
        sum += (count * (c - b))

        map[c] = (map[c] ?: 0) + count
        map[b] = 0

        println(sum)
    }
}



Measured memory_bytes: 70552
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

ll N;
ll A[200010], B[200010];
std::vector<P> ps;

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
  {
    scanf( "%lld%lld", A+i, B+i );
    ps.push_back( P( B[i], A[i] ) );
  }

  std::sort( all(ps) );

  ll p = 0;
  rep( i, N )
  {
    if( p+ps[i].second <= ps[i].first )
      p += ps[i].second;
    else
    {
      puts("No");

      return 0;
    }
  }

  puts("Yes");

  return 0;
}

Measured memory_bytes: 8432
n = int(input())
arr = list(map(int , input().split()))
mod = 10**9+7
h = [0 for i in range(0,n)]
for i in range(0,n):
	h[arr[i]]=h[arr[i]]+1
	if n%2==0 and arr[i]==0:
		print(0)
		exit()
ans=1
if n%2:
	for i in range(2 ,n, 2):
		if h[i]!=2:
			print(0)
			exit()
		ans = (ans*2)%mod
else:
	for i in range(1, n , 2):
		if h[i]!=2:
			print(0)
			exit()
		ans = (ans*2)%mod
print(ans)

Measured memory_bytes: 90004
#include <stdio.h>

int main()
{
  int a,b,c,d;
  scanf("%d %d %d ",&a,&b,&c);

 if( a > b )
 { 
   d = a;
   a = b;
   b = d;
 }
 
 if( b > c )
 { 
  d = b;
  b = c;
  c = d;
 }
 
  if( a > b )
 { 
   d = a;
   a = b;
   b = d;
 }

 printf("%d %d %d\n" ,a,b,c);

return 0;
}

 
 

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

int main(){
    
    int n, m; cin >> n >> m;
    vector<int> cnt(n, 0);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
    }

    bool flag = true;
    for(int i = 0; i < n; i++) if(cnt[i] % 2 == 1) flag = false;
    string ans;
    (flag) ? ans = "YES" : ans = "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

void insertionSort(int*,int);

int main()
{
  int n,i;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++)
  scanf("%d",&A[i]);

  insertionSort(A,n);
  return 0;
  
}

void insertionSort(int *A,int n)
{
  int i,j,key,p;

  for(p=0;p<n;p++)
    {
      if(p==n-1)
      printf("%d",A[p]);
      else
      printf("%d ",A[p]);
    }
      printf("\n");
  
  for(j=1;j<=n-1;j++)
    {
      key=A[j];
      /*A[j]をソート済みの列A[1..j-1]に挿入する*/
      i=j-1;

      while(i>=0&&A[i]>key)
	{
	  A[i+1]=A[i];
	  i=i-1;
	  A[i+1]=key;	  
	}
   for(p=0;p<n;p++)
     {
       if(p==n-1)
	 printf("%d",A[p]);
       else
      printf("%d ",A[p]);
     }
      printf("\n");
    }

}



Measured memory_bytes: 2124
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
using ll = long long;
#define max(a,b) ((a)>(b) ? (a):(b))
#define min(a,b) ((a)<=(b) ? (a):(b))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

int main(){
  ll N,K;
  cin >> N >> K;
  cout << (int)(log(N) / log(K)) + 1;
  return 0;
}



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

int a,b;

int main(){
  cin >> a >> b;
  int num;
  if(b==100) num=1000*a+b;
  else if(b>9) num=100*a+b;
  else num=10*a+b;

  for(int i=0; i<=sqrt((float)num); i++){
    if(i*i==num){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      String str = sc.next();
      int ans =0;
      for(int i=0;i<4;i++){
        if(str.charAt(i)=='+'){
          ans += 1; 
        }else{
          ans -= 1;
        }
      }
      System.out.println(ans);
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;


int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    if(A <= K)
    {
        K = K - A;
        A = 0;
        if(B <= K)
        {
            B = 0;
        } else
        {
            B = B - K;
        }
    } else
    {
        A = A - K;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,a;
int main()
{
    cin>>n>>a;
    n=n%500;
    if(n<=a)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string src = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, 16) if (src.at(i) != s.at(i)) cnt++;
    cout << cnt << endl;
}


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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter0(i, n) for (int i = 0; i < n; ++i)

const int N = 3;
const int mod = 1e9 + 7;

#define cM const Mat&

struct Mat {
	int a[N][N];

	Mat() { memset(a, 0, sizeof(a)); }

	int* operator[](int i) { return a[i]; }
	const int* operator[](int i) const { return a[i]; }
} I;

int n, m, a[101000];

int graph[N][N] = {
	{ 2, 1, 1 }, 
	{ 2, 1, 0 },
	{ 1, 1, 1 }
};

/*
	f[i] = \sum_k (k+1)^2 f[i-k]
	g[i] = \sum_k kf[i-k]
	t[i] = \sum_k f[i-k]

	f[i] = f[i-1] + 2g[i-1] + t[i-1]
	g[i] = g[i-1] + t[i-1]
	t[i] = t[i-1] + f[i]
*/

/*
f[i] += 

*/

Mat operator+(cM a, cM b) {
	Mat c;
	iter0(i, N) iter0(j, N) c[i][j] = (a[i][j] + b[i][j]) % mod;
	return c;
}

Mat operator*(cM a, cM b) {
	Mat c;
	iter0(i, N) iter0(k, N) iter0(j, N) c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
	return c;
}

Mat pow(Mat a, int z) {
	Mat s = I;
	while (z > 0) {
		if (z % 2 == 1) s = s * a;
		a = a * a;
		z /= 2;
	}
	return s;
}

int main() {
	iter0(i, N) I[i][i] = 1;
	scanf("%d%d", &n, &m);
	Mat g;
	iter0(i, N) iter0(j, N) g[i][j] = graph[i][j];
	Mat res = pow(g, n);
//	printf("%lld\n", (res.a[2][0]) % mod);

	Mat ans = I;

	iter(i, m) {
		scanf("%d", &a[i]);

		ans = ans * pow(g, a[i] - a[i - 1]);
		Mat tmp;
		iter0(k, N) tmp[k][k] = (mod - ans[2][0]) % mod;
		ans = ans + tmp;
	}
	ans = ans * pow(g, n - a[m]);
	printf("%d\n", ans[2][0]);
	return 0;
}


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

class C
{
	static void Main()
	{
		Console.ReadLine();
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

		int c = 0, r = 0;
		for (int i = 0; i < h.Length - 1; i++)
		{
			if (h[i] >= h[i + 1])
			{
				c++;
			}
			else
			{
				r = Math.Max(r, c);
				c = 0;
			}
		}
		Console.WriteLine(Math.Max(r, c));
	}
}


Measured memory_bytes: 26204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[3][3];
bool f[3][3];

int main() {
	for(int i=0; i<3; ++i){
		for(int j=0; j<3; ++j){
			cin >> A[i][j];
		}
	}
	int N;
	cin >> N;
	for(int t=0; t<N; ++t){
		int b;
		cin >> b;
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				f[i][j]=f[i][j]||(b==A[i][j]);
			}
		}
	}
	bool flag=false;
	for(int i=0; i<3; ++i){
		flag=flag||(f[i][0]&&f[i][1]&&f[i][2])||(f[0][i]&&f[1][i]&&f[2][i]);
	}
	flag=flag||(f[0][0]&&f[1][1]&&f[2][2])||(f[0][2]&&f[1][1]&&f[2][0]);
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

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



int main(void)
{
	//変数の宣言
	int n;
	int sosu[25];
	int sosucount[25];
	int over74=0;
	int over24=0;
	int over14=0;
	int over4=0;
	int over2=0;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	
	sosu[0]=2;
	sosu[1]=3;
	sosu[2]=5;
	sosu[3]=7;
	sosu[4]=11;
	sosu[5]=13;
	sosu[6]=17;
	sosu[7]=19;
	sosu[8]=23;
	sosu[9]=29;
	sosu[10]=31;
	sosu[11]=37;
	sosu[12]=41;
	sosu[13]=43;
	sosu[14]=47;
	sosu[15]=53;
	sosu[16]=59;
	sosu[17]=61;
	sosu[18]=67;
	sosu[19]=71;
	sosu[20]=73;
	sosu[21]=79;
	sosu[22]=83;
	sosu[23]=89;
	sosu[24]=97;
	
	for(i=0;i<25;i++){
		sosucount[i]=0;
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=1;i<=n;i++){
		temp=i;
		for(j=0;j<25;j++){
			while(temp%sosu[j]==0){
//				printf("i=%d,j=%d,temp=%d\n",i,j,temp);
				sosucount[j]++;
				temp=temp/sosu[j];
			}
		}
	}
	
//	printf("tag1\n");
	
	for(i=0;i<25;i++){
		if(sosucount[i]>=74) over74++;
		if(sosucount[i]>=24) over24++;
		if(sosucount[i]>=14) over14++;
		if(sosucount[i]>=4) over4++;
		if(sosucount[i]>=2) over2++;
	}
	
//	for(i=0;i<25;i++){
//		printf("%dは%d個\n",sosu[i],sosucount[i]);
//	}
	
//	printf("over74=%d\n",over74);
//	printf("over24=%d\n",over24);
//	printf("over14=%d\n",over14);
//	printf("over4=%d\n",over4);
//	printf("over2=%d\n",over2);
	
	ans=over74;
//	printf("tag1 ans=%d\n",ans);
	ans=ans+over24*(over2-1);
//	printf("tag2 ans=%d\n",ans);
	ans=ans+over14*(over4-1);
//	printf("tag3 ans=%d\n",ans);
	ans=ans+over4*(over4-1)*(over2-2)/2;
//	printf("tag4 ans=%d\n",ans);
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

char kalimat[105];

int main(){
   int a,b,c,i;
  scanf("%s", kalimat);
  a=strlen(kalimat);
  b=0;
  for(i=0;i<a/2;i++){
     if(kalimat[i]!=kalimat[a-1-i]){
        b=b+1;
     }
  }
  cout<<b<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(NULL);                \
  cout.tie(NULL);
#define endl '\n'
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, a, b) for (ll i = a; i >= b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector<pair<ll, ll>>
#define viii vector<pair<ll, pair<ll, ll>>>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mp(i, j) make_pair(i, j)
#define fi first
#define se second
#define input(a, n) fr(i, 0, n) cin >> a[i]
#define output(a, n) fr(i, 0, n) cout << a[i] << " "
#define dbg cout << "hurr" << endl;
#define dbg2 cout << "hurr2" << endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()

int main()
{
  fast;

  ll n;
  cin >> n;
  ll arr[n];
  input(arr, n);
  ll sum = 0;
  fr(i, 0, n-1)
  {
    if (arr[i + 1] < arr[i])
    {
      sum = sum + arr[i] - arr[i + 1];
      arr[i + 1] = arr[i];
    }
  }
  cout << sum;

  return 0;
}


Measured memory_bytes: 5176
#include <stdio.h>

typedef struct {
	unsigned long long bunsi,bunbo;
} bunsu_t;

unsigned long long gcd(unsigned long long a,unsigned long long b) {
	while(b>0) {
		unsigned long long r=a%b;
		a=b;
		b=r;
	}
	return a;
}

bunsu_t yakubun(bunsu_t a) {
	if(a.bunsi==0) {
		bunsu_t ret={0,1};
		return ret;
	} else {
		unsigned long long g=gcd(a.bunsi,a.bunbo);
		bunsu_t ret={a.bunsi/g,a.bunbo/g};
		return ret;
	}
}

bunsu_t add(bunsu_t a,bunsu_t b) {
	bunsu_t r;
	r.bunsi=a.bunsi*b.bunbo+b.bunsi*a.bunbo;
	r.bunbo=a.bunbo*b.bunbo;
	return yakubun(r);
}

bunsu_t sub(bunsu_t a,bunsu_t b) {
	bunsu_t r;
	r.bunsi=a.bunsi*b.bunbo-b.bunsi*a.bunbo;
	r.bunbo=a.bunbo*b.bunbo;
	return yakubun(r);
}

void printll(unsigned long long n) {
	char b[64];
	char *p=b;
	do {
		*(p++)=(char)(n%10+'0');
	} while((n/=10)>0);
	do {
		putchar(*(--p));
	} while(p!=b);
}

int main(void) {
	char input[1024];
	while(scanf("%s",input)==1 && input[0]!='#') {
		int is_n[100];
		int n=0,i;
		bunsu_t ret,delta={45,1};
		for(i=0;input[i]!='\0';) {
			if(input[i]=='n') {
				is_n[n++]=1;
				i+=5;
			} else {
				is_n[n++]=0;
				i+=4;
			}
		}
		ret.bunsi=(is_n[n-1]?0:90);
		ret.bunbo=1;
		for(i=n-2;i>=0;i--) {
			if(is_n[i])ret=sub(ret,delta); else ret=add(ret,delta);
			delta.bunbo*=2;
		}
		printll(ret.bunsi);
		if(ret.bunbo>1) {
			putchar('/');
			printll(ret.bunbo);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
#include <cstdio>

int m, n, a, sum;

int main() {
    scanf("%d%d", &m, &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a);
        sum += a;
    }
    if (sum >= m) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int K,S;
    int z;
    int Ans=0;
    cin >> K >> S;
    REP(i,K+1){
        REP(j,K+1){
            z=S-i-j;
            if(i+j+z==S && 0<=z&&z<=K){
                Ans++;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    ll N; cin >> N;
    if(N%2 == 0) {
        cout << N << " " << N << " " << N/2 << endl;
        return 0;
    }

    REP(h,1,3501) {
        REP(n,1,3501) {
            if(4*h*n -(n+h)*N == 0) continue;
            ll w = N*h*n / (4*h*n -(n+h)*N);
            if(w>0 && (h*n+n*w+w*h)*N == 4*h*n*w) {
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	t=1;
	while(t--)
	{
		cin>>n;
		ll a[n];
		double d=0,e=1.0;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		for(i=n-1;i>0;i--)
		{
		    e=e*2;
		    d=d+(a[i]/e);
		}
		d=d+a[0]/e;
		printf("%.10lf",d);
	}
	return 0;
}

Measured memory_bytes: 256
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, x;
    cin >> n;
    ll s = 0, m =INT_MIN;
    while(n--){
        cin >> x;
        s += x;
        m = max(m ,x);
    }
    s -= m;
    if(s > m){
        cout << "Yes\n";
    }
    else{
        cout <<  "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,j,c=0,t,x[101];
    char ch1[101],ch2[101],l,m,n;
    gets(ch1);
    gets(ch2);
    l=strlen(ch1);
    for(i=0;i<l;i++)
    {
        if(ch1[i]==ch2[i])
            c++;
            else break;
    }
    if(c==l)
        printf("Yes\n");
    else
    {
        for(i=0;i<=l;i++)
        {
            t=0;
            x[0]=ch1[l-1];
            for(j=1;j<l;j++)
            {
                x[j]=ch1[j-1];
            }
            for(j=0;j<l;j++)
            {
                ch1[j]=x[j];
            }
            for(j=0;j<l;j++)
            {
                if(ch1[j]==ch2[j])
                    t++;
            }
            if(t==l)
            {
                printf("Yes\n");
                break;
            }
            else if(i==l)
                printf("No\n");
        }
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int main2() {
  int N; cin >> N;
  vector<ll> a(N);
  REP(i, N) cin >> a[i];
  ll ans = 0;
  for (;;) {
    auto p = max_element(ALL(a));
    if (*p < N) break;
    ll d = *p - (N-1);
    ll k = (d + N - 1) / N;
    ans += k;
    REP(i, N) a[i] += k;
    *p -= (N+1) * k;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,k,x,y,total;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%d",&x);
	scanf("%d",&y);
	if(n<=k){
		total = x*n;
	}else{
		total = x*k+y*(n-k);
	}
	printf("%d",total);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;
#define M 1100
#define a 6

int main(){
  string s;
  int i;
  cin >> s;
  int N = s.size();
  for (i = 0; i < N; i++){
    if (i%2 == 0)
      cout << s.at(i);
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int N; ll T; cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t[i];
    ll sum = 0;
    int left = 0;
    FOR(i, 1, N) {
        if(t[i] - t[i-1] <= T) continue;
        sum += t[i-1] - t[left] + T;
        left = i;
    }
    sum += t[N-1] - t[left] + T;
    cout << sum << endl;
    return 0;
}


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

int main() {
    int A, B, count = 0;
    cin >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10) {
            count++;
        }
    }
    cout << count;
}


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

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

    int left = 0;
    int right = S.size() - 1;

    int cnt = 0;
    while(right - left > 0)
    {
        if (S[left] != S[right])
        {
            cnt++;
        }
        left++;
        right--;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256