akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,n) for (register int i=a;i<=n;i++)
#define per(i,a,n) for (register int i=n;i>=a;i--)
#define FOR(i,a,n,x) for (register int i=a;i<=n;i+=x)
#define ROF(i,a,n,x) for (register int i=n;i>=a;i-=x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

template <typename T>

inline void read(T &X) {
  X = 0; char ch = 0; T op = 1;
  for(; ch > '9' || ch < '0'; ch = getchar())
    if(ch == '-') op = -1;
  for(; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}

const int INF = 0x3f3f3f3f;
const int MAXN = 10 + 5;

char ma[MAXN][MAXN];
int n,m,k;

int main() {
#ifdef WiLe
  freopen ("input.txt", "rt", stdin);
#endif

  read(n), read(m), read(k);
  rep (i, 0, n-1) scanf("%s", ma[i]);

  int bcnt = 0;
  rep (i, 0, n-1) rep (j, 0, m-1) {
    if (ma[i][j] == '#') bcnt++;
  }

  int ans = 0;
  rep (i, 0, (1<<n)-1) rep (j, 0, (1<<m)-1) {
    int cnt = bcnt;
    rep (nn, 0, n-1) rep (mm, 0, m-1) {
      if ((1<<nn) & i || (1<<mm) & j) {
        if (ma[nn][mm] == '#') cnt--;
      }
    }
    if (cnt == k) ans++;
  }

  printf("%d\n", ans);

#ifdef WiLe
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
/*
# author : WiLe
# date : 2020/07/18
*/

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int w,h,n;
	cin>>w>>h>>n;
	
	int maxx=0,minx=w,maxy=0,miny=h;
	REP(i,n){
		int x,y,a;
		cin>>x>>y>>a;
		
		if(a==1){
			if(x>maxx) maxx=x;
		}else if(a==2){
			if(x<minx) minx=x;
		}else if(a==3){
			if(y>maxy) maxy=y;
		}else if(a==4){
			if(y<miny) miny=y;
		}
	}
	
	int ans;
	if(minx-maxx<0||miny-maxy<0) ans=0;
	else ans=(minx-maxx)*(miny-maxy);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
	Created by Faisal Ahmed
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	int h, a;
	
	cin >> h >> a;
	
	int ans = 0;
	while(h > 0){
		ans++;
		h -= a;
	}
	
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int x;
  scanf("%d", &x);
  
  if(x >= 1800) printf("1");
  else if(x >= 1600) printf("2");
  else if(x >= 1400) printf("3");
  else if(x >= 1200) printf("4");
  else if(x >= 1000) printf("5");
  else if(x >= 800) printf("6");
  else if(x >= 600) printf("7");
  else printf("8");
    
  return 0;
}

Measured memory_bytes: 1660
import sys
input=sys.stdin.readline
n,m,v,p=map(int,input().split())
a_list=list(map(int,input().split()))
a_list.sort(reverse=True)
ans=p
S=0
for k in range(p+1,n+1):
    S+=a_list[k-2]
    if n-k+p>=v:
        if a_list[k-1]+m>=a_list[p-1]:
            ans+=1
    else:
        if a_list[k-1]+m>=a_list[p-1]:
            d=(k-p)*(a_list[k-1]+m)-S
            if (v-n+k-p)*m<=d:
                ans+=1
print(ans)


Measured memory_bytes: 58812
#include<cstdio>
int main(){
  int S;
  std::scanf("%d",&S);
  int h = S / 3600;
  S %= 3600;
  int m = S /60;
  int s = S % 60;

  std::printf("%d:%d:%d\n",h,m,s);
  return 0;
}


Measured memory_bytes: 2712
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static long B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);


    String s = scanner.nextLine();

    boolean ans = false;
    int N = s.length();
//    System.out.println(N);

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        String temps = s.substring(0,i) + s.substring(j + 1, N);
        if(temps.equals("keyence"))ans = true;
//        System.out.println(temps);
      }

    }

    if(ans){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }


  }

}


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

int main()
{
  int S;
  cin >> S;
  int h, m, s;
  h = S / 3600;
  S %= 3600;
  m = S / 60;
  S %= 60;
  s = S;
  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1&&b==2)
    {
        printf("3\n");
    }
    else if(a==2&&b==1)
    {
        printf("3\n");
    }
    else if(a==2&&b==3)
    {
        printf("1\n");
    }
    else if(a==3&&b==2)
    {
        printf("1\n");
    }
    else if(a==3&&b==1)
        printf("2\n");
    else if(a==1&&b==3)
    {
        printf("2\n");
    }
    return 0;
}

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

const int N = 5;
int A[N];

int main(){
   for(int i = 0; i<N; i++) cin >> A[i];
   for(int i = 0; i<N; i++){
      if(A[i]==0) cout << i + 1 << endl;
   }
   return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios()                \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)

signed main()
{
	ios();
	int N;
	cin >> N;
	int W[N];
	int sum  = 0;
	for (int wi = 0; wi < N; wi++) {
		cin >> W[wi];
		sum += W[wi];
	}
	int tmp = 0;
	for (int wi = 0; wi < N; wi++) {
		tmp += W[wi];
		if (2 * tmp >= sum ) {
			cout << min(abs(sum - 2 * tmp) , abs(sum - 2 * (tmp - W[wi])))<< endl;
			return 0;
		}
	}
}

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

int main(){
  string x;
  cin >> x;
  
  int ans;
  for(int i=0; i < x.size()-2; i++){
    string str;
  	str += x[i];
    str += x[i+1];
    str += x[i+2];
    int num = stoi(str);
    if(i==0){
      ans = abs(753-num);
    }else{
      if(ans>abs(753-num)) ans = abs(753-num);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {

var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var K = inputArray[1];




			//答えの出力
			var ans = getAns(N,K);
			Console.WriteLine(ans);

		}

		private static long getAns(long N , long K) {

			var keta = 1;
			while (true) {

				//その桁で表せる数を超える最小の数:例えばK=10の場合100は2桁で表せない
				var over_keta= Math.Pow(K,keta);

				if (N < over_keta) {
					return keta;
				}
				keta++;
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<ll>v;

ll cal(int middle) {
	ll a, b, c, d;
	int bottom = 0, top = middle;
	while (top - bottom >= 2) {
		if (2 * v[(bottom + top) / 2] > v[middle]) {
			top = (bottom + top) / 2;
		}
		else {
			bottom = (bottom + top) / 2;
		}
	}
	if (v[bottom] + v[top] <= v[middle]) {
		a = v[top];
		b = v[middle] - v[top];
	}
	else {
		a = v[bottom];
		b = v[middle] - v[bottom];
	}
	bottom = middle + 1, top = v.size() - 1;
	while (top - bottom >= 2) {
		if (2 * v[(bottom + top) / 2] > v[v.size() - 1] + v[middle]) {
			top = (bottom + top) / 2;
		}
		else {
			bottom = (bottom + top) / 2;
		}
	}
	if (v[bottom] + v[top] <= v[middle] + v[v.size() - 1]) {
		c = v[top] - v[middle];
		d = v[v.size() - 1] - v[top];
	}
	else {
		c = v[bottom] - v[middle];
		d = v[v.size() - 1] - v[bottom];
	}
	return max(max(a, b), max(c, d)) - min(min(a, b), min(c, d));
}

int main() {
	int n;
	cin >> n;
	ll tmp;
	cin >> tmp;
	v.push_back(tmp);
	REPll(i, 1, n) {
		cin >> tmp;
		v.push_back(v[v.size() - 1] + tmp);
	}
	ll ans = INF;
	REP(i, 1, n - 2) {
		ans = min(ans, cal(i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int n;
	cin >> n;
	int I = max(2, n);
	if (n == 1) {
		cout << 2 << endl;
		return 0;
	}
	for (int i = 1;; i++) {
		if (n * i % 2 == 0) {
			cout << n*i << endl;
			return 0;
		}
	}

	

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  
  for(int i = 0; i < s.size(); i++){
    if(i%2==1){
      if(s.at(i)=='R'){
        ans = false;
        break;
      }
    }
    else{
      if(s.at(i)=='L'){
        ans = false;
        break;
      }
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

inline int in(){int x;scanf("%lld",&x);return x;}

int32_t main()
{
	int r=in();int d=in();int a=in();
	for(int i=0;i<10;i++)
	{
		a=r*a-d;
		cout<<a<<'\n';
	}
	
}

Measured memory_bytes: 3764
import math
x = int(input())

def f(a, b):
    return a ** 5 - b ** 5
def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            # √nで無い数についてもう一個プラス
            if i != n // i:
                divisors.append(n // i)
    return divisors
division = sorted(make_divisors(x))
sele = math.floor(x ** (1/4))
for div in division:
    for j in range(-sele, sele + 1):
        a1 = j
        b1 = j - div
        if f(a1, b1) == x:
            print(a1, b1)
            break
    else:
        continue
    break

Measured memory_bytes: 65460
import sys
sys.setrecursionlimit(10**5+100)

N,M=map(int,input().split())
G=[[] for _ in range(N)]
for _ in  range(M):
    xi,yi=map(int,input().split())
    G[xi-1].append(yi-1)

dp=[-1]*N #各ノードを始点とした時の最長経路

def rec(v):
    if dp[v]!=-1:
        return dp[v]
    
    res=0

    for nv in G[v]:
        res=max(res,rec(nv)+1)
    
    dp[v]=res
    return res

ans=0
for v in range(N):
    ans=max(ans,rec(v))
print(ans)

Measured memory_bytes: 154060
import numpy as np
import heapq
n = list(map(int, input().split()))
h = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(h)
for i in range(n[1]):
    small = heapq.heappop(h)
    heapq.heappush(h, -1*(-small//2))
print(-sum(h))

Measured memory_bytes: 23216
def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  if N == 0 and A[0] != 1:
    print(-1)
    return True
  min_maxs = [0] * len(A)
  min_maxs[len(A)-1] = [A[-1], A[-1]]

  for index in reversed(range(len(A)-1)):
    min_maxs[index] = [min_maxs[index+1][0] // 2 + A[index], min_maxs[index+1][1] + A[index]]

  result = 1
  recent = 1
  for index in range(1, len(A)):
    num_of_node = (recent - A[index-1]) * 2
    if num_of_node < min_maxs[index][0]:
      print(-1)
      return True
    
    result += min(num_of_node, min_maxs[index][1])
    recent = min(num_of_node, min_maxs[index][1])

  print(result)

if __name__ == "__main__":
    resolve()

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

struct node {
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL
void inorder(Node);
void preorder(Node);
void insert(int);

Node root;

int main() {
	int n, i, x;
	char com[20];

	scanf("%d", &n);

	for (x = 0; x < n; x++) {
		scanf("%s", com);

		if (com[0] == 'i') {
			scanf("%d", &i);
			insert(i);
		}
		else {
			if (root != NIL) {
				inorder(root);
				printf("\n");
				preorder(root);
				printf("\n");
			}
		}
	}

	return 0;
}


void insert(int in) {
	Node new, work, move;

	new = (Node)malloc(sizeof(struct node));
	new->key = in;
	new->right = NIL;
	new->left = NIL;

	work = NIL;
	move = root;
	while (move != NIL) {
		work = move;
		if (move->key > in) {
			move = move->right;
		}
		else {
			move = move->left;
		}
	}

	new->parent = work;
	if (work == NIL) root = new;
	else if (work->key > in) work->right = new;
	else work->left = new;

}


void inorder(Node x) {
	if (x->right != NIL) inorder(x->right);
	printf(" %d", x->key);
	if (x->left != NIL) inorder(x->left);
}


void preorder(Node x) {
	printf(" %d", x->key);
	if (x->right != NIL) preorder(x->right);
	if (x->left != NIL) preorder(x->left);
}


Measured memory_bytes: 25128
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol gcd(lol x,lol y){//最大公約数
  if(y>x) swap(x,y);
  lol r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,x,y;
  string s,w;
  lol a[12000];
  cin >>n;
  lol ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      lol p=gcd(i,j);
      for(int k=1;k<=n;k++){
        ans+=gcd(p,k);
      }
    }
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a>b){
            System.out.println("a > b");
        }else if(a<b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
        scan.close();
    }
}


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

int n;
vector<vector<int>> path;
vector<int> fennec, snuke;

void dijkstra(int x, char p);

int main() {
    int a, b, f = 0, s = 0;
    cin >> n;
    vector<vector<int>> node(n);
    rep(i, n - 1) {
        cin >> a >> b;
        node.at(a - 1).push_back(b - 1);
        node.at(b - 1).push_back(a - 1);
    }
    path = node;
    dijkstra(0, 'f');
    dijkstra(n - 1, 's');
    rep(i, n) {
        if(fennec.at(i) <= snuke.at(i)) f++;
        else s++;
    }
    if(f > s) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

void dijkstra(int x, char p) {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    vector<int> d(n, INT_MAX);
    vector<bool> visited(n, false);
    d.at(x) = 0;
    pq.push(make_pair(0, x));
    pair<int, int> t;
    while(!pq.empty()) {
        t = pq.top();
        pq.pop();
        d.at(t.second) = t.first;
        visited.at(t.second) = true;
        rep(i, path.at(t.second).size()) if(!visited.at(path.at(t.second).at(i))) pq.push(make_pair(t.first + 1, path.at(t.second).at(i)));
    }
    if(p == 'f') fennec = d;
    else snuke = d;
}

Measured memory_bytes: 12532
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> g(h);
    for (int i = 0; i < h; i++) {
        cin >> g[i];
    }

    int black = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j] == '#') {
                black++;
            }
        }
    }

    queue<pair<int, int> > q;
    q.emplace(0, 0);

    vector<vector<int> > dist(h, vector<int>(w, -1));
    dist[0][0] = 0;

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

    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        for (int k = 0; k < 4; k++) {
            int yy = y + dy[k];
            int xx = x + dx[k];
            if (yy < 0 || xx < 0 || yy >= h || xx >= w) continue;
            if (g[yy][xx] == '#') continue;
            if (dist[yy][xx] != -1) continue;
            dist[yy][xx] = dist[y][x] + 1;
            q.emplace(yy, xx);
        }
    }

    cout << ((dist[h-1][w-1] == -1)? -1 : (h * w - dist[h-1][w-1] - black - 1)) << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL<<60;

int main()
{
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }

  ll ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += min(B, A * (list[i + 1] - list[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n,x;
    int card[5][14]={0};
    char t;
    cin>>n;
    
    for(int i=0; i<n; i++){
        cin>> t >> x;
        switch(t){
            case 'S' : card[0][x]=1; break;
            case 'H' : card[1][x]=1; break;
            case 'C' : card[2][x]=1; break;
            case 'D' : card[3][x]=1; break;
        }
    }
    for(int i=0; i<4; i++){
        for(int j=1; j<=13; j++){
            if(card[i][j]==0){
                switch(i){
                    case 0 : cout<<'S'<<' '<<j<<endl; break;
                    case 1 : cout<<'H'<<' '<<j<<endl; break;
                    case 2 : cout<<'C'<<' '<<j<<endl; break;
                    case 3 : cout<<'D'<<' '<<j<<endl; break;
                }
            }
        }
    }
 return 0;   
}




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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    string s;
    cin >> s;
    
    if(s[s.size()-1]=='s')
    {
        cout << s ;
        cout << "es" << endl;
    }
    else
    {
        cout << s ;
        cout << "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

pub fn get_divisors(n: u64) -> Vec<u64> {
    let mut m = 1;
    let mut divs = vec![];
    while m * m <= n {
        if n % m == 0 {
            divs.push(m);
            if n / m != m {
                divs.push(n / m);
            }
        }
        m += 1;
    }
    divs.sort();
    divs
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: u64,
    }

    let divs = get_divisors(n);

    let mut ans: u64 = 1 << 60;
    for i in divs {
        let j = n/i;
        ans = min(ans, (i+j-2));
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
## coding: UTF-8
N = input()
#print(N)
#print(N[0])
#print(N[1])
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])


if(A+B+C+D == 7):
    print('{}+{}+{}+{}=7'.format(A,B,C,D))
elif(A+B+C-D == 7):
    print('{}+{}+{}-{}=7'.format(A,B,C,D))
elif(A+B-C+D == 7):
    print('{}+{}-{}+{}=7'.format(A,B,C,D))
elif(A+B-C-D == 7):
    print('{}+{}-{}-{}=7'.format(A,B,C,D))
elif(A-B+C+D == 7):
    print('{}-{}+{}+{}=7'.format(A,B,C,D))
elif(A-B+C-D == 7):
    print('{}-{}+{}-{}=7'.format(A,B,C,D))
elif(A-B-C+D == 7):
    print('{}-{}-{}+{}=7'.format(A,B,C,D))
elif(A-B-C-D == 7):
    print('{}-{}-{}-{}=7'.format(A,B,C,D))



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

int main()
{
  int n;cin>>n;
  vector<int> x(n-1);
  vector<int> y(n-1);
  int i;
  rep(i,n-1)cin>>x[i]>>y[i];
  rep(i,n-1)
  {
    x[i]--;
    y[i]--;
  }
  vector<vector<int>> g(n);
  rep(i,n-1)
  {
    g[x[i]].emplace_back(y[i]);
    g[y[i]].emplace_back(x[i]);
  }
  vector<int> root(n,-1);
  stack<int> st;
  queue<int> q;
  queue<int> q2;
  q.push(0);
  root[0]=-2;
  while(!q.empty())
  {
    while(!q.empty())
    {
      int now=q.front();
      q.pop();
      rep(i,g[now].size())
      {
        if(root[g[now][i]]==-1)
        {
          root[g[now][i]]=now;
          q2.push(g[now][i]);
          st.push(g[now][i]);
        }
      }
    }
    while(!q2.empty())
    {
      q.push(q2.front());
      q2.pop();
    }
  }
  vector<ll> black(n,1);
  vector<ll> white(n,1);
  while(!st.empty())
  {
    int now=st.top();
    st.pop();
    black[root[now]]*=white[now];
    white[root[now]]*=(white[now]+black[now]);
    black[root[now]]%=MOD;
    white[root[now]]%=MOD;
  }
  cout<<(black[0]+white[0])%MOD<<endl;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

const ll mod = 1000000007;

ll p(ll x, ll n){
  if(n == 0) return 1;
  if(n == 1) return x%mod;
  if(n%2==1) return (x*p(x,n-1))%mod;
  ll t = p(x,n/2);
  return (t*t)%mod;
}

int main(){
  int n;
  cin >> n;
  vector<pair<ll,ll>> d(61);

  rep(i,n){
    ll a;
    cin >> a;
    rep(j,60){
      if(a&(1ll<<j)) d[j].second++;
      else d[j].first++; 
      }
  }

  ll ans = 0;
  ll fac = 1;
  rep(i,60){
    ll temp =(d[i].first*d[i].second)%mod;
    temp *= p(2,i) % mod;
    ans += temp%mod;
    ans %= mod;
    //fac *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3560
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: ls, i, cnt=0
    character(200000):: s,t

    read*, s
    read*, t

    do i=1,len_trim(s)
        if (s(i:i) /= t(i:i)) cnt=cnt+1
    end do
    print'(i0)', cnt
end program main

Measured memory_bytes: 3508
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}


int n,Q;
string str;
char buf[100010];
int pre1[100010],pre2[100010];

int main() {
	n=read();
	Q=read();
	scanf("%s",buf);
	str=(string)buf;
	for(int i=0; i<n-1; i++) {
		pre1[i+1]=pre1[i];
		if(str[i]=='A'&&str[i+1]=='C') pre1[i+1]++;
	}
	for(int i=1; i<n; i++) {
		pre2[i+1]=pre2[i];
		if(str[i-1]=='A'&&str[i]=='C') pre2[i+1]++;
	}
//	for(int i=0;i<n;i++) printf("%d ",pre1[i]);
//	puts("");
//	for(int i=0;i<n;i++) printf("%d ",pre2[i]);
	for(int i=0; i<Q; i++) {
		int l,r;
		l=read();
		r=read();
		printf("%d\n",pre2[r]-pre1[l-1]);
	}
	return 0;
}

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

using namespace std;
#define ll long long
int INF=1e9;
const int N=1e3+5;
int dp[N][1<<13];
int n,m;
int a[N],v[N];
int solve(int idx,int mask)
{
    if(idx==m)
    {
        if(mask==(1<<n)-1)
            return 0;
        return INF;
    }
    int &ret=dp[idx][mask];
    if(~ret) return ret;
    ret=solve(idx+1,mask);
    ret=min(ret,solve(idx+1,mask|v[idx])+a[idx]);
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int sz;
        cin>>a[i]>>sz;
        for(int j=0;j<sz;j++)
        {
            int x;
            cin>>x;
            v[i]|=(1<<(x-1));
        }
    }
    int ans=solve(0,0);
    if(ans==INF)
        ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 32512
h=[0,1].map{Hash.new 0}
`sed 1d`.split.map{|v|h[1&$.+=1][v]-=1}
((x,a),(_,b)),((y,c),(_,d))=h.map{|i|i.sort_by &:last}
p$..+x!=y ?a+c:[a+=d||0,c+=b||0].min

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

template<typename T>
class Stack {
public:
	Stack(size_t size);
	~Stack();

	bool push(const T&);
	T pop();

	bool isEmpty() { return mSize; }
	bool isFull() { return mSize - 1 == mBack; }

private:
	T* mArray;
	size_t mSize;
	size_t mBack;
};

template<typename T>
Stack<T>::Stack(size_t size)
	:mArray{ NULL }, mSize{ size }, mBack{ 0 }
{
	mArray = new T[size];
}

template<typename T>
Stack<T>::~Stack() {
	delete[] mArray;
}

template<typename T>
bool Stack<T>::push(const T& t) {
	if (isFull())return false;
	mArray[mBack++] = t;
}

template<typename T>
T Stack<T>::pop() {
	if (mBack)return mArray[--mBack];
	return mArray[0];
}


int main()
{
	Stack<int> stack(1000);
	char c;
	while (cin >> c) {
		if (isdigit(c)) {
			cin.unget();
			int x;
			cin >> x;
			stack.push(x);
		}
		else {
			int x = stack.pop();
			switch (c) {
			case '+':
				x += stack.pop();
				stack.push(x);
				break;
			case '-':
				x = stack.pop() - x;
				stack.push(x);
				break;
			case '*':
				x *= stack.pop();
				stack.push(x);
				break;
			/*case ';':
				cout << stack.pop() << endl;
				break;*/
			default:
				break;
			}
		}
	}

	cout << stack.pop() << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
string s,t;
long long a[30],x[100010][30],b=0,ans;
int main(){
	for (long long i=0;i<30;i++) a[i]=-1;
	cin>>s>>t;
	for (long long i=s.size()-1;i>=0;i--){
		for (long long j=0;j<30;j++) x[i+1][j]=a[j];
		a[s[i]-'a']=i+1;
	}
	for (long long j=0;j<30;j++) x[0][j]=a[j];
	for (long long i=0;i<t.size();i++){
		if (x[b][t[i]-'a']==-1&&x[0][t[i]-'a']==-1){
			cout<<-1<<endl;
			return 0;
		}
		else if (x[b][t[i]-'a']==-1)
			b=x[0][t[i]-'a'],ans++;
		else
			b=x[b][t[i]-'a'];
	}
	cout<<ans*s.size()+b;
	return 0;
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, x, y, cnt = 0;cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> x >> y;
		if(x == y) ++cnt;
		else cnt = 0;
		if(cnt >= 3) {
			puts("Yes");return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3576
package main

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

var N int

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	answer := 1234567890123
	upperBound := 1000000
	for i := 1; i < upperBound; i++ {
		if N%i == 0 {
			answer = MinInt(f(i, N/i), answer)
		}
	}
	fmt.Println(answer)
}

func f(x, y int) int {
	return MaxInt(len(strconv.Itoa(x)), len(strconv.Itoa(y)))
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
main :: IO ()
main = do
    mapM_ putStrLn $ qq

qq :: [String]
qq = reverse $ qq' 9 9
    where
        qq' :: Int -> Int -> [String]
        qq' 1 0 = []
        qq' m 0 = qq' (m-1) 9
        qq' m n = (sm ++ "x" ++ sn ++ "=" ++ (show $ m * n)):(qq' m (n-1))
            where
                sm = show m
                sn = show n

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

int main() {
  int a, b, c, d, l, r;
  string ans;
  
  cin >> a >> b >> c >> d;
  
  l = a + b;
  r = c + d;
  if (l == r) ans = "Balanced";
  else if (l>r) ans = "Left";
  else ans = "Right";
  
  cout << ans << endl;  
}

Measured memory_bytes: 3596
from collections import deque

n = int(input())
ans = deque()


for i in range(n):
    m = list(map(int,input().split()))
    if m[0] == 0:
        if m[1] == 0:
            ans.appendleft(m[2])
        else:
            ans.append(m[2])
    elif m[0] == 1:
        print(ans[m[1]])
    
    elif m[0] == 2:
        if m[1] == 0:
            ans.popleft()
        else:
            ans.pop()


Measured memory_bytes: 21984
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define mp make_pair
using namespace std;

double av(double a){
	if(a<0)return -a;
	return a;
}
int nod(int x){
	if(x<10)return 1;
	return 1+nod(x/10);
}
void psd(int x){
	for(int i = 0;i < 6-nod(x);i ++){
		cout<<0;
	}
	cout<<x;
}
int main(){
	int n, m, y, p;
	vector <pair<int,pair<int,int> > > yp;
	vector <pair<int,int> > op;
	cin>>n>>m;
	vector <int> nocip(n);
	op.resize(m);
	for(int i = 0;i < m;i ++){
		cin>>p>>y;
		yp.push_back(mp(y,mp(p,i)));
	}
	for(int i = 0;i < n;i ++){
		nocip[i]=0;
	}
	sort(yp.begin(),yp.end());
	for(int i = 0;i < yp.size();i ++){
		op[yp[i].second.second].first=yp[i].second.first;
		nocip[yp[i].second.first]++;
		op[yp[i].second.second].second=nocip[yp[i].second.first];
	}
	for(int i = 0;i < m;i ++){
		psd(op[i].first);
		psd(op[i].second);cout<<"\n";
	}
}


Measured memory_bytes: 3956
n,m = map(int,input().split())
cost = [0]*n
lim = [0]*n

tmp = [0]
for i in range(n):
  tmp[0] = input().split()
  cost[i] = int(tmp[0][0])
  lim[i] = int(tmp[0][1])
  
ab = zip(cost,lim)
x = sorted(ab)
a,b = zip(*x)

buy = 0
c = 0
temp = [0]*2
for i in range(0,len(a)):
  #print(a[i],m)
  if(b[i] >= m):
    buy = buy + a[i]*m
    #print(buy)
    break
  else:
    buy = buy + b[i]*a[i] 
    #print(buy)
    m = m - b[i]
    #print(m)
    

print(buy)
  
  

Measured memory_bytes: 64216
n, x, y = map(int, input().split())

LI = [0 for _ in range(n-1)]
for i in range(1,n):
	for j in range(i+1, n+1):
		dis = min((j-i), (abs(j-y)+abs(i-x)+1))
		LI[dis-1] += 1

for i in range(n-1):
	print(LI[i])

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

using i64 = int64_t;

int white[200005]={0}, black[200005]={0};

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=1;i<=n;++i)black[i] = black[i-1] + (s[i-1] == '#' ? 1 : 0);
    for(int i=n;i>=1;--i)white[i] = white[i+1] + (s[i-1] == '.' ? 1 : 0);

    int ans = n;
    for(int i=0;i<=n;++i){
        ans = min(ans, black[i] + white[i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2180
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
  
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
  
#define csh(a,n) memset(a,n,sizeof(a));
char arr[30001];
int main(){
	int n;
	cin>>n;
	int a=n/100;
	int b=n%100;
	if(a*5>=b){
		cout<<1;
	}
	else{
		cout<<0;
	}
} 

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

const int ac = 1e6 + 5, bc = (1 << 18);
ll PR[ac];
ll CS[ac];

struct Tree
{
	vector<ll> T;
	Tree()
	{
		T.resize(bc * 2);
	}
	void update(int a, ll b)
	{
		a += bc;
		T[a] = b;
		while (a)
		{
			a /= 2;
			T[a] = min(T[a * 2], T[a * 2 + 1]);
		}
	}
	ll query(int a, int b)
	{
		a += bc; b += bc;
		ll m = min(T[a], T[b]);
		while (a / 2 != b / 2)
		{
			if (a % 2 == 0) m = min(m, T[a + 1]);
			if (b % 2 == 1) m = min(m, T[b - 1]);
			a /= 2; b /= 2;
		}
		return m;
	}
};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q, a, b; cin >> n >> q >> a >> b; a--; b--;
	vector<ll> Q; Q.push_back(a);
	for (int i = 0; i < q; i++) { int x; cin >> x; x--; Q.push_back(x); } 
	ll s = 0;
	for (int i = 1; i <= q; i++) CS[i] = abs(Q[i] - Q[i - 1]), s += CS[i];
	Tree t1, t2;
	for (int i = 0; i < n; i++) t1.update(i, (ll)1e12), t2.update(i, (ll)1e12);
	t1.update(b, b); t2.update(b, -b);
	for (int i = 1; i <= q; i++)
	{
		ll w = min(t2.query(0, Q[i]) + Q[i], t1.query(Q[i], n - 1) - Q[i]) - CS[i];
		if (w < t1.query(Q[i - 1], Q[i - 1]))
		{
			t1.update(Q[i - 1], w + Q[i - 1]);
			t2.update(Q[i - 1], w - Q[i - 1]);
		}
	}
	ll m = 1e18;
	for (int i = 0; i < n; i++)
		m = min(m, t1.query(i, i) - i);
	cout << m + s << '\n';
}


Measured memory_bytes: 11760
a_list = [0]*3
a_list[0] = list(map(int,input().split()))
a_list[1] = list(map(int,input().split()))
a_list[2] = list(map(int,input().split()))
n = int(input())
#print(a_list)
for k in range(n):
    dum = int(input())
    for i in range(3):
        for j in range(3):
            if a_list[i][j] == dum:
                a_list[i][j] = 0
#print(a_list[0][0])
if a_list[0][0] == 0 and a_list[0][1] == 0 and a_list[0][2] == 0:
    print("Yes")
elif a_list[1][0] == 0 and a_list[1][1] == 0 and a_list[1][2] == 0:
    print("Yes")
elif a_list[2][0] == 0 and a_list[2][1] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][0] == 0 and a_list[1][0] == 0 and a_list[2][0] == 0:
    print("Yes")
elif a_list[0][1] == 0 and a_list[1][1] == 0 and a_list[2][1] == 0:
    print("Yes")
elif a_list[0][2] == 0 and a_list[1][2] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][0] == 0 and a_list[1][1] == 0 and a_list[2][2] == 0:
    print("Yes")
elif a_list[0][2] == 0 and a_list[1][1] == 0 and a_list[2][0] == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 main(){
int n,i;
int fl=0;
int sum1=0;
int sum2=0;
cin>>n;
int a[n];
int b[n];
for(i=0;i<n;i++)
{
    cin>>a[i];
}
for(i=0;i<n;i++)
    cin>>b[i];
    for(i=0;i<n;i++)
    {


if(b[i]>a[i])
{
    int o=b[i]-a[i];

    sum1+=(o/2);

}
else{

    sum2+=(a[i]-b[i]);



}
    }


   if(sum1>=(sum2))
        cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

return 0;}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vi lnum;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define code first
#define index second

const ll MOD9 = 1e9+7;
const ll mod = 1000 * 1000 * 1000 + 7;
const int MOD91 = 1e9+9;
const ll MOD12 = 1e12+39LL;
const ll MOD15 = 1e15+37LL;
const ll INF = 1000LL*1000*1000*1000*1000;
const int base = 1e9;
const int MAX = 2e5;
const double EPS = 1e-10;
const double EPS2 = 1e-9;
int n;
int a[2000];
int s;
bitset<4000001> exist , exist2;
int main()
{
	//freopen("input.txt" , "r" , stdin);
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		s += a[i];
	}
	int req = s / 2 + s % 2;
	exist[0] = 1;
	for(int i = 0; i < n; i++)
	{
		exist2 = exist;
		exist2 |= (exist << a[i]);
		exist = exist2;
	}
	for(int i = req; i <= s; i++)
		if(exist[i])
		{
			cout << i;
			return 0;
		}
	return 0;
}



Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
int n,m,k;

void solve(){
	scanf("%d %d %d",&n,&m,&k);
	printf("%s\n",n<=m*k?"Yes":"No");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>

int main(void)
{
 	int a, b, c;
 	scanf( "%d %d %d", &a, &b, &c);
 	
 	if( a < b ) {
 		if( b < c ) {
 			printf( "Yes\n");
 		} else {
 			printf( "No\n");
 		}
 	} else {
 		printf( "No\n");
 	}


	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x, y;
    cin >> x >> y;
    ll t = x;
    ll ans = 0;
    while(t <= y){
        ans++;
        t <<= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 文字列の入力
    ss <- getLine
    ts <- getLine
    -- 出力
    putStrLn $ solve ss ts

isPre :: String -> String -> Bool
isPre _ [] = True
isPre [] _ = False
isPre (s:ss) (t:ts) = if s == '?' || s == t then isPre ss ts else False

replace :: String -> String -> String -> String
replace ss ts c = map (\x -> if x == '?' then 'a' else x) (present ++ ts ++ latter)
    where
        k = length c
        present = take (length ss - k) ss
        latter  = drop (length present + length ts) ss

solve :: String -> String -> String
solve ss ts = if null cands then "UNRESTORABLE" else minimum $ map (replace ss ts) cands
    where
        cands = filter (flip isPre ts) (tails ss)


Measured memory_bytes: 636
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var points = new Point[n];

        for (int i=0; i<n; i++) {
            var spl = (input.ReadLine()).Split(' ');
            points[i] = new Point(int.Parse(spl[0]), int.Parse(spl[1]));
        }

        //var tbl = new double[n][];
        var sowa = 0.0;
        for (int i=0; i<n; i++) {
            //tbl[i] = new double[n];
            for(int j=0; j<n; j++) {
                if (i != j) {
                    //tbl[i][j] = kyori(points[i], points[j]);
                    sowa += kyori(points[i], points[j]);
                }
            }
        }
        sowa /= 2;
        //Debug.WriteLine("sowa:" + sowa);

        var c = 2 * Permutation(n-1, n-1);
        return sowa * c / Permutation(n,n);
    }

    static double kyori(Point a, Point b) {
        var d = Math.Pow(a.x - b.x, 2) + Math.Pow(a.y - b.y, 2);
        return Math.Sqrt(d);
    }

    static long Permutation(long m, long n) {
        long ret = 1;
        for (long i = 0; i < n; i++) {
            ret = (ret) * (m - i);
        }
    return ret;
}

    class Point
    {
        public int x;
        public int y;
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


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

vector<int> g[200005],dp;

int fa[200005],ans[200005],v[200005];

void dfs(int x,int fath)
{
	int flag = 0;
	int locate,vx;
	if( dp.size() == 0 ) 
	{
		flag = 1;
		dp.push_back(v[x]); 
	}
	else if( v[x] > dp[dp.size()-1] ) 
	{
		flag = 1;
		dp.push_back(v[x]);
	} 
	else 
	{
		flag = 2;
		locate = lower_bound(dp.begin(),dp.end(),v[x]) - dp.begin();
		vx = dp[locate];
		*lower_bound(dp.begin(),dp.end(),v[x]) = v[x];
	}
	ans[x] = dp.size();
	for (int i = 0; i < g[x].size(); i++)
	{
		int t1 = g[x][i];
		if( t1 == fath ) continue;
		dfs(t1,x);
	}
	if( flag == 1 ) dp.pop_back();
	else
	{
		dp[locate] = vx;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	for (int i = 1; i < n; i++)
	{
		int a,b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,0);
	for (int i = 1; i <= n; i++)
	{
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 30000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

const i64 mod = 1e9 + 7;

i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}

i64 n;
vector<vector<int>> g, h;
vector<i64> sub;

void dfs_h(int u, int p) {
    for (int v : g[u]) {
        if (v == p) continue;
        h[u].push_back(v);
        dfs_h(v, u);
    }
}

void dfs_sub(int u) {
    sub[u] = 1;
    for (int v : h[u]) {
        dfs_sub(v);
        sub[u] += sub[v];
    }
}

int main() {
    cin >> n;
    g.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    h.resize(n + 1);
    sub.resize(n + 1);
    dfs_h(1, 0);
    dfs_sub(1);
    i64 ans = 0;
    for (int u = 1; u <= n; ++u) {
        if (g[u].size() >= 2) {
            ans += mod + ipow(2, n - 1) - 1;
            i64 par = n - 1;
            for (int v : h[u]) {
                ans += mod - (ipow(2, sub[v]) - 1);
                par -= sub[v];
            }
            ans += mod - (ipow(2, par) - 1);
            ans %= mod;
        }
    }
    cerr << ans << endl;
    (ans *= inv(ipow(2, n))) %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32000
#include <iostream>
using namespace std;
 
int cnt; int N, Ans;
 
void choose(int k, int l, int digit) {
  if(l == N && k == Ans) { cnt++; return; }
  else if (l == N) return;
  else if (digit >= 10) return;
   
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}
 
int main () {
  while(cin>>N>>Ans, N||Ans) {
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
from collections import deque
n,m=map(int,input().split())
ab=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
que=deque()
que.append(1)
count=[0]*2+[-1]*(n-1)
while que:
    x=que.pop()
    for j in ab[x]:
        if count[j]==-1:
            count[j]=count[x]+1
            que.appendleft(j)
if count[n]==2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 114352