akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
	int h, w;
	while (cin >> h >> w, h) {
		vector<string> map(h);
		for (auto &a : map)cin >> a;
		int dx[] = { 0,0,1,1,1,-1,-1,-1 };
		int dy[] = { 1,-1,0,-1,1,0,1,-1 };
		vector<tuple<string, int, int, int>> buf;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int d = 0; d < 8; d++) {
					buf.push_back(make_tuple((string)"" + map[i][j], j, i, d));
				}
			}
		}
		int l = 1;
		for (;; l++) {
			sort(buf.begin(), buf.end());
			vector<tuple<string, int, int, int>> buf2;
			for (int i = 1; i < buf.size(); i++) {
				if (get<0>(buf[i - 1]).size() < l)continue;
				if (get<0>(buf[i - 1]) == get<0>(buf[i]))buf2.push_back(buf[i - 1]);
				for (; i<buf.size()&&get<0>(buf[i - 1]) == get<0>(buf[i]); i++)buf2.push_back(buf[i]);
			}
			if (buf2.empty())break;
			buf = move(buf2);
			for (auto &a : buf) {
				string str;
				int x, y, d;
				tie(str, x, y, d) = a;
				int x1 = ((x + dx[d]*l) % w + w) % w;
				int y1 = ((y + dy[d]*l) % h + h) % h;
				if (x1 == x && y1 == y)continue;
				str += map[y1][x1];
				a = make_tuple(str, x, y, d);
			}
		}
		if (l < 3)cout << 0 << endl;
		else {
			string str = get<0>(buf[0]);
			cout << str.substr(0, l-1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    string s[n];
    cin(i,s);
    rep(i,n)sort(all(s[i]));
    intl a[26];
    rep(i,26)a[i] = INF;
    rep(i,n){
        intl b[26];
        m0(b);
        intl len = s[i].length();
        rep(j,len){
            b[s[i][j] - (intl)'a']++;
        }
        rep(j,26)a[j] = min(a[j],b[j]);
    }
    string t = "";
    rep(i,26)rep(j,a[i])t += (char)('a' + i);
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 1000000007


n = int(input())
A = list(map(int, input().split()))


ans = 1
counter = [0, 0, 0]
for i in range(n):
    index = list()
    for j in range(len(counter)):
        if counter[j] == A[i]:
            index.append(j)

    ans *= len(index)
    ans = ans % MOD
    if len(index) == 0:
        break
    else:
        counter[index[0]] += 1

print(ans)


Measured memory_bytes: 14008
#!/usr/bin/env python
import statistics
import math

allData = []

while True:
    n = int(input())
    if n == 0:
        break
    data = input().split()
    for i in range(len(data)):
        data[i] = int(data[i])
    allData.append(data)

for x in allData:
    print(math.sqrt(statistics.pvariance(x)))

Measured memory_bytes: 10192
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}

int main(){
    ll a,b; cin >> a >> b;
    vector<ll> a_p, b_p;
    a_p.push_back(1);b_p.push_back(1);
    ll a_tmp = a, b_tmp = b;
    rep(i,sqrt(a)+1){
        if(i <= 1)continue;
        bool ok = false;
        while(a_tmp % i == 0){
            a_tmp /= i;
            ok = true;
            // if(a_tmp == 0)break;
        }
        if(ok)a_p.push_back(i);
        // if(a_tmp == 0)break;
    }
    if(a_tmp != 1)a_p.push_back(a_tmp);

    // print(a_p);
    // rep(i,sqrt(b)+1){
    //     if(i <= 1)continue;
    //     bool ok = false;
    //     while(b_tmp % i == 0){
    //         b_tmp %= i;
    //         ok = true;
    //     }
    //     if(ok)b_p.push_back(i);
    // }
    ll res = 0;
    for(auto i : a_p){
        if(b % i == 0)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])

mysum=0

for v in range(1,1+n):


    mysum+= int(arr_data[v][1])-int(arr_data[v][0])+1
#print("Yes"   if "9"  in n else "No")

print(mysum)

Measured memory_bytes: 3316
#include<stdio.h>

int N;

int M[101][101];

int H(int x, int y){

  int i;
  int f = 0;

  for(i=2; i<=N; i++){
    if(M[x][i] == y){
      f = 1;
    }
  }

  if(f == 1){
    return 1;
  }
  else if(f == 0){
    return 0;
  }
}

main(){

  int i, j, k;

  scanf("%d", &N);

  for(i=1; i<=N; i++){
    j = 1;
    scanf("%d %d", &M[i][1], &k);
    for(j =2; j<k+2; j++){
      scanf("%d", &M[i][j]);
    }
  }

  for(i = 1; i<=N; i++){
    for(j = 1; j <= N; j++){
      if(j == N){
	printf("%d\n", H(i, j));
      }
      else{
	printf("%d ", H(i, j));
      }
    }
  }

  return 0;
}

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

int check(string s) {
    for (int i = 0; i < (int)s.size() - 4; i++) {
        if (s[i] == '[' && s[i + 4] == ']') {
            return i;
        }
    }
    return -1;
}

int main() {
    string S;
    cin >> S;
    vector<char> char_vector;
    for (int i = 0; i < S.size(); i++) {
        char_vector.push_back(S[i]);
    }
    int N = char_vector.size();
    int v[26] = {};
    for (int i = 0; i < N; i++) {
        char a;
        cin >> a;
        cin >> v[a - 'a'];
    }
    while (true) {
        int index = check(S);
        if (index == -1) break;
        if (v[S[index + 1] - 'a'] != 0 && v[S[index + 3] - 'a'] != 0) {
            cout << "No" << endl;
            return 0;
        }
        if (v[S[index + 1] - 'a'] != 0) {
            v[S[index + 1] - 'a']--;
            S.erase(index + 2, 3);
            S.erase(index, 1);
        } else {
            v[S[index + 3] - 'a']--;
            S.erase(index + 4, 1);
            S.erase(index, 3);
        }
    }
    for (int i = 0; i < 26; i++) {
        if (v[i] != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

const int MAXN = 105;

int n, m, dp[MAXN][MAXN][2];
char g[MAXN][MAXN];

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
		scanf("%s", g[i]);
	
	for(int i = n - 1; i >= 0; i--)
	for(int j = m - 1; j >= 0; j--)
	for(int p = 0; p <= 1; p++){
		if(i == n - 1 && j == m - 1){
			dp[i][j][p] = (p == 0 && g[i][j] == '#');
		}else{
			dp[i][j][p] = 1 << 20;
			if(i < n - 1)dp[i][j][p] = min(dp[i][j][p], (p == 0 && g[i][j] == '#') + dp[i + 1][j][g[i][j] == '#']);
			if(j < m - 1)dp[i][j][p] = min(dp[i][j][p], (p == 0 && g[i][j] == '#') + dp[i][j + 1][g[i][j] == '#']);
		}
	}
	printf("%d\n", dp[0][0][0]);
	
	return 0;
}


Measured memory_bytes: 384
h[7];
float v;
main(i){
	scanf("%*d");
	for(;~scanf("%f",&v);){
		i=(v-165)/5+2;
		if(i<1)i=1;
		if(i>6)i=6;
		h[i]++;
	}
	for(i=1;i<=6;i++){
		printf("%d:",i);
		for(;h[i]--;)
			putchar('*');
		puts("");
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>
#include<cstdio>
#include<iomanip>

const int MOD=1000000007;
ll power(ll x,ll n)
{
	ll ret=1;
	ll p=x;
	for (;n>0;n/=2)
	{
		if (n%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}


int main(int argc, char *argv[])
{
	ll k,n;

	cin>>n>>k;
	vector<ll> a(k+1);

	ll ret=0;
	for (ll i=k;i>0;i--)
	{
		ll x=k/i;
		ll n3=power(x,n);
		for (ll j=2;i*j<=k;j++)
		{
			n3=(MOD+n3-a[i*j])%MOD;
		}
		a[i]=n3;
		cerr<<i<<" "<<n3<<endl;
		ret=((n3*i)%MOD+ret)%MOD;
	}

	cout<<ret<<endl;

	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>

bool check(std::vector<bool> vb, int num){
  for(int i=0; i<vb.size()-num; i++){
    if(vb[i]){
      vb[i] = !vb[i];
      vb[i+num] = !vb[i+num];
    }
  }

  if(vb[vb.size()-num]){
    for(int j=0; j<num; j++){
      vb[vb.size()-num+j] = !vb[vb.size()-num+j];
    }
  }
  /*
  for(int i=0; i<=vb.size()-num; i++){
    if(vb[i]){
      for(int j=0; j<num; j++){
	vb[i+j] = !vb[i+j];
      }
    }
  }
  */
  for(int i=0; i<num; i++){
    if(vb[i]) return false;
  }
  return true;
  
}


int bi_search(std::vector<bool> vb, int st, int ed){
  int ret = -1;

  if(st == ed){
    if(check(vb, st)){
      return st;
    }else{
      return -1;
    }
  }
  
  int mid = (st+ed)/2;
  if(check(vb, mid)){
    ret = mid;
    st = mid+1;
  }else{
    ed = mid;
  }

  int ret2 = bi_search(vb, st, ed);
  if(ret < ret2){
    return ret2;
  }else{
    return ret;
  }

  return 0;
}

int main(void){

  std::string s;
  std::cin >> s;

  std::vector<bool> vb;

  for(int i=0; i<s.size(); i++){
    if(s[i] == '0'){
      vb.push_back(false);
    }else{
      vb.push_back(true);
    }
  }

  std::cout << bi_search(vb, 1, s.size()) << std::endl;
  
  
  return 0;
}

Measured memory_bytes: 640
N,M=map(int,input().split())
X=[int(x) for x in input().split()]
Y=[int(y) for y in input().split()]
MOD=10**9+7

SX=0
SY=0

for i in range(N):
  SX=(SX+(2*i+1-N)*X[i])%MOD
for j in range(M):
  SY=(SY+(2*j+1-M)*Y[j])%MOD
  
print((SX*SY)%MOD)

Measured memory_bytes: 19648
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		boolean f = false;

		if (A == B) {
			if (A != C) {
				f = true;
			}
		} else if (A == C) {
			if (A != B) {
				f = true;
			}
		} else if (B == C) {
			if (A != C) {
				f = true;
			}
		}

		if (f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}
}


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


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

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



bool rev(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[s.size()-i-1]){
			return false;
		}
	}
	return true;
}


bool solve(int n,int i){
	stringstream ss1,ss2;
	string tmp;
	ss1<<n-i;
	ss1>>tmp;
	if(rev(tmp)){
		cout<<tmp<<endl;
		return 1;
	}
	ss2<<n+i;
	ss2>>tmp;
	if(rev(tmp)){
		cout<<tmp<<endl;
		return 1;
	}
	return 0;
}


int main(){
	int n;
	cin>>n;
	for(int i=0;1;i++){
		if(solve(n,i)){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp.split(' ')
    i += 1
end

s = line[0][0]
t = line[0][1]
A = line[1][0].to_i
B = line[1][1].to_i

if line[2][0] == s then
  print (A-1).to_s + " " + B.to_s
else
  print A.to_s + " " + (B-1).to_s
end

Measured memory_bytes: 1788
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		List<Integer> L = new LinkedList<>();
		ListIterator<Integer> It = L.listIterator();
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i=0;i<n;i++){
			
			int q = sc.nextInt();
			
			if(q == 0){
				int x = sc.nextInt();
				
				It.add(x);
				It.previous();
				
			}else if(q == 1){
				int d = sc.nextInt();
				
				if(d > 0){
					for(int j=0;j<d;j++)
					It.next();
					
				}else{
					for(int j=0;j< -d;j++)
						It.previous();
				}
			}else{
				It.next();
				
				It.remove();
			}
		}
		
			for(int k : L)
				System.out.println(k);
	}

}


Measured memory_bytes: 309096
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int cnt[15];
int N,D[55];
bool vis[25],mark[15],c[25];
void Init() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(D[i]);cnt[D[i]]++;}
}
void Solve() {
    if(cnt[0] || cnt[12] >= 2) {puts("0");return;}
    int S = 0;
    int ans = 0,d = 12;
    for(int i = 1 ; i <= 12 ; ++i) {
	
	if(cnt[i] > 2) {puts("0");return;}
	if(cnt[i] == 2) {
	    vis[i] = 1;vis[24 - i] = 1;
	}
	else if(cnt[i]) {d = min(d,i);S |= 1 << i - 1;mark[i] = 1;}
    }
    for(int T = S ; ; T = S & (T - 1)) {
	memcpy(c,vis,sizeof(vis));
	for(int i = 1 ; i <= 12 ; ++i) {
	    if(mark[i]) {
		if(T >> (i - 1) & 1) c[24 - i] = 1;
		else c[i] = 1;
	    }
	}
	int pre = 0,t = d;
	for(int i = 1 ; i <= 24 ; ++i) {
	    if(c[i]) {t = min(t,i - pre);pre = i;}
	}
	ans = max(ans,t);
	if(T == 0) break;
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
    return 0;
}


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

using ll=long long;



void solve(){
    int a,b;
    cin>>a>>b;
    a*=b;
    if(a%2==0){
        cout<<"Even"<<endl;
    }else{
        cout<<"Odd"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[45][505][505]; // i番目まででma=j, mb=k とするときの最小値

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,ma,mb; cin>>n>>ma>>mb;
  
  vll a(n), b(n), c(n);
  rep(i,n) cin>>a[i]>>b[i]>>c[i];
  
  rep(i,n+1) rep(j,505) rep(k,505) dp[i][j][k]=LINF;
  dp[0][0][0]=0;
  
  rep(i,n){
    for(ll j=0; j<=400; j++){
      for(ll k=0; k<=400; k++){
        if(dp[i][j][k]==LINF) continue;
        chmin(dp[i+1][j][k], dp[i][j][k]);
        chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
        // cout<<i<<' '<<j<<' '<<k<<' '<<dp[i+1][j+a[i]][k+b[i]]<<endl;
      }
    }
  }
  
  ll ans=LINF;
  for(ll i=1; i*ma<=400; i++){
    if(dp[n][i*ma][i*mb]==-1) continue;
    chmin(ans, dp[n][i*ma][i*mb]);
  }
  if(ans==LINF) cout<<-1<<endl;
  else cout<<ans<<endl;
}

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

int main(void){
  while(1){
    int all;
    cin >> all;
    if(all == -1) break;
    else{
      if(all < 10){
        all =0;
      }
      if(all >=10 && all < 20){
        all -= 10;
        all *= 125;
      }else if(all >= 20 && all < 30){
        all -= 20;
        all *= 140;
        all +=1250; 
      }else if(all >= 30 && all <= 100){
        all -=30;
        all *= 160;
        all += 1250 + 1400;
      }
      all += 1150;
      cout << 4280 - all << endl;
    }
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    int ans=0;
    REP(S,1<<(N-1)){
        int sum=0,cur=s[0]-'0';
        REP(i,N-1){
            if(S>>i&1){
                sum+=cur;
                cur=0;
            }
            cur=cur*10+s[i+1]-'0';
        }
        ans+=sum+cur;
    }
    cout<<ans<<endl;
}


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

int main()
{
  map<string ,int> mp;
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    vector<vector<int>> nums(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> nums[i][j];

    // 各行の最小値を求める
    int line_max[3];
    rep(i, 3) line_max[i] = *min_element(all(nums[i]));

    // 各列の最小値を求める
    int col_max[3];
    rep(i, 3) col_max[i] = min(nums[0][i], min(nums[1][i], nums[2][i]));

    int a[3] = {0}, b[3] = {0};
    for(a[0] = line_max[0]; a[0] >= 0; a[0]--){
        for(a[1] = line_max[1]; a[1] >= 0; a[1]--){
            for(a[2] = line_max[2]; a[2] >= 0; a[2]--){
                bool success_flag = true;
                b[0] = max(0, nums[0][0] - a[0]);
                b[1] = max(0, nums[1][1] - a[1]);
                b[2] = max(0, nums[2][2] - a[2]);
                rep(i, 3) rep(j, 3) if(a[i] + b[j] != nums[i][j]) success_flag = false;

                if(success_flag){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
}

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

using namespace std;


int N;
int K;
int *S;
int **B;

bool calc(){

	int sumB = 0;

	for(int j = 0; j < K; j++){
		sumB = 0;
		for(int i = 0; i < N; i++){
			sumB += B[i][j];
		}
		if(S[j] < sumB){
			return false;
		}
	}

	return true;
}

void solve(){
	ifstream ifs("prob1019.txt");

	while(1){
		//ifs >> N;
		//ifs >> K;
		cin >> N;
		cin >> K;
		
		if(N == 0 && K == 0)
			break;

		S = new int[K];
		B = new int*[N];
		
		for(int i = 0; i < K; i++){
			cin >> S[i];
			//ifs >> S[i];
		}
		
		for(int i = 0; i < N; i++){
			B[i] = new int[K];
			for(int j = 0; j < K; j++){
				cin >> B[i][j];
				//ifs >> B[i][j];
			}
		}
		
		if(calc()){
			cout << "Yes" << endl;
		}
		else
			cout << "No" << endl;
		
		delete [] S;
		for(int i = 0; i < N; i++){
			delete [] B[i];
		}
		delete [] B;
	}

}
	

int main(){

	solve();

	int x;
	cin >> x;

	return 0;
}

Measured memory_bytes: 944
n=int(input())
h=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(h[-(i+1)])
#print(a)
s=0
#print(max(a[2:]))
for i in range(n):
    if a[i]>=max(a[i:]):
        s+=1
print(s)

Measured memory_bytes: 3060
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[N];
const int mo1=1e9+9;
int n,h[N],q[N],h1[N],q1[N];
int cal(int i,int j,int h[],int q[],int mo){return (h[j]-1LL*h[i]*q[j-i]%mo+mo)%mo;}
struct node{
	int v,v1,next;
}g[N];
const int mo=233333;
int head[mo],cnt,dp[N];
int add1(int v,int v1){
	int k=v%mo;
	for(int i=head[k];~i;i=g[i].next){
		if(g[i].v==v&&g[i].v1==v1)return 0;
	}
	g[cnt]={v,v1,head[k]};head[k]=cnt++;
	return 1;
}
int cal(int d){
	if(dp[d]!=0)return dp[d];
	cnt=0;
	memset(head,-1,sizeof(head));
	int ans=0;
	rep(i,0,n-d+1){
		int k=cal(i,i+d,h,q,mod),k1=cal(i,i+d,h1,q1,mo1);
		ans+=add1(k,k1);
	}
	return dp[d]=ans;
}
int main(){
    int T,i,j,k,ca=0,K,m;
    //cout<<setprecision(10)<<fixed;
    scanf("%s",s);n=strlen(s);q[0]=q1[0]=1;
    rep(i,0,n)q[i+1]=q[i]*29LL%mod,h[i+1]=(h[i]*29LL+s[i])%mod,q1[i+1]=q1[i]*37LL%mo1,h1[i+1]=(h1[i]*37LL+s[i])%mo1;
    int l=1,r=n,ans=1;
    while(l+100<r){
    	int x=(2*l+r)/3,y=(2*r+l)/3;
    	int p=cal(x),q=cal(y);
    	if(cal(x)<=cal(y))Max(ans,q),l=x+1;else Max(ans,p),r=y-1;
    }
    rep(i,l,r+1)Max(ans,cal(i));
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

int N, D, X;

int main() {
  cin >> N >> D >> X;

  int a, sum = X;
  rep(i, N) {
    cin >> a;
    sum += (D - 1) / a + 1;
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

N = int(input())
a = list(map(int, input().split(" ")))

hash = {}
for elem in a:
    if not elem in hash:
        hash[elem] = 1
    else:
        hash[elem] += 1

ans = 0
for key, value in hash.items():
    if value > key:
        ans += value - key
    elif value < key:
        ans += value

print(ans)


Measured memory_bytes: 17780
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 15

int memo[MAX][MAX];
int X, Y;
int data[MAX][MAX];

int rec(int x, int y) {
  static int d[3][2] = {{-1,1},{0,1},{1,1}};

  if(memo[y][x] == -1) {
    memo[y][x] = 0;
    if(y == Y-1) {
      memo[y][x] += 1;
    } else if(data[y][x] == 2) {
      int nx = x;
      int ny = y+2;
      if(ny >= Y) {
	memo[y][x] += 1;
      } else {
	if(data[ny][nx] != 1)
	  memo[y][x] += rec(nx, ny);
      }
    } else {
      for(int i = 0; i < 3; i++) {
	int nx = x + d[i][0];
	int ny = y + d[i][1];
	if(nx < 0 || nx >= X) continue;
	if(data[ny][nx] == 1) continue;
	if(i != 1 && data[ny][nx] == 2) continue;
	memo[y][x] += rec(nx, ny);
      }
    }
  }
  return memo[y][x];
}

main() {
  while(1) {
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 0; i < Y; i++) {
      for(int j = 0; j < X; j++) {
	cin >> data[i][j];
	memo[i][j] = -1;
      }
    }
    
    int cnt = 0;
    for(int j = 0; j < X; j++) {
      if(data[0][j] == 0) 
	cnt += rec(j, 0);
    }
    /*for(int i = 0; i < Y; i++) {
      for(int j = 0; j < X; j++) {
	cout << memo[i][j] << ' ';
      }
      cout << endl;
      }
      cout << endl;*/
    cout << cnt << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
double D(double a,double b,double c,double d){
   double res=sqrt((a-b)*(a-b)+(c-d)*(c-d));
   return res;
}
int main(void){
   int N;
   cin>>N;
   vector<double> x(N),y(N);
   for(int i=0;i<N;i++){
      cin>>x[i]>>y[i];
   }
   double ans=0.0;
   vector<int> town(N);
   for(int i=0;i<N;i++){
      town[i]=i;
   }
   int rec=0;
   do{
      rec++;
      double dist=0.0;
      for(int i=0;i<N-1;i++){
         dist+=D(x[town[i]],x[town[i+1]],y[town[i]],y[town[i+1]]);
      }
      ans+=dist;
   }while(next_permutation(town.begin(),town.end()));
   cout<<fixed;
   cout<<setprecision(7)<<ans/(double)rec<<endl;
   return 0;
}


Measured memory_bytes: 3852
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    --a; --b; --c; --d;
    string s;
    cin >> s;

    if(c > d) { // これはちょっとややこしい
        // ちょうどいい待機場所がないか探す
        int e = -1;
        for(int i=b;i<=d;++i) {
            if(s[i] == '.' && (i == 0 || s[i-1] == '.') && (i == n-1 || s[i+1] == '.')) {
                e = i;
                break;
            }
        }
        if(e == -1) {
            cout << "No\n";
            return 0;
        }
        while(b != e) {
            if(s[b] == '#') {
                cout << "No\n";
                return 0;
            }
            if(s[b+1] == '#') {
                b += 2;
            } else {
                b += 1;
            }
        }
    }

    int aa = a, bb = b;
    bool goal = true;
    while(b != d) {
        if(b > d || s[b] == '#') {
            goal = false;
            break;
        }
        if(s[b+1] == '#') {
            b += 2;
        } else {
            b += 1;
        }
    }
    while(goal && a != c) {
        if(a > c || s[a] == '#') {
            goal = false;
            break;
        }
        if(s[a+1] == '#' || a+1 == d) {
            a += 2;
        } else {
            a += 1;
        }
    }

    if(goal) {
        cout << "Yes\n";
        return 0;
    }

    a = aa;
    b = bb;
    goal = true;
    while(goal && a != c) {
        if(a > c || s[a] == '#') {
            goal = false;
            break;
        }
        if(s[a+1] == '#') {
            a += 2;
        } else {
            a += 1;
        }
    }
    while(b != d) {
        if(b > d || s[b] == '#') {
            goal = false;
            break;
        }
        if(s[b+1] == '#' || b+1 == c) {
            b += 2;
        } else {
            b += 1;
        }
    }

    if(goal) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 592
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  string S;cin>>S;
  string T;cin>>T;
  int A,B;cin>>A>>B;
  string U;cin>>U;
  if (S == U) {
    p(A-1,B);
  } else {
    p(A,B-1);
  }
  return 0;
}



Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
a=[30000*(i+1) for i in range(n)]
r=[0]*n
f=1
for i in p:
    r[i-1]=f
    f+=1
b=[30000*(n-i-1)+r[i] for i in range(n)]
print(*a)
print(*b)


Measured memory_bytes: 7176
#include<stdio.h>

int main(){
  int a, b;
  int tmp;
  int prime;
  int gcd, lcm;

  while(scanf("%d %d",&a, &b) != EOF){
    /*GCDとLCMを求める処理*/
    if(b > a){
      tmp = a;
      a = b;
      b = tmp;
    }
    //a >= b
    gcd = 1; lcm = 1;
    prime = 2;
    while(prime <= b){
      if(a%prime == 0 && b%prime == 0){
	a /= prime;
	b /= prime;
	gcd *= prime;
      }
      else{
	prime ++;
      }
    }
    lcm = gcd * a * b;
    printf("%d %d\n",gcd ,lcm);
  }
  return 0;
}  

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

map<char, char> mp, used;
bool vis[30];

bool ok(char c, char t) {
  if (mp[c] == t || !mp[c]) return true;
  if (mp[c] == c) return false;
  return ok(mp[c], t);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  if (s.size() != t.size()) {
    cout << "No\n";
    return 0;
  }
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (!mp[s[i]] && !used[t[i]]) {
      mp[s[i]] = t[i];
      used[t[i]] = s[i];
    }
    else {
      if (used[t[i]] != s[i]) {
        cout << "No\n";
        return 0;
      }
      else if (mp[s[i]] != t[i]) {
        cout << "No\n";
        return 0;
      }
    }
  }
  for (char c = 'a'; c <= 'z'; ++c) {
    mem(vis, 0);
    if (!ok(mp[c], c)) {
      cout << "No\n";
      return 0;
    } 
  }
  cout << "Yes\n";
}

Measured memory_bytes: 916
def sum_digits(digits):
	str_digits = str(digits)
	digit_array = list(map(int, str_digits))
	return sum(digit_array)


n_str, a_str, b_str = input().split(' ')
n = int(n_str)
a = int(a_str)
b = int(b_str)

nums_to_be_summed = []
for x in range(n):
	tmp_sum = sum_digits(x+1)
	if a <= tmp_sum <= b:
		nums_to_be_summed.append(x+1)
print(sum(nums_to_be_summed))

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

int main () {
  int N;
  cin >> N;
  vector <int> cost(N);
  vector <int> value(N);
  for (int i = 0; i < N; i++) cin >> value.at(i);
  for (int i = 0; i < N; i++) cin >> cost.at(i);
  int ans = 0;
  for (int i = 0; i < N; i++){
   if (value.at(i) > cost.at(i)) ans += value.at(i) - cost.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


enum L = 2001;

void main() {
    int n;
    scan(n);
    auto s = readln.chomp;

    if (s[0] != 'B' || s[2*n - 1] != 'B') {
        writeln(0);
        return;
    }

    auto b = new int[](2*n);
    foreach (i ; 0 .. 2*n) {
        if (s[i] == 'B') b[i] = 1;
        else b[i] = 0;
    }

    auto a = new int[](2*n);

    long ans = 1;
    long cnt;

    foreach (i ; 0 .. 2*n) {
        if ((cnt & 1) ^ b[i]) {
            cnt++;
        }
        else {
            ans *= cnt;
            ans %= mod;
            cnt--;
        }
    }

    if (cnt > 0) {
        writeln(0);
        return;
    }

    foreach (i ; 1 .. n + 1) {
        ans *= i;
        ans %= mod;
    }

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;n--;
    cout<<(n*(n+1))/2<<"\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 100100;
int A[MAXN];

struct edge {
	int v;
	long long w;
	edge() {}
	edge(int v, long long w) : v(v), w(w) {};
};

vector<long long> dijkstra(int n, vector<vector<edge> >& G, int s) {
	vector<long long> d(n, 1e18);
	d[s] = 0;
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
	que.push(make_pair((long long)0, s));
	while (!que.empty()) {
		auto p = que.top();
		que.pop();
		int u = p.second;
		long long dist = p.first;
		if (dist > d[u]) continue;
		for (edge e : G[u]) {
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				que.push(make_pair(d[e.v], e.v));
			}
		}
	}
	return d;
}

int main() {
	int N, M, S, T;
	cin >> N >> M >> S >> T;
	S--;
	T--;
	vector<vector<edge> > G(N), rG(N);
	for (int i = 0; i < M; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--;
		G[a].emplace_back(b, c);
		G[b].emplace_back(a, c);
		rG[a].emplace_back(b, d);
		rG[b].emplace_back(a, d);
	}
	auto d = dijkstra(N, G, S);
	auto rd = dijkstra(N, rG, T);
	long long ans = 0;
	vector<long long>Ans(N);
	for (int i = 0; i < N; i++) {
		long long num = d[N - 1 - i] + rd[N - 1 - i];
		if (0 == i) {
			Ans[N - 1 - i] = num;
		}
		else {
			Ans[N - 1 - i] = min(num, Ans[N - i]);
		}
	}
	for (int i = 0; i < N; i++) {
		long long ans = 1e15;
		ans -= Ans[i];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 21124
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 1000007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//typedef int ittt;
//#define int ll


using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const ll inf = 1e18;
ll n, w, wt[MAX], val[MAX];
ll dp[103][MAX], s;


int main(){
    /*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    //memset(dp, -1, sizeof(dp));
    cin>>n>>w;
    for(int i=1;i<=n;i++){
    	cin>>wt[i]>>val[i];
    	s+=val[i];
    }

	for(int j=1;j<=s;j++){
		dp[0][j] = inf;
	}

    for(int i=1;i<=n;i++){
    	for(int ii=1; ii<=s; ii++){
    		dp[i][ii] = min(dp[i-1][ii], wt[i]+dp[i-1][max(0LL, ii-val[i])]);
    	}
    }

    for(int i=s;i>=0;i--){
    	//cerr<<"dp["<<n<<"]["<<i<<"] == "<<dp[n][i]<<'\n';
    	if(dp[n][i]<=w){
    		cout<<i<<'\n';
    		return 0;
    	}
    }

    return 0;
}

Measured memory_bytes: 294016
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

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

            int count = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] * 4 * M < sum) {
                    continue;
                }
                count++;
            }

            System.out.println(count >= M ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27244
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()) {
			int c = s.nextInt();
			int ans = check(c);
			System.out.println(ans);
		}
	}
	static int check(int c) {
		boolean[] prime = new boolean[c+1];
		int count = 0;
		for(int i = 2; i <= Math.sqrt(c); i++) {
			for(int j = i + i; j <= c; j += i) {
				prime[j] = true;
			}
		}
		for(int i = 2; i <= c; i++) {
			if(!prime[i]) {
				count++;
			}
		}
		return count;
	}
}

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

using namespace std;
using ll = long long;

int main() {
  ll N, L;
  cin >> N >> L;
  ll ret = 0;
  int a=0;
  if(L<=0)
    a = -L;
  if(a>=N)
    a=N-1;
  for (int i = 0; i < N; ++i) {
    if(a!=i)
      ret += L+i;
  }
  cout << ret <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    short N;
    cin >> N;
    
    short p;
    short q;

    long P = 0;
    long Q = 0;

    for(short i=0; i<N; i++){
        cin >> p;
        P += p * pow(10, i);
    }
    for(short i=0; i<N; i++){
        cin >> q;
        Q += q * pow(10, i);
    }

    // 順列生成
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    // cout << v << endl;
    long V = 0;

    long p_counter = 0;
    long q_counter = 0;

    long p_result;
    long q_result;

    do{
        for(int i=0; i<N; i++){
            V += v[i] * pow(10, i);
        }
        if(V==P){p_result = p_counter;}
        if(V==Q){q_result = q_counter;}
        p_counter++;
        q_counter++;
        // cout << V << endl;
        V = 0;
    }while(next_permutation(v.begin(), v.end()));

    cout << abs(p_result - q_result) << endl;    

    return 0;
}

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

int main() {
  map<string, int> MA;
  int N;
  cin >> N;
  string S;
  while (cin >> S) MA[S]++;
  int mx = 0;
  for (auto ma : MA) mx = max(mx, ma.second); 
  vector<pair<int, string>> V;
  for (auto ma : MA) V.push_back({ma.second, ma.first});
  sort(V.begin(), V.end());
  for (auto v : V) if (v.first == mx) cout << v.second << "\n";
}

Measured memory_bytes: 29552
#include<iostream>
#include<vector>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> c(n, vector<int>(m + 1));
    rep(i, n) {
        rep(j, m + 1) {
            cin >> c[i][j];
        }
    }
    int mn = 10000000;
    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> rikaido(m);
        int cost = 0;
        rep(i, n) {
            if (bit & (1 << i)) {
                cost += c[i][0];
                rep(j, m) {
                    rikaido[j] += c[i][j + 1];
                }
            }
        }
        bool t = true;
        rep(i, m) {
            if (rikaido[i] < x) t = false;
        }
        if (t) mn = min(mn, cost);
    }
    mn != 10000000 ? cout << mn << endl : cout << -1 << endl;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S, ans string
	fmt.Scan(&S)

	m, _ := strconv.Atoi(S[5:7])

	if m <= 4 {
		ans = "Heisei"
	} else {
		ans = "TBD"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
	
	//準備部分
	int n,x,s,h,i,j;
	
	//入力・計算・出力部分
	while(1){
		s=0;
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)break;
		for(h=1;h<=n-2;h++){
			for(i=h+1;i<=n-1;i++){
				for(j=i+1;j<=n;j++){
					if(h+i+j==x)s+=1;
				}
			}
		}
		printf("%d\n",s);
	}
	
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    for (int i = 0; i < B; i++) {
        if (A * i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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

using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);  
   int k;int a;int b;  
   cin >> k;
   cin >> a >> b;
   int flag=0;
   for(int i=a;i<=b;i++)
   {
       if(i%k==0)
       {
           flag=1;
       }
   }
   if(flag==0)
   {
       cout << "NG" << endl;
   }
   else
   cout << "OK" << endl;
   

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt=0;
  int k,t;
  cin>>k>>t;
  int a[t];
  for(i=0;i<t;i++)cin>>a[i];
  sort(a,a+t,greater<int>());
  if(a[0]-1<=k-a[0])cout<<0;
  else cout<<a[0]-1-(k-a[0]);
}

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

using namespace std;

typedef pair<int, int> P;

int in[4], n;

int dist(P a, P b){
  return abs(a.first - b.first) + abs(a.second - b.second);
}

int solve(int w){
  P p[4];
  for(int i=0;i<4;i++) p[i] = P(in[i]/w, in[i]%w);
  return dist(p[0], p[1]) + dist(p[2], p[3]);
}

main(){
  cin >> n;
  for(int i=0;i<4;i++) cin >> in[i];
  for(int i=0;i<4;i++) in[i]--;
  int ans = (1<<28);
  for(int i=1;i<=n;i++) ans = min(ans, solve(i));
  cout << ans << endl;
}

Measured memory_bytes: 1164
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

p = [a, b, c, d, e]
count = 0
for i in range(5):
    for j in range(i, 5):
        if p[j] - p[i] > k:
            count += 1
            break
if count > 0:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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


    int n;
    cin>>n;

    cout<<(n+1)/2<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    ll N,M; cin >> N >> M;
    ll sum=0;
    rep(i,M){
        ll A; cin >> A;
        sum+=A;
    }
    
    ll ans=N-sum;
    if (ans<0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

static const int N = 100;

int main() {
     int n, p[N + 1], m[N + 1][N + 1];
     cin >> n;
     for ( int i = 1; i <= n; i++ ) {
          cin >> p[i - 1] >> p[i];
     }

     for ( int i = 1; i <= n; i++ ) {
          m[i][i] = 0;
     }
     for ( int l = 2; l <= n; l++ ) {
          for ( int i = 1; i <= n - l + 1; i++ ) {
               int j = i + l - 1;
               m[i][j] = (1 << 21);
               for ( int k = i; k <= j - 1; k++ ) {
                    m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
               }
          }
     }

     cout << m[1][n] << endl;

     return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<stack>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty() ){
    int u = S.top(); S.pop();
    for(int i=0; i<G[u].size(); i++){
      int v = G[u][i];
      if(color[v] == NIL){
	color[v] = c;
	S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for(int i = 0; i<n; i++) color[i] = NIL;
  for(int u = 0; u<n; u++){
    if(color[u] == NIL) dfs(u, id++);
  }
}

int main(){
  int s, t, m, q;

  cin >> n >> m;

  for(int i = 0; i<m; i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for(int i=0; i<q; i++){
    cin >> s >> t;
    if(color[s] == color[t]){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }

  return 0;
}
    



Measured memory_bytes: 8824