akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
using namespace std; 
typedef long long lint;
vector <lint> vec;
int main(){
	string a;
	cin>>a;
	if(a=="SUN")cout<<7;
	if(a=="MON")cout<<6;
	if(a=="TUE")cout<<5;
	if(a=="WED")cout<<4;
	if(a=="THU")cout<<3;
	if(a=="FRI")cout<<2;
	if(a=="SAT")cout<<1;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>


using namespace std;
#define MAX 100000

int main(){
    int N;

    scanf("%d", &N);
    vector<int> a;
    for (int i = 0; i < N; i++){
        int temp;
        scanf("%d", &temp);
        a.push_back(temp);
    }
    int cnt = 0;
    for (int ii = 0; ii < N; ii++){
        while (1){
            if (1 == a[ii] % 2){
                break;
            }
            a[ii] = a[ii] / 2;
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
int n;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	priority_queue <int > dp;

	while(cin>>n){
		dp.push(n);
	}
	for(int i=0;i<3;i++){
		int output=dp.top();
		dp.pop();
		cout<<output<<"\n";
	}
	return 0;
}

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

using namespace std;

const int MOD = 1000000007;
const int MAX32 = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  long long a, b, c, d, max;
  cin >> a >> b >> c >> d;
  max = b * d;
  if (max < a * c) max = a * c;
  if (max < b * c) max = b * c;
  if (max < a * d) max = a * d;
  if (((a <= 0 and 0 <= b) or (c <= 0 and 0 <= d)) and max < 0) max = 0;
  cout << max << endl;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{     
    static int AllPathThroughCount(List<int>[] node, int index, bool[] through)
    {
        if(through[index])
            return 0;
        through[index] = true;
        if(through.All(x => x))
        {
            through[index] = false;
            return 1;
        }
        int total = node[index]
            .Where(x => !through[x])
            .Select(x => AllPathThroughCount(node, x, through))
            .Sum();
        through[index] = false;
        return total;
    }
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        var node = 
            Enumerable.Range(0, n)
            .Select(x => new List<int>())
            .ToArray();
        foreach(int i in Enumerable.Range(0, m))
        {
            inputs = Console.ReadLine().Split();
            int a = int.Parse(inputs[0]) - 1;
            int b = int.Parse(inputs[1]) - 1;
            node[a].Add(b);
            node[b].Add(a);
        }
        int result = AllPathThroughCount(node, 0, new bool[n]);
        System.Console.WriteLine(result);        
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 15572
import sys
input = sys.stdin.readline


def main():
    N, T = map(int, input().split())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB.sort()
#    print(AB)
    dp = [[0]*T for _ in range(N+1)]
    for i, (a, b) in enumerate(AB):
        for t in range(T):
            if t - a >= 0:
                dp[i+1][t] = max(dp[i][t], dp[i][t-a] + b)
            else:
                dp[i+1][t] = dp[i][t]

#    [print(d) for d in dp]
    ans = 0
    for i, d in enumerate(dp):
        B = [0]
        for a, b in AB[i:]:
            B.append(b)
        ans = max(ans, max(d) + max(B))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 115420
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

  int N, K;
  cin >> N >> K;
  int ans = 1;
  int W = K;
  while(true){
    if(W >= N) break;
    W += K-1;
    ans++;
  }
  cout << ans << endl;

}

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

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

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

  int count = 0;
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    swap(a[i], a[minj]);
    if (i != minj) {
      count++;
    }
  }

  for (int i = 0; i < n; i++) {
    if (i<n-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }

  cout << count << endl;
}


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

int colocaMenorNaFrente(const void*x,const void*y){
    int a = *((int*)x), b = *((int*)y);

    if(a<b){
        return -1;
    }
    if(a>b){
        return 1;
    }
    else{
        return 0;
    }
}
int main(){
    int n;
    int meio;
    int resultado;
    scanf("%d",&n);
    meio = n/2;

    int vetor[n];

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

    qsort(vetor,n,sizeof(vetor[0]),colocaMenorNaFrente);

    resultado = vetor[meio]-vetor[meio-1];

    printf("%d\n",resultado);
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
  
void push(int);
int pop(void);

int top,STACK[1000000];

int main()
{
  char s[100];
  int x,y,z;

  top=0;
 
  while(scanf("%s", s)!=EOF)
    {
      if(s[0]=='+')
	{
	  y=pop();
	  z=pop();
	  push(y+z);
	}
      
      else if(s[0]=='-')
	{
	  y=pop();
	  z=pop();
	  push(z-y);
	}

      else if(s[0]=='*')
	{
	  y=pop();
	  z=pop();
	  push(y*z);
	}
      
      else
	{
	  x=atoi(s);
	  push(x);
	}
    					   
    }
  printf("%d\n",pop());
  return 0;
}

void push(int x)
{
  STACK[++top]=x;
}

int pop()
{
  top--;
  return STACK[top+1];
}



Measured memory_bytes: 2108
#include<stdio.h>
int main(){
  int x,a,b,c;
  scanf("%d",&x);
  a=x/3600;
  b=(x%3600)/60;
  c=x-a*3600-b*60;
  printf("%d:%d:%d\n",a,b,c);
  return 0;
}
 

Measured memory_bytes: 592
s = input()
k = int(input())
n = len(s)
renzoku_flag =False
renzoku_count = 0
count = 0
for i in range(n):
    if i != n-1:
        if s[i] == s[i+1]:
            renzoku_count += 1 #iのをカウントしている
        else:
            renzoku_count += 1 #i+1の分をカウント
            count += renzoku_count // 2
            renzoku_count = 0
    else:
        if s[n-2] == s[n-1]:
            renzoku_count += 1
        count += renzoku_count // 2

if s[0] != s[-1]:
    print(count*k)
else:
    ans = count*k
    initial = s[0]

    start_count = 0
    for i in range(n):
        if s[i] == initial:
            start_count += 1
        else:
            break
    else:
        print(n*k//2)
        exit()

    end_count = 0
    for i in range(n)[::-1]:
        if s[i] == initial:
            end_count += 1
        else:
            break

    ans -= (start_count//2 + end_count//2 - (start_count+end_count)//2)*(k-1)
    print(ans)


Measured memory_bytes: 61556
import Data.List

main = do
  li <- getLine
  let [h,w,k] = map read $ words li
  co <- getContents
  let ls = lines co
  print $ compute h w k ls

compute :: Int -> Int -> Int -> [String] -> Int
compute h w k ls = length
  [ ()
  | hcs <- enumu h
  , let ls1 = transpose [ l | (b,l) <- zip hcs ls, b ]
  , k <= (length $ filter ('#' ==) $ concat ls1)
  , wcs <- enumu w
  , let ls2 = [ l | (b,l) <- zip wcs ls1, b ]
  , k == (length $ filter ('#' ==) $ concat ls2)
  ]

enumu 0 = [ [] ]
enumu n = [ b:bs | b <- [False,True], bs <- enumu (pred n) ]


Measured memory_bytes: 4020
string = input()
string = string.lower()
strDict = {}
for i in range(len(string)):
    if string[i] in strDict:
        strDict[string[i]] = strDict[string[i]] - 1
    else:
        strDict[string[i]] = 1
not_fount = True
for key, value in strDict.items():
    if value != 0:
        print("No")
        not_fount = False
        break
        
if not_fount:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

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

    int avr = accumulate(a, a+n, 0)/n;

    int ans = 1e9;
    for(int d=-1; d<2; d++){
        int base = avr + d;
        int cand = 0;
        for(int i=0; i<n; i++){
            cand += (a[i] - base)*(a[i] - base);
        }

        ans = min(ans, cand);
    }

    cout << ans;




    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int H, W;
    int i, j;

    while(1){
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) break;
        for (i = 0; i < H; i++){
            for (j = 0; j < W; j++){
                putchar('#');
            }
            printf("\n");
        }  
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  int H,A;cin>>H>>A;
  if(H==A)cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W,S;
int A[33][33];
int sum[33][33];
pint memo[33][33][33][33];
int sumall;
int f(int y1,int x1,int y2,int x2){
    return sum[y2][x2]-sum[y2][x1]-sum[y1][x2]+sum[y1][x1];
}

pint dfs(int y1,int x1,int y2,int x2){
    pint &ret=memo[y1][x1][y2][x2];
    if(ret.fi!=-1)return ret;

    if(sumall-f(y1,x1,y2,x2)>S)return pint(INT_MIN,INT_MIN);
    ret=pint(1,f(y1,x1,y2,x2));
    for(int i=y1+1;i<y2;i++){
        pint p1=dfs(y1,x1,i,x2),p2=dfs(i,x1,y2,x2);
        p1.fi+=p2.fi;chmin(p1.se,p2.se);
        chmax(ret,p1);
    }
    for(int i=x1+1;i<x2;i++){
        pint p1=dfs(y1,x1,y2,i),p2=dfs(y1,i,y2,x2);
        p1.fi+=p2.fi;chmin(p1.se,p2.se);
        chmax(ret,p1);
    }
    return ret;
}

void solve(){

    rep(i,H)rep(j,W)cin>>A[i][j];

    rep(i,H)rep(j,W)sum[i+1][j+1]=A[i][j]+sum[i+1][j]+sum[i][j+1]-sum[i][j];
    fill_n(***memo,33*33*33*33,pint(-1,-1));
    sumall=f(0,0,H,W);
    pint p=dfs(0,0,H,W);
    cout<<p.fi<<" "<<S-sumall+p.se<<endl;
}

signed main(){
    while(cin>>H>>W>>S,H||W||S)solve();
    return 0;
}

Measured memory_bytes: 21636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 200000
#define INF 2140000000
#define MOD 1000000007


void visit(vector<vector<int> > &adj, int u, int flag[]) {
	flag[u] = 1;
	
	for (int i = 0; i < (int) adj[u].size(); ++i) {
		if(!flag[adj[u][i]]) {
			visit(adj, adj[u][i], flag);
		}
	}
	
	return;
}

int dfs(vector<vector<int> > &adj) {
	int flag[(int) adj.size()] = {0};
	int scc = 0;

	for (int i = 0; i < (int) adj.size(); ++i) {
		if(!flag[i]) {
			scc++;
			visit(adj, i, flag);
		}
	}

	return scc;
}

int main() {
	int n, m, u, v, l;
	cin >> n >> m;

	vector<vector<int> > adj(n);

	for (int i = 0; i < m; ++i) {
		cin >> u >> v >> l;
		adj[u - 1].push_back(v - 1);
		adj[v - 1].push_back(u - 1);
	}

	cout << dfs(adj) << endl;

	return 0;
}

Measured memory_bytes: 10752
#!/usr/bin/env python3.4.3
n = int(input())
fct = {}  # prime factor
for n in range(1, n + 1):
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct[b] = fct.get(b, 0) + e
        b, e = b + 1, 0
    if n > 1:
        fct[n] = fct.get(n, 0) + 1
p = 1
MOD = 10**9+7
for i in fct.values():
    p *= i + 1 % MOD
    p %= MOD
print(p)

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

void solve(int TestCase) {
    int r, c;
    cin >> r >> c;
    vector<string> board(r);
    for(auto& x : board)
        cin >> x;
    
    int ret = 0;
    for(auto si = 0; si < r; ++si) {
        for(auto sj = 0; sj < c; ++sj) {
            if(board[si][sj] == '#') continue;

            queue<vector<int>> q;
            q.push({si, sj, 0});
            vector<vector<bool>> visited(r, vector<bool>(c));
            while(!q.empty()) {
                int y, x, d;
                y = q.front()[0];
                x = q.front()[1];
                d = q.front()[2];
                q.pop();

                if(visited[y][x])
                    continue;
                visited[y][x] = true;

                constexpr int dyx[5] = {-1, 0, 1, 0, -1};
                for(auto i = 0; i < 4; ++i) {
                    int ny = y + dyx[i];
                    int nx = x + dyx[i+1];

                    if(ny < 0 || ny >= r || nx < 0 || nx >= c) continue;
                    if(board[ny][nx] == '#') continue;

                    q.push({ny, nx, d + 1});
                }

                ret = max(ret, d);
            }
        }
    }

    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i)
        solve(i);
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
count = A[0]//2
A[0] %= 2
for i in range(1,N):
    if A[i] == 0:
        continue
    if A[i-1] != 0:
        count += 1
        A[i] -= 1
    count += A[i]//2
    A[i] %= 2
print(count)


Measured memory_bytes: 7072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dwij
 */


#include <bits/stdc++.h>


using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define endl '\n'

/**********************************************/




class BHomework {
public:
    void solve(istream &in, ostream &out) {

        long n, m;
        in >> n >> m;

        long arr[n];
        long sum = 0;
        for (int i = 0; i < m; ++i) {
            in >> arr[i];
            sum += arr[i];
        }


        if (sum > n) {
            out << -1 << endl;
        } else {
            out << n - sum << endl;
        }

    }
};


int main() {
    BHomework solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    long long sum=0;
	cin>>n;	
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)sum=sum+i;
	}
    cout<<sum;
}

Measured memory_bytes: 3644
#include<stdio.h>
int min(int a,int b){return a < b ? a : b;}
int max(int a,int b){return a > b ? a : b;}
int main(){
    int n, a, b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d %d\n",min(a,b),max(0,-(n - a - b)));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 1100
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;



int main() {
	int N, M;
	int ans[10000];
	cin >> N >> M;
	ans[0] = 0;
	int Looptime = pow(2, N);
	rep(j, Looptime) {
		if (j == 0)
			continue;
		ans[j] = pow(10, 9);
	}
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		int atmp = 0;
		rep(j, b) {
			int c;
			cin >> c;
			c--;
			atmp += pow(2, c);
		}
		rep(j, Looptime) {
			int j_or_atmp = j | atmp;
			ans[j_or_atmp] = min(ans[j_or_atmp], ans[j] + a); // iを使うべきか
		}
	}
	int ansans = ans[Looptime - 1];
	if (ansans == pow(10, 9))
		ansans = -1;
	cout << ansans << endl;
	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if x*y >0:
  k=2
else:
  k=1
if x==y:
  print(0)
if x==0 and y<0:
  print(abs(y)+1)

elif x<y:
  if k==2 or x==0:
    print(y-x)
  elif y == 0:
    print(abs(x))
  else:
    print(abs(abs(y)-abs(x))+k)
else:
  if y==0 and x<0:
    print(abs(x))
  else:
    print(abs(abs(y)-abs(x))+k)


Measured memory_bytes: 3064
#include<stdio.h>

int A[2000000], B[2000000];

int main(){
  int C[10000], D[10000];
  int n, i, a;

  scanf("%d",&n);

  for(i = 0; i < 10000; i++) C[i] = 0;

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

  D[0] = 0;

  for(i = 1; i < 10000; i++) D[i] = D[i - 1] + C[i - 1];

  for(i = 0; i < n; i++){
    a = A[i];
    B[D[a]] = a;
    D[a]++;
  }

  for(i = 0; i < n; i++){
    printf("%d",B[i]);
    if(i != n - 1) printf(" ");
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 16308
N,A,B = (int(x) for x in input().split())
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    if B - A == 1:
        if A == 1 or B == N:
            print('1')
        else:
            print('2')
    else:
        if A <= N-B:
            print((A+B-1)//2)
        else:
            print((2*N-A-B+1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>c){
		cout<<"NO"<<endl;
	}else{
		if(a+b>c){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D = 365;
  vector<pair<int, int>> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> t(D);
  
  for(int i = 0; i < 26; i++){
    cin >> c.at(i).first;
    c.at(i).second = 0;
  }
  
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> s.at(i).at(j);
    }
  }
  
  for(int i = 0; i < D; i++){
    t.at(i) = rand() % 26+1;
  }
  
  int count = 0;
  int S = 0;
  vector<int> ans(D);
  while(count++ < 100000){
    
  t.at((rand() % D+1)-1) = rand() % 26+1;

  int Pl = 0;
  int Mi = 0;
  
    for(int i = 0; i < D; i++){
      Pl += s.at(i).at(t.at(i)-1);
      c.at(t.at(i)-1).second = i + 1;
      for(int j = 0; j < 26; j++){
        Mi += c.at(j).first*(i+1 - c.at(j).second);
      }
      Pl -= Mi;
      Mi = 0;
    }
  if(S < Pl){
    S = Pl;
    for(int i = 0; i < D; i++){
      ans.at(i) = t.at(i);
    }
  }
  else if(S >= Pl){
    continue;
  } 
}
  for(int i = 0; i < D; i++){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 3668
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

X = int(input())
if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)

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


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n; cin >> n;
  ll a[85], dp[85];
  for (int i = 1; i <= n; ++i) cin >> a[i];
  dp[1] = 1000;
  for (int i = 2; i <= n; ++i) {
    dp[i] = dp[i-1];
    for (int j = 1; j <= i-1; ++j) {
      ll b = dp[j] / a[j];
      ll v = dp[j] + (a[i]-a[j]) * b;
      dp[i] = max(dp[i], v);
    }
  }
  cout << dp[n] << endl;
}

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

int main(){
  string s;
  cin >> s;
  bool isc = false;
  bool iscf = false;
  REP(i,s.size()){
    if( s[i] == 'C' ) isc = true;
    if( isc && s[i] == 'F' ) iscf = true;
  }
  if( iscf ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
s=str(input())
ans=0
for i in range(1<<(len(s)-1)):
  st=s[0]
  for j in range(len(s)-1):
    if i & (1<<j):
      st+="+"+s[j+1]
    else:
      st+=s[j+1]
  ans+=eval(st)
print(ans)


Measured memory_bytes: 3060
// problem: "https://atcoder.jp/contests/abc160/tasks/abc160_b"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll x;
    cin>>x;

    cout<<1000 * (x/500) + ((x%500)/5) * 5;

    return 0;
}


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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int main()
{
    fast();
    string s , t;
    cin>>s>>t;
    int c=0;
    for(int i=0;i<s.length();++i){
        if(s[i]!=t[i])c++;
    }
    cout<<c<<endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int x,y; scanf("%d%d",&x,&y);
    int nx=0,ny=0,sz=1,pre=0,col=0,rot=0;
    while(1){
        if(nx<=x&&x<nx+sz&&ny<=y&&y<ny+sz){
            printf("%d\n",(col%3)+1); return 0;
        }
        int nxt=sz+pre;
        if(rot==0)nx+=sz;
        if(rot==1){
            nx-=pre; 
            ny+=sz;
        }
        if(rot==2){
            nx-=nxt;
            ny-=pre;
        }
        if(rot==3)ny-=nxt;
        pre=sz; sz=nxt;
        col++; rot=(rot+1)%4;
    }
    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Linq;

namespace HelloWorld
{
    class Vel
    {
        internal int Velocity { get; set; }
    }
    class Program
    {
        static void Main()
        {
            string Dist;
            while ((Dist = Console.ReadLine()) != null)
            {
                var a = Dist.Split(',').Select(x => double.Parse(x)).ToArray();
                double All_Dist = 0;
                for (int j = 0; j < a.Length - 2; ++j)
                {
                    All_Dist += a[j];
                }
                double v1 = a[10];
                double v2 = a[11];
                double time = All_Dist / (v1 + v2);
                double dist = time * v1;
                int count;
                for (count = 0; 0 < dist; ++count)
                {
                    dist -= a[count];
                }
                Console.WriteLine(count);
            }
        }
    }
}



Measured memory_bytes: 18376
*, m = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = a.min + b.min

m.times do
    x, y, c = gets.split.map(&:to_i)
    n = a[x-1] + b[y-1] - c
    ans = n if ans > n
end

puts ans

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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	int n;cin>>n;
	cout<<(n%2==0?(n/2):((n/2)+1))<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int l[n];
  REP(i,n) cin >> l[i];
  int ans = 0;
  sort(l,l+n,greater<>());
  
  FOR(i,0,n){
    FOR(j,i+1,n){
      FOR(k,j+1,n){
        if(abs(l[i]-l[j]) < l[k]) ans++;
        else break;
      }
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll temp;
	ll maxs=0;
	scanf("%lld",&temp);
	for(ll i=1;i*i<=temp;i++)
	{
		if(temp%i==0)
		{
			maxs=max(maxs,i);
		}
	}
	temp/=maxs;
	int res=0;
	while(temp)
	{
		res++;
		temp/=10;
	}
	printf("%d\n",res);
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,y,z;
    cin>>x>>y>>z;


    cout<<z<<" "<<x<<" "<<y<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#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=998244353;


int main(void){
    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1]+='a'-'A';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define itn int

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

int dp[110][110*(int)1e3];

signed main ( ) {

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

    memset(dp, 0x3f, sizeof(dp));

    dp[0][0] = 0;

    for ( int  i = 0; i < n; i++ ) {
        for ( int j = 0; j < 110*(int)1e3; j++ ) {
            if ( j < v[i] ) {
                dp[i+1][j] = dp[i][j];
            }
            else {
                dp[i+1][j] = min ( dp[i][j],
                        dp[i][j-v[i]] + w[i] );
            }
        }
    }

    int rec = 0;
    for ( int i = 0; i < 110*(int)1e3; i++ ) {
        if ( dp[n][i] <= W ) rec = i;
    }

    cout << rec << endl;


    return 0;
}

Measured memory_bytes: 47488
// Vicfred
// https://atcoder.jp/contests/abc153/tasks/abc153_d
// backtracking
import std.stdio;

long f(long h) {
    if(h == 1L)
        return 1;
    return 1L+2L*f(h/2L);
}

void main() {
    long h;
    readf("%s", &h);
    readln;

    f(h).writeln;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
L=[[] for i in range(n)]
for i in range(m):
    s,c=map(int,input().split())
    L[s-1].append(c)
k=0
#print(L)
for i in range(n):
    if len(set(L[i]))>1:
        k=1
if L[0]==[0]:
    k=1
if n==1:
    if set(L[0])=={0} or L[0]==[]:
        print(0)
    elif len(set(L[0]))==1:
        print(L[0][0])
    else:
        print(-1)            
elif k==1:
    print(-1)
else:
    for i in range(n):
        if not(L[i]):
            if i==0:
                print(1,end='') 
            else:
                print(0,end='')
        else:
            print(L[i][0],end='')                           

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll k, n, ans = LLONG_MAX;
        cin >> k >> n;
        ll arr[n+1];
        for(ll i = 0; i < n; i++)cin >> arr[i];
        arr[n] = arr[0]+k;
        for(int i = 0; i < n; i++){
            ans = min(k- (arr[i+1] - arr[i]), ans);
        }
        cout << ans;
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<ll>> dp(n,vector<ll>(n,0));
    for (int i = 0;i < n;++i) dp[0][i] = 1;
    for (int i = 1;i < n;++i) {
        vector<ll> sums(n+1,0);
        for (int j = 0;j < n;++j) sums[j+1] = (sums[j]+dp[i-1][j])%mod;
        if (s[i-1] == '<') for (int j = 0;j < n-i;++j)  dp[i][j] = sums[j+1];
        else for (int j = 0;j < n-i;++j)  dp[i][j] += sums[n]-sums[j+1];
        for (int j = 0;j < n;++j) dp[i][j] %= mod;
    }
    cout << (dp[n-1][0]+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <bitset>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int a[N] , b[N] , ca[N] , cb[N] ;
int work()
{
  int n ;
  cin >> n ;
  for(int i = 0; i < n ;i ++ ) cin >> a[i] , ca[a[i]] ++ ;
  for(int i = 0; i < n ;i ++ ) cin >> b[i] , cb[b[i]] ++ ;
  for(int i = 1; i <= n ;i ++ )
   if(ca[i] + cb[i] > n)
    return 9 * puts("No") ;
  for(int i = 1; i <= n ;i ++ )
   ca[i + 1] += ca[i] , cb[i + 1] += cb[i] ;
   int s = 0 ;
   puts("Yes") ;
   for(int i = 1; i <= n ;i ++ ) s = max(s , cb[i] - ca[i - 1]) ;
  for(int i = 0 ;i < n ;i ++ )
   cout << b[(i + s) % n] << " " ;
  puts("") ;
  return 0 ;
}
int main()
{
  //   freopen("C://Users//spnooyseed//Desktop//in.txt" , "r" , stdin) ;
  //   freopen("C://Users//spnooyseed//Desktop//out.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 6300
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt(), a = scanInt(), b = scanInt();
		if ((Integer.bitCount(a ^ b) & 1) == 0) {
			out.print("NO");
		} else {
			out.println("YES");
			go((1 << n) - 1, a, b);
		}
	}

	static void go(int mask, int a, int b) {
		if ((mask & (mask - 1)) == 0) {
			out.print(a + " " + b + " ");
		} else {
			int c = Integer.lowestOneBit(a ^ b);
			int d = Integer.lowestOneBit(mask ^ c);
			go(mask ^ c, a, a ^ d);
			go(mask ^ c, a ^ d ^ c, b);
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 33556
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int n;
char s[105];
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		scanf("%s", s + 1);
		stack<char> q;
		for(int i = 1; i <= n; i++)
		{
			if(q.empty()) q.push(s[i]);
			else
			{
				if(q.top() == ')') q.push(s[i]);
				else if(q.top() == '(')
				{
					if(s[i] == '(') q.push(s[i]);
					else if(s[i] == ')') q.pop();
				}
			}
		}
		int l = 0, r = 0;
		while(!q.empty())
		{
			if(q.top() == ')') l++;
			else r++;
			q.pop();
		}
		for(int i = 1; i <= l; i++)
			printf("(");
		for(int i = 1; i <= n; i++)
			printf("%c", s[i]);
		for(int i = 1; i <= r; i++)
			printf(")");
		printf("\n");
		memset(s, 0, sizeof(s));
	}
	return 0;
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a==b+c || b==a+c || c==a+b)
        cout<<"Yes";
    else
        cout<<"No";
}




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

const int len = 1e6+6;
char str[len];

int main(){
    scanf("%s", &str);
    int n = strlen(str), cnt = 0, ans = n;
    for (int i = 0; i < n; i++){
        if (str[i] == 'S')
            cnt++;
        else if (cnt > 0){
            ans -= 2;
            cnt--;
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
template<class T>using p_queue=std::priority_queue<T, std::vector<T>, std::greater<>>;

template<class T>struct max_value
{
	T v;
	max_value(T u = std::numeric_limits<T>::min()) :v(u)
	{

	}
	auto& operator=(T const& u)
	{
		v = std::max(v, u);
		return *this;
	}
	T operator*()const
	{
		return v;
	}
	void reset()
	{
		v = std::numeric_limits<T>::min();
	}
};


void Main()
{
	index_t N, K;
	std::cin >> N >> K;
	std::vector<std::pair<std::int64_t, index_t>> sushi(N);
	for (auto& p : sushi)
	{
		std::cin >> p.second >> p.first;
		--p.second;
	}
	boost::sort(sushi, std::greater<>());

	std::vector<int>count(N);
	std::int64_t base = 0, x = 0;
	p_queue<std::pair<std::int64_t, index_t>> queue;
	for (auto i : boost::irange<index_t>(0, K))
	{
		base += sushi[i].first;
		++count[sushi[i].second];
		if (count[sushi[i].second] == 1)
		{
			++x;
		}
		queue.emplace(sushi[i]);
	}
	max_value<std::int64_t> max = base + x * x;
	for (auto i : boost::irange<index_t>(K, N))
	{
		if (count[sushi[i].second])
		{
			continue;
		}
		while (queue.size())
		{
			auto top = queue.top();
			queue.pop();
			if (count[top.second] != 1)
			{
				--count[top.second];
				++count[sushi[i].second];
				base += sushi[i].first - top.first;
				++x;
				max = base + x * x;
				break;
			}
		}
	}
	std::cout << *max << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 4340
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m-1):
  if x > a[-1] or x < a[0]:
    ans1 = 0
    ans2 = 0
  elif a[i] < x <a[i+1]:
    ans1 = len(a[:i+1])
    ans2 = len(a[i+1:])
print(min(ans1, ans2))

Measured memory_bytes: 9200
#include<stdio.h>
int main(){
  int n,h,i,j,d[100]={};
  while(scanf("%d",&n),n){
    h=n<0?-1:1;
    n*=h;//printf("%d\n",n);
    for(i=0;i<100;i++)d[i]=0;
    for(i=0;n;n/=10){//printf("%d\n",n);
      d[i++]=(n%10)*h;
      h*=-1;
    }
    //for(j=0;j<i;j++)printf("%d ",d[j]);printf("\n");
    for(j=0;j<i||d[j];j++){
      if(d[j]>9){
	d[j]-=10;
	d[j+1]--;
      }
      if(d[j]<0){
	d[j]+=10;
	d[j+1]++;
      }
    }
    if(d[j])printf("%d",d[j]);
    while(--j)printf("%d",d[j]);
    printf("%d\n",d[0]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Possible" : "Impossible")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	ll l;

	int at = -1;
	cin >> n >> l;
	ll up = l - 1LL;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		if (i != 0) {
			if (chmax(up, a[i] + a[i - 1])) {
				at = i;
			}
		}
	}

	cout << solve(at != -1) << endl;
	if (at == -1) return 0;
	for (int i = 1; i != at; i++) {
		cout << i << endl;
	}
	for (int i = n - 1; i >= at; i--) {
		cout << i << endl;
	}
}

Measured memory_bytes: 4048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class K
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		int[] a = GetInts(N);

		int[] grundy = new int[K + 1];
		for(int i = 0; i <= K; i++)
		{
			var set = new HashSet<int>();
			for(int j = 0; j < N; j++)
			{
				if(i - a[j] >= 0)
					set.Add(grundy[i - a[j]]);
			}

			for(int j = 0; ; j++)
			{
				if(!set.Contains(j))
				{
					grundy[i] = j;
					break;
				}
			}
		}

		WriteLine((grundy[K] > 0) ? "First" : "Second");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 17948
N, M = [int(c) for c in input().split()]
path = [[] for _ in range(N)]
for i in range(M):
    u, v = [int(c) for c in input().split()]
    path[u-1].append(v-1)

S, T = [int(c)-1 for c in input().split()]

reach = [[-1 for _ in range(N)] for _ in range(3)]
reach[0][S] = 0

queue={S}

time = 1
for _ in range(4*N):
    queue_new = set()
    for q in queue:
        for v in path[q]:
            if reach[time%3][v]==-1:
                reach[time%3][v]=time
                queue_new.add(v)
		
    queue = queue_new
    time += 1

if reach[0][T]==-1:
    print(-1)
else:
    print(reach[0][T]//3)

Measured memory_bytes: 30036
#include <stdio.h>

int main() {
  int i;
  scanf("%d", &i);
  int a, b, c, d;
  d = i % 10;
  c = i % 100 / 10;
  b = i % 1000 / 100;
  a = i / 1000;
  
  if (a == b || b == c || c == d) {
    printf("Bad\n");
  } else {
    printf("Good\n");
  }
  return 0;
}


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

int main() {
    int N,K,maxx;
    int64_t ans = 9223372036854775807,count;
    
    cin >> N>> K;
    vector<int> a(N);
    vector<int> a2(N);
    for(int i=0;i<N;i++)
        cin >> a.at(i);
    for (int bit = 0; bit < (1<<(N-1)); ++bit) {
        vector<int> S;
        count=0;
        a2=a;
        for (int i = 0; i < N-1; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i+1);
            }
        }
        if((int)S.size()!=K-1)
            continue;
        for (int i = 0; i < (int)S.size(); ++i) {
            maxx = *std::max_element(a2.begin(), a2.begin()+S.at(i));
            if(maxx>=a2.at(S.at(i))){
                count+=maxx-a2.at(S.at(i))+1;
                a2.at(S.at(i))+=maxx-a2.at(S.at(i))+1;
            }

        }
        ans=min(ans,count);
        /*for(int i=0;i<N;i++)
            cout << ifa.at(i) <<" ";
        cout << count <<endl;
        */
    }
    if(9223372036854775807==ans)
        ans =0;
    cout << ans <<endl;
    
}

Measured memory_bytes: 3524
"use strict";
    
const main = arg => {
    const times = arg.split("\n")[0].split(" ");
    
    /*
    if(times[2] > times[1]) {
        console.log(0);
        return;
    }
    
    const start = Math.max(times[0], times[2]);
    const end   = Math.min(times[1], times[3]);
    
    console.log(end - start > 0 ? end - start : 0);
    */
    
    console.log(Math.max(0, Math.min(times[1], times[3]) - Math.max(times[0], times[2])));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    int n = 3, k = 4;
    cin >> n >> k;
    cout << k * (ll)(pow(k - 1, n - 1)) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int oo=1e5;
int n,W,w[101],v[101],f[101][100001];
int main()
{
    int res=INT_MAX,kq;
    //freopen("test.inp","r",stdin);
    cin >> n >> W;
    f(i,1,n) cin >> w[i] >> v[i];
    f(i,0,n) f(j,0,oo) f[i][j]=INT_MAX;
    f[0][0]=0;
    
    
    f(i,0,n-1) f(t,0,oo) if(f[i][t]<INT_MAX)
    {
        if(f[i][t]+w[i+1]<=W) f[i+1][t+v[i+1]]=min(f[i+1][t+v[i+1]],f[i][t]+ w[i+1]);
        f[i+1][t]=min(f[i+1][t],f[i][t]);
    }
    for(int i=oo;i>=0;--i)
        if(f[n][i]<INT_MAX)
        {
            cout<<i;
            return 0;
        }
}


Measured memory_bytes: 39680