akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

struct card{char suit, num;};

bool isStable(struct card c1[], struct card c2[], int n){
    rep(i, n){
         if(c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

void bubble(struct card c[], int n){
     rep(i, n){
          for(int j = n-1; j>=i + 1; j--){
               if(c[j].num < c[j-1].num){
                    card tmp = c[j];
                    c[j] = c[j-1];
                    c[j-1] = tmp;
               }
          }
     }
}

void select(struct card c[], int n){
     rep(i, n){
          int minj = i;
          for(int j = i; j<n; j++){
               if(c[j].num < c[minj].num) minj = j;
          }
          card tmp = c[i];
          c[i] = c[minj];
          c[minj] = tmp;
     }
}

int main(){
     int n;
     cin >> n;
     card c1[n], c2[n];
     rep(i, n){
          cin >> c1[i].suit >> c1[i].num;
     }
     rep(i, n) c2[i] = c1[i];

     bubble(c1, n);
     select(c2, n);

     rep(i, n){
          if(i>0) cout << " ";
          cout << c1[i].suit << c1[i].num;
     }
     cout << endl;
     cout << "Stable" << endl;
     rep(i, n){
          if(i>0) cout << " ";
          cout << c2[i].suit << c2[i].num;
     }
     cout << endl;
     if(isStable(c1, c2, n)) cout << "Stable" << endl;
     else cout << "Not stable" << endl;
} 


Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <complex>
#include <assert.h>
#include <limits.h>
//#include <bits/stdc++.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;
//const double INF=1e20;
const int INF=0x3f3f3f3f;
//const int INF= 0x7fffffff;
//const ll INF=0x3f3f3f3f3f3f3f3fll;
const ll INFF=0x3f3f3f3f3f3f3fll;
//const ll INFF=1e14+5;
const int MAX=2e5+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
//const ll MOD=1e9+7;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
//#define double long double
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
//const long double eps=-1.0;
//clock_t t1 = clock();
//fprintf(stderr, "%ld ms\n", clock() - t1);
void open()
{
    freopen("in2.txt","r",stdin);
    freopen("out2.txt","w",stdout);
}

int n;
ll tot,tem;
ll a[MAX],b[MAX];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&a[i],&b[i]),tot+=a[i];
    tem=tot;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>b[i])
            tem=min(tem,b[i]);
    }
    printf("%lld\n",tot-tem);
}
/*

*/


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;
vector<int> v;
map<int, int>mp;
int main() {
	int N;
	cin >> N;
	REP(i, N) {
		int A;
		cin >> A;
		v.push_back(A);
		mp[A]++;
	}
	VSORT(v);
	ll ans = 0;
	for (int i = 32; i > 0; i--) {
		REP(j, N) {
			if (mp[v[j]] > 0) {
				if (v[N - 1] < pow2(2, i) / 2)continue;
				ll x = pow2(2, i) - v[j];
				if (binary_search(v.begin(), v.end(), x)) {
					if (v[j] == x) {
						if (mp[x] >= 2) {
							ans++;
							mp[x] -= 2;
						}
					}
					else {
						if (mp[x] >= 1) {
							ans++;
							mp[x]--;
							mp[v[j]]--;
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 10356
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 2e5 + 7, inf = 1e9;
int n, f[N][2];
char s[N];

int main() {
	rds(s, n), f[0][1] = -inf;
	for (int i = 1; i <= n; i++) {
		f[i][0] = f[i][1] = -inf;
		if (i == 1 || s[i] != s[i-1])
			f[i][0] = max(f[i][0], f[i-1][0] + 1);
		f[i][0] = max(f[i][0], f[i-1][1] + 1);
		if (i > 1) f[i][1] = max(f[i][1], f[i-2][0] + 1);
		if (i > 3 && s[i] != s[i-2] && s[i-1] != s[i-3])
			f[i][1] = max(f[i][1], f[i-2][1] + 1);
	}
	print(max(f[n][0], f[n][1]));
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  int t=0;
  int s=0;
  cin>>N>>M;
  vector<int> vote(N);
  for(int i=0;i<N;i++){
    cin>>vote.at(i);
    s+=vote.at(i);
  }
  for(int i=0;i<N;i++){
    if(4*M*vote.at(i)>=s)
    	t++;
  }
  if(t<M)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define h 500000

int H,A[h+1];

int maxHeapify(int [],int);
int buildMaxHeap(int []);

int main(){
  int i;

  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=H/2;i>=1;i--){
    maxHeapify(A,i);
  }

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}

int maxHeapify(int A[],int i){

  int l,r,x,largest;

  l = 2*i;
  r = 2*i+1;
  if(l <= H && A[l] > A[i])
    largest = l;
  
  else
    largest = i;
  
  if( r <= H && A[r] > A[largest])
    largest = r;
  
  if(largest != i){
    x=A[i];
    A[i]=A[largest];
    A[largest] = x;
    maxHeapify(A, largest);
  }
}

int buildMaxHeap(int A[]){
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(A,i);
}



Measured memory_bytes: 3732
w, h, n = map(int, input().split())

white = [0, w, 0, h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    white[0] = max(x, white[0])
  elif a == 2:
    white[1] = min(x, white[1])
  elif a == 3:
    white[2] = max(y, white[2])
  elif a == 4:
    white[3] = min(y, white[3])
if white[1] - white[0] <= 0 or white[3] - white[2] <= 0:
  print(0)
else:
  print((white[1] - white[0]) * (white[3] - white[2]))

Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 110
ll n;
vector<ll> v;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
      ll a;cin>>a;
      v.push_back(a);
    }
    vector<ll> ans;
    for(int i=0;i<n;i++){
      int j=v.size()-1;
      for(;j>=0;j--){
	if(v[j]==j+1)break;
      }//cout<<j<<endl;
      if(j<0){
	cout<<-1<<endl;
	return 0;
      }
      ans.push_back(j+1);
      vector<ll> ne;
      for(int k=0;k<v.size();k++){
	if(j!=k)ne.push_back(v[k]);
      }
      v=ne;
    }
    for(int i=ans.size()-1;i>=0;i--)cout<<ans[i]<<endl;
    return 0;
}



Measured memory_bytes: 256
def find(fr, target):
    for i in range(fr, len(S)):
        if S[i] == target:
            return i
    return -1

N = int(input())
S = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            now = find(0, str(i))
            if now == -1: continue
            now = find(now+1, str(j))
            if now == -1: continue
            now = find(now+1, str(k))
            if now == -1: continue
            ans += 1
print(ans)


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1000000];

ll solve(ll i,ll x,ll a[])
{
    if(i==x-1)
        return 0;
    ll ans=0;
    if(dp[i]!=-1)
        return dp[i];
    if(i<x){
        ans=min(abs(a[i]-a[i+1])+solve(i+1,x,a),abs(a[i]-a[i+2])+solve(i+2,x,a));
    }
    dp[i]=ans;
    return ans;
}

int main(){
    ll x,i,j,k;
    cin>>x;
    ll ar[x];
    for(i=0;i<x;i++)
        dp[i]=-1;
    for(i=0;i<x;i++)
        cin>>ar[i];
    ll s=solve(0,x,ar);
    cout<<s<<endl;
}


Measured memory_bytes: 5760
city_count = int( input() )
monster_list = list( map( int, input().split() ) )
hero_power_list = list( map( int, input().split() ) )

before_total_monsters = sum( monster_list )
# hero attach !
for i in range( city_count ):
  conflict = min( monster_list[i], hero_power_list[ i ] )
  monster_list[i] -= conflict
  hero_power_list[ i ] -= conflict
  conflict = min( monster_list[ i + 1 ], hero_power_list[ i ] )
  monster_list[ i + 1 ] -= conflict
  hero_power_list[ i ] -= conflict
monster_list[city_count] -= min( monster_list[city_count], hero_power_list[city_count-1] )

after_total_monsters = sum( monster_list )

print( before_total_monsters - after_total_monsters )

Measured memory_bytes: 18476
def main():
    # n = int(input())
    n, m = map(int, input().split())
    # v = list(map(int, input().split()))
    # s = input()
    py = []
    for i in range(m):
        p, y = map(int, input().split())
        py.append([i, p, y])

    py.sort(key=lambda x: (x[1], x[2]))

    num = 1
    for i in range(0, m):
        if i == 0:
            py[i].append(num)
        else:
            if py[i][1] == py[i-1][1]:
                num += 1
            else:
                num = 1
            py[i].append(num)

    py.sort(key=lambda x: x[0])

    for i in range(m):
        print(str(py[i][1]).zfill(6) + str(py[i][3]).zfill(6))


if __name__ == '__main__':
    main()


Measured memory_bytes: 106776
n = int(input())
m = {}
for i in range(n):
    s = input()
    if s in m:
        m[s] += 1
    else:
        m[s] = 1

l = sorted(m.items(), key=lambda x: x[1], reverse=True)
cnt = l[0][1]
p = []
for i in l:
    if i[1] == cnt:
        p.append(i[0])

p.sort()
for i in p:
  print(i)

Measured memory_bytes: 112984
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int kati = 0;
    REP(i, s.size())
    {
        if (s[i] == 'o'){
            kati++;
        }
    }
    if (kati + 15 - s.size() >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		while(n--!=0)
		{
			int y=in.nextInt();
			int m=in.nextInt();
			int d=in.nextInt();
			int yc =0;
			int mc =0;
			for(int i=1;i<y;i++)
			{	
				if(i%3==0)
					yc+=200;
				else
					yc+=195;
			}
			for(int j=1;j<m;j++)
			{
				if(y%3==0||j%2!=0)
					mc+=20;
				else
					mc+=19;
			}
			System.out.println(196471-yc-mc-d);
		}
	}
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++) //ここだけ閉区間にしています。
#define INF 10000000000
#define MOD 1000000007
using ll = long long;

#define bit(n,k) ((n>>k)&1)
int bit_count(ll S){
    int res = 0;
    while(S){
        if(S & 1)res++;
        S = S>>1;
    }
    return res;
}

int main(){
    int N; cin>>N;
    vector<vector<ll>> A(N,vector<ll> (N,0));
    rep(i,N)rep(j,N)cin>>A[i][j];
    vector<ll> dp(1<<N,0);
    dp[0] = 1;
    rep(S,1<<N){
        int i = bit_count(S);
        rep(j,N){
            if(bit(S,j)==1&&A[i-1][j]==1){
                dp[S] = (dp[S^(1<<j)] + dp[S])%MOD;
            }
        }
    }
    cout<<dp[(1<<N)-1]<<endl;
}

Measured memory_bytes: 19620
#include<cstdio>
inline int read()
{
	register char ch;register bool aa=1;
	while(ch=getchar(),ch>57||ch<48)ch=='-'?aa=0:0;register int x=ch^48;
	while(ch=getchar(),ch>47&&ch<58)x=x*10+(ch^48);
	return aa?x:-x;
}
int main()
{
	register int a=read(),b=read();
	if((a*b)&1)return!puts("Yes");
	else return!puts("No");
}

Measured memory_bytes: 128
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.22 22:36:27
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll n; cin >> n;
    vector<ll> a(n),b(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum % (n * (n + 1) / 2) != 0) {
        puts("NO");
        return 0;
    }
    ll k = sum / (n * (n + 1) / 2);
    for (int i = 0; i < n; i++) {
        b[i] = a[(i+1)%n] - a[i];
        b[i] -= k;
        b[i] = -b[i];
    }
    for (int i = 0; i < n; i++) {
        if (b[i] < 0 || b[i] % n != 0) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;

int keta(ll n){
	int res = 0;
	while (n > 0)
	{
		res++;
		n /= 10;
	}
	return res;
}


int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = 0;
	for (int i = 0; i < n - k; i++)
	{
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], ans, cnt[1000009];
set<int> st;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(a, a + n);
	bool one = false;
	for (int i = 0; i < n; i++) {
		if (cnt[a[i]] > 1) {
			st.insert(a[i]);
			if (a[i] == 1) one = true;
			continue;
		}
		if (one) continue;
		bool ok = true;
		for (int j = 2; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				if (st.count(j)) {
					ok = false;
					break;
				}
				if (a[i] / j != j && st.count(a[i] / j)) {
					ok = false;
					break;
				}
			}
		}
		if (ok) ans++;
		st.insert(a[i]);
		if (a[i] == 1) one = true;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 16668
<?php
	while (true) {
		$result = trim(fgets(STDIN));
		list($m, $f, $r) = explode(" ", $result);

		if ($m == -1 && $f == -1 && $r == -1) break;

		$val = "";
		if ($m == -1 || $f == -1) $val = "F";
		else if ($m + $f >= 80) $val = "A";
		else if ($m + $f < 80 && $m + $f >= 65) $val = "B";
		else if ($m + $f < 65 && $m + $f >= 50) $val = "C";
		else if ($m + $f < 50 && $m + $f >= 30) {
			$val = ($r >= 50) ? "C" : "D";
		}
		else $val = "F";

		print "$val\n";
	}

Measured memory_bytes: 6600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S;
  cin>>S;
  int N=S.size();
  ll mod=1e9+7;
  ll dp[100100][4]={};
  dp[0][0]=1;
  rep(i,N){
    if(S[i]=='A' or S[i]=='?'){
      rep(j,4) (dp[i+1][j]+=dp[i][j])%=mod;
      (dp[i+1][1]+=dp[i][0])%=mod;
    }
    if(S[i]=='B' or S[i]=='?'){
      rep(j,4) (dp[i+1][j]+=dp[i][j])%=mod;
      (dp[i+1][2]+=dp[i][1])%=mod;
    }
    if(S[i]=='C' or S[i]=='?'){
      rep(j,4) (dp[i+1][j]+=dp[i][j])%=mod;
      (dp[i+1][3]+=dp[i][2])%=mod;
    }
  }
  cout<<dp[N][3]<<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  int n;
  scanf("%d",&n);
  int a[1000]={0};
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+n);
  printf("%d",a[n-1]-a[0]);

  return 0;
}


Measured memory_bytes: 256
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#include <queue>
#include <map>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
ll A, B;
map<ll, bool> m;
ll gcd(ll a,ll b) {
	if (a % b== 0)
		return b;
	return gcd(b, a % b);
}
void solve(){
	ll g = gcd(A, B);
	ll ans = 1;
	m[1] = true;
	for(ll i = 2; i * i <= g; i++){
		if(g % i == 0){
			if(!m[i]){
				m[i] = true;
				ans++;
			}
			g /= i;
			i--;
		}
	}
	ans += !m[g];
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B;
	solve();
	return 0;
}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n';
#define no cout<<"NO"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,r,g;
    string a,b;
    cin>>r>>g;
    cout<<2*g-r<<endl;
       return 0;
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template<typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template<typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template<typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template<typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

// auto mod int
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }
    mint operator+(const mint a) const {
      mint res(*this);
      return res+=a;
    }
    mint operator-(const mint a) const {
      mint res(*this);
      return res-=a;
    }
    mint operator*(const mint a) const {
      mint res(*this);
      return res*=a;
    }
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }
    
    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a) {
      return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
      mint res(*this);
      return res/=a;
    }
};


mint f(int n) {
  if (!n) return 1;
  mint x = f(n / 2);
  x *= x;
  if (n % 2) {
    x *= 2;
  }
  return x;
}

mint choose(int n, int r) {
  mint x = 1, y = 1;
  for (int i = 0; i < r; ++i) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n, a) + choose(n, b);
  cout << ans.x << '\n';
}




















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

int main()
{
		int i = 0; 			//???????????????????????°
		int x = 0;	//??\?????´??°

		for (i = 0; i < 10000; i++) {
				//??\?????´??°????¨????
				cin >> x;

				if (x == 0) {
						break;
				} else {
						cout << "Case " << i+1 << ':'
								<< ' ' << x << '\n';
				}
		}
		return 0;
}

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

int n;
void add(int u, int v) { printf("%d %d\n", u, v); }
int main() {
    scanf("%d", &n);
    if ((n & -n) == n) return puts("No"), 0;
    puts("Yes");
    add(1, 2), add(2, 3), add(3, 1 + n), add(1 + n, 2 + n), add(2 + n, 3 + n);
    for (int i = 4; i + 1 <= n; i += 2)
        add(1, i), add(i, i + 1), add(1, i + 1 + n), add(i + 1 + n, i + n);
    if (~n & 1) add(n, n + n - 1), add(n << 1, n ^ n - 1 ^ 1);
    return 0;
}

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

int main(){
    int s;
    cin >> s;
    int a,b,c,d;
    d = s%10;
    s /= 10;
    c = s%10;
    s /= 10;
    b = s%10;
    s /= 10;
    a = s;
    int k,t;
    k = a*10 + b;
    t = c*10 + d;
    if (1 <= k && k<= 12 && 1<= t && t<= 12) cout << "AMBIGUOUS" << endl;
    else if (1 <= k && k <= 12) cout << "MMYY" << endl;
    else if (1 <= t && t <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N+1,0);
  int i;
  for(i=0;i<N;i++)cin >> A[i];
  long long money = 1000,kabu = 0;
  for(i=0;i<N;i++) {
    if(A[i] > A[i+1]) {
      money += kabu*A[i];
      kabu = 0;
    }
    else {
      kabu += money / A[i];
      money %= A[i];
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 3620
using System;

namespace v0_0004
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
            {
                var input = line.Split(' ');
                var a = double.Parse(input[0]);
                var b = double.Parse(input[1]);
                var c = double.Parse(input[2]);
                var d = double.Parse(input[3]);
                var e = double.Parse(input[4]);
                var f = double.Parse(input[5]);

                double y = Math.Round((c * d - f * a) / (b * d - e * a), 3);
                double x = Math.Round((c - y * b) / a, 3);

                Console.WriteLine("{0:f3} {1:f3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 9512
N = int(input())
start = [0, 0]
start_t = 0
for i in range(N):
    t, x, y = map(int, input().split())
    now = [x, y]
    dt = t - start_t
    dist = abs(now[0]-start[0]) + abs(now[1]-start[1])
    if dist > dt or dt % 2 != dist % 2:
        print('No')
        break
    else:
        start = now
        start_t = t
else:
    print('Yes')

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

int main() {
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a + b == 0)
			break;
		for (int i = 1; i <= a * b; i++) {
			cout << "#";
			if (i % b == 0)
				cout << endl;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3076
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {

    string str;
    int i,n;

    cin >> str;
    n = str.size();

    //char x[n];

    for(i=0;str[i];++i){
        str[i] = 'x';
    }

    cout << str << endl;
    //printf(x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int d[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> d[i];
    }
    sort(d, d + 3);
    if(d[0] == d[2]) cout << "No" << endl;
    else if(d[0] == d[1] || d[1] == d[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
lst0 = list(map(int, input().split()))
lst1 = [0, 0, 0, 0, 0, 0, 0, 0]
god = 0
Mx, Mn = (0, 0)
for i in range(n):
    if 1 <= lst0[i] <= 399:
        lst1[0] += 1
    elif 400 <= lst0[i] <= 799:
        lst1[1] += 1
    elif 800 <= lst0[i] <= 1199:
        lst1[2] += 1
    elif 1200 <= lst0[i] <= 1599:
        lst1[3] += 1
    elif 1600 <= lst0[i] <= 1999:
        lst1[4] += 1
    elif 2000 <= lst0[i] <= 2399:
        lst1[5] += 1
    elif 2400 <= lst0[i] <= 2799:
        lst1[6] += 1
    elif 2800 <= lst0[i] <= 3199:
        lst1[7] += 1
    else:
        god += 1

Mn = 8 - lst1.count(0)
Mx = Mn + god
if Mn==0:
    Mn = 1
print(str(Mn) + " " + str(Mx))

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

int main() {
long double pi=3.141592653589793238;
int A,B,H,M;
  cin>>A>>B>>H>>M;
  long double h,m;
  m=2*pi*M/60;
  h=2*pi*H/12+pi/6*M/60;
  long double a=abs(m-h);
  long double answer;
  answer=sqrt(A*A+B*B-2*A*B*cos(a));
  int ans=sqrt(A*A+B*B-2*A*B*cos(a))/1;
  cout<<ans<<".";
  for(int i=0;i<10;i++){
  long long int a=answer*pow(10,i+1);
  cout<<a%10;
  }
  cout<<"0"<<endl;
}


Measured memory_bytes: 4156
# -*- coding: utf-8 -*-
def margin0(n):
    if n < 10:
        return "00{}".format(n)
    elif n < 100:
        return "0{}".format(n)
    elif n < 1000:
        return "".format(n%1000)
    else:
        return "{}".format(n%1000 - 1)
n = int(input())
# print(n)
name = ""
if n < 1000:
    name = "ABC{}".format(margin0(n))
else:
    name = "ABD{}".format(margin0(n))
print(name[:3])

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    var (N, K) = listOfLong()
    val MAX = 100005
    val C = LongArray(MAX + 1)
    for (n in 0 until N) {
        val (a, b) = listOfLong()
        C[a.toInt()] += b
    }
    for (a in C.indices) {
        if (K <= C[a]) {
            return println(a)
        }
        K -= C[a]
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


Measured memory_bytes: 54136
//巧妙地转化成矩形后，打表即可发现SG规律 
#include<cstdio>
#include<algorithm>
#define N 100005
using namespace std;
int n,a[N];
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	int pos=1,l1=0,l2=0;
	while(pos+1<=a[pos+1])pos++;
	l1=a[pos]-pos;
	for(int i=pos+1;i<=n&&a[i]==pos;i++)l2++;
	if((l1&1)||(l2&1))puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
seen2 = [i for i in range(n)]
can = []
for i in range(n):
  if seen[i]:
    continue
  now = [i]
  seen[i] = 1
  tmp = 1
  while now:
    last = now
    now = []
    for x in last:
      for y in peer[x]:
        if not seen[y]:
          seen[y] = 1
          seen2[y] = i
          now.append(y)
          tmp += 1
  can.append(tmp)
#print(seen2)
#print(can)
print(max(can))

Measured memory_bytes: 130172
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int r,g,b,n,ans;

signed main(){
	read(r,g,b,n);
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++){
		int x=n-r*i-g*j;
		if(x<0||x%b) continue;
		ans++;
	}
	write(ans);
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        sc.close();
        if (x < a) {
            System.out.println("0");
        } else {
            System.out.println("10");
        }
    }
}


Measured memory_bytes: 21844
# Aizu Online Judge
# Atomic Car Race

class Object
  def apply
    yield(self)
  end
end

solve = -> n, checkpoints, b, r, v, e, f {
  # last_changed 地点でタイヤを変えた時、start から goal まで走行するのにかかる時間
  time = -> start, goal, last_changed {
    res = 0.0
    while start < goal
      x = start - last_changed
      res += if x >= r
               1.0 / (v - e * (x - r))
             else
               1.0 / (v - f * (r - x))
             end
      start += 1
    end
    res
  }

  dp = Array.new(n) { Array.new(checkpoints.size + 1) }

  (n-1).downto(0) do |i|
    0.upto(checkpoints.size) do |j| # checkpoints に入れるときに -1 する
      dp[i][j] = if i == n-1
                   0.0
                 else
                   this_cp = checkpoints[i]
                   next_cp = checkpoints[i+1]
                   last_changed = j==0 ? 0 : checkpoints[j-1]
                   [ dp[i+1][i+1] + time.(this_cp, next_cp, checkpoints[i]) + b,
                     dp[i+1][j] + time.(this_cp, next_cp, last_changed) ].min
                 end
    end
  end

  return dp[0][0] + time.(0, checkpoints[0], 0)
}

# n
# a1 a2 . . . an
# b
# r v e f

loop do
  # n checkpoints
  n = gets.to_i
  break if n == 0
  checkpoints = gets.split.map(&:to_i)

  # b seconds to change tires
  b = gets.to_f

  # time to run from x to x+1:
  #   1/(v - e(x - r)) (if x >= r)
  #   1/(v - f(r - x)) (if x < r )
  r, v, e, f = gets.split.apply { |r, v, e, f| [r.to_i, *[v, e, f].map(&:to_f)] }

  puts solve.(n, checkpoints, b, r, v, e, f).round(4)
end

Measured memory_bytes: 6244
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int sum[1000005];
bool shai[1000005];
void dabiao(){
	for(int i=2;i<=1000000;i++){
		sum[i]=sum[i-1];
		if(!shai[i]){
			for(int j=2*i;j<=1000000;j+=i)
				shai[j]=1;
			sum[i]++;
		}
	}
}
int main()
{
	dabiao();
	int n;
	while(scanf("%d",&n)==1){
		printf("%d\n",sum[n]);
	}
}

Measured memory_bytes: 7416
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**5)

n, m = list(map(int, input().split()))
v = [-1]*(n+1)
adj = [[] for _ in range(n+1)]
for _ in range(m):
    i, j = list(map(int, input().split()))
    adj[i].append(j)
    
def dfs(vi):
    if v[vi] != -1:
        return v[vi]
    res = 0
    for nb in adj[vi]:
        res0 = dfs(nb) +1
        if res < res0:
            res = res0
    v[vi] = res
    return res

ans = 0
for node in range(1, n+1):
    current = dfs(node)
    if current > ans:
        ans = current
print(ans)

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

int main(){
  string s;
  cin >> s;
  if (s[0]==s[1] && s[2]==s[3] && s[2]!=s[1]){
    cout << "Yes" <<endl;
  }else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
    cout << "Yes" <<endl;
  }else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*input
3 998244353
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int>pii;
const int maxn = 5050;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k, MOD, change[maxn];
void add(int &a, int b)
{
	a += b;
	if(a >= MOD)
		a -= MOD;
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> MOD;
	
	k = (n - 1) / 2;
	change[0] = 0;
	for(int i = 1; i <= k; i++)
		change[i] = -i;
	if(n % 2 == 0)
		change[k + 1] = -k;
	int cur = -k;
	for(int i = k + (n % 2 == 0) + 1; i <= n; i++)
	{
		++cur;
		change[i] = cur;
	}

	sort(change, change + n + 1);

	vector<int>dp(n + 1);
	for(int i = 0; i <= n - 1; i++)
		dp[i] = 1;

	int ans = 0;
	for(int i = 0; i < n - 2; i++)
	{
		vector<int>new_dp(n + 1);
		for(int opsbal = 0; opsbal <= n; opsbal++)
		{
			if(opsbal - change[i] + 1 <= n)
				add(dp[opsbal - change[i] + 1], dp[opsbal]);
			add(new_dp[opsbal], dp[opsbal]);
		}
		dp = new_dp;
	}
	for(int opsbal = 0; opsbal <= n; opsbal++)
		add(ans, 1ll * dp[opsbal] * (n - opsbal) % MOD);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        solve2582();
    }

    public static void solve2582() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            String[] step = new String[n];
            for (int i = 0; i < n; i++){
                step[i] = sc.next();
            }
            int ans = 0;
            n = n % 2 == 0 ? n : n-1;
            for(int i = 0;i < n; i = i + 2){
                if(step[i].charAt(0) != step[i+1].charAt(0)){
                    ans++;
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 37460
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int n,k;
    string s;
    cin >> n >> s >> k;
    for(int i=0;i<n;i++){
        if(s.at(i)!=s.at(k-1)){
            s.at(i) = '*';
        }
    }
    cout<< s << endl;
}

Measured memory_bytes: 256
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
b=[ab[i][1] for i in range(n)]
b.sort(reverse=True)
cnt=0
ab.sort(key=lambda x:x[0],reverse=True)
k=0
while k<n and ab[0][0]<b[k] and h>0:
  h-=b[k]
  k+=1
  cnt+=1
if h>0:
  cnt+=(h+ab[0][0]-1)//ab[0][0]
print(cnt)

Measured memory_bytes: 29996
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int a[5];
int mod[5];

int main() {
    rep(i, 5)cin >> a[i];

    int modmi = INF;
    int ix = 0;

    rep(i, 5) {
        mod[i] = a[i] % 10;
        if (mod[i] != 0&&mod[i]<=modmi) {
            modmi = min(modmi, mod[i]);
            ix = i;
        }
    }

    int sum = 0;
    rep(i, 5) {
        if (mod[i]!=0&&i != ix)a[i] += 10 - mod[i];
        sum += a[i];
    }
    cout << sum << endl;
}

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

int a,b,c,d,e,f;
double dp[3005][3005];

double solve(int water, int rem)
{
	if(rem==0) return double(f-water)/(double)f;
	else if(dp[water][rem]>-0.5) return dp[water][rem];
	else
	{
		int sugar=f-rem-water;
		double ret=0;
		if(f!=rem) ret=(double)(sugar)/(double)(f-rem);
		//double ret=(double)sugar/(double)(f-rem);
		if(a<=rem) ret=max(ret,solve(water+a,rem-a));
		if(b<=rem) ret=max(ret,solve(water+b,rem-b));
		if(sugar+c<=e*water/100 && c<=rem) ret=max(ret,solve(water,rem-c));
		if(sugar+d<=e*water/100 && d<=rem) ret=max(ret,solve(water,rem-d));
		// cout<<water<<" "<<rem<<" "<<ret<<endl;
		return dp[water][rem]=ret;
	}
}

int main()
{
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	for(int i=0; i<3005; i++)
		for(int j=0; j<3005; j++)
			dp[i][j]=-1;
	double mx=solve(0,f);
	// cout<<mx<<endl;
	int l=0,r=f;
	double rat=-1;
	while(fabs(rat-mx)>1e-7)
	{
		if(a<=r && fabs(solve(l+a,r-a)-mx)<1e-7)
		{l+=a;r-=a;}
		if(b<=r && fabs(solve(l+b,r-b)-mx)<1e-7)
		{l+=b;r-=b;}
		int sugar=f-r-l;
		if(sugar+c<=e*l/100 && c<=r && fabs(solve(l,r-c)-mx)<1e-7)
			r-=c;
		if(sugar+d<=e*l/100 && c<=r && fabs(solve(l,r-d)-mx)<1e-7)
			r-=d;
		rat=(double)(f-r-l)/(double)(f-r);
		// cout<<l<<" "<<r<<" "<<mx<<" "<<rat<<endl;
	}
	cout<<(f-r)<<" "<<(f-r-l)<<endl;
}

Measured memory_bytes: 70784
w,h,n=map(int,input().split())
o=[0,0]
c=[w,h]
for _ in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    o[0]=x if o[0]<x else o[0]
  elif a==2:
    c[0]=x if c[0]>x else c[0]
  elif a==3:
    o[1]=y if o[1]<y else o[1]
  else:
    c[1]=y if c[1]>y else c[1]
if o[0]<c[0] and o[1]<c[1]:
  print((c[0]-o[0])*(c[1]-o[1]))
else:
  print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
int main()
{
    int a[1009],n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<=k;i++) sum+=a[i];
    cout<<sum;
}



Measured memory_bytes: 3600
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
 
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x <= 3) {
        ans += 100000 * (4 - x);
    }
    if (y <= 3) {
        ans += 100000 * (4 - y);
    }
    if (x == 1 && y == 1) {
        ans += 400000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void) {
  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += 1 + (D - 1) / a;
  }
  cout << ans << endl;

}

Measured memory_bytes: 3640
#include <stdio.h>
#define N 100
int main()
{
  int yousu,haire[N],bunki,i,cou=0,hokan=0;
  scanf("%d",&yousu);
  for(i=0;i<yousu;i++)
    {
      scanf("%d",&haire[i]);
    }
  bunki=1;
  while(bunki==1)
    {
      bunki=0;
      for(i=yousu-1;i>=1;i--)
	{
	  if(haire[i]<haire[i-1])
	    {
	      hokan=haire[i];
	      haire[i]=haire[i-1];
	      haire[i-1]=hokan;
	      cou++;
	      bunki=1;
	    }
	  //cou++;
	}
      
    }
  for(i=0;i<yousu;i++)
    {
      if(i<yousu-1)
	{
	  printf("%d ",haire[i]);
	}
      else
	{
	  printf("%d",haire[i]);
	}
    }
  printf("\n");
  printf("%d\n",cou);
  return 0;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        
        if(k%2!=0){
            System.out.println((k/2+1)*(k/2));
        }else{
            System.out.println((k/2)*(k/2));
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int n; cin >> n;
  int cnt = 0;
  F0R (_, n) {
    int a, b; cin >> a >> b;
    if (a == b) {
      if (++cnt == 3) {
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      cnt = 0;
    }
  }
  cout << "No" << endl;
  
  return 0;
}


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

int main()
{
    ll K, X;
    cin >> K >> X;
    ll min = X - K + 1;
    ll max = X + K -1;
    for(ll i = min; i <= max; ++i) cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256