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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;

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

  vector<ll> b(5);
  for(i=0;i<n;i++){
    switch(a[i][0]){
      case 'M':b[0]++;
      break;
      case 'A':b[1]++;
      break;
      case 'R':b[2]++;
      break;
      case 'C':b[3]++;
      break;
      case 'H':b[4]++;
      break;
    }
  }
  //cout<<b[0] spa b[1] spa b[2] spa b[3] spa b[4]<<endl;
  vector<ll> c ={0,0,1,1,1};
  do{
    buf = 1;
    for(i=0;i<5;i++){
      if(c[i]==1)buf*=b[i];
      //cout<<buf<<endl;
    }
    result+=buf;
  }while(next_permutation(ALL(c)));
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(s==u)a--;
	if(t==u)b--;
	cout<<a<<" "<<b;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
int N,M,K;
vector<int> G[3000];
vector<P> es;
int d[3000],use[30000]; 
int dfs(int x,int k){
	for(int i=x;i<M;i++){
		int a=es[i].fs,b=es[i].sc;
		if(use[a]!=1&&use[b]!=1){
			if(k==0) return -1;
			if(d[a]<d[b]) swap(a,b);
			int best=-1;
			//use a
			if(use[a]<0){	//use[a]==-1
				use[a]=1;
				vector<int> vc;
				for(int v:G[a]){
					if(use[v]<0){
						vc.pb(v);
						d[v]--;
					}
				}
				chmax(best,dfs(x+1,k-1));
				for(int v:vc) d[v]++;
				use[a]=-1;
			}
			//not use a
			if(d[b]>1){
				use[a]=0;
				vector<int> vc;
				int nk=k;
				for(int v:G[a]){
					//assert(use[v]!=0);
					if(use[v]!=1){
						use[v]=1;
						nk--;
						vc.pb(v);
						d[v]--;
					}
				}
				chmax(best,dfs(x+1,nk));
				for(int v:vc) use[v]=-1,d[v]++;
				use[b]=-1;
			}
			return best;
		}
	}
	return k;
}
int main(){
	cin>>N>>M>>K;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].pb(b);
		G[b].pb(a);
		d[a]++,d[b]++;
		es.pb(P(a,b));
	}
	rep(i,N) use[i]=-1;
	rep(i,N) if(d[i]==0) use[i]=0;
	int k=K;
	while(true){
		int v=-1;
		rep(i,N) if(d[i]>k){
			v=i;break;
		}
		if(v<0) break;
		use[v]=1;
		for(int u:G[v]){
			if(d[u]) d[u]--;
		}
		d[v]=0;
		k--;
		if(k<0){
			puts("Impossible");
			return 0;
		}
	}
	int Mc=M;
	M=0;
	rep(i,Mc) if(use[es[i].fs]!=1&&use[es[i].sc]!=1) es[M++]=es[i];
	if(M>k*k){
		puts("Impossible");
		return 0;
	}
	rep(v,N){
		int j=0;
		rep(i,G[v].size()){
			int u=G[v][i];
			if(use[v]!=1&&use[u]!=1) G[v][j++]=u;
		}
		G[v].resize(j);
	}
//	show(K);
//	show(k);
//	show(M);
	int ans=dfs(0,k);
	if(ans<0){
		puts("Impossible");
		return 0;
	}
	cout<<K-ans<<endl;
}

Measured memory_bytes: 1848
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i=1;i<=n;i++){
           map.put(i,0);
        }
        for(int i=0;i<n-1;i++){
            int an = sc.nextInt();
            int va = map.get(an);
            map.replace(an, va + 1);
        }
        for(int i=1;i<=n;i++){
            System.out.println(map.get(i));
        }
        sc.close();
    }
}

Measured memory_bytes: 62888
#include<stdio.h>
int main(void)
{
    int a,b,c[15],d[15],i,f;
	scanf("%d",&a);
	while(a!=0){
	    f=0;
	    scanf("%d",&b);
	    for(i=0;i<b;i++){
		    scanf("%d %d",&c[i],&d[i]);
		}
		for(i=0;i<b;i++){
		    f=f+(d[i]-c[i]);
		}
		if(f>=a) printf("OK\n");
		else if(f<a) printf("%d\n",a-f);
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << ", ";
#define ll long long
#define pb push_back
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int INF = 1e9 + 7;

int main()
{
    FAST_IO
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(n, vector<ll>(W + 1, 0));
    for (int i = 0; i <= W; i++)
    {
        if (i >= w[0])
            dp[0][i] = v[0];
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i][j] = max(dp[i - 1][j], (j - w[i] >= 0 ? v[i] + dp[i - 1][j - w[i]] : 0));
        }
    }
    cout << dp[n - 1][W] << endl;
}


Measured memory_bytes: 79488
#include <stdio.h>
#define N 20000001
void CountingSort(int*,int*,int);

int n;
int A[N],B[N],C[N];
int main()
{
  int i,max;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    if(i==0){
      max = A[i];
    }
    if(A[i] > max){
      max = A[i];
    }
  }

  CountingSort(A,B,max);
  for(i=1;i<=n;i++){
    if(i==n){
      printf("%d\n",B[i]);
    }
    else printf("%d ",B[i]);
  }
}

void CountingSort(int *A,int *B,int k){
  int i,j;
  for(i=0;i<=k;i++){
    C[i] = 0;
  }
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
 
  for(i=1;i<=k;i++){
    C[i] = C[i]+C[i-1];
  }
 
  for(j=n-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}
  



Measured memory_bytes: 17412
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
#define pii pair<int,int>
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int INF = 1e7;

namespace NetFlow
{
	const int N = 2e5+2;
	const int M = 4e5;
	struct Edge
	{
		int v,w,nxt,rev;
	} e[(M<<1)+3];
	int fe[N+3];
	int te[N+3];
	int dep[N+3];
	int que[N+3];
	int n,en,s,t;
	void addedge(int u,int v,int w)
	{
		en++; e[en].v = v; e[en].w = w;
		e[en].nxt = fe[u]; fe[u] = en; e[en].rev = en+1;
		en++; e[en].v = u; e[en].w = 0;
		e[en].nxt = fe[v]; fe[v] = en; e[en].rev = en-1;
	}
	bool bfs()
	{
		for(int i=1; i<=n; i++) dep[i] = 0;
		int head = 1,tail = 1; que[1] = s; dep[s] = 1;
		while(head<=tail)
		{
			int u = que[head]; head++;
			for(int i=fe[u]; i; i=e[i].nxt)
			{
				int v = e[i].v;
				if(e[i].w>0 && dep[v]==0)
				{
					dep[v] = dep[u]+1;
					if(v==t) return true;
					tail++; que[tail] = v;
				}
			}
		}
		return false;
	}
	int dfs(int u,int cur)
	{
		if(u==t||cur==0) {return cur;}
		int rst = cur;
		for(int &i=te[u]; i; i=e[i].nxt)
		{
			int v = e[i].v;
			if(e[i].w>0 && rst>0 && dep[v]==dep[u]+1)
			{
				int flow = dfs(v,min(rst,e[i].w));
				if(flow>0)
				{
					e[i].w -= flow;	
					rst -= flow;
					e[e[i].rev].w += flow;
					if(rst==0) {return cur;}
				}
			}
		}
		if(rst==cur) {dep[u] = -2;}
		return cur-rst;
	}
	int dinic(int _n,int _s,int _t)
	{
		n = _n,s = _s,t = _t;
		int ret = 0;
		while(bfs())
		{
			for(int i=1; i<=n; i++) te[i] = fe[i];
			memcpy(te,fe,sizeof(int)*(n+1));
			ret += dfs(s,INF);
		}
		return ret;
	}
}
using NetFlow::addedge;
using NetFlow::dinic;

const int N = 1e5;
vector<int> adj[(N<<1)+3];
vector<pair<int,pii> > ans;
int mch[(N<<1)+3];
bool vis[(N<<1)+3];
int que[N+3];
int n;

bool bfs()
{
	int hd = 1,tl = 1; que[1] = 1; vis[1] = true;
	while(hd<=tl)
	{
		int u = que[hd]; hd++;
		for(int o=0; o<adj[u].size(); o++)
		{
			int v = adj[u][o]; if(vis[v]) continue;
			if(vis[mch[v]]) continue;
			que[++tl] = mch[v]; vis[v] = vis[mch[v]] = true;
			ans.push_back(mkpr(v,mkpr(u,mch[v])));
		}
	}
	if(tl<n) {return false;}
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) addedge(1,i+2,1);
	for(int i=n+1; i<n+n; i++) addedge(i+2,2,1);
	for(int i=1; i<n; i++)
	{
		int sz; scanf("%d",&sz);
		while(sz--)
		{
			int x; scanf("%d",&x); adj[i+n].push_back(x); adj[x].push_back(i+n);
			if(x!=1) {addedge(x+2,i+n+2,1);}
		}
	}
	if(dinic(n+n+1,1,2)<n-1) {puts("-1"); return 0;}
	for(int u=3; u<=n+2; u++)
	{
		for(int i=NetFlow::fe[u]; i; i=NetFlow::e[i].nxt)
		{
			int v = NetFlow::e[i].v; if(v<=n+2) continue;
			if(NetFlow::e[i].w==0)
			{
				mch[u-2] = v-2,mch[v-2] = u-2;
				break;
			}
		}
	}
//	printf("match: "); for(int i=1; i<=n+n-1; i++) printf("%d ",mch[i]); puts("");
	if(!bfs()) {puts("-1"); assert(0); return 0;}
	sort(ans.begin(),ans.end());
	for(int i=0; i<ans.size(); i++) printf("%d %d\n",ans[i].second.first,ans[i].second.second);
	return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxd = 7;
int dp[maxd][10][10][2]; VI digit;

int dfs(
    const int i, const int j, const int k, const int d1, const int d2,
    const bool limit)
{
    if (i < 0)
        return j == d1 && k == d2;
    int& ans = dp[i][j][k][limit];
    if (-1 == ans) {
        ans = 0;
        const int last = limit ? digit[i] : 9;
        FOR(d,0,last+1) {
            if (!j) {
                if (d == 0 || d == d1)
                    ans += dfs(i-1,d,d,d1,d2, limit && (d==last));
            }
            else {
                ans += dfs(i-1,j,d,d1,d2, limit && (d==last));
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        digit.clear(); int x = n;
        while (x) {
            digit.push_back(x%10);
            x /= 10;
        }
        while (digit.size() < 9)
            digit.push_back(0);
        int ans = 0;
        FOR(i,1,n+1) {
            x = i; VI A;
            while (x) {
                A.push_back(x%10);
                x /= 10;
            }
            memset(dp,-1,sizeof(dp));
            ans += dfs(maxd-1,0,0,A[0],A.back(),true);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import bisect
INF = 10**13
A, B, Q = map(int, input().split())
S = [int(input()) for a in range(A)]
T = [int(input()) for b in range(B)]
for q in range(Q):
    x = int(input())
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    Sq = [S[max(si-1, 0)], S[min(si, A-1)]]
    Tq = [T[max(ti-1, 0)], T[min(ti, B-1)]]
    ans = float('inf')
    for i in range(2):
        for j in range(2):
            s = Sq[i]
            t = Tq[j]
            if (s < x and t < x) or (x < s and x < t):
                xs, tx = abs(x-s), abs(x-t)
                ans = min(ans, max(xs, tx))
            else:
                xs, tx = abs(s-x), abs(t-x)
                ans = min(ans, min(xs, tx)*2 + max(xs, tx))

    print(ans)


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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}


int main() {
	string s; cin >> s;
	char t[110000];
	int N = s.length();
	for (int i = 0; i < N+1; i++) {
		if (i % 2 == 0)t[i] = '0';
		else t[i] = '1';
	}
	int su1 = 0, su2 = 0;
	for (int i = 0; i < N; i++) {
		if (t[i] != s[i])su1++;
		if (t[i + 1] != s[i])su2++;
	}
	cout << min(su2, su1);
}

Measured memory_bytes: 540
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}


int main() {
	int A, B;
	cin >> A >> B;
	int a = 1;
	int ans = 0;
	while (a < B) {
		a += A-1;
		ans++;
	}

	cout << ans << endl;
	return 0;
}

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

_x = int(input())


def chker(x):
    lower = x / 105
    upper = x / 100

    if lower.is_integer() or upper.is_integer():
        print(1)
    else:
        if int(lower) == int(upper):
            print(0)
        else:
            print(1)


chker(_x)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int N,X,i,c=1;

cin >> N >> X;
std::vector<int> L(N+1);

std::vector<int> D(N+1);
D[0]=0;

for(i=1;i<N+1;i++){
  cin >> L[i];

  D[i]=D[i-1]+L[i];

    if(D[i]>X){
    break;
    }
    else{
    c++;
    }


}

cout << c << endl;
}

Measured memory_bytes: 3620
s = input()

answer = 0
count = 0
for i in range(len(s)):
  if s[i] == "R":
    count += 1
    if i == len(s)-1 :
      if count > answer :
        answer = count  
  else :
    if count > answer :
      answer = count
    count = 0
  
print(answer)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  int n;
  cin >> n;
  vector<vint> F(n,vint(10));
  vector<vint> P(n,vint(11));
  rep(i,n){
    rep(j,10){
      cin >> F[i][j];
    }
  }
  
  rep(i,n){
    rep(j,11){
      cin >> P[i][j];
    }
  }
  vint now(10);
  ll ans = -1000000000000;
  rep1(i,1<<10){
    ll sum = 0;
    rep(j,10){
      if(i>>j&1)
        now[j] = 1;
      else
        now[j] = 0;
    }
    //rep(i,10) cout << now[i];
    //cout << endl;
    rep(j,n){
      int count = 0;
      rep(s,10){
        if(now[s] == 1 && now[s] == F[j][s]){
         count++;
        }
      }
      //cout << count << endl;
      sum += P[j][count];
      //cout << sum << endl;
    }
    if(ans < sum){
      ans = sum;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,j,k,l,m,n,a[10005],b[100005];
    char s[100005];
    map<int,int>mp;
    pair<int,int>p[200005];
    cin>>n;
    scanf("%s",s);
    int count=0;
    int count1=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')
        count++;
        else
        count1++;
    }
    if(count>count1)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll k, a = 0;
    cin >> k;
    for (ll i = 1; i < N; i++)
    {
        a = (a * 10 % k + 7) % k;
        if (!a)
            return cout << i, 0;
    }
    cout << -1;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
   int h, m, s, i;
   cin>>i;
   h=i/3600;
   m=(i-h*3600)/60;
   s=i-h*3600-m*60;
   cout <<h<<":"<<m<<":"<<s<< endl; 
   return 0;
}


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

const int INF=1e9+1;

int main() {
  int n,k; cin>>n>>k;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  vector<int> dp(n, INF);
  dp[0]=0;
  for (int i=1; i<n; i++) {
    for (int j=1; j<=k; j++) {
      if (i-j<0) continue;
      dp[i]=min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    k = f.read_int()

    a = 1
    ans = []
    for n in xrange(1,16):
        ans2 = []
        ma = 0
        nine = float('inf')
        for i in xrange(10**a-1,10**(a-1)-1,-1):
            si = str(i) + '9'*(n-a)
            sn = sum(map(int, list(si)))*1.0/int(si)
            if sn >= ma:
                j = n
                while j > 0 and si[j-1] == '9': j -= 1
                nine = min(n-j, nine)
                ans2.append(si)
                ma = sn
        a = n-nine+1
        ans += ans2[::-1]

    return "\n".join(ans[:k])


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6028
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back

using namespace std;
using ll=long long;
// using ll=int;

const ll mod = (ll)(1e9+7);

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;


int main(){

    /*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("myoutput.txt", "w", stdout);
    #endif
    */

    fast;
    ll t = 1;
    // cin >> t;
    while(t--){
        ll n; cin >> n;
        ll sum = 0;
        for(ll i = 1; i <= n; i++){
            for(ll j = 1; j <=n; j++){
                for(ll k = 1; k <= n; k++){
                    sum += __gcd(i, __gcd(j, k));
                }
            }
        }

        cout << sum << endl;
    }
    // cerr << (double)clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3688
program name
    implicit none
    integer(8):: n,m
    integer(8),allocatable:: a(:), b(:)
    integer(8):: i, mon

    read*, n,m
    allocate(a(n), b(n))
    do i=1,n
        read*, a(i), b(i)
    end do

    call double_merge_sort(a,b,1_8,n)

    mon=0
    do i=1,n
        mon=mon+a(i)*min(b(i),m)
        m=m-b(i)
        if (m <= 0) exit
    end do

    print*, mon
contains
subroutine swap(x,y)
    integer(8),intent(inout):: x,y
    integer(8):: t
    t=x;x=y;y=t
end subroutine


recursive subroutine double_merge_sort(a1,a2, fst, lst)
    integer(8),intent(inout):: a1(:), a2(:)
    integer(8),intent(in):: fst,lst
    integer(8):: mdl

    if (lst - fst < 2) then
        if (a1(fst) > a1(lst))then
            call swap(a1(fst), a1(lst))
            call swap(a2(fst), a2(lst))
        end if
        return
    end if

    mdl = (fst+lst)/2
    call double_merge_sort(a1,a2,fst,mdl)
    call double_merge_sort(a1,a2,mdl+1,lst)
    call double_merge(a1,a2,fst,mdl,lst)
end subroutine


subroutine double_merge(a1,a2,fst,mdl,lst)
    integer(8),intent(inout):: a1(:), a2(:)
    integer(8),intent(in):: fst,mdl,lst
    integer(8),allocatable:: t1(:),t2(:)
    integer(8):: li, ri, ti

    allocate(t1(lst-fst+1), t2(lst-fst+1))
    li = fst
    ri = mdl+1
    ti = 1

    do while (li <= mdl .and. ri <= lst)
        if (a1(li) <= a1(ri)) then
            t1(ti) = a1(li)
            t2(ti) = a2(li)
            li=li+1
        else
            t1(ti) = a1(ri)
            t2(ti) = a2(ri)
            ri=ri+1
        end if
        ti=ti+1
    end do

    if (li <= mdl) then
        t1(ti:) = a1(li:mdl)
        t2(ti:) = a2(li:mdl)
    else
        t1(ti:) = a1(ri:lst)
        t2(ti:) = a2(ri:lst)
    end if

    a1(fst:lst) = t1(:)
    a2(fst:lst) = t2(:)
    deallocate(t1)
    deallocate(t2)
end subroutine
end program name

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) A[i] = i+1;
  vector<int> P(n), Q(n);
  rep(i,n) cin >> P[i];
  rep(i,n) cin >> Q[i];
  int count = 0, a, b;
  do {
    count++;
    if (A == P) a = count;
    if (A == Q) b = count;
  } while (next_permutation(A.begin(), A.end()));
  int ans = fabs(a-b);
  cout << ans << endl;
  return 0;
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];  
  }
  
  map<int,int>mp;  
  for(int k=0;k<N;k++){
    int temp=A[k];
    for(int i=2;i*i<=temp;i++){
      int cnt=0;
      while(temp%i == 0){
        cnt++;
        temp/=i;
      }
      if(cnt>0) mp[i]=max(cnt,mp[i]);
    }
    if(temp !=1 ) mp[temp]=max(mp[temp],1);
  }
  long long M=1;
  
  for(auto it=mp.begin();it != mp.end();it++){
    for(int i=0;i<it->second;i++){
      M*=it->first;
      M%=MOD;
    }
  }
  //cout<<M<<endl;
  long long ans=0;
  for(int i=0;i<N;i++){
    ans=ans+M*modinv(A[i],MOD)%MOD;
    ans%=MOD;
    //cout<<M<<" "<<A[i]<<" "<<ans<<endl;
  }
  cout<<ans<<endl;

  return 0;
}





Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  sort(all(a));
  ll mi = a[0], ma = a[n-1];
  
  ll ans = 1000000009;
  for(ll i = mi; i <= ma; i++){  
    ll sum = 0;
    for(ll j = 0; j < n; j++){
      sum += pow(i - a[j], 2);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
	return 0;
}

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

int w, h;
string field[21]; // 文字を扱うのでstring型の配列を使うと便利です。

// 4近傍(上下左右)のときは次のような配列を用意すると便利
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

// 現在地(x,y)
void dfs(int x, int y){
    // 今いるところを'B'に置き換える
    field[y][x] = 'B';

    // 移動する4方向をループ
    for(int i=0 ; i < 4 ; i++ ){
        // x方向にdx[i], y方向にdy[i], 移動した場所を(mx,my)とする
        int mx = x + dx[i];
        int my = y + dy[i];
        // 範囲外に出たときは次の処理へ
        if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
        // 黒いタイル'.'だったら再帰呼び出し
        if( field[my][mx] == '.' ){
            dfs( mx , my );
        }
    }
}

int main(){
    while( cin >> w >> h , w || h ){
        for(int y=0 ; y < h ; y++ ){
            cin >> field[y];
        }

        for(int y=0 ; y < h ; y++ ){
            for(int x=0 ; x < w ; x++ ){
                if( field[y][x] == '@' ){ // 人'@'だったら再帰関数を呼び出す
                    dfs( x , y );
                }
            }
        }
        int ans = 0;
        // ループで'B'の数を数える(到達可能な黒いタイルの数)
        for(int y=0 ; y < h ; y++ ){
            for(int x=0 ; x < w ; x++ ){
                if( field[y][x] == 'B' )
                    ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1216
A,B,K = map(int,input().split())
L = []
for i in range(A,A+K) :
    if i <= B :
        L.append(i)
for j in range(B-K+1,B+1) :
    if j >= A :
        L.append(j)
L = list(set(L))
L = sorted(L)
for k in range(len(L)) :
    print(L[k])
    
    

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

long long int N,A,B;

int main(){
  cin >> N>>A>>B;
  long long int ans = 0;
  
  for (int i=1;i<=N;i++){
    int sum=0;
    int tmp = i;
    while(tmp!=0){
      sum+=tmp%10;
      tmp/=10;
    }
    if (sum>=A && sum<=B) ans+=i;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = abs(0.5 * (60 * h - 11 * m));
    if (angle > 180) {angle = 360 - angle;}
    angle *= 3.14159265358979323846/180.0;
    cout << fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(angle));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 4108
from math import cos, pi, sin


def coord(l, t):
    return l * cos(t), l * sin(t)


def d(a, b, c, d):
    return ((a - c)**2 + (b - d)**2)**0.5


def solve(string):
    a, b, h, m = map(int, string.split())
    return str(d(*coord(a, (h + m / 60) / 6 * pi), *coord(b, m / 30 * pi)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9512
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    ll cnt = 0;
    rept(i, 1, N+1) {
        if (i % 3 != 0 && i % 5 != 0) cnt += i;
    }
    cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a1[] = {2};
		int a2[] = {4,6,9,11};
		int a3[] = {1,3,5,7,8,10,12};
		String ans = "No";
		
		for(int i=0; i<1; i++){
		    for(int j=0; j<1; j++){
		        if(x == a1[i] && y == a1[j]){
		            ans = "Yes";
		        }
		    }
		}
		
		for(int i=0; i<4; i++){
		    for(int j=0; j<4; j++){
		        if(x == a2[i] && y == a2[j]){
		            ans = "Yes";
		        }
		    }
		}
		
		for(int i=0; i<7; i++){
		    for(int j=0; j<7; j++){
		        if(x == a3[i] && y == a3[j]){
		            ans = "Yes";
		        }
		    }
		}
		
	
        System.out.println(ans);
	}
}


Measured memory_bytes: 35548
import java.util.*;
import java.lang.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int m=n/2;
    String a=s.substring(0,m);
    String b=s.substring(m,s.length());
    if(n%2!=0) {
      System.out.println("No");
    }
    else if(s.equals(a+a)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
	}
}

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

int main() {
	int n,kind_num = 1;
  cin >> n;
  vector<string> s(n);
  for (int i = 0 ; i < n ; i++){
    cin >>s[i];
  }
  sort(s.begin(),s.end());
  
 for(int i = 1 ; i < n;i++){
   if(s[i-1] != s[i]) kind_num++;
 }
  
  cout << kind_num << endl;
}

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

unordered_map<ll,int> cnt;
vll yakusu(ll x){
    vll ret;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            ll a=i,b=x/i;
            if(a!=1&&a!=b&&cnt.count(a)==0){
                ret.push_back(a);
                cnt[a]++;
            }
            if(b!=1&&cnt.count(b)==0){
                ret.push_back(b);
                cnt[b]++;
            }
        }
    }
    return ret;
}
long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    ll res=0;
    vll first=yakusu(n-1);
    res+=first.size();
    vll second=yakusu(n);
    for(ll t:second){
        ll cp=n;
        while(cp%t==0){
            cp/=t;
        }
        if(cp%t==1)res++;
    }
    cout<<res<<endl;
    return 0;
}




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll K;
    cin >> K;
    vector<ll> A(K);
    REP(i, K){
    	cin >> A[i];
    }

    ll ma = 2;
    ll mi = 2;
    REP(i, K){
    	ll X = A[K-1-i];
    	ll mibai = (mi/X) * X;
    	if(mi%X != 0) mibai += X;
    	ll mabai = ma/X * X;
    	if(mibai > ma || mabai < mi){
    		cout << -1 << endl;
    		exit(0);
    	}
    	ma = mabai + X - 1;
    	mi = mibai;
    }
    cout << mi << " " << ma << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using ll = unsigned long long;

int main() {
  string s;

  cin >> s;

  if (s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON") {
    cout << 6 << endl;
  } else if (s == "TUE") {
    cout << 5 << endl;
  } else if (s == "WED") {
    cout << 4 << endl;
  } else if (s == "THU") {
    cout << 3 << endl;
  } else if (s == "FRI") {
    cout << 2 << endl;
  } else if (s == "SAT") {
    cout << 1 << endl;
  }
}


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

int N;
struct st{
	int i,a;
} A[100010];
bool cmp(const st &x, const st &y){
	return x.a<y.a;
}

int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i].a;
		A[i].i=i;
	}
	sort(A,A+N,cmp);
	for(int i=0;i<N;i++)
		cout<<A[i].i+1<<" ";
	cout<<endl;

	return 0;
}

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


int main() {
  ll n;
  cin >> n;
  ll ans=10000;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      string s=to_string(n/i);
      ans = min(ans,(ll)s.size());
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, num(0);
    cin >> n;

    for (ll i=1; i<=n; i++)
        num += i;

    cout << num << endl;
        

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<bitset>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for(int i=0; i<n; i++)
		cin >> s[i];
	sort(s.begin(), s.end());
	string ans;
	for(int i=0; i<n; i++)
		ans += s[i];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<cstring>
#include<map>
#define mem(m,i) (memset(m,i,sizeof(m)))
using namespace std;
typedef long long ll;

int main()
{
    string ss;
    cin>>ss;
    int sum=0;
    if(ss.length()==1)
        cout<<1<<endl;
    else
    {
        int f=0;
        if(ss[ss.length()-1]==ss[ss.length()-2])
        {
            for(int i=0; i<ss.length()-2; i++)
                if(i==ss.length()-2)
                    break;
                else if(ss[i]!=ss[i+1])
                {
                    sum++;
                    f=1;
                    //cout<<ss[i]<<endl;
                }
                else if(i+2<ss.length()-2)
                {
                    sum+=2;
                    f=2;
                   // cout<<ss[i]<<endl;
                   // cout<<ss[i+1]<<ss[i+2]<<endl;
                    i+=2;
                }
                else
                {
                    f=3;
                   // cout<<ss[i]<<endl;
                    sum++;
                }
                sum+=1;
        }
        else
        {
            for(int i=0; i<ss.length(); i++)
                if(ss[i]!=ss[i+1])
                {
                    sum++;
                    f=1;
                   // cout<<ss[i]<<endl;
                }
                else
                {
                    sum+=2;
                    f=2;
                   // cout<<ss[i]<<endl;
                   // cout<<ss[i+1]<<ss[i+2]<<endl;
                    i+=2;
                }
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int main() {
  
  int table[3][3];
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int i = 0; i <= table[0][0]; i++) {
    
    int a1 = i, b1 = table[0][0] - i,
        a2 = table[1][0] - b1, b2 = table[0][1] - a1,
        a3 = table[2][0] - b1, b3 = table[0][2] - a1;
    
    if (table[1][1] == a2 + b2 &&
        table[1][2] == a2 + b3 &&
        table[2][1] == a3 + b2 && 
        table[2][2] == a3 + b3) {
      
      cout << "Yes" << endl;
      
      return 0;
      
    }
    
  }
  
  cout << "No" << endl;
  
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, k;
void solve(){
	cin >> n >> k;
	
	if(k == 0){
		cout << n*n << endl;
		return;
	}
	i64 ans = 0;
	for(int i = k+1; i <= n; i++){
		ans += n/i * (i-k);
		ans += max(0LL, n%i - k + 1);
		//cout << ans << endl;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	if(a == b) printf("Draw\n");
	else if(a == 1 or (b != 1 and b < a)) printf("Alice\n");
	else printf("Bob\n"); 
	return 0;
}


Measured memory_bytes: 256
nu = gets.to_i
fr = gets.chomp.split(" ").map(&:to_i)
sum = 0
for i in 0..nu - 1
  sum += fr[i]
  fr[i] *= nu
end
ans = 0
dis = 100000
for i in 0..nu - 1
  if (sum - fr[i]).abs < dis
    ans = i
    dis = (sum - fr[i]).abs
  end
end
puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <set>
#include <iostream>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

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

  long long s = a - b;
  long long e = a + b;

  const int MAX = 1500000;
  vector<int> prime;
  vector<bool> p(MAX, true);
  vector<bool> ans(2 * b + 1, true);

  p[0] = p[1] = false;

  for(int i = 4; i < MAX; i += 2) p[i] = false;
  for(int i = 3; (long long)i * i < MAX; i += 2)
    if(p[i])
      for(int j = i + i; j < MAX; j += i)
	p[j] = false;


  REP(i,MAX) if(p[i]) prime.push_back(i);
  // REP(i,prime.size()) cout << prime[i] << endl;

  const int n = prime.size();


  if(s < 0){
    ans = vector<bool>(e+1,true);
    s = 0;
  }
  
  if(s == 0) ans[0]   = false;
  if(s <= 1) ans[1-s] = false;

  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      long long t = 1;
      t *= prime[i];
      t *= prime[j];
      t *= prime[j];

      //printf("test: %d %d\n", i, j);

      if(t > e) break;
      long long k = t * ((s + t - 1) / t);
      if(k > e) continue;

      for(long long kk = k; kk <= e; kk += t){
	if(ans[kk - s]){
	  int icnt = 0;
	  int jcnt = 0;
	  long long kkk = kk;
	  while(kkk % prime[i] == 0){ kkk /= prime[i]; icnt++; }
	  while(kkk % prime[j] == 0){ kkk /= prime[j]; jcnt++; }
	  
	  if(icnt < jcnt) ans[kk - s] = false;
	}
      }
    }
  }

  int cnt = 0;
  REP(i, ans.size()) if(ans[i]) cnt++;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1776
using System;
public class Program {
  public static void Main() {
    string S = Console.ReadLine();
    string T = Console.ReadLine();
    for (int i = 0; i < S.Length; i++) {
      S = S.Insert(0, S[S.Length-1].ToString());
      S = S.Remove(S.Length-1);
      if (S == T) {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
  }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 2001
int f[N][N], n;
ll ans = 1e18, x;
int query(int l, int r) { return l > 0 ? f[l][r] : min(f[l + n][n], f[1][r]); }
int main() {
    scanf("%d%lld", &n, &x);
    for (int i = 1; i <= n; i++) scanf("%d", &f[i][i]);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) f[i][j] = min(f[i][j - 1], f[j][j]);
    for (int i = 0; i < n; i++) {
        ll sum = 0;
        for (int j = 1; j <= n; j++) sum += query(j - i, j);
        ans = min(ans, sum + x * i);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 15232
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

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

  std::vector<intmax_t> x(N), s(N);
  intmax_t res=0;
  for (int i=0; i<N; ++i) {
    scanf("%jd %jd", &x[i], &s[i]);
    res = std::max(res, s[i]);
  }

  x.push_back(1e18);
  s.push_back(0);

  intmax_t X=0, V=0;
  for (int i=0; i<=N; ++i) {
    if (V > res)
      res = V;

    V += s[i];
    V -= x[i]-X;
    X = x[i];
    if (V > s[i])
      continue;

    X = x[i];
    V = s[i];
  }

  printf("%jd\n", std::max(res, V));
}


Measured memory_bytes: 6884
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    vector<int> A;
    int N, t;
    ll ans=0, second=0;
    cin>>N;
    REP(i,0,N) {
        cin>>t;
        A.push_back(t-i-1);
    }
    sort(A.begin(),A.end());
    int b=A[N/2];
    REP(i,0,N){
        ans+=abs(A[i]-b);
    }
    cout<<ans;
    return 0;
}
// 3 1 -1 -3 -4 -5 -6    12, -6
// 

Measured memory_bytes: 1400
#C
n, m = map(int, input().split())
l = []
r = []
for _ in range(m):
    tmp=list(map(int,input().split()))
    l.append(tmp[0])
    r.append(tmp[1])
lmax = max(l)
rmin = min(r)
# print(lmax,rmin)
if rmin >= lmax:
    print(rmin -lmax + 1)
else:
    print(0)


Measured memory_bytes: 11040
#!/usr/bin/env python3
n = int(input())
def count(x):
    c = 0
    t = n
    while t:
        c += t//x
        t //= x
    return c +1
prime = [2]
limit = int(n**0.5)
ans = count(2)
if n < 3:
    print(ans)
    exit()
data = [i + 1 for i in range(2, n, 2)]
while True:
    p = data[0]
    if limit < p:
        for i in data:
            ans *= count(i)
            ans %= 10**9+7
        break
    ans *= count(p)
    ans %= 10**9 + 7
    data = [e for e in data if e % p != 0]
print(ans)


Measured memory_bytes: 9348
using System;
using System.Linq;

namespace arc058_aarc058_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] d = Console.ReadLine().Split();
            bool find = false;
            while (!find)
            {
                find = true;
                for (int i = 0; i < x[1]; i++)
                {
                    if (x[0].ToString().Contains(d[i]))
                    {
                        find = false;
                    }
                }
                x[0]++;
            }
            Console.WriteLine(--x[0]);
        }
    }
}

Measured memory_bytes: 15424
x, y = map(int, input().split())
while not(x == 0 and y == 0):
	for i in range(x):
		for j in range(y):
			if (i+j)%2 == 0:
				print('#', end = '')
			else:
				print('.', end = '')
		print()
	print()
	x, y = map(int, input().split())


Measured memory_bytes: 7008
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigDecimal d = BigDecimal.valueOf(sc.nextInt());

		BigDecimal[] x = new BigDecimal[n];
		BigDecimal[] y = new BigDecimal[n];
		for(int i = 0;i<n;i++) {
			x[i]=BigDecimal.valueOf(sc.nextInt());
			y[i]=BigDecimal.valueOf(sc.nextInt());
		}
		sc.close();

		int ans = 0;
		for(int i = 0;i<n;i++) {
			BigDecimal tmp = x[i].multiply(x[i]).add(y[i].multiply(y[i]));
			BigDecimal dd = d.multiply(d);
			if(dd.compareTo(tmp)==1||dd.compareTo(tmp)==0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 77792
n, m, x = map(int, input().split())
#n,m,x,i,j,l,money,k,o
books = []
for i in range(n):
    books.append(list(map(int, input().split())))

ans = 10 ** 10000
import itertools
for i in range(n+1):
    for j in itertools.combinations(books, i):#j:組み合わせ
        l = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for o in range(1, m + 1):
                l[o-1] += k[o]

        if all(a >=x for a in l):
            if money < ans:
                ans = money

if ans == 10 ** 10000:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9132
package main

import "fmt"

var ans = -100000

func main() {
	var n int
	fmt.Scan(&n)
	vr := make([]int, n)
	cr := make([]int, n)
	for i := range vr {
		fmt.Scan(&vr[i])
	}
	for i := range cr {
		fmt.Scan(&cr[i])
	}
	f(0, 0, 0, vr, cr)
	fmt.Println(ans)
}

func f(sv, sc, n int, vr, cr []int) {
	if n == len(vr) {
		if ans < sv-sc {
			ans = sv - sc
		}
		return
	}
	f(sv, sc, n+1, vr, cr)
	f(sv+vr[n], sc+cr[n], n+1, vr, cr)
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> h(N+2);
  h[0] = 0;
  rep(i, N) cin >> h[i+1];
  h[N+1] = 0;

  bool flag = true;
  int ans = 0;
  while(flag){
    flag = false;
    bool prev0 = true;
    for(int i = 1; i < N+2; i++){
      if(h[i] == 0){
        if(!prev0) {
          ans++;
        }
        prev0 = true;
      } else {
        h[i]--;
        prev0 = false;
        flag = true;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256