akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 10000

bool a[60][60];
bool b[60][60];
ll d[60][60];
queue<pll> que;

void CanMove(ll x, ll y, ll dis) {
  pll q;
  if (a[x][y] && !b[x][y]) {
	q.first = x;
	q.second = y;
	que.push(q);
	b[x][y] = true;
	d[x][y] = dis;
  }
}

int main(void) {
  ll h, w;
  char c;
  pll p1(0, 0);
  pll p;

  cin >> h >> w;

  FOR(i, 0, 60) {
	FOR(j, 0, 60) {
	  a[i][j] = false;
	  b[i][j] = false;
	  d[i][j] = 0;
	}
  }

  FOR(i, 0, h) {
	FOR(j, 0, w) {
	  cin >> c;
	  c == '.' ? a[i][j] = true : a[i][j] = false;
	  if (a[i][j]) cnt++;
	}
  }

  que.push(p1);
  b[p1.first][p1.second] = true;

  while (!que.empty()) {
	p = que.front();
	que.pop();
	if (p.first == h - 1 && p.second == w - 1) {
	  cout << cnt - d[p.first][p.second] - 1 << endl;
	  return 0;
	}
	CanMove(p.first + 1, p.second, d[p.first][p.second] + 1);
	CanMove(p.first, p.second + 1, d[p.first][p.second] + 1);
	if (p.first > 0) {
	  CanMove(p.first - 1, p.second, d[p.first][p.second] + 1);
	}
	if (p.second > 0) {
	  CanMove(p.first, p.second - 1, d[p.first][p.second] + 1);
	}
  }

  cout << "-1" << endl;

  return 0;
}


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

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

    char x, y;
    cin >> x >> y;

    if(x <= y) {
        if(x == y) puts("=");
        else puts("<");
    }
    else puts(">");
}   

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

int main(){
    std::vector<int> vec;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int d;
        std::cin >> d;
        vec.push_back(d);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    std::cout << vec.size() << std::endl;
}


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

int main() {
	int a, b, c;
	int A, B;
	cin >> a >> b >> c;
	A = a * b;
	B = c;
	if (A > B) {
		cout << B << endl;
	}
	else if (B >= A) {
		cout << A << endl;
	}
}

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

list_h = list(map(int, input().split()))
dic_t = {i:T-h*0.006 for i, h in enumerate(list_h, 1)}

min_d = 100000
min_key = 0

for key, v in dic_t.items():
    d = abs(A-v)
    if d < min_d:
        min_d = d
        min_key = key
    else:
        pass

print(min_key)

Measured memory_bytes: 3188
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long start = 100;
        int years = 0;
        while(start < n)
        {
            start *= 1.01;
            years++;
        }
        System.out.println(years);
    }
}


Measured memory_bytes: 35512
def examA():
    H1, M1, H2, M2, K = LI()
    T = (H2-H1)*60 + (M2-M1)
    ans = T-K
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 76716
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
static const int MAX_H = 500;
static const int MAX_W = 500;
static const int INF = 1 << 30;

int R;
int W1, H1, X1, Y1;
int W2, H2, X2, Y2;
int L1[MAX_H][MAX_W], L2[MAX_H][MAX_W];
bool visited[MAX_H][MAX_W];
int dy[] = {0, -1, 0, 1};
int dx[] = {1, 0, -1, 0};

vector<P> bfs(int L[MAX_H][MAX_W], int W, int H, int X, int Y){
	vector<P> ret;
	fill(visited[0], visited[H], false);
	ret.push_back(P(0, 0));
	priority_queue<PP, vector<PP>, greater<PP> > pqa;
	pqa.push(PP(1, P(Y, X)));
	visited[Y][X] = true;
	int max_sec = 0;
	int cnt = 0;
	while(!pqa.empty()){
		PP cur = pqa.top(); pqa.pop();
		cnt++;
		int cy = cur.second.first, cx = cur.second.second;
		int sec = cur.first;
		if(sec > max_sec){
			max_sec = sec;
			ret.push_back(P(max_sec, cnt));
		}else{
			ret.back().second = cnt;
		}
		for(int i = 0; i < 4; i++){
			int ny = cy + dy[i], nx = cx + dx[i];
			if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if(visited[ny][nx]) continue;
			pqa.push(PP(L[ny][nx], P(ny, nx)));
			visited[ny][nx] = true;
		}
	}
	return ret;
}

int main(){
	for(;;){
		scanf("%d", &R);
		if(R == 0) break;
		scanf("%d %d %d %d", &W1, &H1, &X1, &Y1);
		X1--; Y1--;
		for(int i = 0; i < H1; i++){
			for(int j = 0; j < W1; j++){
				scanf("%d", &L1[i][j]);
			}
		}
		scanf("%d %d %d %d", &W2, &H2, &X2, &Y2);
		X2--; Y2--;
		for(int i = 0; i < H2; i++){
			for(int j = 0; j < W2; j++){
				scanf("%d", &L2[i][j]);
			}
		}
		vector<P> va = bfs(L1, W1, H1, X1, Y1);
		vector<P> vb = bfs(L2, W2, H2, X2, Y2);
		int res = INF;
		int j = vb.size() - 1;
		for(int i = 0; i < va.size(); i++){
			for(; j >= 1 && va[i].second + vb[j - 1].second >= R; j--);
			if(va[i].second + vb[j].second >= R) res = min(res, va[i].first + vb[j].first);
		}
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 7480
n = int(input())

a = list(map(int, input().split()))
s = [a[0]]

for i in range(1, n):
    s.append(s[-1]+a[i])


cnt_a = 0
base = 0
for i in range(n):
    if ((base + s[i] >= 0) and (i % 2 == 1)) or ((base + s[i] <= 0) and (i % 2 == 0)):
        cnt_a += (1 + abs(base + s[i]))
        base += (1 + abs(base + s[i])) * (-1) ** i


cnt_b = 0
base = 0
for i in range(n):
    if ((base + s[i] <= 0) and (i % 2 == 1)) or ((base + s[i] >= 0) and (i % 2 == 0)):
        cnt_b += (1 + abs(base + s[i]))
        base -= (1 + abs(base + s[i])) * (-1) ** i

print(min(cnt_a, cnt_b))

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

void solve() {
  string x,y;
  cin >> x >> y;
  int xz = (int) x.size();
  int yz = (int) y.size();
  int d = abs(xz - yz);
  if(d > 0) {
    cout << "Alice";
    return;
  }
  else {
    int sum = 0;
    for (int i = 0; i < xz; i++) {
      sum += abs ( (x[i] - '0') - (y[i] - '0'));
      if(sum > 1) {
        cout << "Alice";
        return;
      }
    }
    cout << "Brown";
  }
}


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


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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}
/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
ll dp[mx][5],n;
ll arr[mx][5];
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    ll tst,a,b,c,k,m,res=0,ans=0,t=0;
    memset(dp,-1,sizeof(dp));
    sl(n);
    for(ll i=1;i<=n;i++)
    {
        sl(a),sl(b),sl(c);
        arr[i][1]=a;arr[i][2]=b;arr[i][3]=c;
    }
    dp[1][1]=arr[1][1],dp[1][2]=arr[1][2],dp[1][3]=arr[1][3];
    for(ll i=2;i<=n;i++)
    {
        for(ll j=1;j<=3;j++)
        {
            ll maxi=-1;
            for(ll k=1;k<=3;k++)
            {
                if(k!=j)maxi=max(maxi,dp[i-1][k]);
            }
            dp[i][j]=arr[i][j]+maxi;
        }
    }
    res=max({dp[n][1],dp[n][2],dp[n][3]});
    printf("%lld\n",res);


    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int N;
int T[111111],A[111111];

int H[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>T[i];
    rep(i,N)cin>>A[i];
    memset(H,-1,sizeof(H));
    int p=0;
    rep(i,N){
        if(p==T[i])continue;
        if(H[i]!=-1&&H[i]!=T[i]){
            cout<<0<<endl;
            return 0;
        }
        H[i]=T[i];
        p=T[i];
    }

    p=0;
    for(int i=N-1;i>=0;i--){
        if(p==A[i])continue;
        if(H[i]!=-1&&H[i]!=A[i]){
            cout<<0<<endl;
            return 0;
        }
        H[i]=A[i];
        p=A[i];
    }

    vint X(N);
    rep(i,N)X[i]=min(T[i],A[i]);
    rep(i,N){
        if(H[i]>X[i]){
            cout<<0<<endl;
            return 0;
        }
    }

    int ans=1;
    rep(i,N){
        if(H[i]!=-1)continue;
        ans=ans*X[i]%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
N, M = map(int, input().split())
LR = []
Lmax = 0
Rmin = float("INF")
for i in range(M):
    L, R = map(int, input().split())
    LR.append([L,R])
    Lmax = max(Lmax,L)
    Rmin = min(Rmin,R)
print(Rmin-Lmax+1) if Rmin>=Lmax else print(0)

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;

  int flg = 1;
  for (int i = 0; i < a+b+1; i++)
  {
    if(i==a){
      if(s[i]!='-') flg=0;
    }
    else{
      if(s[i]=='-') flg=0;
    }
  }
  
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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



int N;

int main () {
  cin >> N;

  if ((N-1) % 2 == 0) {
    cout << (N-1) / 2 << "\n";
  } else {
    cout << (N-1) / 2 << "\n";
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    var(string, s);
    print(string(s.length(), 'x'));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//repetition
//------------------------------------------
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;

int main() {
    int N, l, r, total = 0;
    cin >> N;

    int i = 0;
    REP(i, N) {
        cin >> l >> r;
        total += (r - l + 1);
    }
    cout << total << endl;

}

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

using namespace std;

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

using ll = long long;
using ld = long double;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}



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

  int n; cin >> n;
  vector<pair<ll, ll>> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.rbegin(), v.rend());

  vector<vector<ll>> dp(n, vector<ll>(n+1, -LINF));
  dp[0][0] = v[0].first * abs(n - 1 - v[0].second);
  dp[0][1] = v[0].first * v[0].second;

  for(int i=1;i<n;++i) {
    for(int j=0;j<n;++j) {
      if(dp[i-1][j] == -LINF) continue;
      chmax(dp[i][j+1], dp[i-1][j] + v[i].first * abs(v[i].second - j));
      chmax(dp[i][j], dp[i-1][j] + v[i].first * abs(n - 1 - (i - j) - v[i].second));
    }
  }

  ll ans = 0;
  for(int i=0;i<n;++i) {
    chmax(ans, dp[n-1][i]);
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 34616
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {

    int n;
    cin >> n;
    string s;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++)
    {
        cin >> s;
        if(s == "AC")
        {
            ac++;
        }
        else if(s == "WA")
        {
            wa++;
        }
        else if(s == "TLE")
        {
            tle++;
        }
        else
        {
            re++;
        }
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
	return 0;
}


Measured memory_bytes: 3640
# B
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append('#' + input() + '#')
    
from collections import deque
a = deque(a)
a.appendleft('#'*(w+2))
a.append('#'*(w+2))

for i in a:
    print(''.join(i))

Measured memory_bytes: 3444
import math

a, b, x = list(map(int, input().split()))
if x==a**2*b:
    print(0)
elif x>a**2*b/2:
    print(90-math.atan(a/(2*b-2*x/a**2))*180/math.pi)
else:
    print(90-math.atan(2*x/a/b**2)*180/math.pi)

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int input,i;
		
		i = 1;
		do{
			input = scan.nextInt();
			if(input > 0){
				System.out.println("Case "+i+": "+input);
			}
			i++;
		}while(input > 0);
		
	}

}

Measured memory_bytes: 42576
#include <stdio.h>
#include <stdlib.h>

typedef struct {
  long a;
  long b;
} Drink;

int cmp( const void *p, const void *q )
{
    return ((Drink*)p)->a - ((Drink*)q)->a;
}

int main(void)
{
  long i;
  long N, M;
  scanf("%ld %ld", &N, &M);

  Drink d[N];
  for (i = 0; i < N; i++)
    scanf("%ld %ld", &d[i].a, &d[i].b);

  qsort(d, N, sizeof(Drink), cmp);

  i = 0;
  long count = 0;
  while (M >= 0) {
    if (M <= d[i].b) {
      count += (d[i].a * M);
      M -= M;
      break;
    } else {
      count += (d[i].a * d[i].b);
      M -= d[i].b;
    }
    i++;
  }

  printf("%ld\n", count);
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int gcd(long long int a, long long int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
int main()
{
    long long int i,j,k,n,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

// ユニオンファインドツリー
struct uf_tree {
    vector<int> parent;
    int internal_size;
    uf_tree(int size_) : parent(size_, -1), internal_size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            internal_size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return internal_size; }
};

int main(void) {
    int n, m;
    cin >> n >> m;
    
    vector<int> v(n+1, 0);
    vector<int> p(n+1, 0);
    repeat_from_to (i, 1, n) {
        int a;
        cin >> a;
        v[i] = a;
        p[a] = i;
    }
    
    uf_tree uf(n+1);
    rep (m) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }
    
    int ans = 0;
    repeat_from_to (i, 1, n) {
        if (uf.find(v[i]) == uf.find(i)) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		String s = br.readLine();
		if (a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}
	}
}

Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    ll n;
    scanf("%lld", &n);
    int cnt = 0;
    for(ll i = 1; ; i *= 10)
        for(ll j = 1 * i; j <= 10 * i; j += i) {
            if(j != i) cnt++;
            if(j - 1 > n) {
                printf("%d\n", cnt - 1);
                return 0;
            }
        }
    return 0;
}

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

int main(void){
    int n, m, total = 0, ok = 0;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) total += a[i];
    for(int i = 0; i < n; i++){
        if(4*a[i]*m >= total) ok++;
    }
    if(ok >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3580
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int a[3*100001];
int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	int n;
	cin>>n;
	for(int i=1; i<=3*n; ++i) {
		cin>>a[i];
	}
	sort(a+1,a+1+3*n,greater<int>());
	LL sum=0;
	for(int i=1; i<=n; ++i) {
		sum+=a[i*2];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	ll a, b, c; 
	
	int cnt = 0;
/* BIEN CUC BO END*/

void solve(){	
	cin >> a >> b >> c;
	for (int i=min(a,b); i>=1; --i){
		if (a%i == 0 && b%i == 0){
			++cnt;
			if (cnt == c){
				cout << i;
				break;
			}
		}
	}
}

int main(){ FIO;
	solve();
return 0;}	

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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

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

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

string str_tolower(string s) {
  transform(s.begin(), s.end(), s.begin(),
            [](unsigned char c) { return tolower(c); });
  return s;
}

////////////////////////////////////////////////////////////

double X1, Y1, X2, Y2;

int main() {
  cin >> X1 >> Y1 >> X2 >> Y2;
  double d = sqrt(
      pow(Y2 - Y1, 2)
      +
      pow(X2 - X1, 2)
  );
  printf("%f\n", d);
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n, k; cin >> n >> k;
    int ans = 0;
    while(n){
        n /= k;
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b;
#define chmin(a,b) if(b<a)a=b;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
#define N 8
#define FREE -1
#define NOT_FREE 1
vi row(N, FREE), col(N, FREE), dpos(2 * N - 1, FREE), dneg(2 * N - 1, FREE);
vv(bool, X, N, N, false);
void printBoard() {
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(X[i][j] != 0 && row[i] != j) return;
		}
	}
	rep(i, 0, N) {
		rep(j, 0, N) {
			p((row[i] == j) ? "Q" : ".");
		}
		P("");
	}
}
void recursive(int i) {
	if(i == N) {
		printBoard(); return;
	}
	rep(j, 0, N) {
		if (NOT_FREE == col[j] ||
			NOT_FREE == dpos[i + j] ||
			NOT_FREE == dneg[i - j + N - 1]) continue;
		row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		recursive(i + 1);
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}
int main() {
	int k; cin >> k;
	int r, c;
	rep(i, 0, k) {
		cin >> r >> c;
		X[r][c] = true;
	}
	recursive(0);
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    string N;
    cin >> N;

    int Nlen = N.length();
    vector<vector<int>> dp(Nlen + 3, vector<int>(2, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i <= Nlen; ++i) {
        int num = (i < Nlen ? N[i] - '0' : 0);
        dp[i + 1][0] = min(dp[i][0] + num, dp[i + 1][0]);
        if (num != 9)
            dp[i + 1][0] = min(dp[i][1] + num + 1, dp[i + 1][0]);
        dp[i + 1][1] = min(dp[i][1] + 9 - num, dp[i + 1][1]);
        if (num != 0)
            dp[i + 1][1] = min(dp[i][0] + 10 - num, dp[i + 1][1]);
    }

    cout << dp[Nlen + 1][0] << endl;

    return 0;
}


Measured memory_bytes: 58924
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x <= 599) {
        cout << 8 << endl;
    } else if(x <= 799) {
        cout << 7 << endl;
    }else if(x <= 999) {
        cout << 6 << endl;
    }else if(x <= 1199) {
        cout << 5 << endl;
    }else if(x <= 1399) {
        cout << 4 << endl;
    }else if(x <= 1599) {
        cout << 3 << endl;
    }else if(x <= 1799) {
        cout << 2 << endl;
    }else if(x <= 1999) {
        cout << 1 << endl;
    }
}


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

int main(){
    long long x,y; cin>>x>>y;
    long long ans;
    if(abs(x)<abs(y)){
        if(x>=0 && y>0) ans=y-x;
        else if(x*y<=0) ans=abs(y)-abs(x)+1;
        else ans= abs(y)-abs(x)+2;
    }
    else if(abs(x)==abs(y))ans=1;
    else{
        if(x<0 && y<=0) ans=abs(x)-abs(y);
        else if (x*y<=0) ans=abs(x)-abs(y)+1;
        else ans = abs(x)-abs(y)+2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double pot[100][3],xp,yp,xq,yq,d,a,ans;
int i,j,n;
void check(double x,double y,int p,int q){
	int i; double px,py,a=2.0;
	for(i=0;i<n;i++){
		if(i!=p && i!=q){
			px=pot[i][0];py=pot[i][1];
			if((px-x)*(px-x)+(py-y)*(py-y)<=1){a+=pot[i][2];}
		}
	}
	if(a>ans)ans=a;
}
int main(void){
	while(scanf("%d",&n)*n){
		ans=1;i=0;
		for(;n>0;n--){
			scanf("%lf,%lf",&xp,&yp);
			pot[i][2]=0;
			for(j=0;j<i;j++){if(xp==pot[j][0] && yp==pot[j][1])break;}
			pot[j][2]++;if(pot[j][2]>ans)ans=pot[j][2];
			if(i==j){i++;pot[j][0]=xp;pot[j][1]=yp;}
		}
		n=i;

		for(i=0;i<n-1;i++){
			xp=pot[i][0];yp=pot[i][1];
			for(j=i+1;j<n;j++){
				xq=pot[j][0];yq=pot[j][1];
				d=(xp-xq)*(xp-xq)+(yp-yq)*(yp-yq);
				if(d==4)check((xp+xq)/2,(yp+yq)/2,i,j);
				else if (d<4){
					d=sqrt(1-d/4);
					a=atan2(xq-xp,yp-yq);
					check((xp+xq)/2+d*cos(a),(yp+yq)/2+d*sin(a),i,j);
					check((xp+xq)/2-d*cos(a),(yp+yq)/2-d*sin(a),i,j);
				}
			}
		}
		printf("%d\n",(int)ans);
	}
	return 0;
}

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

int a[100003];
int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3344
def main():
    from collections import Counter as ct

    def soinsuu(a):
        yy, j = [], 2
        y = yy.append
        while(a > 1):
            for i in range(j, int(a**0.5)+1):
                if a % i == 0:
                    y(i)
                    a, j = a//i, i
                    break
            else:
                y(a)
                break
        return ct(yy)

    def soinsuu2(a):
        s = {1}
        for i, j in a.items():
            s2 = set()
            for k in range(1, j+1):
                for l in s:
                    s2.add(l*pow(i, k))
            s |= s2
        s.remove(1)
        return s

    n = int(input())

    ans = 0
    s = soinsuu(n)
    s2 = soinsuu2(s)
    for i in s2:
        m = n
        while m % i == 0:
            m //= i
        m -= 1
        if m % i == 0:
            ans += 1

    n -= 1
    ans2 = 1
    for i in soinsuu(n).values():
        ans2 *= i+1
    ans2 -= 1
    print(ans+ans2)


main()


Measured memory_bytes: 40380
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=1e5+10;
const ll mod=1e9+7;
ll a[MAX];
ll check(ll x,ll n)
{
	int i;
	for(i=0;i<n;i++)
	{
		x=x/a[i]*a[i];
	}
	return x;
}
int main()
{
	ll n,i,ans[2];
	while(~scanf("%lld",&n))
	{
		mem(ans,0);
		for(i=0;i<n;i++) scanf("%lld",&a[i]);
		ll l,r,mid;
		l=2;
		r=(ll)1e18;
		while(l<r)
		{
			mid=(l+r)>>1;
			if(check(mid,n)<2) l=mid+1;
			else r=mid;
		}
		if(check(l,n)==2) ans[0]=l;
		else
		{
			puts("-1");
			continue;
		}
		l=2;
		r=(ll)1e18;
		while(l<r)
		{
			mid=(l+r)>>1;
			if(check(mid+1,n)<=2) l=mid+1;
			else r=mid;
		}
		if(check(l,n)==2) ans[1]=l;
		else ans[1]=ans[0];
		printf("%lld %lld\n",ans[0],ans[1]);
	}
	return 0;
}
/*
2 2 3
3 3 5
4 4 7
3 6 8
6 6 11

3
2 3 2
5
6 3 4 3 2
4
3 4 3 2
5
3 4 100 3 2
10
2 2 2 2 2 2 2 2 2 2
*/

Measured memory_bytes: 1024
from collections import Counter
def main():
    H,W = map(int,input().split())
    s = [list(map(str,input())) for _ in range(H)]
    INF = 10**5
    maze_list = [[INF for _ in range(W)] for _ in range(H)]
    maze_list[0][0] = 0
    def item(array):
        return [item for sublist in array for item in sublist]

    counter = list(Counter(item(s)).items())
    num = 0
    for i in range(len(counter)):
        if counter[i][0] == ".":
            num = counter[i][1]
            break

    queue = []
    queue.insert(0,(0,0))
    while len(queue):
        x,y = queue.pop()
        if x == H-1 and y == W-1:
            break
        for i in range(4):
            nx,ny = x + [1,0,-1,0][i],y + [0,1,0,-1][i]
            if (0<=nx and nx<H and 0<=ny and ny<W and \
                s[nx][ny]!="#" and maze_list[nx][ny]==INF):
                queue.insert(0,(nx,ny))
                maze_list[nx][ny] = maze_list[x][y] + 1

    if maze_list[H-1][W-1] == INF:
        print(-1)
    else:
        print(num-maze_list[H-1][W-1]-1)

if __name__ == "__main__":
    main()

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

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

  unordered_set<string> S;
  while (cin >> word) { // 入力がある限り読み込む
    if (word == "insert") {
      string n;
      cin >> n;
      S.insert(n);
    }
    else if (word == "find") {
      string n;
      cin >> n;
      if (S.count(n) == 1) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
}


Measured memory_bytes: 31916
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] h = new int[n];
    long ans = 0;
    for(int i=0; i<n; ++i)
      h[i] = sc.nextInt();
    Arrays.sort(h);
    for(int i=0; i<n-k; ++i)
      ans += h[i];
    System.out.println(ans);
  }
}

Measured memory_bytes: 66300
from collections import deque


def main():
    def bfs(start):
        q = deque([start])
        while q:
            u = q.popleft()
            for v, w in g[u]:
                if color[v] == -1:
                    q.append(v)
                    if w == 0:
                        color[v] = color[u]
                    else:
                        color[v] = color[u] ^ 1

    n = int(input())
    g = [[] for _ in range(n)]
    color = [-1] * n
    color[0] = 1
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        w %= 2
        g[u].append((v, w))
        g[v].append((u, w))
    bfs(0)
    print(*color)


if __name__ == "__main__":
    main()

Measured memory_bytes: 37516
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll H, W, K;

void dfs(vl &choice, ll &ans, vvc &c){
  if(choice.size() == H+W){
    ll cnt = 0;
    
    rep(i, H){
      rep(j, W){
	if((choice[i] == 1) || (choice[j + H] == 1)) continue;
	if(c[i][j] == '#') cnt++;
      }
    }

    if(cnt == K) ans++;
    
    return;
  }

  rep(i, 2){
    choice.push_back(i);
    dfs(choice, ans, c);
    choice.pop_back();
  }
}

int main(){
  cin >> H >> W >> K;
  string row;
  vvc c(H, vc(W));
  rep(i, H){
    cin >> row;
    
    rep(j, W) c[i][j] = row[j];
  }

  ll ans = 0;
  vl choice;
  dfs(choice, ans, c);

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k){
        cout<<s<<endl;
    }
    else{
        f(i,k){
            cout<<s[i];
            
        }
        cout<<"..."<<endl;
    }

    


    return 0;
}



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

int main()
{
  int A,B;
  cin >> A >> B;
  int total = 0;

  if(A<=B)
  {
    total += B;
    B -= 1;
  }
  else
  {
    total +=A;
    A -= 1;
  }

  if(A<=B)
  {
    total += B;
    B -= 1;
  }
  else
  {
    total +=A;
    A -= 1;
  }

  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	if((A == 1) || (B == 1)){
		if(A == B){
			cout << "Draw\n";
		}else if(A == 1){
			cout << "Alice\n";
		}else{
			cout << "Bob\n";
		}
	}else{
		if(A > B){
			cout << "Alice\n";
		}else if(A < B){
			cout << "Bob\n";
		}else{
			cout << "Draw\n";
		}
	}
}

int main(){
	cin >> A >> B;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) cout << ":(" << '\n';
    else cout << "Yay!" << '\n';
    return 0;
}

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

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) {return 2 * i + 1; }

int main(void) {
    int h, i;
    scanf("%d", &h);
    int A[h+1];
    for (i = 1; i <= h; i++) scanf("%d", &A[i]);

    for (i = 1; i <= h; i++) {
        printf("node %d: key = %d, ", i, A[i]);
        if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
        if (left(i) <= h) printf("left key = %d, ", A[left(i)]);
        if (right(i) <= h) printf("right key = %d, ", A[right(i)]);
        printf("\n");
    }

    return 0;
}

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

typedef long long ll;

int main(){
    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N,greater<int>());
    ll ans1=0,ans2=0;
    if(N%2){
        for(int i=0;i<(N-1)/2-1;i++){
            ans1+=2*a[i];
        }
        for(int i=0;i<(N-1)/2;i++){
            ans2+=2*a[i];
        }
        ans1+=a[(N-1)/2-1]+a[(N-1)/2];
        ans2-=a[(N-1)/2]+a[(N-1)/2+1];
        for(int i=(N-1)/2+1;i<N;i++){
            ans1-=2*a[i];
        }
        for(int i=(N-1)/2+2;i<N;i++){
            ans2-=2*a[i];
        }
        cout << max(ans1,ans2) << endl;
    }else{
        for(int i=0;i<N/2-1;i++){
            ans1+=2*a[i];
        }
        ans1+=a[N/2-1]-a[N/2];
        for(int i=N/2+1;i<N;i++){
            ans1-=2*a[i];
        }
        cout << ans1 << endl;
    }
    

    

}

Measured memory_bytes: 640
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(ll i = z; i < n; i++)
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll C = 1000, B = 0;
    rep(i, 0, N) cin >> A.at(i);
    rep(i, 0, N - 1){
        C += A.at(i) * B;
        B = 0;
        if(A.at(i) < A.at(i + 1)){
            B = C / A.at(i);
            C %= A.at(i);
        }
        //cout << i << " " << B << " " << C << endl;
    }
    C += A.at(N - 1) * B;
    B = 0;
    cout << C << endl;
}


Measured memory_bytes: 3560
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int p[] = new int[n];
			
			for (int i=0; i<n; i++) {
				p[i] = sc.nextInt();
			}

			Integer count[] = {0, 0, 0};

			for (int i=0; i<n; i++) {
				if (p[i] <= a) {
					count[0]++;
				} else if (a < p[i] && p[i] <= b) {
					count[1]++;
				} else if (b < p[i]) {
					count[2]++;
				}
			}
			
			Arrays.sort(count);
			
			System.out.println(count[0]);

		}
	}
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a = in(), b = in(), c = in();

	for (int i = 0; i <= b; ++i) {
		int n = a * i;
		if (n % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
}



Measured memory_bytes: 256
# フェルマーの小定理
def main():
    from builtins import pow

    K = int(input())
    S = input()

    m = 1000000007

    result = 0
    a = 1
    b = 1
    t = pow(26, K, m)
    u = pow(26, m - 2, m) * 25 % m
    l = len(S)
    for i in range(K + 1):
        # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m)
        result += t * (a * pow(b, m - 2, m))
        result %= m
        t *= u
        t %= m
        a *= l + i
        a %= m
        b *= i + 1
        b %= m
    print(result)


main()


Measured memory_bytes: 70360
import java.util.*;
import java.io.*;

public class Main {

  public static void main(String[] args) {

      Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      int bill = 1000;

      if(N%bill==0)
      {


          System.out.println(0);
      }
        else
      {
          int no_of_notes = N/bill + 1;
          System.out.println(no_of_notes*1000-N);
      }
  }

}


Measured memory_bytes: 35628
A,B = map(int,input().split())
def factoring(M,n=2):
    for i in range(n,int(M**0.5)+1):
        if M%i==0:
            ret = factoring(M//i,i)
            ret[i] = ret.get(i,0)+1
            return ret
    return {M:1}
print(len(set(factoring(A).keys()) & set(factoring(B).keys())) + (1-(A==B==1)))

Measured memory_bytes: 3060