akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n=s.size();
	long long ans=0;
	for(int i=0;i<(1<<(n-1));i++)
	{
		long long count=0;
		long long plus=0;
		for(int j=0;j<n;j++)
		{
			if((i&(1<<(j-1)))!=0)
			{
				count+=plus;
//cout << plus << " ";
				plus=0;
			}
			plus*=10;
			plus+=(s[j]-'0');
		}
		count+=plus;
//cout << plus << " ";
//cout << "\t" << count << endl;
		ans+=count;
	}
	cout << ans << endl;

		



	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        char[] alp = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                       'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 
                       'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
                       'y', 'z'};
        char input = br.readLine().charAt(0);

        int result = 0;

        for(int i = 0; i < alp.length; i++){
          if(alp[i] == input){
            result = i;
            break;
          }
        }

        System.out.println(alp[result+1]);
      }
    }
}


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

int main() {
  int n,ans = -1,now = 1;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
   cin >> a.at(i);
  }
  for(int i = 1; i <= n; i++){
    now = a.at(now - 1);
    if(now == 2){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int getmin(int val1, int val2) {
	if (val1 < val2) {
		return val1;
	}
	else {
		return val2;
	}
}

int getmax(int val1, int val2) {
	if (val1 > val2) {
		return val1;
	}
	else {
		return val2;
	}
}

typedef struct data {
	char c;
	int cnt;
} data;

char l[100005];
int len;
ll cnt[100005];

int fnc2() {
	int n = geti();
	int k = geti();
	if (k == 1) {
		return 0;
	}
	else {
		return n - k;
	}
}

int fnc1() {
	int ret = fnc2();
	outi(ret);
	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc1();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc1();
#endif

	return 0;
}


Measured memory_bytes: 128
import collections
n = int(input())
list_a = list(map(int, input().split(" ")))
count = collections.Counter(list_a)

flag = True
for key, value in count.items():
  if value == 2 or (key == 0 and value == 1):
    pass
  else:
    flag = False
    break

if flag:
  print(2 ** (n // 2) % (7 + 10 ** 9))
else:
  print(0)

Measured memory_bytes: 14812
#include<stdio.h>
int main()
{
  int a,b,c,n;
  scanf("%d",&n);
  a=n/100;
  b=(n-a*100)/10;
  c=n%10;
  if(a<b||a<c){
    a=a+1;
  }
  n=a*100+a*10+a;
  printf("%d",n);
  return 0;
}


Measured memory_bytes: 128
n = int(input())

a_ascii = ord("A")
z_ascii = ord("Z")
range_ascii = z_ascii - a_ascii + 1
s = list(map(lambda x: ord(x) - a_ascii, list(input())))
s = list(map(lambda x: x + n, s))

for i in range(len(s)):
    if (s[i] - range_ascii) >= 0:
        s[i] = abs(s[i] - range_ascii)

s = list(map(lambda x: chr(x + a_ascii), s))

print("".join(s))


Measured memory_bytes: 41328
#include <iostream>
using namespace std;
int dice[6];
int dice2[6];
void shokika(){
    dice[0] = 1;
    dice[1] = 2;
    dice[2] = 3;
    dice[3] = 5;
    dice[4] = 4;
    dice[5] = 6;
}
void copy(){
    for(int i = 0;i < 6;i++){
        dice2[i] = dice[i];
    }

}
void north(){
    copy();
    dice[0] = dice2[1];
    dice[1] = dice2[5];
    dice[5] = dice2[3];
    dice[3] = dice2[0];
}
void south(){
    copy();
    dice[0] = dice2[3];
    dice[1] = dice2[0];
    dice[5] = dice2[1];
    dice[3] = dice2[5];
}
void east(){
    copy();
    dice[0] = dice2[4];
    dice[2] = dice2[0];
    dice[5] = dice2[2];
    dice[4] = dice2[5];
}
void west(){
    copy();
    dice[0] = dice2[2];
    dice[2] = dice2[5];
    dice[5] = dice2[4];
    dice[4] = dice2[0];
}
void right(){
    copy();
    dice[1] = dice2[2];
    dice[2] = dice2[3];
    dice[3] = dice2[4];
    dice[4] = dice2[1];
}
void left(){
    copy();
    dice[1] = dice2[4];
    dice[2] = dice2[1];
    dice[3] = dice2[2];
    dice[4] = dice2[3];
}

int main(){
    int a[5];
    int k = 0;
    while(1){
        a[k] = 1;
        int n;
        cin >> n;
        if(n == 0)break;
        shokika();
        for(int i = 0;i < n;i++){
            string g;
            cin >> g;
            if(g == "North")north();
            if(g == "South")south();
            if(g == "West")west();
            if(g == "East")east();
            if(g == "Right")right();
            if(g == "Left")left();
            a[k] += dice[0];
        }
        k++;
    }
    for(int i= 0;i < k;i++){
        cout << a[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#include <stdio.h>
long xxx[10][1001][101];
long pattern(int n,int s,int from){
    if(n>1){
        long i,x=0;
		if(xxx[n][s][from]>=0)x=xxx[n][s][from];
        else{
		for(i=from; i<100 && i<=s ;i++){x+=pattern(n-1,s-i,i+1);}
		xxx[n][s][from]=x;
		}
        return x;
    }
    else{if(from<=s && s<=100)return 1; else return 0;}
}
 
int main(void){
    int n,s,i,j,k;
	for(i=0;i<10;i++){for(j=0;j<1001;j++){for(k=0;k<101;k++){xxx[i][j][k]=-1;}}}
    while(scanf("%d %d",&n,&s)*(n+s)){printf("%ld\n",pattern(n,s,0));}
    return 0;
}

Measured memory_bytes: 8496
O = input()
E = input()
Ans = []

if len(O) - len(E) == 0:
  for i in range(len(O)):
  	Ans.append(O[i])
  	Ans.append(E[i])
else:
  for i in range(len(E)):
    Ans.append(O[i])
    Ans.append(E[i])
  Ans.append(O[len(O)-1])
  
print(''.join(Ans))

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2E3;
int n, m, ans;
vector<int> e[N], p[N], de, di;
vector<pair<int, int>> path;
int parent[N], dep[N], c[N], in[N];
int dfs_now;
void dfs(int u) {
    in[u] = dfs_now++;
    if (parent[u] != -1)
        e[u].erase(find(e[u].begin(), e[u].end(), parent[u]));
    for (int v : e[u]) {
        dep[v] = dep[u] + 1;
        parent[v] = u;
        dfs(v);
    }
}
int lca(int u, int v) {
    while (u != v) {
        if (dep[u] < dep[v])
            swap(u, v);
        u = parent[u];
    }
    return u;
}
void dfs1(int u) {
    reverse(e[u].begin(), e[u].end());
    for (int v : e[u]) {
        dfs1(v);
        c[u] += c[v];
    }
    ans += min(c[u], 2);
    if ((int)p[u].size() >= 2) {
        int i = p[u].back();
        p[u].pop_back();
        int j = p[u].back();
        p[u].pop_back();
        int x = path[i].first;
        int y = path[j].first;
        if (x != y) {
            if (in[x] > in[y]) {
                swap(x, y);
                swap(i, j);
            }
            de[i] = de[j] = (int)path.size();
            p[y].push_back((int)path.size());
            path.emplace_back(x, y);
            de.push_back(-1);
            di.push_back(0);
        }
        di[j] = 1;
    }
    while (!p[u].empty()) {
        int i = p[u].back();
        p[u].pop_back();
        int x = path[i].first;
        int y = parent[u];
        if (x == y)
            continue;
        if (in[x] > in[y]) {
            swap(x, y);
            di[i] = 1;
        }
        de[i] = (int)path.size();
        p[y].push_back((int)path.size());
        path.emplace_back(x, y);
        de.push_back(-1);
        di.push_back(0);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        e[--u].push_back(--v);
        e[v].push_back(u);
    }
    parent[0] = -1;
    dfs(0);
    path.resize(m);
    de.assign(m, -1);
    di.resize(m);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        int l = lca(--u, --v);
        ++c[u];
        ++c[v];
        c[l] -= 2;
        if (in[u] > in[v])
            swap(u, v);
        p[v].push_back(i);
        path[i] = {u, v};
    }
    dfs1(0);
    for (int i = (int)path.size() - 1; i >= 0; --i)
        if (de[i] != -1)
            di[i] ^= di[de[i]];
    for (int i = 0; i < m; ++i)
        if (di[i] == 1)
            swap(path[i].first, path[i].second);
    cout << ans << "\n";
    for (int i = 0; i < m; ++i) {
        int u, v;
        tie(u, v) = path[i];
        cout << ++u << " " << ++v << "\n";
    }
    return 0;
}

Measured memory_bytes: 9264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int a, b;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> a >> b;
	if(a>=13){
		cout << b;
	}else if(a>=6){
		cout << (b / 2);
	}else{
		cout << 0;
	}
	return 0;
}

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

int main() {
  long long a, b, c;
  cin>>a>>b>>c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout<<0<<endl;
  } else {
    cout<<min(a*b, min(b*c, c*a))<<endl;
  }
}

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

using namespace std;

int main(){
    int m;
    cin >> m;
    for(int dat=0;dat<m;dat++){
        int init,nen,n;
        cin >> init >> nen >> n;
        int m = -1;
        for(int i=0;i<n;i++){
            int how,tesu;
            double rate;
            cin >> how >> rate >> tesu;
            int have = init;
            int soko = 0;
            for(int j=0;j<nen;j++){
                double r = have*rate;
                int rr = floor(r);
                if(how){
                    have += rr - tesu;
                }else{
                    soko += rr;
                    have -= tesu;
                }
            }
            m = max(m,have+soko);
        }
        cout << m << endl;
    }
}

Measured memory_bytes: 1232
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S.back() == 's') {
    cout << S << "es" << endl;
  } else {
    cout << S << "s" << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
K, N = map(int, input().split())
mod = 998244353
A = []
p = mod - 2
while p != 0:
  A = [p%2] + A[:]
  p //= 2
def inved(x):
  y = 1
  for _ in range(len(A)):
    if A[_] == 1:
      y *= x
      y %= mod
    if _ != len(A) - 1:
      y *= y
      y %= mod
  return y

X = [0 for i in range(2*K-1)]
frac = [1]
for i in range(N + K):
  frac.append(((i+1)*frac[i])%mod)
invf = []
for i in range(N + K + 1):
  invf.append(inved(frac[i]))
for k in range(2, K+2):
  S = 0
  sign = 1
  l = k // 2
  for m in range(min(l+1, N//2+1)):
    prod = (sign * (frac[l]*frac[N+K-2*m-1])) % mod
    prod *= (invf[m]*invf[l-m]) % mod
    prod %= mod
    prod *= (invf[N-2*m] * invf[K-1]) % mod
    prod %= mod
    S += prod
    S %= mod
    sign *= -1
  X[k-2], X[2*K-k] = S, S
for i in range(2*K-1):
  print(X[i])

Measured memory_bytes: 3608
require'date'

while line=gets.chomp
    break if line=="-1 -1 -1 -1 -1 -1"
    y1,m1,d1,y2,m2,d2=line.split.map(&:to_i)
    a=Date.new(y1,m1,d1)
    b=Date.new(y2,m2,d2)
    puts (b-a).to_i
end

Measured memory_bytes: 6232
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() {
    int a,x;
    cin>>x>>a;

    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
}



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

const int N=1e5+77;

signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("poly.in", "r", stdin);
    // freopen("poly.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    string S;
    cin>>S;
    int n=0, w=0, e=0, s=0;
    for(char i:S){
        n+=i=='N';
        w+=i=='W';
        e+=i=='E';
        s+=i=='S';
    }
    if(n||s){
        if(!n||!s){
            cout<<"No";
            return 0;
        }
    }
    if(w||e){
        if(!w||!e){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    System.out.println(s.equals("ABC") ? "ARC" : "ABC");
  }
}

Measured memory_bytes: 25376
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for _ in range(101)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).find('AGC') != -1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

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

void swap(int& a, int& b){
	int h = a;
	a = b;
	b = h;
}

int BubbleSort(vector<int>& A){
	int count = 0;
	for(int i = 0;i<A.size();i++){
		for(int j = A.size()-1; j>i; j--){
			if(A[j] < A[j-1]){
				count++;
				swap(A[j], A[j-1]);
			}
		}
	}
	return count;
}

int main(){
	int n,h;
	vector<int> v;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> h;
		v.push_back(h);
	}
	int c = BubbleSort(v);
	cout << v[0];
	for(int i=1;i<n;i++){
		cout << " " << v[i];
	}
	cout << endl << c << endl;
	return 0;
}

Measured memory_bytes: 1216
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const ll linf = 1e18 , P = 1e9 + 7;
vector<ll> fib;
vector<vector<pair<ll,ll> > > v;

void dfs(int a,ll b,ll c,int d){
    if(b&&c/b==1) v[a].pb(mp(b,c)),v[a].pb(mp(c,b));
    if(d==0){
        ll nb=c,nc=b+c*2;
        if(nb<=linf&&nb<=fib[a+3]&&nc<=linf&&nc<=fib[a+3])
            dfs(a+1,nb,nc,1);
    }
    ll nb=c,nc=b+c;
    if(nb<=linf&&nb<=fib[a+3]&&nc<=linf&&nc<=fib[a+3])
        dfs(a+1,nb,nc,d);
}

int main(){
    fib.pb(1);
    fib.pb(1);
    while(*fib.rbegin()<linf) fib.pb(fib[sz(fib)-1]+fib[sz(fib)-2]);
    v.resize(sz(fib));
    dfs(0 , 1 , 1 , 0);
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        ll x,y;scanf("%lld%lld",&x,&y);
        if(x>y) swap(x,y);
        int k=1;
        rep(i,1,sz(fib)-1) if(fib[i]<=x&&fib[i+1]<=y)
            k=i;
        ll ans=0;
        if(k == 1) ans=(x%P)*(y%P)%P;
        else {
            for(auto e : v[k]) {
                if(e.fi > x || e.se > y) continue;
                (ans += (y - e.se) / e.fi + 1) %= P;
            }
        }
        printf("%d %lld\n",k,ans);
    }
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    string s;
    cin >> s;
    
    for(int i=0;i<s.size();i++){
        if(s.substr(i,7) == "dreamer" && s.substr(i+5,5) != "erase")
            i += 6;
        else if(s.substr(i,6) == "eraser")
            i += 5;
        else if(s.substr(i,5) == "erase")
            i += 4;
        else if(s.substr(i,5) == "dream")
            i += 4;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int n,m,x,y,z,a[20][20],val[40000],dp[40000][20],sum=0;

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		cin>>x>>y>>z;
		x--;
		y--;
		sum+=z;
		a[x][y]=a[y][x]=z;
	}
	rep(i,1<<n) rep(j,n) for(int k=j+1;k<n;k++) if((i&(1<<j))>0&&(i&(1<<k))>0) val[i]+=a[j][k];
	rep(i,39995) rep(j,18) dp[i][j]=-1;
	rep(i,1<<n) if((i&1)==1) dp[i][0]=val[i];
	rep(i,1<<n)
	{
		rep(j,n)
		{
			if(dp[i][j]==-1) continue;
			int rest=(1<<n)-1-i;
			for(int k=rest;k>0;k=(k-1)&rest)
			{
				rep(p,n)
				{
					if((k&(1<<p))==0||a[j][p]==0) continue;
					dp[i|k][p]=max(dp[i|k][p],dp[i][j]+val[k]+a[j][p]);
				}
			}
		}
	}
	cout<<sum-dp[(1<<n)-1][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 3456
public class Main{
  static int N = 10000001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] p;
    int pn, i, n, a;

    p = new int[N / 6];
    pn = getprime(p);

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      a = 13;
      for(i = 6;p[i] <= n && i < pn;i++){
        if(p[i] - p[i-1] == 2 && p[i] - p[i-2] == 6 && p[i] - p[i-3] == 8){
          a = p[i];
        }
      }
      out.println(a);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int getprime(int[] p){
    int i, j, count = 0;
    boolean[] e;
    e = new boolean[N];
    e[0] = true; e[1] = true;
    for(i = 2;i < N;i++)if(!e[i]){
      p[count++] = i;
      for(j = i * 2;j < N;j+=i)e[j] = true;
    }
    return count;
  }
}

Measured memory_bytes: 40212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  ll a,b,c;
  cin >> a >> b >> c;
  if((a==b && b !=c) || (b== c && c!=a) || (a==c && a!=b)) cout<< "Yes"<<endl;
  else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)<abs(x-b)) cout<<"A";
	else cout<<"B";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m, f, r;
    
    while(1){
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1)
            break;
        else if(m == -1 || f == -1)
            cout << "F" << endl;
        else if(m+f >= 80)
            cout << "A" << endl;
        else if(m+f >= 65)
            cout << "B" << endl;
        else if(m+f >= 50 || (m+f >= 30 && r >= 50))
            cout << "C" << endl;
        else if(m+f >= 30)
            cout << "D" << endl;
        else
            cout << "F" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

const int INFTY=1000;
int n,W;
vector<int> w(INFTY),v(INFTY);
int rec(int n,int W){
    vector<vector<int>> dp(n+1,vector<int>(W+1,0));
    rep(i,n) rep(j,W+1){
        if(j<w[i]) dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
    return dp[n][W];
}
int main() {
    cin >> n >> W;
    rep(i,n) cin >> v[i] >> w[i];
	cout << rec(n,W) << endl;
}





Measured memory_bytes: 6844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

	string ans;

	if (N == 0) {
		ans = "0";
	}
	else {
		for (long long m = -2; N != 0; m *= -2) {
			if (N % m == 0) {
				ans += '0';

			}
			else {
				ans += '1';
				N += m / 2;
			}
		}
	}
	reverse(ans.begin(), ans.end());

	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var H = HW[0];
            var W = HW[1];
            var input = new List<string>();
            for(var i =0;i<H;i++)
            {
                var t = Console.ReadLine();
                input.Add(t.Replace(t,"#"+t+"#"));
            }
            var tmp = Enumerable.Range(0, W + 2).Select(x => '#').ToArray();
            Console.WriteLine(tmp);
            input.ForEach(x => Console.WriteLine(x));
            Console.WriteLine(tmp);
        }
    }

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

int main() {
  string S;
  cin >> S;
  bool ok = true;
  for (int i = 0; i < S.size(); ++i) {
    if (i % 2 == 0) {
      if (S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D') {
        continue;
      }
    } else {
      if (S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D') {
        continue;
      }
    }
    ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string s, t;
int main() {
    while (cin >> s >> t) {
        bool ok = false;
        for (int i = 0; i < s.size(); ++i) {
            string ss = s.substr(1) + s[0];
            if (ss == t) ok = true;
            s = ss;
        }
        if (ok) puts("Yes");
        else puts("No");
    }
}





























Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    
    for(int i = a; i <= b; i++){
        int s = i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i / 1000 % 10;
        if( s == t && u ==v) cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
	istringstream is(s);
	T res;
	is >> res;
	return res;
}
template <class T> string to_s(const T &a) {
	ostringstream os;
	os << a;
	return os.str();
}

vi E[1100];
vi C[1100];
long long N;
long long M;
typedef pair<int, int> pp;
bool E_chk[2000][2000];

vector<long long> b(11000);
vector<long long> c(11000);
vector<long long> a(11000);

void djk(int st, int go) {
	int cost[120];
	fill(cost, cost + 120, 1e8);

	cost[st] = 0;
	deque<pp> que;
	que.push_back(pp(0, st));
	vi cmd[1100];
	cmd[st].push_back(st);

	while (true) {
		sort(ALL(que));
		pp pos = que.front();
		que.pop_front();
		bool stop = false;
		if (pos.second == go) {
			stop = true;
			break;
		};
		REP(i, E[pos.second].size()) {
			int to = E[pos.second][i];
			int cc = C[pos.second][i];
			if (cost[pos.second] + cc >= cost[to])
				continue;
			cost[to] = cost[pos.second] + cc;
			que.push_back(pp(cost[to], to));
			cmd[to] = cmd[pos.second];
			cmd[to].push_back(to);
		}
		if (stop)
			break;
	}

	FOR(i, 1, cmd[go].size()) {
		E_chk[cmd[go][i - 1]][cmd[go][i]] = true;
		E_chk[cmd[go][i]][cmd[go][i - 1]] = true;
	}
}

void solve() {
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			if (i == j)
				continue;
			djk(i, j);
		}
	}

	ll ans = 0;
	REP(i, M) {
		int s = a[i];
		int e = b[i];
		if (!E_chk[s][e])
			ans++;
	}

	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	cin >> M;

	for (int i = 0; i <= M - 1; i++) {
		cin >> a[i];
		a[i]--;
		cin >> b[i];
		b[i]--;
		cin >> c[i];

		E[a[i]].push_back(b[i]);
		C[a[i]].push_back(c[i]);

		E[b[i]].push_back(a[i]);
		C[b[i]].push_back(c[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 896
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"


using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)


//2

int main(void) {
	int n = 0, x = 0;
	cin >> n >> x;
	int minM = 999999;
	int cost = 0;
	rep(0, n) {
		int m = 0;
		cin >> m;
		minM = min(minM, m);
		cost += m;
	}
	cout << n + (x - cost) / minM << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<stdio.h>
#include<string.h>
#include<set>
#define INF 99999999

using namespace std;

typedef pair<int,int> P;
typedef queue<P> Q;


int H,W,N;
char cmap[1200][1200];
int sx,sy;
int kotae;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int d[1200][1200];

void bfs(int x,int y,int a){
	for(int i=0;i<1200;i++){
		for(int j=0;j<1200;j++){
			d[j][i] = INF;
		}
	}
	d[x][y] = 0;
	Q q;
	q.push(P(x,y));
	while(!q.empty()){
		P p = q.front();q.pop();
		for(int i = 0;i<4;i++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(nx<0 || nx>=W || ny<0 || ny>=H)continue;
			if(cmap[nx][ny] == 'X')continue;
//			printf("d[%d][%d]=%d\n",nx,ny,d[nx][ny]);
//			printf("cmap[%d][%d]=%c\n",nx,ny,cmap[nx][ny]);
//			printf("a=%d\n",a);
			if(cmap[nx][ny] == a+'0'){
//				printf("a\n");
				d[nx][ny] = d[p.first][p.second]+1;
				kotae += d[nx][ny];
//				printf("kotae=%d\n",kotae);
				sx = nx;sy = ny;
				return;
			}
			if(d[nx][ny] == INF){
				d[nx][ny] = d[p.first][p.second]+1;
				q.push(P(nx,ny));
			}
		}
	}
}

int main(){
	cin >> H >> W >> N;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> cmap[j][i];
			if(cmap[j][i] == 'S'){
				sx = j;sy = i;
			}				
		}
	}
	for(int i=0;i<N;i++){
		bfs(sx,sy,i+1);
	}
	cout << kotae << endl;
	return 0;
}
		

Measured memory_bytes: 9836
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  if((A+B)%2 == 1){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (A+B)/2 << endl;
  }
  return 0;
}

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

int main(){
  int n,r,ans;cin>>n>>r;
  if(n>=10) ans=r;
  else ans=r+100*(10-n);
  
  cout<<ans;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
counter = 0
for i in range(n):
    x -= a[i]
    if x == 0 and i == 0:
        counter +=1
    elif x > 0 and 0 <= i <= n-2:
        counter +=1
    elif x == 0 and i == n-1:
        counter +=1
print(counter)

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

#define ll long long int
#define pb push_back


int main(){
ll h,a;
  cin>>h>>a;
  ll val=h/a;
  
  if(val*a==h)
    cout<<val<<endl;
  
  else
    cout<<val+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
   string S;
   cin>>S;
   vector<string> as;
   as.push_back("dream");
   as.push_back("dreamer");
   as.push_back("erase");
   as.push_back("eraser");

   ll tou[100500]={0};
   ll sz = S.size();

   S+= "aaaaaaaaaaaaaaaaaaaaaaaaaaa";
   tou[0]=1;
ll tmp,tmp1,tmp2,tmp3;
    for(ll i=0;i<sz;+i++){
      if(tou[i]==1){
      for(ll j=0;j<as.size();j++){
        tmp2 = as[j].size();
          for(ll t=0;t<tmp2;t++){
            if(S[i+t]!=as[j][t])
            break;
            if(t==tmp2-1){
              tou[i+tmp2]=1;
            }
          }
       
        }
      }
    }
   

   if(tou[sz]==1){
     cout<<"YES"<<endl;
   }
   else{
     cout<<"NO"<<endl;
   }

}

Measured memory_bytes: 1280
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  
  int N, a;
  vector<int> L;

  cin >> N;
  for(int i=0;i<N;i++){
  	cin >> a;
  	L.push_back(a);
  }
  sort(L.begin(), L.end());

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

  if(L[N-1]<sum){
  	cout << "Yes" <<endl;
  }else{
  	cout << "No" <<endl;
  }
  

  return 0;
}

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

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))[::-1]
yaba = None
for i in range(N):
  if A[i]==B[i]:
    yaba = A[i]

if not yaba:
  print("Yes")
  print(*B)
  exit()

daijobu = []
for i in range(N):
  if A[i]!=yaba and B[i]!=yaba:
    daijobu.append(i)

for i in range(N):
  if A[i]==B[i]:
    if not daijobu:
      print("No")
      exit()
    else:
      p = daijobu.pop()
      B[i],B[p] = B[p],B[i]
      
print("Yes")
print(*B)

Measured memory_bytes: 126744
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int A,B,C,D; cin >> A >> B >> C >> D;
	cout << max(A*B,C*D) << endl;
	
}



Measured memory_bytes: 256
n=int(input())

a=[]

import sys

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


c=1
if a.count(0)>=1:
    print(0)
    sys.exit()

for k in range(n):

    c*=int(a[k])

    if c>10**18:
        print(-1)
        sys.exit()


print(c)


Measured memory_bytes: 21784
n=gets.to_i
s=gets.chomp
c=[0]
cc=0
0.upto(n-2) do |i|
  if s[i]=="W"
    cc+=1
  end
  c[i+1]=cc
end
cc=0
(n-1).downto(1) do |i|
  if s[i]=="E"
    cc+=1
  end
  c[i-1]+=cc
end
puts c.min


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

using namespace std;

int main() {
    int n;
    cin>>n;
    
    long long a[n];
    
    for(int i=0;i<n;i++)
        cin>>a[i];
        
    
    long long sum=0;
    
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }

    cout<<sum;
}

Measured memory_bytes: 5128
#木の根を得る
def root(x):
    while par[x] >= 0:
        x = par[x]
    return x

#木の併合
def unite(x,y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if rx > ry:
            rx,ry = ry,rx
        par[rx] += par[ry]
        par[ry] = rx

#2つのデータx,yが属する木が同じならtrueを返す
def same(x,y):
    rx = root(x)
    ry = root(y)
    return rx == ry

#属する木のサイズ
def size(x):
    return -par[root(x)]

#ABC157D
N,M,K = map(int,input().split())
par = [-1]*N
g = [[] for _ in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    A,B = A-1,B-1
    unite(A,B)
    g[A].append(B)
    g[B].append(A)

for i in range(K):
    C,D = map(int,input().split())
    C,D = C-1,D-1
    if same(C,D):
        g[C].append(D)
        g[D].append(C)

for i in range(N):
    print(size(i)-len(g[i])-1,end=' ')

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

using namespace std;

vector<int> counts(30, 0);

void Add(int a) {
  for (int i = 0; i < 20; i++) {
    if (a & (1 << i)) {
      counts[i]++;
    }
  }
}

void Remove(int a) {
  for (int i = 0; i < 20; i++) {
    if (a & (1 << i)) {
      counts[i]--;
    }
  }
}

bool IsValid() {
  for (int i = 0; i < 20; i++) {
    if (counts[i] >= 2) return false;
  }
  return true;
}

int64_t Count(int64_t left, int64_t right) {
  int64_t k = right - left + 1;
  return (k + 1) * k / 2;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int a = 0, b = 0;
  int lastB = -1;
  Add(A[0]);

  int64_t result = 0;
  while (true) {
    while (b < N && IsValid()) {
      b++;
      Add(A[b]);
    }

    result += Count(a, b - 1);
    if (a <= lastB - 1) {
      result -= Count(a, lastB - 1);
    }
    lastB = b;

    while (!IsValid() && a < b) {
      Remove(A[a]);
      a++;
    }

    if (b == N) break;
  }
  cout << result << endl;

  return 0;
}


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


int main() {
    int X, N;
    cin >> X >> N;
    vector<int> vec(105);
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        vec.at(a.at(i)) = 1;
    }

    int p = 0;
    for (int i = 101; i >= 0; i--) {
        if (abs(X-p) >= abs(X-i) && vec.at(i) == 0) p = i;
    }
    cout << p << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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 x,k,d;cin>>x>>k>>d;
	ll y = abs(x);
	ll cnt = (y + d - 1) / d;
	if (cnt <= k && cnt % 2 == k % 2){
		cout << abs(abs(x) - d * cnt) << endl;
	}
	else if(cnt<= k){
		cout << min(abs(abs(x) - d * (cnt + 1)),abs(abs(x) - d * (cnt - 1))) << endl;
	}
	else{
		cout << min(abs(x + k*d),abs(x - k* d)) << endl;
	}	
	return 0;
}

Measured memory_bytes: 3624
n=int(input())
a=list(map(int,input().split()))
accuml=[0]*n
accumr=[0]*n
accuml[0]=a[0]
accumr[0]=a[n-1]
for i in range(n-1):
    accuml[i+1]+=a[i+1]+accuml[i]
    accumr[i+1]+=a[n-i-2]+accumr[i]
ll=0
rr=n-3
ans=10**18
for i in range(1,n-2):
    sl=accuml[i]
    sr=accumr[n-2-i]
    while abs(accuml[ll+1]-sl/2)<abs(accuml[ll]-sl/2):
        ll+=1
    while abs(accumr[rr-1]-sr/2)<abs(accumr[rr]-sr/2):
        rr-=1
    maxi=max(sl-accuml[ll],accuml[ll],sr-accumr[rr],accumr[rr])
    mini=min(sl-accuml[ll],accuml[ll],sr-accumr[rr],accumr[rr])
    ans=min(ans,maxi-mini)
print(ans)

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

int main() {
    ll x, y;
    cin >> x >> y;
    ll a = abs(x), b = abs(y);
    ll ans = 0;
    if(a < b) {
        if(x < 0) ans++;
        ans += b-a;
        if(y < 0) ans++;
    }
    else if(a==b){
        if(x*y<0) ans++;
    }
    else{
        if(x > 0) ans++;
        ans+=abs(b-a);
        if(y > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3900
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  string s;
  cin >> n >> s;
  stack<char> t;
  rep(i, n) {
    if (s[i] == '(') {
      t.push('(');
      continue;
    }
    if (t.size() && t.top() == '(') {
      t.pop();
      continue;
    }
    t.push(')');
  }
  for (; t.size() && t.top() == '('; t.pop()) s += ")";
  for (; t.size(); t.pop()) s = "(" + s;
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll n,sum=0;
    cin>>n;
    ll a[n+1],b[n];
    for(ll i=0;i<n+1;i++){
        a[i]=0;
    }
    for(ll i=0;i<n;i++){
        ll temp;
        cin>>temp;
        b[i]=temp;
        a[temp]+=1;
        //sum+=(a[temp]*(a[temp]-1))/2 - ((a[temp]-1)*(a[temp]-2))/2 ;
    }
    for(ll i=1;i<=n;i++){
        sum+=(a[i]*(a[i]-1))/2;
    }
    for(ll i=0;i<n;i++){
        if(a[b[i]]){
            cout<<sum - (a[b[i]]*(a[b[i]]-1))/2 + ((a[b[i]]-1)*(a[b[i]]-2))/2 <<endl;
        }
        
    }
    
    
    
}


Measured memory_bytes: 5760
x = int(input())

if 400 <= x and x < 600:
    print(8)
elif 600 <= x and x <800:
    print(7)
elif 800 <= x and x <1000:
    print(6)
elif 1000 <= x and x <1200:
    print(5)
elif 1200 <= x and x <1400:
    print(4)
elif 1400 <= x and x <1600:
    print(3)
elif 1600 <= x and x <1800:
    print(2)
elif 1800 <= x and x <2000:
    print(1)




Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int x; cin >> x;
        if(x >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(t) for t in input().split()]
a.insert(0,0)
a.append(0)
s = 0
for i in range(1,n+2):
  s += abs(a[i-1] - a[i])
for i in range(1,n+1):
  if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:
    print(s)
  else:
    res = s
    res -= abs(a[i-1] - a[i])
    res -= abs(a[i] - a[i+1])
    res += abs(a[i-1] - a[i+1])
    print(res)

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

int main() {
    ll A, B, N;
    cin >> A >> B >> N;

    ll num = min(B - 1, N);
    ll res = (A * num / B) - A * (num / B);
    cout << res << endl;
}

Measured memory_bytes: 3592