akhauriyash/Code-Regression huggingface dataset:
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int n,s;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	int x=n;
	while(x>0)
	{
		int l=x%10;
		x/=10;
		s+=l;
	}
	if (n%s==0) cout<<"Yes"; else cout<<"No";
	return 0;
}


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

const int MAXN = 1e5+5;
const int inf = (1<<30);

int n, a[MAXN], ans;
int g = 0, endd = -1;

int ct(int x) {
    if (x == 1)
        return 0;
    return 1 + ct((x+1)/2);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans += ct(a[i]);
    }

    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            int x = ct(a[i]);
            endd = x;
        } else {
            int x = ct(a[i]);
            if ((1<<x) == a[i])
                g += min(x, endd), endd = x;
            else {
                if (x-1 >= endd)
                    g += endd, endd = x;
                else
                    g += x, endd = x-1;
            }
        }
    }

    cout << ans - g << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        /**           入力                    **/
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //キー入力を取得
        String line = br.readLine();//1列目を取得
        String aInput[] = null;
        aInput = line.split(" ");
        //デバッグ
//        for(String aTxt : aInput) {
//          System.out.println(aTxt);
//        }
        
        /********** ここから問題 ********/
        /**           定数                    **/
        int nN = Integer.parseInt(aInput[0]);
        int nY = Integer.parseInt(aInput[1])/1000;

        final int Cst1000 = 1;
        final int Cst5000 = 5;
        final int Cst10000 = 10;
        
        /**           変数                    **/
        int nAns1000  = 0;
        int nAns5000  = 0;
        int nAns10000 = 0;
        boolean bEnd = false;
        
        /**           処理                    **/
        for(int nLp10 = 0; nLp10 <= nN; nLp10++) {
            for(int nLp5 = 0; nLp5 <= nN-nLp10; nLp5++) {
                for(int nLp1 = 0; nLp1 <= nN-nLp10 - nLp5; nLp1++) {
            if(nLp1 + nLp5 + nLp10 == nN && nLp1 * Cst1000 + nLp5 * Cst5000 + nLp10 * Cst10000 == nY) {
                nAns1000  = nLp1;
                nAns5000  = nLp5;
                nAns10000 = nLp10;
                bEnd = true;
                break;
            }
            if( (nN) * Cst10000 < nY) {
                bEnd = false;
                break;
            }
        }
            }
        }
        
        
        /**           出力                    **/
        if(bEnd) {
          System.out.println(nAns10000 + " " + nAns5000 + " " + nAns1000);
        } else {
          System.out.println("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(void){
  int n,x;
  int sum=0;
  int i,j,k;
  while(1){
    sum = 0;
    scanf("%d %d",&n,&x);
    if(n==0&&x==0)return(0);
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x&&i!=j&&j!=k&&k!=i){
	    sum++;
	  }
	}
      }
    }
    printf("%d\n",sum);
  }
  return(0);
}

Measured memory_bytes: 1848
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABX = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = ABX[0];
            int B = ABX[1];
            int X = ABX[2];
            if (A > X || A + B < X)
            {
                Console.WriteLine("NO");
                return;
            }
            Console.WriteLine("YES");
        }
    }
}

Measured memory_bytes: 13396
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(ll i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define pi 3.1415926535897932384626433832795028841971
#define mem(a,b) memset(a , b , sizeof a ) ;
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
//cout<<fixed<<setprecision(15);
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
void solve()
{
	char c;
	cin>>c;
	if(c<='Z')cout<<"A";
	else
		cout<<"a";
}
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/




Measured memory_bytes: 3644
#include<iostream>
#include<vector>

using namespace std;
using ll = long long;

const ll mod = 1000000007;

int main() {
	ll a, b;
	cin >> a >> b;
	if (abs(a - b) > 1) {
		cout << 0 << endl;
		return 0;
	}
	if (a == b) {
		ll ans = 2;
		for (ll i = 1; i <= a; i++) {
			ans *= i;
			ans %= mod;
		}
		for (ll i = 1; i <= b; i++) {
			ans *= i;
			ans %= mod;
		}
		cout << ans << endl;
		return 0;
	}
	else {
		ll ans = 1;
		for (ll i = 1; i <= a; i++) {
			ans *= i;
			ans %= mod;
		}
		for (ll i = 1; i <= b; i++) {
			ans *= i;
			ans %= mod;
		}
		cout << ans << endl;
		return 0;
		
	}

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a * 100 + b * 10 + c) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(input())
s=input()
c=Counter(s)

ans=c['R']*c['G']*c['B']

lim=n//2
for i in range(1,n//2+1):
  for j in range(i,n-i):
    l=s[j-i]
    m=s[j]
    r=s[j+i]
    if l!=m and m!=r and r!=l:
      ans-=1

print(ans)

Measured memory_bytes: 9404
(defparameter +white_char+ #\.)
(defparameter +black_char+ #\#)

(defparameter *H* (read))
(defparameter *W* (read))
(defparameter *squares* (make-array (list *H* *W*)))

(dotimes (h *H*)
  (dotimes (w *W*)
    (setf (aref *squares* h w) (read-char)))
  ; 改行を空読み
  (read-char))

(defparameter *display* (make-array (list *H* *W*) :initial-element t))

; すべてが+black_char+でない行のマスに、フラグを付ける
(dotimes (h *H*)
  (let ((f t))
    (dotimes (w *W*)
      (if (equal (aref *squares* h w) +black_char+)
        (setf f nil)))
    (if f
      (dotimes (w *W*)
        (setf (aref *display* h w) nil)))))
; 列も同じく
; XXX: どうまとめれば良いかわからない
(dotimes (w *W*)
  (let ((f t))
    (dotimes (h *H*)
      (if (equal (aref *squares* h w) +black_char+)
        (setf f nil)))
    (if f
      (dotimes (h *H*)
        (setf (aref *display* h w) nil)))))

; フラグをもとに表示
(dotimes (h *H*)
  (dotimes (w *W*)
    (if (aref *display* h w)
      (princ (aref *squares* h w))))
  (fresh-line))


Measured memory_bytes: 19688
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int collatz(int n){
	if(n==1) return 0;
	if(n&1) return 1+collatz(3*n+1);
	else return 1+collatz(n/2);
}
int32_t main(){
	int n;cin>>n;if(n<=2)cout<<4;else cout<<collatz(n)+2;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
an=0
before=0

for i in a:
    an+=b[i-1]

for j in range(n-1):
    if a[j]==(a[j+1]-1):
        an+=c[a[j]-1]

print(an)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[20005];
ll a[1005];
ll b[1005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    ll ans=999999999;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<=20004;i++)
      dp[i]=999999999;
    for(int i=1;i<=n;i++)
    {

        for(int j=a[i];j<=h+10000;j++)
        {

            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    for(int i=h;i<=h+10000;i++)
    {

        ans=min(ans,dp[i]);
    }


    cout<<ans<<'\n';


}
















Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000007;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    static ll n;
    static ll t[100010];
    static ll a[100010];
    static ll h[100010];
    static ll H[100010];
    scanf("%lld", &n);
    rep(i, n) scanf("%lld", &t[i]);
    rep(i, n) scanf("%lld", &a[i]);

    rep(i, 100010) {
        h[i] = -1;
        H[i] = 1000000000;
    }
    int x = -1;
    rep(i, n) {
        if (x < t[i]) {
            h[i] = t[i];
            x = t[i];
        } else
            H[i] = t[i];
    }
    x = -1;
    rrep(i, n) {
        if (x < a[i]) {
            if (h[i] != -1 && h[i] != a[i]) {
                puts("0");
                return 0;
            }
            h[i] = a[i];
            x = a[i];
        } else
            H[i] = min(H[i], a[i]);
    }

    ll ret = 1;
    rep(i, n) {
        if (h[i] > H[i]) {
            puts("0");
            return 0;
        }
        if (h[i] == -1) {
            ret *= H[i];
            ret %= M;
        }
    }
    cout << ret;

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 3328
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N=int(input())
print(l[N-1])


Measured memory_bytes: 3316
#include<iostream>
#include <cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[200005];
long long b[200005];
int main(){
	long long n;
	long long sum1=0;
	long long sum=0;
	long long temp=0;
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	for(int i=0;i<n-1;i++){
		//b[i]用来存结果
		sum1+=a[i];
		temp=sum-sum1;
	//	cout<<"sum1="<<sum1<<endl;
	//	cout<<"temp="<<temp<<endl;
		
		b[i]=abs(sum1-temp);
//		cout<<"b["<<i<<"]="<<b[i]<<endl;
		
		
	}
	sort(b,b+n-1);
//	for(int i=0;i<n-1;i++)
//	{
//	cout<<"b["<<i<<"]="<<b[i]<<endl;
//	}
	printf("%lld",b[0]);
	return 0;
} 


Measured memory_bytes: 3328
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        long k = scan.nextLong();
 
        Pair[] p = new Pair[(int) n];
        for (int i = 0; i < n; i++) {
            p[i] = new Pair(scan.nextLong(), scan.nextLong());
        }
        Arrays.sort(p);
        long place = 0;
        for (int i = 0; i < n; i++) {
            place += p[i].times;
            if (place >= k) {
                System.out.println(p[i].num);
                break;
            }
        }
    }
}
 
class Pair implements Comparable<Pair> {
    long times, num;
 
    public Pair(long a, long b) {
        num = a;
        times = b;
    }
    @Override
    public int compareTo(Pair o) {
        return (int)(this.num - o.num);
    }
}

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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;




int main() {
	int X;cin>>X;
	int K;cin>>K;
	vector<int>rs(K+1);
	vector<int>as(K+1),bs(K+1,X);

	int pre=0;
	int a=0;
	int b=0;
	
	for (int i = 0; i < K; ++i) {
		cin>>rs[i+1];
		
	}
	vector<int>mins(K+1);
	vector<int>maxs(K+1,X);
	for (int i = 0; i < K; ++i) {
		int sa = rs[i+1]-rs[i];

		if (i % 2 == 0) {
			mins[i + 1] = max(0, mins[i] - sa);
			maxs[i+1]=max(0,maxs[i]-sa) ;
		}
		else {
			maxs[i + 1] = min(X, maxs[i] + sa);
			mins[i+1]=min(X,mins[i]+sa);
		}
	}
	for (int i = 0; i < K; ++i) {
		int sa = rs[i + 1] - rs[i];

		if (i % 2 == 0) {
			int yoyuu=mins[i];
			as[i+1]=as[i]+max(0,sa-yoyuu);
			bs[i+1]=bs[i];
			as[i+1]=min(as[i+1],bs[i+1]);
		}
		else {
			int yoyuu=X-maxs[i];
			as[i+1]=as[i];
			bs[i + 1] = bs[i]-max(0,sa-yoyuu);
			bs[i+1]=max(bs[i+1],as[i+1]);
		}
	}

	int Q;cin>>Q;
	while (Q--) {
		int t,a;cin>>t>>a;
		auto it=prev(upper_bound(rs.begin(),rs.end(),t));

		int x=it-rs.begin();
		int dif=t-*it;

		bool flag=x%2;

		int ans=-1;

		int d;
		if (a < as[x]) {
			d=mins[x];
		}
		else if (a < bs[x]) {
			d=mins[x]+(a-as[x]);
		}
		else {
			d=maxs[x];
		}
		ans=x%2?(d+dif):(d-dif);
		ans=max(0,min(X,ans));
		cout<<ans<<endl;
	}

	return 0;
} 

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


int main (){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll asset = 1000;
  ll stock = 0;
  
  rep(i, n-1){
    if(a[i] < a[i+1]){
      ll add = asset / a[i];
      stock += add;
      asset -= a[i] * add;
    }if(a[i] > a[i+1]){     
      if(a[i-1] <= a[i]){
        asset += a[i] * stock;
        stock = 0;
      }  
    }
  }
  asset += a[n-1] * stock;
  
  cout << asset << endl; 
  
  return 0;
}

Measured memory_bytes: 3528
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[1001][200];
int L[200][200];
int S[200][200];
char str[2];
int z[1000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				L[i][j]=S[i][j]=111111111;
		for(int i=0;i<a;i++)L[i][i]=S[i][i]=0;
		for(int i=0;i<b;i++){
			int c,d,e;
			scanf("%d%d%d%s",&c,&d,&e,str);
			c--;d--;
			if(str[0]=='S')S[c][d]=S[d][c]=min(S[c][d],e);
			else L[c][d]=L[d][c]=min(L[c][d],e);
		}
		for(int k=0;k<a;k++)
			for(int i=0;i<a;i++)
				for(int j=0;j<a;j++){
					L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
					S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
				}
		int r;
		scanf("%d",&r);
		for(int i=0;i<r;i++)
			for(int j=0;j<a;j++)
				dp[i][j]=2111111111;
		for(int i=0;i<r;i++){scanf("%d",z+i);z[i]--;}
		dp[0][z[0]]=0;
		for(int i=0;i<r-1;i++){
			for(int j=0;j<a;j++){
				if(dp[i][j]>=2111111111)continue;
				if(L[z[i]][z[i+1]]<111111111)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+L[z[i]][z[i+1]]);
				for(int k=0;k<a;k++){
					if(L[z[i]][j]<111111111&&S[j][k]<111111111&&L[k][z[i+1]]<111111111)dp[i+1][k]=min(dp[i+1][k],dp[i][j]+L[z[i]][j]+S[j][k]+L[k][z[i+1]]);
				}
			}
		}
		int ret=2111111111;
		for(int i=0;i<a;i++)ret=min(ret,dp[r-1][i]);
		printf("%d\n",ret);
	}
}

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

using namespace std;
int main (){
    int k,s;
    cin >> k >> s;
    int count=0;

    for (int i = 0; i <= k; i++){
        for (int j = 0; j <= k; j++){
            if(s-i-j<=k && 0<=s-i-j) count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
ll n,w,wgt[100],val[100];
const int size=100003;
int main()
{
    fastread;
    cin>>n>>w;
    for(ll i=0;i<n;i++)
    	cin>>wgt[i]>>val[i];
    ll dp[100][size];
    for(ll j=0;j<size;j++)
    	dp[0][j]=inf;
    dp[0][0]=0;
    dp[0][val[0]]=wgt[0];
    for(ll i=1;i<n;i++)
    {
    	for(ll j=0;j<size;j++)
    	{
    		dp[i][j]=dp[i-1][j];
    		dp[i][j]=min(dp[i-1][j],dp[i-1][max(0LL,j-val[i])]+wgt[i]);
    		if(dp[i][j]<0)
    		{
    			cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    		}
    	}
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<size;j++)
    	{
    		if(dp[i][j]<=w&&dp[i][j]<inf)
    		{
    			ans=max(ans,j);
    		}
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10, B = 16;

int val[N];
int dp[1 << B];

int solve(int bm) {
    if (!bm) return 0;
    if (dp[bm] != -1) return dp[bm];
    dp[bm] = INF;
    int ans = INF;
    for (int i = 0; i < B; i++) {
        if (!(bm & (1 << i))) continue;
        for (int j = i+1; j < B; j++) {
            if (!(bm & (1 << j)) ) continue;
            int nbm = bm ^ (1 << i) ^ (1 << j) ^ (1 << (i ^ j));
            bool b = bm & (1 << (i ^ j));
            ans = min(ans, solve(nbm) + 1 + b);
        }
    }
    return dp[bm] = ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int x, y, a; cin >> x >> y >> a;
        val[x] ^= a;
        val[y] ^= a;
    }
    int ans = 0;
    int bm = 0;
    for (int i = 0; i < n; i++) {
        if (!val[i]) continue;
        if (bm & (1 << val[i])) ans++;
        bm ^= 1 << val[i];
    }
    memset(dp, -1, sizeof dp);
    cout << ans + solve(bm) << nl;
    return 0;
}


Measured memory_bytes: 896
<?php


fscanf(STDIN, "%d", $n);
$ans = 1000000000000000;
for($i=1;$i<=(sqrt($n) + 1);$i++){
    if($n%$i==0){
        $ans = min($ans, ($i-1) + ($n/$i - 1));
    }
}

echo $ans;

Measured memory_bytes: 4856
# Aizu Problem 0062: What is the Bottommost
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    try:
        A = [int(_) for _ in input().strip()]
    except EOFError:
        break
    for _ in range(9):
        A = [(A[i]+A[i+1]) % 10 for i in range(len(A) - 1)]
    print(A[0])

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

Measured memory_bytes: 592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        string A = cin.next();
        string B = cin.next();
        string C = cin.next();

        Console.WriteLine(A[0].ToString() + B[0].ToString() + C[0].ToString());
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2648
import java.util.*;

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

  private void run() {
    while(sc.hasNext()) {
      int[] as = new int[4];
      int[] bs = new int[4];

      for(int i = 0; i < 4; i++) as[i] = sc.nextInt();
      for(int i = 0; i < 4; i++) bs[i] = sc.nextInt();

      int hit = 0;
      int blow = 0;

      for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
          if(as[i] == bs[j]) {
            if(i == j) hit++;
            else blow++;
          }
        }
      }

      System.out.println(hit + " " + blow);
    }
  }

  private final Scanner sc = new Scanner(System.in);
}

Measured memory_bytes: 12000
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, N):
        self._data_size = N
        self._roots = [-1] * N

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def unite(self, x, y):
        x = self[x]
        y = self[y]
        if x == y:
            return
        elif self._roots[y] < self._roots[x]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x

    def is_connected(self, x, y):
        return self[x] == self[y]


def main():
    import sys

    read = sys.stdin.buffer.read

    N, Q, *TUV = map(int, read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 145288
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,a,b,c;cin>>n>>a>>b>>c;
    vector<int> l(n);
    rep(i,n) cin>>l[i];

    ll ans=LINF;
    for(ll bit=0;bit<(1<<(2*n));bit++){
        ll cost=0;
        ll la=0,lb=0,lc=0;


        ll tmp=bit;
        rep(i,n){
            ll x=tmp%2;
            tmp/=2;
            ll y=tmp%2;
            tmp/=2;
            if(x==0&&y==1){
                la+=l[i];
                cost+=10;
            }
            else if(x==1&&y==0){
                lb+=l[i];
                cost+=10;
            }
            else if(x==1&&y==1){
                lc+=l[i];
                cost+=10;
            }
        }
        if(la==0||lb==0||lc==0){
            continue;
        }
        cost-=30;
        cost+=abs(la-a)+abs(lb-b)+abs(lc-c);
        ans=min(ans,cost);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

int a,b,c,z,i;
z = 0;

scanf("%d %d %d",&a,&b,&c);

for(i=a; i<=b; i++){
if(c%i == 0){
z++;
}
}
printf("%d\n",z);

return 0;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		vector<vector<int>> v(31);
		for (int i = 0, f; i < n; i++) {
			cin >> f;
			for (int j = 0, d; j < f; j++) {
				cin >> d;
				v[d - 1].push_back(i);
			}
		}
		vector<vector<int>> dp(n, vector<int>(n));
		for (int i = 0; i < n; i++) {
			dp[i][i] = 1;
		}
		int res = -1;
		for (int i = 0; i <= 30; i++) {
			for (int k = 0; k < n; k++) {
				bool flag = true;
				for (int j = 0; j < n; j++) {
					if (dp[k][j] == 0) {
						flag = false;
						break;
					}
				}
				if (flag) {
					res = i;
					break;
				}
			}
			if (res != -1) {
				break;
			}
			if (v[i].size() > 1) {
				vector<int> su(n);
				for (auto m : v[i]) {
					for (int j = 0; j < n; j++) {
						su[j] = max(su[j], dp[m][j]);
					}
				}
				for (auto m : v[i]) {
					for (int j = 0; j < n; j++) {
						dp[m][j] = max(dp[m][j], su[j]);
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	O, E := getString(), getString()

	n := len(O) + len(E)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			fmt.Printf("%c", O[i/2])
		} else {
			fmt.Printf("%c", E[i/2])
		}
	}
	fmt.Println("")

}


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

int main() {
  int n,d;
  cin >> n >> d;
  int m = 1;
  while((2*d+1)*m < n)m++;
  cout << m << endl;
    return 0;    
}

Measured memory_bytes: 256
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

int main() {
    i64 x;
    cin >> x;
    i64 sum = 0;
    for (int i = 1; i < 1000000; ++i) {
        sum += i;
        if (sum >= x) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vector<int> a(5);
    cin >> a;
    sort(a.begin(), a.end());
    int ans = lim<int>::max();
    do {
        int t = 0;
        for(int i = 0; i < 5; i++) {
            t = (t + 9) / 10 * 10;
            t += a[i];
        }
        ans = min(ans, t);
    } while(next_permutation(a.begin(), a.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#else
#define DBG(expr)
#endif
#define UNREACHABLE() do { \
        cerr << "[Oops] UNREACHABLE: at line " << __LINE__ << endl; \
        __builtin_unreachable(); \
        exit(123); \
    } while (0)
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define T_FIRST(tuple) (std::get<0>(tuple))
#define T_SECOND(tuple) (std::get<1>(tuple))
#define T_THIRD(tuple) (std::get<2>(tuple))
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll a,b,t;
    cin >> a >> b >> t;
    ECHO(t / a * b)
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000];
int main()
{	for(rint i=1,now;i<=1e5;i++){now=i;while(now)a[i]+=now%10,now/=10;}
	int n,ans=1e9; cin>>n;
	for(rint i=1;i<n;i++) ans=min(ans,a[i]+a[n-i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define mp make_pair
#define pb push_back
const int mod = 1e9+7;

using namespace std;
ifstream fi("");
ofstream fo("");

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int a[n];
     for (int i=0;i<n;i++) cin>>a[i];
    int d=1;

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

        }

}





Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }


signed main() {
	int N, A, B; cin >> N >> A >> B;
	V v(N); input(v);
	int ans = 0;
	rep(i, 1, N) {
		ans += min((v[i] - v[i - 1]) * A, B);
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll n, k;
    cin >> k;
    queue<ll> lunlun;
    lunlun.push(1);
    lunlun.push(2);
    lunlun.push(3);
    lunlun.push(4);
    lunlun.push(5);
    lunlun.push(6);
    lunlun.push(7);
    lunlun.push(8);
    lunlun.push(9);
    ll now = 0;
    rep(i, 1, 11) {
        ll n = lunlun.size();
        REP(j, n) {
            if (lunlun.front() % 10 != 0) {
                lunlun.push(lunlun.front() * 10 + lunlun.front() % 10 - 1);
            }
            lunlun.push(lunlun.front() * 10 + lunlun.front() % 10);
            if (lunlun.front() % 10 != 9) {
                lunlun.push(lunlun.front() * 10 + lunlun.front() % 10 + 1);
            }
            now++;
            // cout << lunlun.front() << endl;
            if (now == k) {
                cout << lunlun.front() << endl;
                return 0;
            }
            lunlun.pop();
        }
    }
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
#define md 1000000007
#define MAX 200000
using namespace std;
typedef long long ll;

ll f1[MAX], f2[MAX];
void Setc(int n){
  f1[1] = 1;
  for(int i = 1; i <= n; i++) f1[i+1] = f1[i]*(i+1)%md;
  ll y = f1[n+1]; f2[n+1] = 1;
  for(int i = md-2; i; i/=2){
    if(i&1) f2[n+1] = f2[n+1]*y%md;
    y = y*y%md;
  }
  for(int i = n; i >= 0; i--) f2[i] = f2[i+1]*(i+1)%md;
}
ll comb(int n, int m){ return f1[n]*f2[n-m]%md*f2[m]%md;}	

int main(){
  int h, w, a, b;
  ll ans = 0;
  scanf("%d%d%d%d", &h, &w, &a, &b);
  Setc(h+w);
  ans += comb(h+w-2, w-1);
  for(; a > 0 && b > 0; a--, b--){
    ans = (ans + md - comb(h-a+b-1, b-1)*comb(w+a-1-b, w-b)%md)%md;
  }
  printf("%lld\n", ans);
}

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

using namespace std;

const int weight[10]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int INF = 1e5;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int min_A=-INF;
    for(int m=0; m<M; m++) {
        cin >> A[m];
        min_A = min(min_A, A[m]);
    }
    
    sort(A.begin(), A.end(), greater<int>());
    
    vector<int> dp(N+1, -INF);
    dp[0] = 0;
    
    for(int n=1; n<=N; n++) {
        for(int m=0; m<M; m++) {
            int A_w=weight[A[m]];
            if(n-A_w>=0 && dp[n-A_w]!=-INF) {
                dp[n] = max(dp[n-A_w]+1, dp[n]);
            }
        }
    }
    
    int count=N;
    while(count>0) {
        for(int m=0; m<M; m++) {
            int A_w=weight[A[m]];
            if(count-A_w>=0 && dp[count-A_w]+1==dp[count]) {
                cout << A[m];
                count -= A_w;
                break;
            }
        }
    }
    cout << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

int main()
{
    int A, B;
    cin >> A >> B;
    vector<int> valueA(2, 0), valueB(2, 0); // [0]: min, [1]: max

    //valueA[0] = static_cast<int>(ceil(A * 100.0 / 8.0));
    valueA[0] = A * 100 / 8;
    while(static_cast<int>(valueA[0] * 0.08) != A) {
        ++valueA[0];
    }
    valueA[1] = valueA[0];
    while(static_cast<int>(valueA[1] * 0.08) == A) {
        ++valueA[1];
    }
    --valueA[1];

    //valueB[0] = static_cast<int>(ceil(B * 10.0));
    valueB[0] = B * 10;
    while(static_cast<int>(valueB[0] * 0.1) != B) {
        ++valueB[0];
    }
    valueB[1] = valueB[0];
    while(static_cast<int>(valueB[1] * 0.1) == B) {
        ++valueB[1];
    }
    --valueB[1];

    if ((valueA[0] > valueB[1]) || (valueB[0] > valueA[1])) {
        cout << -1 << endl;
        return 0;
    }
    int ans = max(valueA[0], valueB[0]);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		1000

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//int dp[MAX];

int main(){
	int N;cin>>N;
	cout << "AB";
	if(N<1000)cout<<"C"<<endl;
	else cout << "D"<<endl;
	return 0;
}

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

sum_min = 10000000
for i in range(1,N):
	A = i
	B = N-i
	sum_A = sum(list(map(int,list(str(A)))))
	sum_B = sum(list(map(int,list(str(B)))))
	if sum_min > sum_A+sum_B:
		sum_min = sum_A+sum_B

print(sum_min)


Measured memory_bytes: 3060
def putnum(arr, i, j):
    i_l = i-1 if i-1 >= 0 else 50
    j_l = j-1 if j-1 >= 0 else 50
    try: arr[i_l][j_l] += 1
    except: pass
    try: arr[i_l][j] += 1
    except: pass
    try: arr[i_l][j+1] += 1
    except: pass
    try: arr[i][j_l] += 1
    except: pass
    try: arr[i][j+1] += 1
    except: pass
    try: arr[i+1][j_l] += 1
    except: pass
    try: arr[i+1][j] += 1
    except: pass
    try: arr[i+1][j+1] += 1
    except: pass

h, w = map(int, input().split())
fie = [[0]*w for _ in range(h)]
for i in range(h):
    for j, c in enumerate(list(input())):
        if c=="#": fie[i][j]=9

for i in range(h):
    for j in range(w):
        if fie[i][j] >= 9: putnum(fie, i, j)

for i in fie:
    i = list(map(str, map(lambda x:min(9,x), i)))
    print("".join(i).replace("9", "#"))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;

    int now = 0;
    for (int i = 1; i <= t; i++)
        if (i % a == 0)
            now += b;
    cout << now;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef double ll;
int main()
{
	int n;
	cin>>n;
	ll p[n];
	for(int i=0;i<n;i++)
	cin>>p[i];
	ll dp[n+1][n+1];
	dp[1][1]=p[0];
	dp[1][0]=1-p[0];
	for(int i=2;i<=n;i++)
	dp[i][0]=dp[i-1][0]*(1-p[i-1]);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
	}
	ll sum=0;
	for(int i=n/2+n%2;i<=n;i++)
	sum+=dp[n][i];
	cout<<setprecision(10)<<sum;
	return 0;
}


Measured memory_bytes: 69888
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

m, d = MAP()

# print(d1)
# print(l)
count = 0
for i in range(1, m+1):
    for j in range(1, d+1):
        if j >= 20:
            d1 = j % 10
            d10 = j // 10
            # print(d1)

            if d1 >= 2:
                # print("d1:"d1)
                
                if d1 * d10 == i:
                    count += 1

        # if d1 >= 2:
        #     if d10 >= 2:
        #         if d1 * d10 == m:
        #             count += 1


print(count)

Measured memory_bytes: 5324
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
const int MAXN = 1e5+5;
int N, a[MAXN];
vi wn[MAXN];
int f(int v){
    int ret = wn[v].size();
    vi ds;
    for(int u:wn[v]){
        ds.pb(f(u));
    }
    sort(all(ds), greater<int>());
    FOR(i,0,ds.size()){
        mxze(ret, ds[i]+i+1);
    }
    return ret;
}

int main(){
    scan(N);
    FOR(i,1,N) scan(a[i]), a[i]--, wn[a[i]].pb(i);
    printf("%d\n",f(0));
}


Measured memory_bytes: 15488
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    string s;
    cin >> s;
    if (s == "ABC") printf("ARC\n");
    else printf("ABC\n");
    return 0;
}


Measured memory_bytes: 3132