akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
	int a;
	cin>>a;
	int A[100];
	int c;
	for (int i = 0; i < a; i++) {
		cin>>A[i];
	}
	for (int i = 0; i < a; i++) {
		if (i)cout << " ";
		cout<<A[i];
	}
	cout << endl;
	for (int i = 1; i < a; i++) {
		int key = A[i];
		int j = i -1;
		while (j >= 0 && A[j] > key) {
			A[j + 1] = A[j];
			j--;
		}
		A[j+1] = key;
		for (int i2 = 0; i2 < a; i2++) {
			if(i2)cout<<" ";
			cout << A[i2];
		}
		cout<<endl;
	}
	return 0;
}


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

int main(void){
    int n, a, b, sum=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i){
        int tmp = i;
        int wa = 0;
        while(tmp > 0){
            int keta = tmp%10;
            wa += keta;
            tmp /= 10;
        }
        if(wa >= a && wa<=b){
            sum += i;
        }
    }
    cout << sum << endl;
}

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

bool isACGT(char c){
    if(c == 'A' or c == 'G' or c == 'C' or c == 'T')
        return true;
    return false;
}

void calculate(){
    string s;
    cin >> s;
    int res = 0;
    for(int i = 0;i < (int)s.size();++i){
        int j = i;
        while(isACGT(s[j])) j++;
        res = max(res,j - i);
        i = j;
    }
    cout << res << '\n';
}

int main(int, char**) {
    calculate();
    return 0;
}


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

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    s = read(str)

    ans = 0
    for i in range(1, len(s) - 1):
        x = s[0:i]
        y = s[i:]

        x_chrs = set(list(x))
        y_chrs = set(list(y))

        nr_dup_chrs = x_chrs & y_chrs
        if ans < len(nr_dup_chrs):
            ans = len(nr_dup_chrs)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ll ans = a[n-1];
	int total = 2;
	int idx = n-2;
	while(total<n){
		ans += a[idx];
		++total;
		if(total == n)
			break;
		ans += a[idx];
		++total;
		--idx;
	}		

	cout<<ans<<"\n";	
}

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

int main()
{
    int n,W;
    cin>>n>>W;
    long long int w[n],v[n];
    long long int dp[n][W+1];
    for(int i=0;i<n;i++)
    {   
        
        cin>>w[i]>>v[i];
     
    }
    for(int i=0;i<=W;i++)
    {
            if(i>=w[0])
            {
            dp[0][i]=v[0];
            }
            else{
                dp[0][i]=0;
            }
        
    }
    
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<=W;j++)
        {   
           if(j<w[i])
           {
               dp[i][j]=dp[i-1][j];
           }
           else{
               dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
           }
        }
    }
    
   cout<<dp[n-1][W]; 
}

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

int main() {
  int n, a[110];

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

  sort(a, a+n);
  reverse(a, a+n);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) ans += a[i];
    else ans -= a[i];
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) {
  return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

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

  int32_t N, x;
  cin >> N >> x;
  vector<int32_t> A(N);
  for (int32_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int32_t count = 0;
  for (int32_t i = 0; i < N; ++i) {
    if (x - A[i] >= 0) {
      ++count;
      x -= A[i];
    } else {
      x = 0;
      break;
    }
  }
  if (x > 0) {
    count = max(0, count - 1);
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
def larger(x, y):
	if x > y: return x
	else: return y

matchlist = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
dp = [['', 0]]
for i in range(1, N+1):
	tmp = ''
	tmpmatch = 0
	for j in range(0, len(A)):
		if i-matchlist[A[j]] >= 0:
			if dp[i-matchlist[A[j]]][1]+matchlist[A[j]] == i:
				if len(tmp) < len(dp[i-matchlist[A[j]]][0])+1:
					tmp = larger(dp[i-matchlist[A[j]]][0]+str(A[j]), str(A[j])+dp[i-matchlist[A[j]]][0])
					tmpmatch = dp[i-matchlist[A[j]]][1]+matchlist[A[j]]
				elif len(tmp) == len(dp[i-matchlist[A[j]]][0])+1:
					if tmp != larger(tmp, larger(dp[i-matchlist[A[j]]][0]+str(A[j]), str(A[j])+dp[i-matchlist[A[j]]][0])):
						tmp = larger(dp[i-matchlist[A[j]]][0]+str(A[j]), str(A[j])+dp[i-matchlist[A[j]]][0])
						tmpmatch = dp[i-matchlist[A[j]]][1]+matchlist[A[j]]
	dp.append([tmp, tmpmatch])
print(dp[N][0])

Measured memory_bytes: 134788
# coding: utf-8

from queue import Queue

N = int(input())
graph = [None]
for _ in range(N):
    graph.append(list(map(int, input().split(" ")))[1:])

class BFSSolver:

    def __init__(self, graph):
        self.graph = graph
        self.queue = Queue()
        self.queue.put(1)
        self.before_id = 1
        self.already_searched = [1]
        self.res = [0]
        for _ in range(N):
            self.res.append(-1)
        self.res[1] = 0
        self.turn = 0

    def next_turn(self):
        now_id = self.queue.get()
        before_id = now_id
        neighbors = self.graph[now_id][1:]
        for i in neighbors:
            if i not in self.already_searched:
                self.turn = self.res[before_id] + 1
                self.already_searched.append(i)
                self.res[i] = self.turn
                self.queue.put(i)

    def solve(self):
        while not self.queue.empty():
            self.next_turn()

        for id, i in enumerate(self.res[1:]):
            print("{} {}".format(id+1, i))

s = BFSSolver(graph)
s.solve()



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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n; cin >> n;
	vector<int> probs;
	for(int i{}; i<n; i++){
		int b; cin >> b;
		probs.push_back(b);
	}

	int m; cin >> m;
	for(int i{}; i<m; i++){
		int p,x,temp;
		cin >> p >> x;
		temp = probs[p-1];
		probs[p-1] = x;
		int sum{};

	for(int j{}; j<n; j++){
		sum+=probs[j];
	}
		cout << sum << "\n";
		probs[p-1]=temp;
	}










 return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    s = [str(input().rstrip('\n')) for _ in range(h)]
    L = [[0] * w for _ in range(h)]
    R = [[0] * w for _ in range(h)]
    U = [[0] * w for _ in range(h)]
    D = [[0] * w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                L[i][j] = 0
            else:
                if i == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i - 1][j] + 1
            if s[-i-1][j] == "#":
                R[-i-1][j] = 0
            else:
                if i == 0:
                    R[-i-1][j] = 1
                else:
                    R[-i-1][j] = R[-i][j] + 1
            if s[i][j] == "#":
                U[i][j] = 0
            else:
                if j == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i][j-1] + 1
            if s[i][-j-1] == "#":
                D[i][-j-1] = 0
            else:
                if j == 0:
                    D[i][-j-1] = 1
                else:
                    D[i][-j-1] = D[i][-j] + 1
    mn = 0
    for i in range(h):
        for j in range(w):
            mn = max(mn, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
    print(mn)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 177288
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

//   ifstream in("input.txt");
//   cin.rdbuf(in.rdbuf());

  int h,w;cin>>h>>w;
  REP(i,h)REP(j,w){
      string s;cin>>s;
      if(s=="snuke"){
          cout<<(char)(j+65)<<i+1<<endl;
      }
  }
  return 0;
}


Measured memory_bytes: 256
#if 0
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D&lang=jp
#endif

#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <stack>
#include <vector>

using namespace std;

#define FOR(var, start, count) for(int var=start; var<count; var++)
#define REP(var, count) FOR(var,0,count)

int main(void) {
	string str;
	cin >> str;
	
	stack<int> stk;
	stack<pair<int, int> > kouho;
	
	
	REP(i, str.size()) {
		if ( str[i] == '\\' ) {
			stk.push(i);
		} else if ( str[i] == '/' ) {
			if ( stk.size() > 0 ) {
				int start = stk.top();
				stk.pop();
				
				int under = 0;
				while ( kouho.size() != 0 ) {
					pair<int, int> prev = kouho.top();
					if ( prev.first > start ) {
						kouho.pop();
						under += prev.second;
					} else {
						break;
					}
				}
				
				kouho.push( make_pair( start, under + i-start ) );
			}
		}
	}
	
	vector<int> res;
	while ( kouho.size() > 0 ) {
		pair<int, int> p = kouho.top();
		kouho.pop();
		
		res.push_back(p.second);
	}
	
	reverse(res.begin(), res.end());
	
	cout << accumulate(res.begin(), res.end(), 0) << endl;
	cout << res.size();
	REP(i, res.size()) { cout << " " << res[i]; }
	cout << endl;
	
}

Measured memory_bytes: 3304
#include <ios>
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);

	int n, i, j, k, m, c = 0, a[100] = {};
	cin >> n;
	for(i = 0; i < n; ++i)
		cin >> a[i];
	
	for(i = 0; i < n; ++i){
		m = i;
		for(j = i; j < n; ++j){
			if( a[j] < a[m] )
				m = j;
		}
		if( m != i ){
			k = a[i];
			a[i] = a[m];
			a[m] = k;
			++c;
		}
	}

	for(i = 0; i < n; ++i){
		cout << a[i];
		if( i != n - 1 )
			cout << " ";
	}
	cout << "\n" << c << "\n";

	return 0;
}

Measured memory_bytes: 1204
a, b = map(int, input().split())

mat = []

for n in range(a):
	tmp = list(map(int, input().split()))
	mat.append(tmp)

mat2 = []
for m in range(b):
	tmp = int(input())
	mat2.append(tmp)


res = []

for i in range(a):
	tmp = 0
	for j in range(b):
		tmp += mat[i][j] * mat2[j]
	print(tmp)




Measured memory_bytes: 6012
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
const int MOD=1000000000;
const LL INF=(2e5)*(1e9)+5;
LL a[MAXN];
LL sum[MAXN];

int main()
{
    int n;
    while(cin>>n)
    {
        LL tot=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
            tot+=a[i];
        }
        LL Min=INF;
        for(int i=1;i<n;i++)
        {
            if(Min>abs(2*sum[i]-tot))
                Min=abs(2*sum[i]-tot);
        }
        cout<<Min<<endl;
    }

    return 0;
}

Measured memory_bytes: 3328
from operator import itemgetter
import sys
sys.setrecursionlimit(500000)
N, T, E, S = map(int, input().split())

G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, w = map(int, input().split())
    G[a].append((b, w))
    G[b].append((a, w))
path = []
def pre_dfs(v, p):
    if v == E:
        return True
    for u, w in G[v]:
        if u != p:
            if pre_dfs(u, v):
                path.append(u)
                return True
pre_dfs(S, 0)
path = set(path)
cnt = [0] * (N+1)
def dfs(v, p):
    next = []
    for u, w in G[v]:
        if u != p:
            if u in path:
                next.append((u, w, float("inf")))
            else:
                next.append((u, w, w))
    next.sort(key=itemgetter(2))
    for u, w, _ in next:
        #print(u, v, cnt[v], cnt[u], w)
        if (cnt[v] + cnt[u]) * T < w:
            cnt[u] += 1
            dfs(u, v)
            if (cnt[v] + cnt[u]) * T >= w:
                #print(cnt)
                if 0 < T < 10:
                    print("Yes")
                    exit()
                print("No")
                exit()
            cnt[v] += 1
        else:
            if 0 < T < 10:
                print("Yes")
                exit()
            #print(cnt)
            print("No")
            exit()
    if v==E:
        if 0 < T < 10:
            print("No")
            exit()
        #print(cnt)
        print("Yes")
        exit()

dfs(S, 0)



Measured memory_bytes: 73416
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vvl pow(n, vl(17, 1));
    for (int i = 0; i < n; ++i) {
        pow[i][0] = a[i];
        for (int j = 1; j < 17; ++j) {
            pow[i][j] = 4 * pow[i][j - 1];
        }
    }
    vvl dpl(n, vl(17, -1));
    vvl dpr(n, vl(17, -1));
    iota(dpl[n - 1].begin(), dpl[n - 1].end(), 0);
    iota(dpr[0].begin(), dpr[0].end(), 0);
    for (int i = n - 2; i >= 0; --i) {
        ll over = 0;
        for (int j = 0; j < 17; ++j) {
            auto it   = lower_bound(pow[i + 1].begin(), pow[i + 1].end(), pow[i][j]);
            dpl[i][j] = j;
            ll k      = it - pow[i + 1].begin();
            if (over == 0) {
                if (it == pow[i + 1].end()) {
                    over++;
                    dpl[i][j] += over * (n - 1 - i) + dpl[i + 1][16];
                } else
                    dpl[i][j] += dpl[i + 1][k];
            } else {
                over++;
                dpl[i][j] += over * (n - 1 - i) + dpl[i + 1][16];
            }
        }
    }
    for (int i = 1; i < n; ++i) {
        ll over = 0;
        for (int j = 0; j < 17; ++j) {
            auto it   = lower_bound(pow[i - 1].begin(), pow[i - 1].end(), pow[i][j]);
            dpr[i][j] = j;
            ll k      = it - pow[i - 1].begin();
            if (over == 0) {
                if (it == pow[i - 1].end()) {
                    over++;
                    dpr[i][j] += over * i + dpr[i - 1][k - 1];
                } else
                    dpr[i][j] += dpr[i - 1][k];
            } else {
                over++;
                dpr[i][j] += over * i + dpr[i - 1][16];
            }
        }
    }
    ll ret = 2 * dpl[0][0];
    for (int i = 1; i < n; ++i) {
        ll temp = 2 * dpr[i - 1][0] + 2 * dpl[i][0] + i;
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N + 1); rep1(i, N) cin >> a[i];
  vector<ll> b(N + 1, 0);
  
  ll ans = 0;
  bool ok = true;

  for(ll i = N; i > 0; i--) {
    ll cnt = 0;
    for(ll j = i; j <= N; j += i) {
      cnt += b[j]; 
    }
    b[i] = (cnt + a[i]) % 2 ;
    //    cerr << i << "]" << cnt << "->" << b[i] << endl;
    ans += b[i];
  }
  cout << ans << endl;
  if(ans > 0) {
    rep1(i, N) {
      if(b[i] == 1) cout << i << " " ;
    }
    cout << endl;
  }



}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 6392
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, v;
    ll b, w;
    cin>>a>>v>>b>>w;
    ll t;
    cin>>t;
    if(a == b) {
    	cout<<"YES\n";
    }
    else if(v - w <= 0) {
    	cout<<"NO\n";
    } else{
    	if(a > b) {
    		swap(a, b);
    	}
    	ll dis1 = a + t * v;
    	ll dis2 = b + t * w;
    	if(dis1 >= dis2) {
    		cout<<"YES\n";
    	} else {
    		cout<<"NO\n";
    	}
    }
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    string s,t;
    cin >> s>>t;
    string ans=t+s;
    cout<<ans<<endl;
    return 0;
}



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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e3 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n, m;
        cin >> n >> m;
        ll sum = 0;
        for (int i = 1; i <= m; i++){
                ll a;
                cin >> a;
                sum += a;
        }
        sum = n - sum;
        if (sum >= 0) cout << sum;
        else cout << -1;
}



Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, h, w, ans;
int main()
{
	cin >> n >> h >> w;
	FOR(i,0,n)
	{
		FOR(j,0,n)
		{
			ll nx = i + h-1;
			ll ny = j + w-1;
			if(nx >= n || ny >= n) continue;
			ans ++;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.*;

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

        int h = sc.nextInt();
        int n = sc.nextInt();

        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        int num = 0;

        for (int i = 0; i < n; i++) {
            num += array[i];
        }

        if (num >= h) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }
}

Measured memory_bytes: 50304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;
ll NumberSize(ll N) {
	int cnt = 0;
	while (N > 0) {
		N /= 10;
		cnt++;
	}
	return cnt;
}
int main() {
	ll N;
	cin >> N;
	int ans = NumberSize(N);
	for (ll i = 1; i * i <= N; i++) {
		if (N % i != 0) continue;
		ll B = N / i;
		int size = max(NumberSize(i), NumberSize(B));
		if (ans > size) ans = size;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    long long n,m;
    cin>>n>>m;
    if(n==1||m==1)
    {
        cout<<1<<endl;
        return 0;
    }
    long long ans=(n%2+n/2)*(m%2+m/2)+n/2*(m/2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#line 1 "test/aoj/GRL_4_B.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/GRL_4_B"
#line 1 "test/aoj/../../graph/topological-sort.cpp"
#include <vector>
#include <stack>
#line 1 "test/aoj/../../graph/template.cpp"
#include <vector>

using namespace std;

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = vector< Edge< T > >;
template< typename T >
using Graph = vector< Edges< T > >;
#line 4 "test/aoj/../../graph/topological-sort.cpp"
using namespace std;

template< typename G >
vector<int> topologicalSort(const G &g) {
  // トポロジカルソートした結果を返す
  const int V = g.size();
  vector<int> indegree(V); // 200000とかだと遅い？ 厳しそうならグローバル変数にする
  // 入次数の初期化. ほんとは読み込み時にやったほうが効率が良いけど許容する
  for (int v = 0; v < V; ++v) {
    for (auto& e: g[v]) ++indegree[e.to];
  }

  stack<int> st;
  for (int v = 0; v < V; ++v) {
    // 入次数0の点をstackにいれる
    if (indegree[v] == 0) st.push(v);
  }

  vector<int> order;
  while (!st.empty()) {
    int v = st.top(); st.pop();
    order.push_back(v);
    for (auto& e: g[v]) {
      --indegree[e.to];
      if (indegree[e.to] == 0) st.push(e.to);
    }
  }

  return order;
}
#line 3 "test/aoj/GRL_4_B.test.cpp"

#include <iostream>
using namespace std;

using G = Graph<int>;
int main() {
  int V, E; cin >> V >> E;
  G graph(V);
  for (int i = 0; i < E; ++i) {
    int s, t; cin >> s >> t;
    graph[s].emplace_back(s, t);
  }
  vector<int> order = topologicalSort(graph);
  for (int v: order) { cout << v << endl; }
}



Measured memory_bytes: 4096
#include <stdio.h>
using namespace std;
typedef long long ll;

ll abs(ll a) {
  return a > 0 ? a : -a;
}

ll max(ll a, ll b) {
  return a > b ? a : b;
}

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll x[n], y[n], h[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld%lld", &x[i], &y[i], &h[i]);
  for(i = 0; i <= 100; ++i) for(j = 0; j <= 100; ++j) {
    ll ht;
    for(k = 0; k < n; ++k) if(h[k]) {
      ht = h[k] + abs(i - x[k]) + abs(j - y[k]);
      break;
    }
    bool b = true;
    for(k = 0; k < n; ++k) if(max(ht - abs(i - x[k]) - abs(j - y[k]), 0) != h[k]) b = false;
    if(b) {
     printf("%lld %lld %lld", i, j, ht);
     return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  while(res<0){
    res=res + mod;
  }
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
string S;
ll N;
ll dp[100010][13];
ll v[100010][13];

ll dpf(ll n, ll m){
  if(v[n][m]==1){
    return dp[n][m];
  }else{
    v[n][m] = 1;
    if(n==0){
      if((S[n]-'0')== m){
        dp[n][m]=1;
      }else if(S[n]=='?' and m<=9){
        dp[n][m]=1;
      }else{
        dp[n][m]=0;
      }
    }else{
      if(S[n]=='?'){
        dp[n][m]=0;
        ll tmp = modpow(10, n, 13);
        rep(i, 10){
          dp[n][m] = mod( dp[n][m] + dpf(n-1, mod(m -i*tmp, 13) ), MOD);
        }
      }else{
        ll tmp = S[n]-'0';
        tmp = mod(tmp * modpow(10, n, 13), 13);
        ll target = mod(m - tmp,13);
        dp[n][m] = dpf(n-1, target);
      }
    }
    return mod(dp[n][m],MOD);
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> S;
  N=S.size();
  reverse(ALL(S));
  cout << dpf(N-1, 5) << endl;;
  /*ll cnt=0;
  rep(i, 10000){
    if(i%13==5){
      //cout << i << endl;
      cnt++;
    }
  }
  cout << cnt;*/
  return 0;
  
}


Measured memory_bytes: 27008
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];

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

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include<functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/

double tanri(int money, int year, int rate)
{
	return 1.0 * money * (1.0 + year * rate / 100.0);
}

double hukuri(int money, int year, int rate)
{
	return money * pow(1.0 + rate / 100.0, year);
}

int main()
{
	int n, y, b, r, t;
	int ind;
	
	while (cin >> n, n)
	{
		double max_price = -1.0;
		cin >> y;
		REP(n)
		{
			cin >> b >> r >> t;
			switch (t)
			{
			case 1:
				if (max_price < tanri(1, y, r))
				{
					max_price = tanri(1, y, r);
					ind = b;
				}
				break;
			case 2:
				if (max_price < hukuri(1, y, r))
				{
					max_price = hukuri(1, y, r);
					ind = b;
				}
			}
		}
		cout << ind << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1252
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()

	num := make([]byte, 0)
	for {
		N--
		now := N % 26
		num = append(num, byte('a'+now))

		N = N / 26
		if N == 0 {
			break
		}
	}

	for i := len(num) - 1; i >= 0; i-- {
		fmt.Print(string(num[i]))
	}
	fmt.Println()

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


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

using namespace std;

int main() {
	long long h, w;
	cin >> h >> w;
	long long s = h * w;
	if (s % 2 != 0) {
		++s;
	}
	if (h == 1 || w == 1) {
		s = 2;
	}
	cout << s / 2;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[10];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1); 
	if (s[n] == '0') {
		puts("pon");
	}
	if (s[n] == '1') {
		puts("pon");
	}
	if (s[n] == '2') {
		puts("hon");
	}
	if (s[n] == '3') {
		puts("bon");
	}
	if (s[n] == '4') {
		puts("hon");
	}
	if (s[n] == '5') {
		puts("hon");
	}
	if (s[n] == '6') {
		puts("pon");
	}
	if (s[n] == '7') {
		puts("hon");
	}
	if (s[n] == '8') {
		puts("pon");
	}
	if (s[n] == '9') {
		puts("hon");
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 55;
const int MOD = 1e9+7;

int N, K;

ll dp[MAX][MAX][MAX*MAX/2];

ll solve() {
    if (K%2 == 1) return 0;
    K /= 2;
    dp[0][0][0] = 1;
    REP (i, N) {
        REP (j, i+1) REP (k, K+1) {
            (dp[i+1][j+1][k+j+1] += dp[i][j][k]) %= MOD;
            (dp[i+1][j][k+j] += dp[i][j][k] * (2*j+1)) %= MOD;
            if (j >= 1) {
                (dp[i+1][j-1][k+j-1] += dp[i][j][k] * (j * j % MOD)) %= MOD;
            }
        }
    }
    return dp[N][0][K];
}

int main() {
    cin >> N >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 33152
A,B,C = map(int,input().split())
#if A%2 == 0 or B%2 == 0 or C%2 == 0 :
#    print(0)
#    exit()
L = abs(A*B*(C//2) - (A*B*(C-C//2)))
N = abs(A*C*(B//2) - (A*C*(B-B//2)))
M = abs(C*B*(A//2) - (C*B*(A-A//2)))

print(min(L,N,M))

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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(){
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	REP(i,h) cin >> s[i];
	
	vector<vector<int>> ans(h,vector<int>(w,0));
	int sb=1;
	REP(i,h) REP(j,w){
		if(s[i][j]=='#'){
			ans[i][j]=sb;
			sb++;
		}
	}
	
	REP(i,h){
		REP(j,w){
			if(j!=0 && ans[i][j]==0){
				ans[i][j] = ans[i][j-1];
			}
		}
		for(int j=w-1; j>=0; j--){
			if(j!=w-1 && ans[i][j]==0){
				ans[i][j] = ans[i][j+1];
			}
		}
	}
	
	REP(j,w){
		REP(i,h){
			if(i!=0 && ans[i][j]==0){
				ans[i][j] = ans[i-1][j];
			}
		}
		for(int i=h-1; i>=0; i--){
			if(i!=h-1 && ans[i][j]==0){
				ans[i][j] = ans[i+1][j];
			}
		}
	}
	
	REP(i,h){
		REP(j,w){
			if(j!=0) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n = s.length();
  bool ok = true;
  for (int i=0; i<n; i++) {
    if (i % 2 == 0) {
      if (s[i] != s[0]) {
        ok = false;
        break;
      }
    } else {
      if (s[i] != s[1]) {
        ok = false;
        break;
      }
    }
  }
  if (ok) {
    cout<<"Second"<<endl;
    return 0;
  }
  if (s[0] == s[n-1]) {
    if (n % 2 == 0) {
      cout<<"First"<<endl;
    } else {
      cout<<"Second"<<endl;
    }
  } else {
    if (n % 2 == 0) {
      cout<<"Second"<<endl;
    } else {
      cout<<"First"<<endl;
    }
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    int X, Y;
    cin >> X >> Y;
    int money = 0;
    if (X == 3) money += 100000;
    else if (X == 2) money += 200000;
    else if (X == 1) money += 300000;
    if (Y == 3) money += 100000;
    else if (Y == 2) money += 200000;
    else if (Y == 1) money += 300000;
    if (X == 1 && Y == 1) money += 400000;
    cout << money << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 -o2 -Wall ABC097B.cpp -o ./out/ABC097B.out
// ./out/ABC097B.out

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;


int main() {
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  int ans = 1;
  rep(i, int(sqrt(x)) + 1) {
    if (i <= 1) continue;
    int temp = i;
    for (;;) {
        temp *= i;
        if (temp <= x) {
          ans = max(ans, temp);
        } else {

          break;
        }
    }
  }
  cout << ans << "\n";
  return 0;
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;
template <class X> map<X,int> prime_factorize(X a){
    int b = 2;
    map<X,int>cnt;
    while(a >= b * b){
        if(a % b == 0){
            cnt[b]++;
            a /= b;
        }else b++;
    }
    cnt[a]++;
    return cnt;
}
int main(){
    ll x;
    cin >> x;
    ull ans;
    if(x % 11 == 0) ans = x / 11 * 2;
    else if(1 <= x % 11 and x % 11 <= 6) ans = x / 11 * 2 + 1;
    else ans = x / 11 * 2 + 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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

	ll N, W;

	cin >> N >> W;

	vector<ll> w(N);
	vector<ll> v(N);
	for (ll i = 0; i < N; ++i) cin >> w[i] >> v[i];
	
	vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));

	for (ll i = 1; i <= N; ++i)
	{
		for (ll w_ub = 0; w_ub <= W; ++w_ub)
		{
			if (w[i-1] <= w_ub)
			{
				chmax(dp[i][w_ub], dp[i - 1][w_ub - w[i - 1]] + v[i - 1]);
			}
			chmax(dp[i][w_ub], dp[i-1][w_ub]);
		}
	}

	cout << dp[N][W] << endl;
	system("pause");
}


Measured memory_bytes: 80256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>

long sum(std::string& S, int v){
    std::vector<long> d;
    //std::cout << "--" << v << "--" << std::endl;
    std::string s = "";
    s += S.at(0);
    for(int i = 1; i < S.size(); i++){
        if(v&0x01 == 1){
            d.push_back(std::stol(s));
            s = S.at(i);
        }else{
            s += S.at(i);
        }
        v = v >> 1;
    }
    d.push_back(std::stol(s));
    long ans = 0;
    for(int i = 0; i < d.size(); i++){
        //std::cout << d.at(i) << std::endl;
        ans += d.at(i);
    }
    return ans;
}

int main(int argc, char **argv)
{
    std::string S;
    std::cin >> S;

    int bits = std::pow(2, S.size()-1);
    //std::cout << bits << std::endl;

    long ans = 0;
    for(int i = 0; i < bits; i++){
        ans += sum(S, i);
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int _P=1000000007;
int main(){
	int n;
	cin >> n;
	long long res=1;
	vector<long long> v(n);
	for(int i=0;i<n;++i) {
		cin >> v[i];
		if(v[i]==0) {cout << 0 << endl; return 0;}
	}
	for(int i=0;i<n;++i) {
		if(res > 1000000000000000000 / v[i]) {res = -1; break;}
		res*= v[i];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

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

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( *lower_bound(A, A + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();

        int max,count=0;
        max = b/a;
        if(c>max) System.out.println(max);
        else System.out.println(c);

    }
}

Measured memory_bytes: 23252
bingo = []
for _ in range(3):
    bingo.extend(list(map(int,input().split())))

N = int(input())
nl = [int(input()) for _ in range(N)]

bing_indexs = [
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6]
]

bingmap = list(map(lambda x:x in nl,bingo))

for bing_index in bing_indexs:
    for i,num in enumerate(bing_index):
        if(not bingmap[num]):
            break
        if(i==2):
            print("Yes")
            exit(0)

print("No")


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];

    int max_len = 0;
    int sum = 0;
    rep(i,n){
        max_len = max(l[i],max_len);
        sum += l[i];
    }

    cout << (max_len < sum-max_len ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll pw[500][500];
ll dp[500][500];
int a[500], b[500];
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	for (int i = 1; i <= 420; i++)
	{
		pw[i][0] = 1;
		for (int j = 1; j <= 420; j++)pw[i][j] = pw[i][j - 1] * i%mod;
	}
	for (int i = 0; i < num; i++)scanf("%d", &a[i]);
	for (int i = 0; i < num; i++)scanf("%d", &b[i]);
	dp[0][0] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j <= gen; j++)
		{
			ll t = 0;
			for (int k = a[i]; k <= b[i]; k++)t += pw[k][j];
			t %= mod;
			for (int k = 0; k <= gen - j; k++)dp[i + 1][k + j] = (dp[i + 1][k + j] + dp[i][k] * t) % mod;
		}
	}
	printf("%lld\n", dp[num][gen]);
}

Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int a[3],i,tmp,j;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(a[i]>a[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a[3];
  rep(i, 0, 3){
    cin >> a[i];
  }
  sort(a, a + 3);
  int b = a[1] + a[2] * 10;
  cout << a[0] + b << "\n";
}


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

#define int long long 

int32_t main()
{
    int n,m;
    cin>>n>>m;
    int l,r;
    l = 0, r=INT64_MAX;
    for(int i=0; i<m; i++)
    {
        int li,ri;
        cin>>li>>ri;
        if(li > r || l > ri)
        {
            cout<<0;
            return 0;
        }
        l = max(l, li);
        r = min(r, ri);
    }
    cout<<r-l+1;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int K;
    int S;

    cin >> K >> S;

    int cnt = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++)
        {
            int z = S - x - y;

            if (z >= 0 && z <= K)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

using namespace std;
int n,m,q;
int no[2001][2001];
int e1[2001][2001];
int e2[2001][2001];
int main() {
  cin >> n >> m >> q;
  string s;

  for(int i = 1; i <= n; i++) {
    cin >> s;
    for(int j = 1; j <= s.length(); j++) {
      no[i][j] = s[j-1] - '0';
      e1[i][j] = no[i][j] & no[i][j-1];
      e2[i][j] = no[i][j] & no[i-1][j];
    }
  }

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      no[i][j] += no[i][j-1];
      e1[i][j] += e1[i][j-1];
      e2[i][j] += e2[i][j-1];
    }
    for(int j = 1; j <= m; j++) {
      no[i][j] += no[i-1][j];
      e1[i][j] += e1[i-1][j];
      e2[i][j] += e2[i-1][j];
    }
  }

  for(int i = 0; i < q; i++) {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int node = no[x2][y2] + no[x1-1][y1-1] - no[x1-1][y2] - no[x2][y1-1];
    node -= e1[x2][y2] + e1[x1-1][y1] - e1[x1-1][y2] - e1[x2][y1];
    node -= e2[x2][y2] + e2[x1][y1-1] - e2[x2][y1-1] - e2[x1][y2];
    cout << node << endl;
  }

}

    


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

int a[100005];
int dp[100005];

main()
{
	int n , k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)cin >> a[i];
	
	for(int i = 2; i <= n; i++)dp[i] = INT_MAX;
	
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= min(n , i + k); j++)
		{
			dp[j] = min( dp[j] , dp[i] + abs( a[j] - a[i] ) );
		}
	}
	
	cout << dp[n] << endl;
	
}


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

int main(){
  int a,b;
  1<=(a,b)<=10000;
  cin>>a>>b;
  if (a%2==0 || b%2==0){
    cout<< "Even"<<endl;
  }
  else{
    cout<< "Odd"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		long[][] a = new long[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				a[i][j] = sc.nextLong();
			}
		}

		long[][][] dp = new long[2][200][200];
		dp[0][0][0] = a[0][0];
		for (int t = 0; t < H + W - 2; ++t) {
			int next = (t + 1) % 2;
			int pre = t % 2;
			for (int i = 0; i < 200; ++i) {
				for (int j = 0; j < 200; ++j) {
					if (!(0 <= i && i < H && 0 <= j && j < H && 0 <= t - i && t - i < W && 0 <= t - j && t - j < W))
						continue;
					for (int to1 = 0; to1 <= 1; ++to1) {
						for (int to2 = 0; to2 <= 1; ++to2) {

							if (!(0 <= i + to1 && i + to1 < H && 0 <= j + to2 && j + to2 < H && 0 <= t - i + (to1 ^ 1)
									&& t - i + (to1 ^ 1) < W && 0 <= t - j + (to2 ^ 1) && t - j + (to2 ^ 1) < W))
								continue;

							long get = a[i + to1][t - i + (to1 ^ 1)] + a[j + to2][t - j + (to2 ^ 1)];
							if (i + to1 == j + to2 && t - i + (to1 ^ 1) == t - j + (to2 ^ 1))
								get /= 2;
							dp[next][i + to1][j + to2] = Math.max(dp[next][i + to1][j + to2], dp[pre][i][j] + get);
						}
					}
				}
			}
		}
		System.out.println(dp[(H + W - 2) % 2][H - 1][H - 1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 47908
<?php

fscanf(STDIN,"%d%d%d",$a,$b,$c);

$array = [$a,$b,$c];
$max = max($array);
$amari = ($a + $b + $c) - $max;


if ($max == $amari){
    echo 'Yes';
}else{
    echo 'No';
}

Measured memory_bytes: 4604