akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, ans = 0;
  cin >> N;
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.rbegin(), a.rend());
  if (N % 2 == 0) {
    for (int i = 0; i < N / 2; i++) {
      ans += a[i * 2] - a[i * 2 + 1];
    }
  }
  else {
    for (int i = 0; i < N / 2; i++) {
      ans += a[i * 2] - a[i * 2 + 1];
    }
    ans += a[N - 1];
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Map<Integer, List<Character>> map = new HashMap<Integer, List<Character>>();
		List<Character> list = new ArrayList<Character>();
		list.add('R');
		list.add('U');
		list.add('D');
		map.put(0, list);
		list = new ArrayList<Character>();
		list.add('L');
		list.add('U');
		list.add('D');
		map.put(1, list);

		for (int i = 0; i < s.length; i++) {
			int key = i % 2;
			if (!map.get(key).contains(s[i])) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,x;
    int c,h;
    scanf("%d %d",&a,&b);
    c=b-a;
    h=(c*c+c)/2;
    x=h-b;
    
    printf("%d",x);
    
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main() {
    int m, k;
    scanf("%d %d", &m, &k);

    if (m == 0) {
        if(k == 0) {
            puts("0 0");
        } else {
            puts("-1");
        }

        return 0;
    }

    if (m == 1) {
        if(k == 0) {
            puts("0 0 1 1");
        } else {
            puts("-1");
        }

        return 0;
    }

    int n = (1<<m);
    if(k >= n) {
        puts("-1");
        return 0;
    }

    for(int i = 0; i < n; i++) {
        if(i != k) printf("%d ", i);
    }

    printf("%d ", k);

    for(int i = n - 1; i >= 0; i--) {
        if(i != k) printf("%d ", i);
    }

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N, M;

    scanf("%d%d", &N, &M);

    int a[N], b[N];

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

    int c[M], d[M];

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

    for(int i = 0; i < N; i++){
        int min = 1000000000;
        int minj = 0;
        for(int j = 0; j < M; j++){
            if(abs(c[j]-a[i]) + abs(d[j]-b[i]) < min){
                min = abs(c[j]-a[i]) + abs(d[j]-b[i]);
                minj = j;
            }
        }
        printf("%d\n", minj+1);
    }

    return 0;
}

Measured memory_bytes: 1672
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

ll read() {
	ll X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,lt,lim; char s[N];
int sum[N][26];
ll ans[26],len[100],cnt[100][26];

int nxt[N];
void getnext() {
	for (int i=2,j=0;i<=n;++i) {
		while (j&&s[j+1]!=s[i]) j=nxt[j];
		if (s[j+1]==s[i]) ++j;
		nxt[i]=j;
	}
}

void calc_sp(ll p,int w) {
	if (!p) return;
	for (int i=0;i<26;++i) ans[i]+=w*(p/lt)*sum[lt][i];
	for (int i=0;i<26;++i) ans[i]+=w*sum[p%lt][i];
}

void calc(ll p,int w) {
	if (!p) return;
	for (int i=lim;i;--i) {
		if (p<len[i]) continue;
		p-=len[i];
		for (int j=0;j<26;++j) ans[j]+=w*cnt[i][j];
	}
	for (int i=0;i<26;++i) ans[i]+=w*sum[p][i];
}

int main() {
	scanf("%s",s+1); n=strlen(s+1)>>1;
	ll l=read(),r=read();
	getnext(); lt=n-nxt[n];
	for (int i=1;i<=n;++i) {
		memcpy(sum[i],sum[i-1],sizeof(sum[i]));
		++sum[i][s[i]-'a'];
	}
	if (n%lt==0) calc_sp(r,1),calc_sp(l-1,-1);
	else {
		len[1]=n,len[2]=n+lt;
		for (int i=0;i<26;++i)
			cnt[1][i]=sum[n][i],cnt[2][i]=sum[n][i]+sum[lt][i];
		for (int i=3;;++i) {
			len[i]=len[i-1]+len[i-2];
			for (int j=0;j<26;++j) cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
			if (len[i]>1e18) { lim=i; break; }
		}
		calc(r,1),calc(l-1,-1);
	}
	for (int i=0;i<26;++i) printf("%lld ",ans[i]); puts("");
	return 0;
}

Measured memory_bytes: 14452
// C - 2D Plane 2N Points
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vvi AB(N, vi(2));
	vvi CD(N, vi(2));
	rep(i, N) cin>>AB[i][0]>>AB[i][1];
	rep(i, N) cin>>CD[i][0]>>CD[i][1];

	sort(all(CD));
	sort(allr(AB), [](vi a, vi b){ return a[1] < b[1]; });

	vvi dim_b(N, vi());
	rep(b, N)
		rep(r, N)
			if(AB[r][0] < CD[b][0] && AB[r][1] < CD[b][1])
				dim_b[b].push_back(r);

	vi vis_r(N, false);
	rep(b, N){
		// int max_ry, max_r = max_ry = -1;
		for(auto r:dim_b[b]){
			if(!vis_r[r]){ vis_r[r] = true; break; }
			// if(vis_r[r]) continue;
			// if(max_ry < AB[r][1]){
			// 	max_ry = AB[r][1];
			// 	max_r = r;
			// }
		}
		// if(max_r >= 0) vis_r[max_r] = true;
	}

	int ans = 0;
	rep(i, N) ans += vis_r[i];
	cout<< ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, Y;
    cin >> N >> Y;
    int ax,ay,az;
    for (int x = 0; x <= N; x++){
        for (int y = 0; y <= N; y++){
            if (N-x-y >= 0){
                if (x*1000+y*5000+(N-x-y)*10000 == Y){
                    ax = x;
                    ay = y;
                    az = N-x-y;
                    cout << az << " " << ay << " " << ax << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lv = rli()
    lv.sort()
    ans = lv[0]
    for i in range(1, n):
        ans = (lv[i]+ans)/2
    print(ans)



if __name__ == '__main__':
    main()


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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,A,B;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N>>A>>B;
    if(A>B){
        cout<<0<<endl;
        return 0;
    }
    if(N==1){
        if(A==B)cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    int x=B-A;
    cout<<(x*(N-2))+1<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

Measured memory_bytes: 256
let is_prime n = match n with
    2|3|5|7 -> 1
    | n when n mod 2 = 0 -> 0
    | n ->
       let rec loop i =
         if i*i > n then 1
         else if n mod i = 0 then 0
         else loop (i+2);
       in loop 3

let () =
  let n = read_int () in
  let rec read ct = function
      0 -> ct
    | i ->
       let m = read_int () in
       read ((is_prime m)+ct) (i-1)
  in
  Printf.printf "%d\n" (read 0 n)

Measured memory_bytes: 3116
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0,ma=0;
  for(int i=0;i<3;i++){
    if(s[i] == 'R'){
      ans++;
      ma=max(ans,ma);
    }else if(ans>0){
      ma=max(ans,ma);
      ans=0;
      
    }
  }
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#define min(x, y) (x < y ? x : y)

int main()
{
  int N;
  scanf("%d",&N);

  int count =  0 ;
  int res = 0 ;

  for (int i = 1 ; i<=N;i+=2)
  {
    for (int j = 1 ; j<=N;j++) 
    {
      if (i%j == 0 )count++;
    }
    if (count == 8)res++;
    count = 0 ;
  }
  
  printf("%d",res);

  return 0;
}


Measured memory_bytes: 128
list = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    list[b-1][f-1][r-1] += v
 
for k in range(4):
    for j in range(3):
        for i in range(10):
            print ("", end=" ")
            print (list[k][j][i], end = "")
        print("")
    if k != 3:
        print("####################")


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

typedef long long ll;
const int N = 200010;

int n;
vector<int> G[N], v[2];
int p[N];

void dfs(int u, int fa, bool f) {
	v[f].push_back(u);
	for(auto &i : G[u]) if(i != fa) dfs(i, u, f ^ 1);
} 

int main() {
	scanf("%d", &n);
	for(int u, v, i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		G[v].push_back(u);
		G[u].push_back(v);
	}
	dfs(1, 1, 1);
	if(v[0].size() > v[1].size()) swap(v[0], v[1]);
	int x = n / 3;
	if((int)v[0].size() <= x) {
		int now = 3, T = 0;
		for(auto &i : v[0]) p[i] = now, now += 3;
		for(auto &i : v[1]) {
			if(now > n) now = ++T;
			p[i] = now;
			now += 3;
		}
	} else {
		int now = 1;
		for(auto &i : v[0]) {
			p[i] = now;
			now += 3;
			if(now > n) now = 3;
		}
		int T = now;
		now = 2;
		for(auto &i : v[1]) {
			p[i] = now;
			now += 3;
			if(now > n) now = T;
		}
	}
	for(int i = 1; i <= n; ++i) printf("%d ", p[i]);
	return 0;
}

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

if x <= 3:
  print(x)
  exit()

ans = 0
for i in range(2, int(x**0.5)+1):
  s = 0
  t = 1
  while i**t <= x:
    s = i**t
    t += 1
  ans = max(ans, s)
print(ans)


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int MAX = 1 << 20;
bool ok[MAX];
string s;
int n;

void dfs(int i, int state, int used) {
    if (i == n) {
        ok[state] = true;
        return;
    }

    if (s[i] == 'a' || ((used >> (s[i] - 'a')) & 1))
    {
        dfs(i + 1, state, used | (1 << (s[i] - 'a')));
    }
    if (s[i] != 'z' && !((used >> (s[i] - 'a' + 1)) & 1))
    {
        dfs(i + 1, state | (1 << i), used | (1 << (s[i] - 'a' + 1)));
    }
}

string f(int state) {
    string t;
    rep(i, n) {
        t += s[i] + ((state >> i) & 1);
    }
    return t;
}

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

    while (cin >> s, s != "#") {
        n = s.size();

        rep(i, 1 << n) {
            ok[i] = false;
        }

        dfs(0, 0, 0);

        int cnt = 0;
        vector<int> v;
        rep(i, 1 << n) {
            if (ok[i]) {
                cnt++;
                v.emplace_back(i);
            }
        }
        cout << cnt << endl;

        vector<string> vs;
        rep(i, v.size()) {
            vs.emplace_back(f(v[i]));
        }

        sort(all(vs));

        if (cnt <= 10) {
            rep(i, vs.size()) {
                cout << vs[i] << endl;
            }
        } else {
            rep(i, 5) {
                cout << vs[i] << endl;
            }
            rep2(i, (int)vs.size() - 5, vs.size()) {
                cout << vs[i] << endl;
            }
        }
    }

}

Measured memory_bytes: 5616
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
bool is(string &s)
{
    string t = s;
    reverse(all(t));
    return (s==t);
}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       map<int,int> mp;
       int arr[n];
       rep(i,0,n){
       cin>>arr[i];
       mp[arr[i]]++;
       }
       int ans = 0;
       for(int i=0;i<200007;++i)
       {
           int x = mp[i];
           ans+= ((x)*(x-1))/2;
       }
       //cout<<ans<<el;
       rep(i,0,n)
       {
           int x = ans;
           if(mp[arr[i]]>=2)
           {
              x+=-mp[arr[i]]+1;
           }
           cout<<x<<el;
       }


    }
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        if(b%2==0)a[i]=2;
        else a[i]=1;
    }
    long long ans=1;
    for(int i=0;i<n;i++)ans*=3;
    long long num=1;
    for(int i=0;i<n;i++)num*=a[i];
    ans-=num;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#標準入力
s = [int(x) for x in input().split()]

hp = s[0]
attack = s[1]


#割り算で攻撃回数を取得
acount = hp // attack

#余りが出た場合は攻撃回数+1回
if hp % attack == 0:
    print(acount)
else:
    print(acount + 1)
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, x;
    std::string op;
    while(1){
        cin >> a >> op >> b;
        if(op == "+"){
            x = a + b;
        }
        if(op == "-"){
            x = a - b;
        }
        if(op ==  "*"){
            x = a * b;
        }
        if(op ==  "/"){
            x = a / b;
        }
        if(op ==  "?"){
            return 0;
        }
        cout << x << endl;
    }
}


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

int main(void){
	int x,y,d,a,b;
	cin>>x>>y;
	if(y>x){
		b=y;
		y=x;
		x=b;
	}
	if(x==y){
		cout<<x<<endl;
		return 0;
	}
	a=x%y;
	for(d=a;;d--){
		if(y%d==0&&a%d==0){
			cout<<d<<endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
         Scanner sc = new Scanner (System.in);
         while (true){
         int h = sc.nextInt();
         int w = sc.nextInt();
         if(h==0 && w==0){
             break;
         }

         for(int i=0;i<h;i++){
             for(int j=0; j<w;j++){
                System.out.print((i+j)%2==0 ? '#' : '.');
            }
             System.out.println();
         }
        System.out.print("\n");
        }
        sc.close();
    }
}
    


Measured memory_bytes: 37056
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

int main()
{
    int m1, d1, m2, d2;
  
  	cin >> m1 >> d1 >> m2 >> d2;
  
  	if(m1 != m2)
      cout << '1';
  	else
      cout << '0';
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {

        int A = in.nextInt();
        int B = in.nextInt();
        int Q = in.nextInt();
        long s[] = new long[A];
        long t[] = new long[B];
        long x[] = new long[Q];
        for (int i = 0; i < A; i++) {
            s[i] = in.nextLong();
        }
        for (int i = 0; i < B; i++) {
            t[i] = in.nextLong();
        }
        for (int i = 0; i < Q; i++) {
            x[i] = in.nextLong();
        }

        for (int i = 0; i < Q; i++) {
            long ans = 1_000_000_000_000L;
            int jm = binary_search(x[i], 0, s);
            int ju = binary_search(x[i], 1, s);
            int tm = binary_search(x[i], 0, t);
            int tu = binary_search(x[i], 1, t);

            if (jm != 1_111_111_111 && tm != 1_111_111_111) {
                ans = Math.min(ans, Math.max(s[jm]-x[i], t[tm]-x[i]));
            }
            if (ju != 1_111_111_111 && tu != 1_111_111_111) {
                ans = Math.min(ans, Math.max(x[i]-s[ju], x[i]-t[tu]));
            }
            if (jm != 1_111_111_111 && tu != 1_111_111_111) {
                ans = Math.min(ans, 2 * (s[jm] - x[i]) + (x[i] - t[tu]));
                ans = Math.min(ans, (s[jm] - x[i]) + 2 * (x[i] - t[tu]));
            }
            if (ju != 1_111_111_111 && tm != 1_111_111_111) {
                ans = Math.min(ans, 2 * (x[i]-s[ju]) + (t[tm] - x[i]));
                ans = Math.min(ans, (x[i]-s[ju]) + 2 * (t[tm] - x[i]));
            }
            out.println(ans);
        }
    }

boolean isOK(int index, long key, int ver, long[] a) {
        if (a[index] >= key && ver == 0) return true;
        if (a[index] <= key && ver == 1) return true;
        else return false;
    }

int binary_search(long key, int ver, long[] a) {
        int ng = -1;
        int ok = (int)a.length - 1;
        if(ver == 1){
            ok = 0; ng = (int)a.length;
        }
        if(!isOK(ok, key, ver, a)){
            return 1_111_111_111;
        }
        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (isOK(mid, key, ver, a)) ok = mid;
            else ng = mid;
        }
        return ok;
    }

}
}



Measured memory_bytes: 98112
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;

    vector<bool> v(3, true);
    v[A - 1] = false;
    v[B - 1] = false;

    for (int i = 0; i < 3; i++)
        if (v[i] == true)
            cout << i + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [0] * (N+1)

for i in range(N):
  if A[i] > B[i]:
    C[i] = B[i]
  elif A[i] <= B[i] and A[i]+A[i+1] > B[i]:
    C[i] = B[i]
    A[i+1] = A[i]+A[i+1] - B[i]
  else:
    C[i] = A[i]+A[i+1]
    A[i+1] = 0
    
print(sum(C))


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

int main(){
  int n,r=0,b=0;
  cin>>n;
  for(int i=0; i<n; i++){
    char c;
    cin>>c;
    if(c=='R')r++;
    else b++;
  }

  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BinomialCoefficients solver = new BinomialCoefficients();
        solver.solve(1, in, out);
        out.close();
    }

    static class BinomialCoefficients {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            Arrays.sort(a);
            long ans = a[n - 1];

            if (ans % 2 == 0) {
                long mid = ans / 2;
                long min = Long.MAX_VALUE;
                long ans2 = 0;
                for (int i = 0; i < n; i++) {
                    if (a[i] == ans) {
                        continue;
                    }
                    long tmp = Math.abs(mid - a[i]);
                    if (tmp < min) {
                        min = tmp;
                        ans2 = a[i];
                    }
                }
                out.print(ans + " " + ans2);
            } else {
                long mid1 = ans / 2;
                long mid2 = mid1 + 1;
                long min = Long.MAX_VALUE;
                long ans2 = 0;
                for (int i = 0; i < n; i++) {
                    if (a[i] == ans) {
                        continue;
                    }
                    long tmp = Math.min(
                            Math.abs(mid1 - a[i]),
                            Math.abs(mid2 - a[i])
                    );
                    if (tmp < min) {
                        min = tmp;
                        ans2 = a[i];
                    }
                }
                out.print(ans + " " + ans2);

            }
        }

    }
}



Measured memory_bytes: 60896
#include<stdio.h>
int main(void)
{
    int n,l[1000],r[1000],i,s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d%d",&l[i],&r[i]);
    for(i=0;i<n;i++)
        s+=r[i]-l[i]+1;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int N;
  cin >> N;
  ll x;
  cin >> x;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  ll ans = 0;
  repp(i, 1, N - 1) {
    ll sum = a[i] + a[i - 1];
    if (sum <= x)
      continue;

    ll eat = min(a[i], sum - x);
    ans += eat;
    a[i] -= eat;
  }

  if (a[0] + a[1] > x) {
    ans += a[0] + a[1] - x;
  }

  cout << ans << endl;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int a; cin >> a;
  int b; cin >> b;
  int c; cin >> c;
  
  cout << min(b / a , c) << endl; 

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

typedef long long ll;

const int maxn = 200005;
ll mod = 1e9+7;
vector<int>g[maxn];

ll pot( ll b, ll e ){
    if( !e )return 1;
    if( e % 2 == 0 ) return pot( (b*b)%mod, e/2 );
    return (b%mod * pot(b, e-1))%mod;
}

ll f[maxn], ifact[maxn], dp[maxn], prodsz[maxn], proddp[maxn], sz[maxn];
ll solve[maxn];

void dfs1( int nodo, int pad ){

    sz[nodo] = 1;
    ll pdp = 1, pisz = 1;
    for( auto i : g[nodo] ){
        if( i == pad )continue;
        dfs1(i, nodo);
        pdp = (pdp * dp[i])%mod;
        pisz = (pisz * ifact[sz[i]])%mod;
        sz[nodo] += sz[i];
    }

    dp[nodo] = ((f[ sz[nodo]-1 ] * pdp) % mod * pisz)%mod;
    prodsz[nodo] = pisz;
    proddp[nodo] = pdp;
}

void dfs2( int nodo, int pad ){

    for( auto i : g[nodo] ){
        if( i == pad )continue;
        proddp[nodo] = (proddp[nodo] * pot( dp[i], mod-2 ))%mod;
        prodsz[nodo] = (prodsz[nodo] * f[ sz[i] ])%mod;
        sz[nodo] -= sz[i];
        dp[nodo] = ((f[ sz[nodo]-1 ] * proddp[nodo]) % mod * prodsz[nodo])%mod;

        sz[i] += sz[nodo];
        proddp[i] = (proddp[i] * dp[nodo])%mod;
        prodsz[i] = (prodsz[i] * ifact[sz[nodo]])%mod;
        dp[i] = ((f[ sz[i]-1 ] * proddp[i]) % mod * prodsz[i])%mod;
        solve[i] = dp[i];

        dfs2(i, nodo);

        proddp[i] = (proddp[i] * pot(dp[nodo], mod-2) )%mod;
        prodsz[i] = (prodsz[i] * f[sz[nodo]])%mod;
        sz[i] -= sz[nodo];
        dp[i] = ((f[ sz[i]-1 ] * proddp[i]) % mod * prodsz[i])%mod;


        proddp[nodo] = (proddp[nodo] * dp[i])%mod;
        prodsz[nodo] = (prodsz[nodo] * ifact[ sz[i] ])%mod;
        sz[nodo] += sz[i];
        dp[nodo] = ((f[ sz[nodo]-1 ] * proddp[nodo]) % mod * prodsz[nodo])%mod;

    }
}


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int n;
    cin >> n;

    int a, b;
    for( int i = 1; i < n; i++ ){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }


    f[0] = 1;
    for( ll i = 1; i <= n; i++ )
        f[i] = (i * f[i-1])%mod;

    ifact[n] = pot(f[n], mod-2);
    for( ll i = n-1; i >= 0; i-- )
        ifact[i] = (ifact[i+1]*(i+1))%mod;


    dfs1(1, -1);
    solve[1] = dp[1];
    dfs2(1, -1);

    for( int i = 1; i <= n; i++ )
        cout << solve[i] << "\n";

    return 0;
}


Measured memory_bytes: 24820
#include <bits/stdc++.h>
using namespace std;
 
	int main() {
		int a,b;
		int c=0;
		cin>>a>>b;
		for(int i=0;i>a;i--)
           c++;
		if(a<=0&&0<=b)
		cout<<"Zero";
	else if(b<0&&(b-a+1)%2==1)
		cout<<"Negative";
	else
		cout<<"Positive";
	}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  string S; cin>>S;
  int ans = 1000000;
  for(int i = 2; i < S.length(); i++) {
    int a = S[i-2] - '0';
    int b = S[i-1] - '0';
    int	c = S[i-0] - '0';
    int v = a * 100 + b * 10 + c;
    ans = min(ans, abs(v - 753));
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i,n) {
    int h;
    cin >> h;
    if(h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
)

func answer(reader io.Reader, writer io.Writer) {
	var a, b int
	var s string
	var r string
	_, _ = fmt.Fscan(reader, &a)
	_, _ = fmt.Fscan(reader, &b)
	_, _ = fmt.Fscan(reader, &s)
	if b > 1 {
		r = s[:b-1]
	}
	r = r + strings.ToLower(string(s[b-1]))
	if b < len(s) {
		r = r + s[b:]
	}
	_, _ = fmt.Fprintf(writer, "%s", r)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2000;
int a[maxn+5],n,now;
int num[maxn*maxn+5],T;
bitset<maxn*maxn+maxn> S;
int main(){
	scanf("%d",&n),S[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&now);
		S|=S<<now;
	}
	for(int i=1;i<=maxn*maxn;i++) if(S[i]) num[++T]=i;
	printf("%d\n",num[(T+1)>>1]);
	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxS = 100 + 1; int k;
char nn[maxS];
string n;

lli memo[maxS][4][2];
lli solve(int i = 0, int kk = 0, bool onLimit = true)
{
  if (i == n.size()) return kk == k;
  if (kk > k) return 0;
  if (memo[i][kk][onLimit] != -1) return memo[i][kk][onLimit];

  lli ans = solve(i + 1, kk, onLimit && n[i] == '0');
  for (int d = 1; onLimit ? d <= n[i] - '0' : d <= 9; d ++)
    ans += solve(i + 1, kk + 1, onLimit && n[i] - '0' == d);

  return memo[i][kk][onLimit] = ans;
}

int main()
{
  while (scanf(" %s", nn) != EOF)
  {
    scanf("%d", &k);
    n = string(nn);

    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}

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

int main(){
 
  double A,B,C,D;
  cin>>A>>B>>C>>D;

  while(A>0 && C>0){
    C -= B;
    if(C<=0){
      cout<<"Yes"<<endl;
    }else{
      A -= D;
      if(A<=0){
        cout<<"No"<<endl;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3692
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		int ans = 0;

		while(true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?")) {
				break;
			}else if(op.equals("+")) {
				ans = a+b;
			}else if(op.equals("-")) {
				ans = a-b;
			}else if(op.equals("*")) {
				ans = a*b;
			}else if(op.equals("/")) {
				ans = a/b;
			}
			System.out.println(ans);
		}

		sc.close();
	}
}


Measured memory_bytes: 26156
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for(int i=0;i<n;i++){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();

			double a1 = 2*(x2 - x1);
			double b1 = 2*(y2 - y1);
			double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;

			double a2 = 2*(x3 -x1);
			double b2 = 2*(y3 - y1);
			double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;

			double x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
			double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);

			double r_2 = (x1 - x)*(x1 - x) + (y1 - y)*(y1 - y);
			double r = Math.sqrt(r_2);

			System.out.printf("%.3f %.3f %.3f\n",x,y,r);
		}
	}
}

Measured memory_bytes: 20796
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)

	f := 0
	for i := 0; i < n; i++ {
		f += scanInt(sc) - 1
	}

	fmt.Println(f)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


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

void trace(int A[], int N){
  for ( int i = 0; i < N; i++ ){
    if ( i > 0 ) cout << " ";
    cout << A[i];
  }
  cout << "\n";
}

void bubbleSort(int A[], int N){
  int v, i = 0, flag = 1, cnt = 0;

  while(flag){
    flag = 0;
    for ( int j = N-1; j > i; j-- ){
      if ( A[j-1] > A[j] ){
        v = A[j];
        A[j] = A[j-1];
        A[j-1] = v;
        cnt++;
        flag = 1;
      }
    }
    i++;
  }

  trace(A, N);
  cout << cnt << endl;
}

int main(){
  int N, A[100];

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

  bubbleSort(A, N);

  return 0;
}


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

int t[10000];
vector<P>E[10000];
int d[10000][3][201];

struct st {
	int u, c, i, a;
};
bool operator<(const st&a, const st&b) {
	return a.c > b.c;
}
int main() {
	int n, m, x; scanf("%d%d%d", &n, &m, &x);
	rep(i, n)scanf("%d", &t[i]);
	rep(i, m) {
		int a, b, d; scanf("%d%d%d", &a, &b, &d); a--; b--;
		E[a].push_back(P(d, b)); E[b].push_back(P(d, a));
	}
	priority_queue<st>que;
	memset(d, 0x3f, sizeof(d));
	d[0][0][0] = 0; que.push({ 0,0,0,0 });
	while (!que.empty()) {
		st s = que.top(); que.pop();
		if (d[s.u][s.i][s.a] != s.c)continue;
		for (P&v : E[s.u]) {
			int a = min(x, s.a + v.first), k = t[v.second];
			if (abs(s.i - t[v.second]) == 2) {
				if (a < x)continue;
			}
			if (k == 1)k = s.i;
			else a = 0;
			if (d[v.second][k][a] > s.c + v.first) {
				d[v.second][k][a] = s.c + v.first;
				que.push({ v.second, d[v.second][k][a],k,a });
			}
		}
	}
	int Min = INF;
	rep(i, x + 1) {
		Min = min(Min, d[n - 1][0][i]);
		Min = min(Min, d[n - 1][2][i]);
	}
	printf("%d\n", Min);
}

Measured memory_bytes: 27848
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=105;
int ans[MAXN],A,B,C,D;
bool check(int sum,int x)
{
	LL ls1=1LL*sum*x,ls2=sum;if(ls1>A||ls2>B)return false;
	ls1=A-ls1;ls2=B-ls2;
	ls2=(ls2+x-1)/x;return ls2<=ls1;
}
void print1(int l,int r,int x)
{
	for(int i=l;i<=r;i++)
	{
		int u=(i-1)%(x+1)+1;
		if(u<=x)putchar('A');else putchar('B');
	}
}
void print2(int l,int r,int x)
{
	for(int i=l;i<=r;i++)
	{
		int u=(A+B-i+1-1)%(x+1)+1;
		if(u<=x)putchar('B');else putchar('A');
	}
}
int main()
{
	int Q=read();while(Q--)
	{
		A=read();B=read();C=read();D=read();
		int len=(max(A,B)+min(A,B))/(min(A,B)+1);
		int l=0,r=max(A,B),num=0;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(check(mid,len))num=mid,l=mid+1;
			else r=mid-1;
		}
		int ps=num*(len+1),ls2=B-num,ls1=A-num*len;
		ls2=(ls2+len-1)/len;ls1-=ls2;
		int ps1=ps+ls1+1;
		if(D<=ps)print1(C,D,len);
		else if(ps1<C)print2(C,D,len);
		else
		{
			for(int i=C;i<=ps;i++)
			{
				int u=(i-1)%(len+1)+1;
				if(u<=len)putchar('A');else putchar('B');
			}
			for(int i=max(C,ps+1);i<=min(ps1,D);i++)putchar('A');
			for(int i=ps1+1;i<=D;i++)
			{
				int u=(A+B-i+1-1)%(len+1)+1;
				if(u<=len)putchar('B');else putchar('A');
			}
		}puts("");
	}
	return 0;
}


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


int main(){
    int B[105], A[105], n, m, c;
    cin >> n >> m >> c;
    for(int i = 0; i < m; i++)
        cin >> B[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            int k; cin >> k;
            sum += B[j]*k;
        }
        sum += c;
        if(sum > 0)
            ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import heapq
import bisect
import copy
# import math
def warshall_floyd(d, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i * N +j] = min(d[i * N +j], d[i * N + k] + d[k * N + j])
    return d

MOD = 10**9 + 7

def main():
    n = getN()
    nums = getlist()
    ans = 1
    bc, bv, bb = -1, -1, -1
    for num in nums:
        tmp = 0
        added = 0
        if num == bc + 1:
            tmp += 1
            if not added:
                bc += 1
                added = 1

        if num == bv + 1:
            tmp += 1
            if not added:
                bv += 1
                added = 1

        if num == bb + 1:
            tmp += 1
            if not added:
                bb += 1
                added = 1

        ans *= tmp
        ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()



Measured memory_bytes: 57200
#include <stdio.h>

int main(int argc, char *args[])
{
	char mojiretsu_in[1001];
	int sum;
	int i;

	while(1) {
		scanf("%s", mojiretsu_in);

		if( mojiretsu_in[0] == 0x30 ) {
			break;
		}

		sum=0;
		i=0;

		while( mojiretsu_in[i] != 0 ) {
			sum += mojiretsu_in[i] - '0';
			i++;
		}

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

	}


	return 0;

}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N + 1);
  int a;
  for(int i = 0; i < N; i++){
    cin >> a;
    data.at(a)++;
  }
  int flag = 1;
  if(N % 2 == 0){
    for(int i = 0; i < N / 2; i++){
      if(data.at(i * 2 + 1) != 2){
        flag = 0;
        break;
      }
    }
  } else {
    for(int i = 0; i < (N + 1) / 2; i++){
      if((data.at(i * 2) != 2 && i != 0) || (data.at(i * 2) != 1 && i == 0)){
        flag = 0;
        break;
      }
    }
  }
  long ans = 1;
  if(flag == 1){
    if(N % 2 == 0){
      for(int i = 0; i < N / 2; i++){
        ans *= 2;
        ans %= 1000000007;
      }
    } else {
      for(int i = 0; i < (N - 1) / 2; i++){
        ans *= 2;
        ans %= 1000000007;
      }
    }
  }
  if(flag == 0)cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
ary = []
3.times do
	ary << gets.chomp.split.map(&:to_i)
end

a = [0,0,0]
b = [0,0,0]
flag = nil

(ary[0].min+1).times do |n|
	a[0] = n
	b[0] = ary[0][0]-a[0]
	b[1] = ary[0][1]-a[0]
	b[2] = ary[0][2]-a[0]
	a[1] = ary[1][0]-b[0]
	a[2] = ary[2][0]-b[0]

	isCorrect = 0
	3.times do |na|
		3.times do |nb|
			if ary[na][nb] != a[na]+b[nb] then
				isCorrect = nil
			end
		end
	end
	if isCorrect then
		flag = 0
	end
end
print "#{flag ? "Yes" : "No"}\n"

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
vector<int> a,b,c,d;
int x,n,m,q;
void dfs(vector<int> p){
  if(p.size()==n+1){
    int s=0;
    for(int i=0;i<q;i++){
      if(p.at(b.at(i))-p.at(a.at(i))==c.at(i)){
        s+=d.at(i);
      }
    }
    x=max(x,s);
    return;
  }
  p.push_back(p.back());
  while(p.back() <=m){
    dfs(p);
    p.back()++;
  }
  return;
}

int main(){
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;i++){
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
  }
  dfs(vector<int>(1,1));
  cout<<x<<endl;
  
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MAXN = 1e5+200;
int main(){
    ll a[MAXN] = {0};
    ll n;
    cin>>n;
    for(ll i = 0; i < n; i++){
      cin>>a[i];
    }
    ll k = a[0];
    ll sum = 0;
    for(int i= 0; i < n; i++){
      if(i == n -1){
        if(a[i] >= k){
          k = a[i];
        }
        sum+=k;
      }else{
        if(a[i] >= k){
          k = a[i];
        }else{
          sum += k - a[i];
          k = a[i];
        }
      }

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d", &x);
	y = x % 100;
	z = (y + 4) / 5;
	z = 100 * z;
	z += y;
	if(z<=x)printf("1\n");
	else printf("0\n");


	


	return 0;
}


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

int main(){
  long long int a, b, r, tmp, x, y;
  cin >> a >> b;
  x = a * b;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  cout << x / b << endl;
  return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(void) {
	int time,h,m,s;
	scanf("%d",&time);
	h = time/ 3600;
	m = (time % 3600) /60;
	s = (time % 3600) % 60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int main() {
	char b,s;
    cin >> b;
    if(b == 'A'){
      s = 'T';
    }
    else if(b == 'T'){
      s = 'A';
    }
    else if(b == 'G'){
      s = 'C';
    }
    else{
      s = 'G';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
//from Kuugo
#include<bits/stdc++.h>
using namespace std;
#define N 333333
#define rev(a) reverse(a+1,a+n+1)
 
int n,m;
long long t[N],s[N],l[N],r[N],f[N],g[N],h[N],q[N];
 
double slope(int i,int j){
	return (double)(g[i]-g[j])/(i-j);
}
 
void pop(int i){
	while (m>1&&slope(q[m],q[m-1])<=i) m--;
}
 
void push(int i){
	while (m>1&&slope(i,q[m])>=slope(q[m],q[m-1])) m--;
	q[++m]=i;
}
 
void calc(long long f[]){
	for (int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	q[m=1]=0;
	for (int i=1;i<=n;i++){
		pop(i);
		f[i]=max(f[i-1],g[q[m]]-1ll*i*q[m]+1ll*i*(i+1)/2-s[i]);
		g[i]=f[i]+1ll*i*(i-1)/2+s[i];
		push(i);
	}
}
 
void solve(int x,int y){
	if (x==0&&y==n) for (int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	if (x==y) return;
	int mid=(x+y)/2;m=0;
	for (int i=x;i<=mid;i++){
		g[i]=l[i]+1ll*i*(i-1)/2+s[i];
		push(i);
	}
	for (int i=mid+1;i<=y;i++){
		pop(i);
		h[i]=g[q[m]]-1ll*i*q[m]+1ll*i*(i+1)/2-s[i]+r[i+1];
	}
	for (int i=y-1;i>mid;i--) h[i]=max(h[i],h[i+1]);
	for (int i=mid+1;i<=y;i++) f[i]=max(f[i],h[i]);
	solve(x,mid);solve(mid+1,y);
}
 
int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();
	for (int i=1;i<=n;i++) t[i]=read(),f[i]=-1e18;
	calc(l);rev(t);calc(r);rev(t);rev(r);
	solve(0,n);rev(t);rev(f);rev(l);rev(r);swap(l,r);
	solve(0,n);rev(t);rev(f);rev(l);rev(r);swap(l,r);
	for (int m=read();m;m--){
		int p=read(),x=read();
		printf("%lld\n",max(l[p-1]+r[p+1],t[p]+f[p]-x));
	}
	return 0;
}

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

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n,0);
    for(auto&& i: a)cin >> i;
    long sum = 0;
    for(auto&& i: a)sum += i;
    if(sum >= h)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

    if( X <= 599 ) cout << "8" << endl;
    if( (600 <= X) && (X <= 799) ) cout << "7" << endl;
    if( (800 <= X) && (X <= 999) ) cout << "6" << endl;
    if( (1000 <= X) && (X <= 1199) ) cout << "5" << endl;
    if( (1200 <= X) && (X <= 1399) ) cout << "4" << endl;
    if( (1400 <= X) && (X <= 1599) ) cout << "3" << endl;
    if( (1600 <= X) && (X <= 1799) ) cout << "2" << endl;
    if( (1800 <= X) && (X <= 1999) ) cout << "1" << endl;
}


Measured memory_bytes: 3636
s=input()
a=list(map(int,input().split()))
mx=0
l=[]
for i in a[::-1]:
    mx = max(mx,i)
    l+=[mx-i]
l.sort()
r = 0
for i in l[::-1]:
    if i==l[-1]:
        r+=1
print(r)

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

using namespace std;

typedef long long int ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define nl '\n'
#define debug1(x)       cout<<" #x "<< ": " << x << endl
#define debug2(x, y)    cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

string to_upper(string &in)
{
    for (int i = 0; i < in.length(); i++)
          if('A'<=in[i] and 'Z'>=in[i]){
              continue;
          }
          else{
              in[i] = in[i] - 'a' + 'A';
          }
          return in;
}

void solve(){
    int n,m;
    ll tot=0;
    cin>>n>>m;
    while(m--){
        int time;
        cin>>time;
        tot+=time;
    }
    if(tot>n){
        cout<<"-1"<<endl;
    }
    else{
        cout<<n-tot<<endl;
    }
    //aa
//   int r;
//   cin>>r;
//   cout << setprecision(15) <<2*3.141592653589793238*r<< '\n';

 }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e14;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

int main(){
    string Str;
    cin >> Str;

    int n = Str.length()-1;
    ll sum=0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        /* bit で表される集合の処理を書く */
        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        // bit の表す集合の出力
        ll start=0;
        for (int i = 0; i < (int)S.size(); ++i) {
            ll left = stoll(Str.substr(start, S[i]-start+1));
            sum += left;
            start = S[i]+1;
        }
        sum += stoll(Str.substr(start, Str.length()-start)) ;
    }
    
    cout << sum << endl;

    return 0;
}


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


int main()
{
    

    int n, k, approved = 1;
    cin >> n;
    while(n--)
    {
        cin >> k;

        if(k%2 == 0)
        {
            if ( k%3 != 0 && k%5 != 0)
            {
                approved = 0;
            }
        }
    }

    if(approved)
        cout << "APPROVED";
    else
    {
        cout << "DENIED";
    }
    


    return 0;    

}


Measured memory_bytes: 256