akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


int main(){
  char buf[1024];
  int A,B,C;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d", &A, &B, &C);

  if((A<C && C<B) || (B<C && C<A)){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;


}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
#p copy q
import copy
q=copy.copy(p)
a=0
for i in range(n):
    if p[i]!=i+1 and a==0:
        q[i]=int(p[p[i]-1])
        q[p[i]-1]=p[i]
        a+=1
p.sort()
if p==q:
    print("YES")
else:
    print("NO")
#135b


Measured memory_bytes: 3572
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
n,k = inp
t = inp.sort
a = [n-k,0].max
p (a==0)? 0: sum(t[0...a])

Measured memory_bytes: 22668
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);

    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    
    int ans;
    if(N%2 == 0){
        int m = N/2;
        ans = d[m] - d[m-1];
        
    }
    else ans = 0;

    cout << ans ;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

ll a[maxn];
ll res[maxn];

ll C(ll n,ll m)
{
    ll sum=1;
    for(ll i=1,j=n;i<=m;i++,j--){
        sum=sum*j/i;
	}
    return sum;
}
int main(){
	// in;
	// out;
	ll n;
	cin>>n;
	me(res);
	ll maxx=-1;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>maxx) maxx=a[i];
		res[a[i]]++;
	}
	ll sum=0;
	for(ll i=1;i<=maxx;i++){
		sum+=C(res[i],2);
	}
	
	for(ll i=1;i<=n;i++){
		ll ans=0;
		ans+=sum-C(res[a[i]],2)+C(res[a[i]]-1,2);
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 200000;
ll a,b,c,x,y,i,A,B,ta,tb,ans = LLONG_MAX;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>c>>x>>y;
    rep(i,0,N + 1){
        A = i / 2;
        B = i / 2;
        ta = x - A;
        tb = y - B;
        ans = min(ans,i * c + (ta > 0 ? ta * a : 0) + (tb > 0 ? tb * b : 0));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace  std;
const long long mod = 1e9 + 7;
typedef long long LL;
int n;
LL Pow(LL a, LL b)
{
	LL sum = 1;
	while(b)
	{
		if(b & 1) sum = (sum * a)% mod;
		a = (a * a) % mod;
		b >>= 1;
	}
/*	for(int i = 1; i <= b; i ++)
	 sum = (sum * a) % mod;*/
	return sum;
}
int main()
{
	scanf("%d", &n);
	if(n < 2)
	{
		printf("0");
		return 0;
	}
	LL a = Pow(10, n), b = 2 * Pow(9, n), c = Pow(8, n);
	LL ans = ( a - b + c + mod * mod ) % mod;
	printf("%lld", ans);
	return 0;
}
/*
4 206;
3 4;
_ _ _ _ _ 0
_ _ _ _ _ 0 
*/

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

using s64 = long long;

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

  vector<int> low(n);
  stack<int> sta;
  for (int i = 0; i < n; ++i) {
    while (!sta.empty() && a[i] < a[sta.top()]) {
      sta.pop();
    }
    low[i] = sta.empty() ? -1 : sta.top();
    sta.push(i);
  }

  s64 answer = 0;
  while (!sta.empty()) {
    sta.pop();
  }
  for (int i = n - 1; ~i; --i) {
    while (!sta.empty() && a[i] < a[sta.top()]) {
      sta.pop();
    }
    answer += (s64)a[i] * (i - low[i]) * ((sta.empty() ? n : sta.top()) - i);
    sta.push(i);
  }

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef pair<int, int> P;
const int maxn = 500, maxm = maxn * maxn;
int n, m, res[maxm + 3];
P a[maxn + 3];

int main() {
	scanf("%d", &n);
	m = n * n;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		if (res[x]) puts("No"), exit(0);
		res[x] = i;
		a[i] = make_pair(x, i);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) if (a[i].se != 1) {
		int x = a[i].se - 1;
		for (int j = 1; j < a[i].fi; j++) if (!res[j]) {
			res[j] = a[i].se, x--;
			if (!x) break;
		}
		if (x > 0) puts("No"), exit(0);
	}
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) if (a[i].se != n) {
		int x = n - a[i].se;
		for (int j = m; j > a[i].fi; j--) if (!res[j]) {
			res[j] = a[i].se, x--;
			if (!x) break;
		}
		if (x > 0) puts("No"), exit(0);
	}
	puts("Yes");
	for (int i = 1; i <= m; i++) printf("%d%c", res[i], " \n"[i == m]);
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;
const int MAXN = 5004;

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int a, b;
    while(~scanf("%d%d", &a, &b)) {
        int t = gcd(a, b);
        printf("%d %d\n", t, a/t*b);
    }
    return 0;
}



Measured memory_bytes: 2664
from sys import stdin
import math

n = int(stdin.readline().rstrip())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

li = make_divisors(n)

total = n+1

for i in range(len(li)):
    a = li[i]
    b = n//a
    total = min(total,a+b)

print(total-2)


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n,l;cin >> n >> l;
    vector<string> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(),a.end());    

    for(int i = 0; i < n-1; i++) {
        cout << a[i];
    }
    cout << a[n-1] << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
#include<iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y>2019){printf("TBD\n");return 0;}
	if(m>4){printf("TBD\n");return 0;}
	printf("Heisei\n");
	return 0;
}



Measured memory_bytes: 256
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<math.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
  ll N;
  cin >>N;
  
  vector<ll> ans(N);
  ll x, y, z;
  if (N<5) {
    for (x=1; x*x<N; x++) {
      for (y=1; y < (N - x*x - x); y++) {
        for (z=1; z <(N - x*x - y*y - x*y - y - z); z++) {
          ll val = x*x + y*y + z*z + x*y + y*z + z*x;
          if (val>N) break;
          for (ll n=0; n<N; n++) {
            if (val == (n+1)) ans.at(n)++;
          }
        }
      }
    }
    
    for (int i=0; i<N; i++) {
      cout << ans.at(i) << endl;
    }
    
    return 0;
  } 
  
  for (x=1; x*x<(N-5); x++) {
    for (y=1; y < (N - x*x - x); y++) {
      for (z=1; z <(N - x*x - y*y - x*y - y - z); z++) {
        ll val = x*x + y*y + z*z + x*y + y*z + z*x;
        if (val>N) break;
        for (ll n=5; n<N; n++) {
          if (val == (n+1)) ans.at(n)++;
        }
      }
    }
  }
  
  for (int i=0; i<N; i++) {
    cout << ans.at(i) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> data(m, vector<int>(2));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  sort(data.begin(), data.end());
  vector<bool> b(n);
  vector<bool> c(n);
  for (int i = 0; i < m; i++) {
      if(data[i][0]==1)
      b[data[i][1]]=true;
      else if(data[i][1]==n)
      c[data[i][0]]=true;
    }
    for (int i = 0; i < n; i++){
      if(b[i] && c[i]){
      cout << "POSSIBLE" << endl;
      return 0;
      }
    } 
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 14356
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (auto &x: a) cin >> x;
    for (auto &x: b) cin >> x;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a[0] > b[0]) swap(a[0], b[0]);
    auto f = [&](int l, int r) {
        long long ret = 1, rem = 0;
        int j = r-1;
        for (int i = r-1; i >= l; i--) {
            while (l <= j && a[i] < b[j]) rem++, j--;
            ret *= rem--; ret %= mod;
        }
        return ret;
    };
    long long ans = 1; int rg = b[0], lf = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) swap(a[i], b[i]);
        if (rg < a[i]) {
            ans *= f(lf, i); ans %= mod;
            lf = i;
        }
        rg = max(rg, b[i]);
    }
    ans *= f(lf, n);
    cout << ans % mod << "\n";
    return 0;
}

Measured memory_bytes: 1024
ABC = [0] * 3
N, ABC[0], ABC[1], ABC[2] = map(int, input().split())
s = [''] * N
for i in range(N):
	s[i] = input()
a = ''
b = True
for i in range(N):
	if not ABC[ord(s[i][0]) - ord('A')]:
		if not ABC[ord(s[i][1]) - ord('A')]:
			b = False
			break
		ABC[ord(s[i][0]) - ord('A')] += 1
		ABC[ord(s[i][1]) - ord('A')] -= 1
		a += s[i][0]
	elif not ABC[ord(s[i][1]) - ord('A')]:
		ABC[ord(s[i][0]) - ord('A')] -= 1
		ABC[ord(s[i][1]) - ord('A')] += 1
		a += s[i][1]
	else:
		if i == N - 1:
			ABC[ord(s[i][0]) - ord('A')] += 1
			ABC[ord(s[i][1]) - ord('A')] -= 1
			a += s[i][0]
		else:
			if s[i][0] == s[i + 1][0] or s[i][0] == s[i + 1][1]:
				ABC[ord(s[i][0]) - ord('A')] += 1
				ABC[ord(s[i][1]) - ord('A')] -= 1
				a += s[i][0]
			else:
				ABC[ord(s[i][0]) - ord('A')] -= 1
				ABC[ord(s[i][1]) - ord('A')] += 1
				a += s[i][1]
if b:
	print('Yes')
	for i in a:
		print(i)
else:
	print('No')

Measured memory_bytes: 16400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define rrep(...) _overload3(__VA_ARGS__,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload3(__VA_ARGS__,a,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(a,b,c);
    if(c>a+b)out("NA");
    else out(max(c-a,0));
}















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



















int water (vector<int> h) {
    int result = 0;

    int N = h.size();
    vector<int> allzero(N, 0);

    while (h != allzero) {
        int count = 0;
        while (h[count] == 0) count++;

        while (count < N) {
            int count1 = count;
            int minimum = 100;

            while (count < N && h[count] != 0) {
                minimum = min (minimum, h[count]);
                count++;
            }

            result += minimum;
            for (int i = count1; i <= count - 1; i++) {
                h[i] -= minimum;
            }

            while (count < N && h[count] == 0) count++;
        } 
    }
    return result;
}








int main () {
    int N;
    cin >> N;
    vector<int> h(N);

    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    cout << water(h) << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main(){

	char head = 'd', tail = 'x';
	set<string> check;
	string out, in, mid = "opqrstuv";
	
	do{
		out = mid;
		out += tail;
		out.insert(out.begin(), head);

		cout << "?" << out << endl;
		cin>>in;
		
		if(check.count(in) || in[0]!=tail){
			cout << "!OUT" << endl;
			break;
		}

		check.insert(in);
		head = in[in.size()-1];

	}while(next_permutation(mid.begin(), mid.end()));
	
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int maxn = 2*1000005;

#define FILENAME ""

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> a;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.pb(x);
    }
    vector <ll> dp(sz(a) + 1, inf);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        for (int j = i - 1; j >= (i - 2); j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[210];
  for (int i = 0; i < n; i++) cin >> a[i];
  int count = 0;
  while(true){
    bool is_odd =false;
    for (int i = 0; i < n; i++){
      if(a[i]%2 != 0){
        is_odd =true;    
      }
    }
    if(is_odd) break;
    for (int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ++count;
  }
  cout << count << endl;
}

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

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    string s,t;
    cin>>s>>t;
    int ch = 0;
    for(int i=0;i<s.length();++i)    if(s[i] != t[i])    ch++;

    cout<<ch<<"\n";

    return 0;
}

Measured memory_bytes: 3776
use proconio::input;
use proconio::marker::Usize1;

fn f(x: usize) -> usize {
    let mut res = 0;
    let mut x = x;
    while x > 0 {
        res += x % 10;
        x /= 10;
    }
    res
}

fn main() {
    input! {
        n: usize,
    };
    let ans = n % f(n) == 0;
    println!("{}", if ans { "Yes" } else { "No" });
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int fr = 0, re = 0, cnt = 0;

    rep(i, n) {
        if (s[i] == '(') cnt++;
        else {
            cnt--;
            if (cnt < 0) cnt = 0, fr++;
        }
    }
    re = cnt;

    rep(i, fr) cout << '(';
    cout << s;
    rep(i, re) cout << ')';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        String uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String lowercase = "abcdefghijklmnopqrstuvwxyz";

        String alpha = scanner.nextLine();

        if(uppercase.contains(alpha))
            System.out.println("A");
        else
            System.out.println("a");
    }
}


Measured memory_bytes: 35704
#include<cstdio>
const int N=1000002;
int n,i,a[N],f[N];
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",a+i);
	for(i=n;i>0;i-=2)
		printf("%d ",a[i]),f[i]=1;
	for(i=1;i<=n;i++)
		if(!f[i])
			printf("%d ",a[i]);
	printf("\n");
}


Measured memory_bytes: 6912
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N;
int A[100004];
int X[100004],Y[100004];
int ans=0;
signed main(){
    scanf("%lld",&N);
    int cntn=0,cntp=0;
    rep(i,N){
        scanf("%lld",&A[i]);
        if(A[i]>=0)cntp++;
        else if(A[i]<0)cntn++;
    }
    sort(A,A+N);//A[cntn]以上は０以上
    int minusdodai=A[0];
    int plusdodai=A[N-1];
    int minusite=1;
    if(cntn!=0&&cntp!=0){
        rep(i,N-1){
            if(i<cntp-1){//最後だけ残す
                X[i]=minusdodai;Y[i]=A[cntn+i];
                minusdodai-=Y[i];
            }else if(i<N-2){
                X[i]=plusdodai;
                Y[i]=A[minusite];//1,2,....
                plusdodai-=Y[i];minusite++;
            }else{//i==N-1
                X[i]=plusdodai;
                Y[i]=minusdodai;
            }
        }
    }
    if(cntn==0){
        rep(i,N-1){
            if(i<N-2){
               X[i]=minusdodai;Y[i]=A[minusite];
               minusdodai-=Y[i];minusite++;
            }else{//i==N-1
                X[i]=plusdodai;
                Y[i]=minusdodai;
            }
        }
    }
    if(cntp==0){
        rep(i,N-1){
            X[i]=plusdodai;
            Y[i]=A[i];
            plusdodai-=Y[i];
        }
    }
    ans=X[N-2]-Y[N-2];
    printf("%lld\n",ans);
    rep(i,N-1){
        printf("%lld %lld\n",X[i],Y[i]);
    }
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <math.h>

int main(){
	
	int a,b;
	int tmp,aa,bb;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		for(int i=0;i<b;i++){
			aa= aa + a * pow(10,i);
		}
	}	

	else {		
		for(int i=0;i<a;i++){
			bb= bb + b * pow(10,i);
		}
	}
	
	if (aa>bb) printf("%d",aa);
	else printf("%d",bb);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void solve(){
    int x;
    cin>>x;
    int sm=0;
    sm+=(x/500)*1000;
    x%=500;
    sm+=(x/5)*5;
    cout<<sm;
}
void trials(){
    int t;
    for(cin>>t;t--;cout<<endl){
        solve();
    }
}
int main(){
    solve();
}

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

using namespace std;

const long long LINF = (1LL << 60);

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

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

  long long sum = 0, ans = LINF, cnt = 0;
  // patern of +-+-+-...
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (i & 1) {
      if (sum >= 0) {
        cnt += abs(sum) + 1;
        sum = -1;
      }
    } else {
      if (sum <= 0) {
        cnt += abs(sum) + 1;
        sum = 1;
      }
    }
  }
  ans = min(ans, cnt);

  sum = 0;
  cnt = 0;
  // patern of -+-+-+...
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (!(i & 1)) {
      if (sum >= 0) {
        cnt += abs(sum) + 1;
        sum = -1;
      }
    } else {
      if (sum <= 0) {
        cnt += abs(sum) + 1;
        sum = 1;
      }
    }
  }
  ans = min(ans, cnt);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void) 
{
    int a, b;
    scanf("%d %d",&a,&b);
    if(a+b>=a-b&&a+b>=a*b)
        printf("%d\n",a+b);
    else if(a-b>=a+b&&a-b>=a*b)
        printf("%d\n",a-b);
    else
        printf("%d\n",a*b);  
}

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



int main() {
  string S;
  ll K;
  cin >>S >> K;
  rep(i,K){
  if (S[i] != '1'){
      cout << S[i] << endl;
      return 0;
    }
  
  }
  
  cout << 1 << endl;



  return 0;
}








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

int main(){
    string s;
    cin >> s;
    string ans = "No";
    rep(i, 3){
        if(s.at(i) == 'a') a = true;
        if(s.at(i) == 'b') b = true;
        if(s.at(i) == 'c') c = true;
    }
    if(a&&b&&c) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    input(a,n);
    set<lint>s;
    lint cnt=0;
    rep(i,n){
        if(a[i]>=3200)cnt++;
        else s.insert(a[i]/400);
    }
    cout<<max<lint>(1,s.size())<<" "<<s.size()+cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long res=0;
long long now=0;
string s;

void f(int i,long long pp)
{
	if(i==s.size())
	{
		res+=now+pp;
		return;
	}

	long long temp=now;

	now+=pp;
	f(i+1,s[i]-'0');

	now=temp;
	f(i+1,pp*10+s[i]-'0');
}

int main()
{
	cin>>s;
	f(1,s[0]-'0');
	cout<<res;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int E=1;
    for(int i=0;i<m;i++){
         E*=2;
    }
    int ans=E*m*1900+(n-m)*100*E;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()

    N, M = len(S), len(T)
    ans = []

    for i in range(N - M + 1):
        ok = True
        s = list(S)
        for j in range(M):
            if S[i + j] == '?':
                s[i + j] = T[j]
            elif S[i + j] != T[j]:
                ok = False
                break
        if ok:
            ans.append(''.join(s).replace('?', 'a'))

    if ans:
        print(min(ans))
    else:
        print('UNRESTORABLE')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include <stdio.h>

int main(void)
{
	int a, b;
	int keta;
	int num;
	
	num = 0;
	
	while (scanf("%d %d", &a, &b) != EOF){
		keta = 0;
		num = a + b;
		while (num > 0){
			num /= 10;
			keta++;
		}
		
		printf("%d\n", keta);
	}
	
	return (0);
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _T>
inline void _prfe(const char *_n, _T _c, bool _p = false){
    ITER(_c) _it=_c.begin();
    if(_p){ cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{ cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#endif

int t[101][101];


void solve(int n){
    ll max = -(1LL<<62);
    REP(y1,n){
        REP(x1,n){
            for(int y2 = y1; y2 < n; y2++){
                ll sum = 0;
                for(int x2 = x1; x2 < n; x2++){
                    for(int y3 = y1; y3 <= y2; y3++){
                        sum += t[y3][x2];
                    }
                    pf("(%d,%d)-(%d,%d) = %lld\n", x1,y1,x2,y2,sum);
                    max = MAX(max, sum);
                }
            }
        }
    }
    cout << max << endl;
    return;
}

int main(){
    int n;
    cin >> n;
    REP(i,n) REP(j,n){
        cin >> t[i][j];
    }
    solve(n);
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;
	}else{
		cout<<b-a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  a=MAX(a,c);
  b=MIN(b,d);
  printf("%d\n",MAX(0,b-a));
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  long long int x, y;
  int cnt=0;
  cin >> x >> y;

  int tmp=x;
  while(x<=y){
    cnt++;
    x*=2;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

void dijkstra(vector<vector<int>> v, vector<vector<int>> c, vector<int> &d) {
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(0, 0));
	while (!pq.empty()) {
		int s = pq.top().second;
		int dis = pq.top().first;
		pq.pop();
		if (dis > d[s]) continue;
		REP(j, v[s].size()) {
			int u = v[s][j];
			int w = c[s][j];
			if (d[u] > d[s] + w) {
				d[u] = d[s] + w;
				pq.push(P(d[u], u));
			}
		}
	}
}

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

	int n;
	cin >> n;
	vector<vector<int>> v(n), c(n);
	REP(i, n) {
		int u, k;
		cin >> u >> k;
		v[u] = vector<int>(k);
		c[u] = vector<int>(k);
		REP(j, k) cin >> v[u][j] >> c[u][j];
	}
	vector<int> d(n, INF);
	dijkstra(v, c, d);
	REP(i, n) {
		cout << i << " " << d[i] << "\n";
	}
	
	return 0;
}



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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i=0; i<n; ++i) {
        cin >> c[i];
        for (int j=0; j<m; ++j) {
            cin >> a[i][j];
        }
    }
    int ans = 1e9;
    for (int bit = 1; bit < (1 << n); ++bit) {
        vector<int> p(m, 0);
        int sum = 0;
        bool can = true;
        for (int i=0; i<n; ++i) {
            if (bit & (1 << i)) {
                sum += c[i];
                for (int j=0; j<m; ++j) {
                    p[j] += a[i][j];
                }
            }
        }
        for (int i=0; i<m; ++i) {
            if (p[i] < x) can = false;
        }
        if (can) {
            ans = min(ans, sum);
        }
    }
    if (ans == 1e9) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
        int a,b;
        char op;
        while(1){
                scanf("%d %c %d",&a,&op,&b);
                if(op=='?') break;
                if(op=='+') printf("%d\n",a+b);
                if(op=='-') printf("%d\n",a-b);
                if(op=='*') printf("%d\n",a*b);
                if(op=='/') printf("%d\n",a/b);
        }
        return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>
#define sf(n) scanf("%d",&n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define ll long long
#define mod 1000000007
#define INF 400000
using namespace std;
int main(){
    int n;sf(n);
    int a[30]={0};
    for(int i=0;i<n;i++){
        sf(a[i]);
    }
    int mmax=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>=mmax){
            cnt++;mmax=a[i];
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

ll memo[60][2];
const ll mod = 1000 * 1000 * 1000 + 7;

int rec(int pos, int carry, const string &A, const string &B, const string &C){
  if (pos == -1){
    return carry == 0;
  }

  if (memo[pos][carry] != -1){
    return memo[pos][carry];
  }

  ll &res = memo[pos][carry] = 0;

  REP(a, 10){
    REP(b, 10){
      if (A[pos] != '?' && A[pos] != '0' + a) continue;
      if (B[pos] != '?' && B[pos] != '0' + b) continue;
      if (pos == 0 && (a == 0 || b == 0)) continue;

      int c = (a + b + carry) / 10;
      int d = (a + b + carry) % 10;

      if (C[pos] == '?' || C[pos] == '0' + d){
        res += rec(pos - 1, c, A, B, C);
        res %= mod;
      }
    }
  }
  return res;
}

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

  string A, B, C;
  while (cin >> A && A != "0"){
    cin >> B >> C;
    memset(memo, -1, sizeof(memo));

    cout << rec(A.size() - 1, 0, A, B, C) << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	s := nextString()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1756
function Main(input) {
	input = input.split(" ");
	var a = input[0];
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
	//出力
	console.log((parseInt(input[0]+input[1]+input[2], 10) % 4 == 0) ? 'YES' : 'NO');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
//using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define REP(countName, end) for (ll countName = 0; countName < end; countName++)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)
#define REV(countName, end) for (ll countName = end - 1; countName >= 0; countName--)

int main(void)
{
    std::vector<std::pair<int, int>> v(4);
    for (int i = 0; i < 2; i++)
    {
        cin >> v[i].first >> v[i].second;
    }

    int x = v[1].first - v[0].first;
    int y = v[1].second - v[0].second;

    //cout << x << " " << y << endl;
    cout << v[1].first - y << " " << v[1].second + x << " ";
    cout << v[0].first - y << " " << v[0].second + x << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

def get_primes(n):
    if not isinstance(n, int):
        raise TypeError('n is int-type.')
    if n < 2:
        raise ValueError('n is more than 2')
    
    from math import sqrt 
    def _sieve_of_eratosthenes(n):
        primes = []
        limit = sqrt(n)
        data = [i + 1 for i in range(1, n)]
        while True:
            p = data[0]
            if limit <= p:
                return primes + data
            primes.append(p)
            data = [e for e in data if e % p != 0]
    return _sieve_of_eratosthenes(n)

primes = get_primes(10**5 + 3)
print(primes[bisect_left(primes, int(input()))])

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, max_w;
	cin >> n >> max_w;

	int w[n], v[n];
	rep(i, n) cin >> w[i] >> v[i];

	ll dp[n+1][max_w+1] = {};
	// dp[i][j] : i番目の品物で重さj以下の価値の最大値

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= max_w; j++){
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			if(j - w[i-1] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
		}
	}

	ll ans = 0;
	for(int i = 0; i <= max_w; i++) ans = max(ans, dp[n][i]);
	cout << dp[n][max_w] << endl;
}


Measured memory_bytes: 79232
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [[0 for i in range(w+2)] for j in range(h+2)]
for y in range(h):
    for x in range(w):
        if(a[y][x] == '#'):
            b[y][x] += 1
            b[y+1][x] += 1
            b[y+2][x] += 1
            b[y][x+1] += 1
            b[y+2][x+1] += 1
            b[y][x+2] += 1
            b[y+1][x+2] += 1
            b[y+2][x+2] += 1
d = [""] * h
for y in range(h):
    for x in range(w):
        if(a[y][x] == "."):
            d[y] += str(b[y+1][x+1])
        else:
            d[y] += '#'
for s in d:
    print(s)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include<cmath>
#include<set>


using namespace std;

int ans = 0;
bool g[8][8] = {};
bool visited[8] = {};
int n, m;

void dfs(int count, int now) {
	if (count == n) {
		ans++;
		return;
	}
	for (int i = 0; i < n; i++) {
		if (!visited[i] && g[now][i]) {
			visited[i] = true;
			dfs(count + 1, i);
			visited[i] = false;
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a][b] = g[b][a] = true;
	}
	visited[0] = true;
	dfs(1, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=0,k,l;
int main()
{
	string s;
	cin>>s>>k;
	l=s.length();
	if(s[0]!=s[l-1])
	{
		for(int i=0;i<l;i++)
		{
			int j=i;
			while(s[j]==s[i] && j<l) j++;
			ans+=(j-i)/2;
			i=j-1;
		}
		ans=ans*k;
		cout<<ans;
	}
	else
	{
		int pre,suf,i=0,j=l-1;
		pre=suf=0;
		while(s[i]==s[0] && i<l) 
		{
			i++;
			pre++;
		}
		while(s[j]==s[l-1] && j>=0)
		{
			j--;
			suf++;
		}
		if(pre==l)
		cout<<(l*k)/2;
		else
		{
			//cout<<pre<<" "<<suf<<endl;
			for(int cn=i;cn<=j;cn++)
			{
				int pn=cn;
				while(s[pn]==s[cn] && pn<=j) pn++;
				ans+=(pn-cn)/2;
				cn=pn-1;
			}
			ans=ans*k;
			ans=ans+pre/2+(k-1)*((pre+suf)/2)+suf/2;
			cout<<ans;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * GCA : "Computer is artificial subject absolutely,Math is God"
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cctype>
#include <utility>

using namespace std;
#ifdef DEBUG
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...) printf("DEBUG: "),printf(__VA_ARGS__)
#else
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...)
#endif
typedef unsigned int uint;
typedef long long int Int;
typedef unsigned long long int UInt;
#define Set(a,s) memset(a,s,sizeof(a))
#define Pln() printf("\n")
#define For(i,x)for(int i=0;i<x;i++)
#define CON(x,y) x##y
#define M 1005
#define PB push_back
#define oo INT_MAX
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)
#define eps 1e-9
#define X first
#define Y second
inline bool xdy(double x,double y){return x>y+eps;}
inline bool xddy(double x,double y){return x>y-eps;}
inline bool xcy(double x,double y){return x<y-eps;}
inline bool xcdy(double x,double y){return x<y+eps;}
const Int mod=1000000007;
int n;
int god[M];
int ti[M];
int inti[M];
int sid[M];
char ppl[M];
int main() {
	ios_base::sync_with_stdio(0);
	while(~scanf("%d",&n)&&n){
		Set(inti,-1);
		Set(god,0);
		for(int i=0;i<n;i++){
			int mon,d,h,m;
			scanf("%d/%d %d:%d ",&mon,&d,&h,&m);
			ti[i]=mon*100*24*60+d*24*60+h*60+m;
			scanf("%c %d",&ppl[i],&sid[i]);
		}
		bool godtime=false;
		for(int i=0;i<n;i++){
			if(ppl[i]=='I'){
				if(sid[i]==0){
					godtime=true;
					for(int j=1;j<n;j++){
						if(inti[j]!=-1){
							inti[j]=ti[i];
						}
					}
				}else{
					inti[sid[i]]=ti[i];
				}
			}else{
				if(sid[i]==0){
					for(int j=1;j<n;j++){
						if(inti[j]!=-1)god[j]+=ti[i]-inti[j];
					}
					godtime=false;
				}else{
					if(godtime&&inti[sid[i]]!=-1){
						god[sid[i]]+=ti[i]-inti[sid[i]];
					}
					inti[sid[i]]=-1;
				}
			}
		}
		int ans=0;
		for(int i=1;i<1000;i++){
			ans=max(ans,god[i]);
		}
		printf("%d\n",ans);
	}

















}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<long double> vec(N, 0.0);
	vector<string> s(N, "");
	for(int i = 0; i < N; ++i){
		double x;
		string r;
		cin>>x>>r;
		vec[i] = x;
		s[i] = r;
	}
	long double res = 0;
	for(int i = 0; i < N; ++i){
		if(s[i] == "JPY")res += vec[i];
		else res += vec[i] * 380000.00;
	}
	cout<<setprecision(20)<<res<<endl;
	return 0;
}


Measured memory_bytes: 256