akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
    #include<string.h>
    int main()
    {
        int i,j,k,l;
        char S[27];
        scanf("%s",S);
        l = strlen(S);
        k=0;
        for(i=0;i<l;i++){
          for(j=i+1;j<l;j++){
          if(S[i] == S[j]) k++; 
          }
        }
        if(k==0) printf("yes\n");
        else printf("no\n");
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int X1, Y1, X2, Y2, X3, Y3;
	int ten9 = (int)1e9;
	if (N <= ten9) {
		X1 = Y1 = 0;
		X2 = 1; Y2 = 0;
		X3 = 0; Y3 = N;
	}
	else {

		int a = N % ten9;
		int b = N / ten9;

		if (a == 0) {
			a = 1e9;
			b--;
		}

		X1 = Y1 = 0;
		X2 = b + 1; Y2 = 1;
		X3 = ten9 - a; Y3 = ten9;


	}
	//cerr << abs(X3 * Y2 - X2 * Y3) << endl;
	cout << X1 << " " << Y1 << " " << X2 << " " << Y2 << " " << X3 << " " << Y3 << endl;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n;
	cin >> n;

	vi h(n);
	for(auto& el : h) 
		cin >> el;

	vi dp(n);
	rep(i , n)
	{
		if(i > 0) dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if(i > 1) dp[i] = min(dp[i] , dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 1024
/*
  AOJ 0507
  Title:Square
  @kankichi573
*/
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))

int prefix[31];

void print_prefix(int len)
{
  int i;

  for(i=0;i<len;i++)
    printf("%d ",prefix[i]);
}
void print_square(int sum,int len,int max_)
{
  int i;

  //printf(":%d %d %d\n",sum,len,max_);

  if(sum<=0)
    return;

  if(sum<=max_)
    {
      print_prefix(len);
      printf("%d\n",sum);
    }
  else if(1==max_||1==sum)
    {
      print_prefix(len);
      for(i=0;i<sum;i++)
	{
	    printf("1");
	    if(i<sum-1)
	      printf(" ");
	}
      printf("\n");
    }

  if(max_>1)
    for(i=min(max_,sum-1);i>=1;i--)
      {
	prefix[len]=i;
	print_square(sum-i,len+1,i);
      }
}

main()
{
  int i,ret,N;


  while(scanf("%d",&N)  && (N   ))
    print_square(N,0,N);
  return(0);
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

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

int main(void) {
	int n, l, aji_sum = 0;
	cin >> n >> l;
	vector<int> aji(n+1);
	REPS(i, n) {
		aji[i] = l + i - 1;
		aji_sum += aji[i];
	}
	vector<int> eat_aft(n+1);
	int ans;
	int num1 = INF;
	REPS(i, n) {
		int sum = 0;
		REPS(j,n) {
			if (j != i) {
				sum += aji[j];
			}
		}
		eat_aft[i] = sum;
		int num = abs(aji_sum - eat_aft[i]);
		if (num < num1) {
			ans = eat_aft[i];
			num1 = num;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a,b,c,ans;
  cin >> a >> b >> c;
  if(a*a+b*b==c*c) {
    ans=a*b/2;
  }else if(a*a+c*c==b*b) {
    ans=a*c/2;
  }else {
    ans=b*c/2;
  }
  cout << ans << endl;
}


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

class Point{
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator +(Point p) { return Point(x+p.x, y+p.y); }
  Point operator -(Point p) { return Point(x-p.x, y-p.y); }
  Point operator *(double a) { return Point(x*a, y*a); }
};

typedef Point Vector;

double cross(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}

int main() {
  Point p[4];
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
	      &p[0].x, &p[0].y, &p[1].x, &p[1].y,
	      &p[2].x, &p[2].y, &p[3].x, &p[3].y) != EOF) {

    bool okFlag = true;
    for(int i = 0; i < 4; i++) {
      int idx1, idx2, idx3;
      idx1 = (i+1)%4;
      idx2 = (i+2)%4;
      idx3 = (i+3)%4;
      if(cross(p[idx1]-p[i], p[idx2]-p[i])
	 *cross(p[idx2]-p[i], p[idx3]-p[i]) < 0) {
	okFlag = false;
	break;
      }
    }

    if(okFlag) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, ll>;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    P ans = P(n, n);

    // 中心が1つ
    for(int i = 0; i < n; i++)
    {
        vector<int> d(n);
        vector<int> ord(n);
        for(int j = 0; j < n; j++)
        {
            d[j] = -1;
            ord[j] = 0;
        }
        d[i] = 0;
        queue<int> que;
        que.push(i);

        while(!que.empty())
        {
            int cand = que.front();
            que.pop();
            for(auto nx : g[cand])
            {
                if(d[nx] == -1)
                {
                    d[nx] = d[cand] + 1;
                    que.push(nx);
                    ord[cand]++;
                }
            }
        }
        // dごとのordmax
        vector<int> ma(n);
        int dmax = 0;
        for(int j = 0; j < n; j++)
        {
            if(d[j] != -1)
            {
                dmax = max(dmax, d[j]);
                ma[d[j]] = max(ma[d[j]], ord[j]);
            }
        }
        ll second = 1;
        for(int j = 0; j < n; j++)
        {
            if(ma[j] != 0)
            {
                second *= ma[j];
            }
        }
        ans = min(ans, P(dmax+1, second));
    }
    
    // 中心が2つ 
    for(int i = 0; i < n; i++)
    {
        for(auto tmp: g[i])
        {
            // tmp: もう一つの中心
            vector<int> d(n);
            vector<int> ord(n);
            for(int j = 0; j < n; j++)
            {
                d[j] = -1;
                ord[j] = 0;
            }
            d[i] = 0;
            queue<int> que;
            que.push(i);
            d[tmp] = 0;
            que.push(tmp);

            while(!que.empty())
            {
                int cand = que.front();
                que.pop();
                for(auto nx : g[cand])
                {
                    if(d[nx] == -1)
                    {
                        d[nx] = d[cand] + 1;
                        que.push(nx);
                        ord[cand]++;
                    }
                }
            }
            // dごとのordmax
            vector<int> ma(n);
            int dmax = 0;
            for(int j = 0; j < n; j++)
            {
                if(d[j] != -1)
                {
                    dmax = max(dmax, d[j]);
                    ma[d[j]] = max(ma[d[j]], ord[j]);
                }
            }
            ll second = 2;
            for(int j = 0; j < n; j++)
            {
                if(ma[j] != 0)
                {
                    second *= ma[j];
                }
            }
            ans = min(ans, P(dmax+1, second));
        }
    }
    cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		char[]c=s.next().toCharArray();
		
		int n=c.length;
		long r=0,d=0;
		for(int i=0;i<n;++i) {
			if(c[i]=='B')
				++d;
			else
				r+=d;
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 28556
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

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

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

using namespace std;
using ll = long long;

int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    vector<vector<ll>> p(d, vector<ll>(n));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
        }
    }
    ll money = x;
    for (int i = 0; i < d - 1; i++) {
        vector<ll> profit(n);
        for (int j = 0; j < n; j++) {
            profit[j] = p[i + 1][j] - p[i][j];
        }
        vector<vector<ll>> inner_dp(n + 1, vector<ll>(money + 1, -1));
        inner_dp[0][0] = 0;
        for (int j = 0; j < n; j++) {
            for (int m = 0; m <= money; m++) {
                if (inner_dp[j][m] > -1) {
                    inner_dp[j + 1][m] = inner_dp[j][m];
                }
            }
            for (int m = 0; m <= money; m++) {
                if (inner_dp[j + 1][m] > -1 and m + p[i][j] <= money) {
                    inner_dp[j + 1][m + p[i][j]] = max(inner_dp[j + 1][m + p[i][j]], inner_dp[j + 1][m] + profit[j]);
                }
            }
        }
        ll maxi = 0;
        for (int j = 0; j <= money; j++) {
            maxi = max(maxi, inner_dp[n][j]);
        }
        money += maxi;
    }
    cout << money << endl;

    return 0;
}

Measured memory_bytes: 5680
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
V<int> dx={1,0,-1,0},dy={0,-1,0,1};
map<P,P> mp;
int main(){
   ll a,b;
   cin>>a>>b;
   cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math


def isprime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        for i in range(3, math.floor(math.sqrt(n)) + 1, 2):
            if n % i == 0:
                return False
        else:
            return True


def main():
    n = int(input())
    ms = (int(input()) for i in range(n))
    print(len(list(filter(isprime, ms))))

if __name__ == "__main__":
    main()

Measured memory_bytes: 7788
N = int(input())
H = list(map(int,input().split()))
ans = 0
num = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        num += 1
    else:
        ans = max(ans,num)
        num = 0
    ans = max(ans,num)
print(ans)

Measured memory_bytes: 63984
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

vector<long long> tab;
long long x, ans, n;

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n;
	for( int a = 1; a <= 2*n; a++ )
	{
		cin>>x;
		tab.push_back( x );	
	}
	sort( tab.begin(), tab.end() );
	for( int a = 0; a < 2*n; a+=2 )
	{
		ans += tab[a];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
sub p{my($a,$b)=@_;$b?p($a**2%$=,$b>>1)*($b%2?$a:1)%$=:1}$==1e9+7;@s=map$%=($%+p$_,$=-2)%$=,++$f..<>;$s+=$_*($s[$i++]+$s[-$i]-1)%$=,$f=$f*$i%$=for glob<>;print$s%$=*$f%$=

Measured memory_bytes: 34892
def stamina(x, p):
    return (x - p) ** 2


def resolve():
    N = int(input())
    Xs = list(map(int, input().split()))

    min_sum = 10 ** 10
    for p in range(1, 101):
        s_sum = 0
        for p_x in Xs:
            s_sum += stamina(p_x, p)

        min_sum = min(min_sum, s_sum)

    print(min_sum)
resolve()

Measured memory_bytes: 63776
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

P dir[2] = {{0, 1}, {1, 0}};

int main() {
    int H, W; cin >> H >> W;
    //dist[i][j] : (0, 0) -> (i, j) に行くまでに踏む最小の黒マスブロックの個数
    string s[H];
    rep(i, H) cin >> s[i];
    vector<vector<int>> dist(H, vector<int>(W, INF));
    dist[0][0] = (s[0][0] == '#');
    queue<pair<int, int>> Q;
    Q.push(mp(0, 0));
    // (h, w)
    while(!Q.empty()) {
        auto q = Q.front(); Q.pop();
        rep(i, 2) {
            int h = q.first + dir[i].first, w = q.second + dir[i].second;
            if(w >= W || h >= H) continue;
            if(dist[h][w] == INF) Q.push(mp(h, w));
            int add = (s[h][w] == '#' && s[q.first][q.second] == '.');
            dist[h][w] = min(dist[h][w], dist[q.first][q.second] + add);
        }
    }
    cout << dist[H - 1][W - 1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void qsort(int list1[], int left, int right) {
    int l = left;
    int r = right;
    int pivot = list1[(left + right) / 2]; // 中央からピボットを選択
    int temp;

    while (1) {
        while (list1[l] < pivot) l++;
        while (list1[r] > pivot) r--;

        if (l > r) break;

        // pivotより小さい値を左、大きい値を右に入れ替え
        temp = list1[l];
        list1[l] = list1[r];
        list1[r] = temp;
        

        l++, r--;
    };

    // pivotより小さい領域と大きい領域をそれぞれ再帰的にソート
    if (left < r)  qsort(list1,left,r);
    if (l < right) qsort(list1,l,right);
}

int main(void){
    int N;
    scanf("%d",&N);
    int d[N];
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
    }
    qsort(d,0,N-1);
    // for(int i=0;i<N;i++){
    //     printf("%d",d[i]);
    // }
    // printf("\n");
    printf("%d",(d[N/2]-d[(N/2)-1]));

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using int64=long long;
const int INF=1145141919,MOD=1e9+7;
const int64 LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int h,w,n; cin>>h>>w>>n;
    int sy,sx; cin>>sy>>sx;
    string s,t; cin>>s>>t;
    int up=1,down=h;
    int left=1,right=w;
    for(int i=n-1;i>=0;i--){
        if(t[i]=='U') down=min(h,down+1);
        if(t[i]=='D') up=max(1,up-1);
        if(t[i]=='L') right=min(w,right+1);
        if(t[i]=='R') left=max(1,left-1);
        if(s[i]=='U') up++;
        if(s[i]=='D') down--;
        if(s[i]=='L') left++;
        if(s[i]=='R') right--;
        if(down<up||right<left){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(up<=sy&&sy<=down&&left<=sx&&sx<=right){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, std::pair<int,int> > P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
#define int long long
 
signed main(){

	int tmp;

	char a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
	cout<<a<<e<<i<<endl;
}



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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    sort(all(p));
    ll sum=0;
    rep(i,k) sum+=p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3560
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == "#" and s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] == ".":
          r = "No"
print(r)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll x; cin >> x;
  ll now = 100;
  int cnt = 0;
  while(now < x){
    now += now / 100;
    cnt++;
  }
  cout << cnt << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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


int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t/a*b << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> G[1000005],G2[1000005];
bool used[1000005];
int ans[1<<18];

void solve(int l,int r,int bit,int a,int b){
    if(bit==0)return;
    int dif=0;
    for(int i=0;i<n;i++){
        if(bit>>i & 1){
            if((a>>i & 1)!=(b>>i & 1)){
                dif=i;
            }
        }
    }
    for(int i=l;i<(l+r)/2;i++){
        ans[i]+=(a>>dif & 1)<<dif;
    }
    for(int i=(l+r)/2;i<r;i++){
        ans[i]+=(b>>dif & 1)<<dif;
    }
    int b_dif=0;
    for(int i=0;i<n;i++){
        if(bit>>i & 1){
            if(i!=dif)b_dif=i;
        }
    }
    int c=a;
    c^=1<<b_dif;
    solve(l,(l+r)/2,bit-(1<<dif),a,c);
    solve((l+r)/2,r,bit-(1<<dif),c,b);
}

int main(void){
    int a,b;
    scanf("%d%d%d",&n,&a,&b);
    int cnt=0;
    for(int i=0;i<n;i++){
        if(((a>>i)&1)!=((b>>i)&1)){
            cnt++;
        }
    }
    if(cnt%2==0){
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    solve(0,(1<<n),(1<<n)-1,a,b);
    for(int i=0;i<(1<<n);i++){
        printf("%d%c",ans[i],i+1==(1<<n)?'\n':' ');
    }
    return 0;
}




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

int main(void){
    int a, b, count;

    cin >> a >> b;

    count = 0;
    for(int i = 0; i < 2;i++){
        if(a < b){
            count += b;
            b--;
        }else{
            count += a;
            a--;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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 main(){
    ll n;cin >> n;
    vl v(n);
    rep(i,n)cin >> v[i];
    if(v[0]!=0){
        cout << -1 <<endl;return 0;
    }
    bool check=false;
    rep(i,n-1){
        if(v[i+1]>v[i]+1)check=true;
    }
    if(check){
        cout << -1 <<endl;return 0;
    }
    ll ans=0,ind=0;
    while(ind<n){
        while(v[ind+1]==v[ind]+1){
            ind++;
        }
        ans+=v[ind];
        ind++;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 1792
n,m = map(int,input().split())
a = list(map(int,input().split()))
p = [[aa,1] for aa in a]
for _ in range(m):
  b = list(map(int,input().split()))
  b.reverse()
  p.append(b)
p.sort()
p.reverse()
rest = n
score = 0
for ni in range(n):
  use = min(p[ni][1],rest)
  rest -= use
  score += p[ni][0] * use
  if rest==0: break
print(score)

Measured memory_bytes: 42452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, q;
    cin >> n;
    bitset<40005> dp = 1;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        dp |= dp << a;
    }
    cin >> q;
    for(int i = 0; i < q; ++i){
        int x;
        cin >> x;
        if(dp[x])   puts("yes");
        else    puts("no");
    }
}


Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

int main() {
	for (;;) {
		int N, M; cin >> N >> M;
		if (N == 0 && M == 0) break;
		vector<int> h(N), w(M);
		for (int i = 0; i < N; i++) cin >> h[i];
		for (int j = 0; j < M; j++) cin >> w[j];
		vector<int> hsum(N + 1), wsum(M + 1);
		for (int i = 1; i <= N; i++) hsum[i] = hsum[i - 1] + h[i - 1];
		for (int j = 1; j <= M; j++) wsum[j] = wsum[j - 1] + w[j - 1];
		vector<int> m(1500001);
		for (int j = 0; j <= M; j++)
			for (int _j = j + 1; _j <= M; _j++)
				m[wsum[_j] - wsum[j]]++;
		ll cnt = 0;
		for (int i = 0; i <= N; i++)
			for (int _i = i + 1; _i <= N; _i++)
				cnt += m[hsum[_i] - hsum[i]];
		cout << cnt << endl;
	}
}

Measured memory_bytes: 7076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

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

    return 0;
}



Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

const int MAX_PRIME = 34000;
vector<int> primes;
bool isPrime[MAX_PRIME+1];
// sieve of Erastosthenes
inline void prime_list(){
  const int sz = MAX_PRIME;
  fill(isPrime, isPrime+sz+1, true);
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  prime_list();
  int p,q;
  cin>>p>>q;
  q /= __gcd(p,q);
  int res = 1;
  for(int pr: primes){
    if(q%pr==0) res *= pr;
    while(q%pr==0){q /= pr;}
  }
  res *= q;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3184
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		if aa[i] > i {
			ans = -1
			break
		}
		if i == n-1 {
			ans += aa[i]
			continue
		}
		if aa[i]+1 < aa[i+1] {
			ans = -1
			break
		}
		if aa[i]+1 != aa[i+1] {
			ans += aa[i]
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int n;
int v[MAXX];

int main()
{
    _FastIO;

    cin >> n;
    int k = n / 2;
    vector<int> cnt(MAXX , 0);
    vector<int> cn(MAXX , 0);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        if(i % 2)
            cnt[v[i]]++;
        else
            cn[v[i]]++;
    }
    vector<pair<int , int> > x;
    vector<pair<int , int> > y;
    for(int i = 1; i <= 100000; i++){
        if(cnt[i])
            x.push_back({cnt[i] , i});
        if(cn[i])
            y.push_back({cn[i] , i});
    }
    if(x.size() == 1){
        x.push_back({0 , 0});
    }
    if(y.size() == 1){
        y.push_back({0 , 100001});
    }
    sort(x.begin() , x.end());
    reverse(x.begin() , x.end());
    sort(y.begin() , y.end());
    reverse(y.begin() , y.end());
    int a = x[0].second;
    int b = y[0].second;
    int c = x[1].second;
    int d = y[1].second;
    int e = x[0].first;
    int f = y[0].first;
    int g = x[1].first;
    int h = y[1].first;
    if(a != b){
        int ans = k - e + k - f;
        cout << ans << endl;
        return 0;
    }
    int saleh = k - g + k - f;
    int revan = k - e + k - h;
    int ans = min(saleh , revan);
    cout << ans << endl;
    return 0;
}


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

	 
	int main()
	{
		int a, b; cin >> a >> b;
		bool found = false;
		for (int i = 10 * b; i <= 10 * b + 9; i++) {
			if (floor(0.08 * i) == a) {
				cout << i << endl;
				found = true;
				break;
			}
		}
		if (!found)cout << -1 << endl;
		return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define int ll
#define double ld
#define openfiles ifstream in("input.txt");ofstream out("output.txt");
#define faster ios_base::sync_with_stdio(false);
typedef pair<int,int> pii;
const int inf=1e18;
const int mod=1e9+7;
const double eps=0.00000001;
///----------------------------------------------------------------------
int n;
vector<int> dp;
vector<vector<int> > mat;
vector<int> prec;
void init()
{
    cin>>n;
    dp.resize((1<<n),-inf);
    prec.resize((1<<n),0);
    mat.resize(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cin>>mat[i][j];
    }
    for(int mask=0;mask<(1<<n);mask++)
    {
        vector<int> ind;
        for(int i=0;i<n;i++)
        {
            if((mask>>i)&1)
                ind.push_back(i);
        }
        int sum=0;
        for(int i=0;i<ind.size();i++)
        {
            for(int j=i+1;j<ind.size();j++)
            {
                sum+=mat[ind[i]][ind[j]];
            }
        }
        prec[mask]=sum;
    }
}

int go(int mask)
{
    if(mask==0)
        return 0;
    int ans=dp[mask];
    if(dp[mask]!=-inf)
        return dp[mask];
    for(int submask=mask;submask;submask=(submask-1)&mask)
    {
        int currmask=mask^submask;
        int sum=prec[submask];
        int curr=sum+go(currmask);
        if(curr>dp[mask])
        {
            dp[mask]=curr;
        }
    }
    ans=dp[mask];
    return dp[mask];
}

signed main()
{
    init();
    cout<<go((1<<n)-1);
    return 0;
}




















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

 
int main() {
    
     string s;
     cin >> s;
    int l = s.size();
    
   
    
    
    cout <<s[0]<<l-2<<s[l-1]<< endl;
    
    
    
    
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int t = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		t = __gcd(t, x);
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int ans = 0;
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0) ans = i + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
from heapq import heappush, heappop


class Dijk:
    def __init__(self, n):
        self.table = [[] for i in range(n)]
        self.n = n

    def add(self, x, y, f):
        self.table[x].append((y, f))

    def di(self, s):
        inf = 10 ** 20
        self.val = [inf] * self.n
        self.val[s] = 0
        h = []
        heappush(h, (0, s))
        while h:
            q, i = heappop(h)
            if self.val[i] < q:
                continue
            for x, c in self.table[i]:
                if self.val[x] > self.val[i] + c:
                    self.val[x] = self.val[i] + c
                    heappush(h, (self.val[x], x))

    def dist(self, s, t):
        return self.val[t]


N, M, s, t = map(int, input().split())
stra = Dijk(N)
rstra = Dijk(N)
for i in range(M):
    u, v, a, b = map(int, input().split())
    stra.add(u - 1, v - 1, a)
    stra.add(v - 1, u - 1, a)
    rstra.add(u - 1, v - 1, b)
    rstra.add(v - 1, u - 1, b)
stra.di(s - 1)
rstra.di(t - 1)
ans = []
T = 10 ** 15
mod = 10 ** 15
for i in range(N - 1, -1, -1):
    T = min(stra.dist(s - 1, i) + rstra.dist(t - 1, i), T)
    ans.append(mod - T)
print('\n'.join(map(str, ans[::-1])))

Measured memory_bytes: 93600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

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

    cout << (N<=W ? "unsafe" : "safe");
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define N 200000
#define M 1001001
int n;
vector<int> u(M, 0);
vector<int> a(N);

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        u[a[i]]++;
    }
    int res = 0;
    for(int i = 0; i < n; i++){
        bool can = true;
        auto v = divisor(a[i]);
        for(auto vi : v){
            if(vi == a[i] && u[vi] == 1) continue;
            if(u[vi]) can = false;
        }
        if(can) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7832
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
int main(int argc, char *argv[]) {
    	int n,x,i,j=1;
	int m[100];
	int add = 0;
	int count = 0;

	scanf("%d %d",&n,&x);
	for(i = 0; i < n;i++){
		scanf("%d",&m[i]);
		add += m[i];
	}
	count = n;
	x -= add;
	sort(m,m+n);
		

	//while((x - m[0] * j) >0)
	//j++;

	count += x/(m[0]);

	printf("%d\n",count);
		
}

Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let c = ref 0
let _ = Array.iteri (fun i p -> if p <> i + 1 then incr c) ps; print_endline @@ if !c > 2 then "NO" else "YES"

Measured memory_bytes: 4480
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int m; cin >> m;
    ll sum=0, dig=0;
    REP(i, m){
        ll d, c; cin >> d >> c;
        sum += d*c; dig += c;
    }
    
    cout << dig - 1 + ((sum-1)/9) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1985;

int xor128()
{
  static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  int t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int D;
int c[26];
int s[365][26];
vector<int> ans;

int eval(vector<int> &ans)
{
  int score = 0;
  int last[26] = {};
  for (int i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (int j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  double C = timeLimit * 100, forceLine;
  int currentTime;
  vector<int> now = ans;
  int bestScore = -1e9, nowScore = -1e9, loop = 0;
  while ((currentTime = chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000) < timeLimit)
  {
    int t[3] = {xor128() % D, xor128() % 26};
    t[2] = now[t[0]];
    now[t[0]] = t[1];
    int score = eval(now);
    forceLine = (timeLimit - currentTime) / C;
    if (bestScore < score)
    {
      ans = now;
      bestScore = score;
    }
    if (nowScore < score || forceLine * 1000 > rand() % 1000)
    {
      nowScore = score;
    }
    else
    {
      now[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (int)(1e6) << endl
       << "loop: " << loop << endl;
}

void init()
{
  for (int i = 0; i < D; i++)
  {
    int m = -1e9;
    for (int j = 0; j < 26; j++)
    {
      if (m < s[i][j])
      {
        m = s[i][j];
        ans[i] = j;
      }
    }
  }
}

void input()
{
  cin >> D;
  for (int i = 0; i < 26; i++)
    cin >> c[i];
  for (int i = 0; i < D; i++)
    for (int j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (int i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  input();
  init();
  solve();
  output();
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int diceMax = length - 1;
		int count = 1;
		int maxCount = 1;
		int[] masu = new int[length];
		for (int i = 0; i < length; i++) {
			masu[i] = sc.nextInt();
		}
		for (int i = 0; i < length; i++) {
			if (masu[i] == 1) {
				count++;
			} else {
				count = 1;
			}
			if (count > maxCount) {
				maxCount = count;
			}
		}
System.out.println(maxCount);
	}
}



Measured memory_bytes: 26504
# AGC014A - Cookie Exchanges
def main():
    A, B, C = map(int, input().split())
    if A == B == C:  # corner case
        flg = A % 2
        print(0 if flg else -1)
        return
    ans = 0
    while 1 not in (A % 2, B % 2, C % 2):
        A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long int llint;
typedef unsigned long long int ullint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;

//#define DEBUG
//#define USE_SCANF

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)

#ifdef DEBUG
#define dump(i) cout << "[*] " #i ": " << i << endl;
#define line cout << "\n[*]---------------[*]" << endl;
#else
#define dump(i)
#define line
#endif

constexpr int INT_INF = INT_MAX >> 1;
constexpr llint LL_INF = LLONG_MAX >> 1;
// variable -----
constexpr int MAX_N = 1e5;
int n;
vector<int> edge[MAX_N];

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

inline void input() {
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
}

inline void solve() {
	queue<int> q;
	vector<int> f(n);
	f[0] = 1;
	q.push(0);
	while (!q.empty()) {
		int now = q.front();
		q.pop();
		rep(i, edge[now].size()) {
			int next = edge[now][i];
			if (f[next] == 0) {
				f[next] = f[now] + 1;
				q.push(next);
			}
		}
	}

	vector<int> s(n);
	s[n - 1] = 1;
	q.push(n - 1);
	while (!q.empty()) {
		int now = q.front();
		q.pop();
		rep(i, edge[now].size()) {
			int next = edge[now][i];
			if (s[next] == 0) {
				s[next] = s[now] + 1;
				q.push(next);
			}
		}
	}

	int fennec = 0, snuke = 0;
	rep(i, n) {
		if (f[i] <= s[i]) {
			fennec++;
		} else {
			snuke++;
		}
	}

	if (fennec > snuke) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}
}

int main() {
#ifndef USE_SCANF
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif

	input();
	line;
	solve();

	return 0;
}


Measured memory_bytes: 6656
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			String str;
			StringBuilder cards = new StringBuilder( 200+1 );
			int m, shuffle, len;
	        while( null != ( str = kb.readLine() ) ) {
	        	if( str.equals( "-" ) ) { break; }
	        	
	        	m = Integer.parseInt( kb.readLine() );
	        	len = str.length();
	        	for( int i=0; i<m; i++ ) {
	        		shuffle = Integer.parseInt( kb.readLine() );
	        		cards.append( str.substring( shuffle, len ) );
	        		cards.append( str.substring( 0, shuffle ) );
	        		str = cards.toString();
	        		cards.setLength( 0 );
	        	}
	        	System.out.println( str );
	        	
	        }
			
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 17084
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = 1;
        int cnt = 0;
        cnt = b - a;
        if (b == 1) {
            System.out.println(0);
        } else if (cnt <= 0) {
            System.out.println(ans);
        } else {
            cnt = b;
            while (cnt > 0) {
                if (cnt - a <= 0) {
                    break;
                }
                ans++;
                cnt = cnt - (a - 1);
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    int n;
    cin >> n;
    long long a[3*n];
    rep(i,3*n) cin >> a[i];
    long long leftmax[3*n];
    multiset<long long> left;
    leftmax[n]=0;
    rep(i,n){
        leftmax[n]+=a[i];
        left.insert(a[i]);
    }
    for(int i = n;i<2*n;i++){
        auto tmp = left.begin();
        if(*tmp<a[i]){
            leftmax[i+1]=leftmax[i]+(a[i]-*tmp);
            left.erase(tmp);
            left.insert(a[i]);
        }
        else{
            leftmax[i+1]=leftmax[i];
        }
    }
    multiset<long long> right;
    long long rightmin[3*n];
    rightmin[2*n]=0;
    for(int i = 3*n-1;i>=2*n;i--){
        rightmin[2*n]+=a[i];
        right.insert(a[i]);
    }
    for(int i = 2*n-1;i>=n;i--){
        auto tmp = right.end();
        tmp--;
        if(*tmp>a[i]){
            rightmin[i]=rightmin[i+1]-(*tmp-a[i]);
            right.erase(tmp);
            right.insert(a[i]);
        }
        else{
            rightmin[i]=rightmin[i+1];
        }
    }
    long long ans = -1e15;
    for(int i = n;i<=2*n;i++){
        ans = max(ans,leftmax[i]-rightmin[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d\n", &n);
	char prev;
	scanf("%c", &prev);
	int count = 1;
	for(int i = 1; i < n; i++) {
		char ch;
		scanf("%c", &ch);
		if (ch != prev) {
			count++;
		}
		prev = ch;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=[]
l=[0]*n
ans=0
for i in range(n):
  a.append(int(input()))
  l[i]=[list(map(int,input().split())) for i in range(a[-1])]
for i in range(2**n):
  i=format(i,'b').zfill(n)
  c=[]
  for j in range(n):
    if i[j]=='1':
      c.append(j)
  for j in c:#cは正直者と仮定した人のインデックスを格納してる
    for k in l[j]:#kは1人あたりの証言たちから1つずつ取り出す
      if k[1]==1 and (k[0]-1 not in c):
        break#正直者(仮)が「正直者だ！」って言った人が正直者候補にいない場合（この人が嘘ついてる）
      elif k[1]==0 and (k[0]-1 in c):
        break#正直者(仮)が「嘘つきだ！」って言った人が正直者候補にいる場合（この人が嘘ついてる）
    else:
      continue
    break
  else:#これらを切り抜けたらcはすべて正直者だと言える
    ans=max(ans,len(c))
print(ans)

Measured memory_bytes: 3064