akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // exit()
#include <stdbool.h>

#define MAX_V 20
#define MAX_E 100

typedef struct list_tbl
{
	int t;
	int next;
} list_t;

int V;
int G[MAX_V];
list_t list[MAX_E];
bool visited[MAX_V];
int out[MAX_V];
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

void
dfs(int u)
{
	visited[u] = true;
	for (int l = G[u]; l != -1; l = list[l].next)
	{
		int v = list[l].t;
		if (!visited[v])
			dfs(v);
	}

	out[--ix] = u + 1;
}

void
solve()
{
	for (int u = 0; u < V; ++u)
		visited[u] = false;

	ix = V;
	for (int u = 0; u < V; ++u)
	{
		if (!visited[u])
			dfs(u);
	}

	for (; ix < V; ++ix)
		printf("%d\n", out[ix]);
}

int
main(int argc, char **argv)
{
	scanf("%d", &V);
	for (int u = 0; u < V; ++u)
		G[u] = -1;

	int E;
	scanf("%d", &E);

	int nl = 0;
	for (int i = 0; i < E; ++i)
	{
		int s, t;
		scanf("%d%d", &s, &t);
		if (nl >= MAX_E)
		{
			fprintf(stderr, "graph area overflow. size:%d\n", MAX_E);
			cleanup(1);
		}

		list[nl].t = t - 1;
		list[nl].next = G[s - 1];
		G[s - 1] = nl++;
	}

	solve();
	return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;
string str;

int check(int i) {
    if (i >= str.length())
        return true;

    string ns1 = str.substr(i, 5);
    string ns2 = str.substr(i, 6);
    string ns3 = str.substr(i, 7);

    int good = 0;
    if (ns3 == "dreamer") {
        good += check(i + 7);
    }
    if (ns2 == "eraser") {
        good += check(i + 6);
    }
    if (ns1 == "erase") {
        good += check(i + 5);
    }
    if (ns1 == "dream") {
        good += check(i + 5);
    }

    return good >= 1 ? 1 : 0;
}

int main() {

    cin >> str;
    
    if(check(0)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
	int Q = 0;
	double N;
	cin >> N;

	for (int i = N; i >= 1; i--) {
		if (i % 2 != 0) {
			Q++;
		}
	}

	double ans = Q / N;
	cout << setprecision(10) << Q / N << endl;
}

Measured memory_bytes: 256
from collections import deque,defaultdict
def solve():
    N = int(input())
    S = list(input())
    dic = defaultdict(lambda: False)
    ans = 0
    d = deque()
    for s in S:
        for _ in range(len(d)):
            t = d.popleft()
            d.append(t)
            if len(t)==1:
                u = t+s
                if dic[u]==False:
                    dic[u] = True
                    d.append(u)
            if len(t)==2:
                u = t+s
                if dic[u]==False:
                    dic[u] = True
                    ans += 1
        if dic[s]==False:
            dic[s] = True
            d.append(s)
    return ans
print(solve())

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

int main(){
    int m,h;
    string card,head,tail;
    while(1){
        cin >> card;
        if(card=="-") break;
        
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            head = card.substr(0,h);
            tail = card.substr(h,card.size()-h);
            card = tail + head;
            
        }
        cout << card << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
using namespace std;
int A[128], N;
int main(){
    while(cin >> N, N){
        A[0] = 1;
        for (int i=1; i<=N; ++i){
            A[i] = A[i-1];
            if(i >= 2) A[i] += A[i-2];
            if(i >= 3) A[i] += A[i-3];
        }
        cout << ((A[N]+9)/10 + 364)/365 << endl;
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long tint;
typedef long double ld;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);
#define dbg cout << "hu" << endl;

const int INF = 50000001;
const int MOD = 1000000007;

//impossible pairs: (a^3, 1) (a^2, a^1)

int main(){
	string s; cin >> s;
	int n = s.size();
	tint quan = tint(n)*tint(n-1)/2;
	vector<int> cont (26, 0);
	forn(i, n){
		cont[s[i]-'a']++;
	}
	tint ret = 0;
	forn(i, 26){
		if(cont[i]) ret+=(tint(cont[i])*tint(cont[i]-1))/2;
	}
	cout << quan-ret+1 << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 123456789;
const int maxx = 1005;
ll q, t, n, m, T, k, ans, a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, str, sa, sb;

char ss[maxx][maxx];

struct dang
{
    ll val, sl;
};
dang st[maxn];
bool lt(const dang &x, const dang &y)
{
    return x.val < y.val;
}
ll ns, nsa, nsb;
void test()
{
    //ll c[maxn], d[maxn];
    cin >> s;
    if(s == "ABC")cout << "ARC";
    else cout << "ABC";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    test();
}



Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (array.Sum() >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[100005],maxn;
int main()
{
    
    cin>>n>>k>>a[0];
    maxn=a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        a[0]=__gcd(a[0],a[i]);
        maxn=max(a[i],maxn);
    }
    if(k%a[0]==0&&k<=maxn) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

int main()
{
	int N;
	int sum = 0;
	int cnt = 0;
	cin >> N;

	bool flag2 = false;

	for(int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if(A % 4 == 2) {
			if(!flag2) {
				flag2 = true;
				sum++, cnt++;
			}
		} else if(A % 4 != 0) {
			cnt++, sum++;
		} else sum++;
	}
	if(cnt > (sum - cnt + 1)) cout << "No" << endl;
	else cout << "Yes" << endl;

	return (0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stack>
using namespace std;

struct Point {
    Point() {x=0,y=0;}
    Point(int _x,int _y){x  =_x,y=_y;}

    int x,y;
};

// 重载相应的比较运算符
bool operator < (Point a, Point b)
{
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
long long gcd(long a, long b) {
    return b ? gcd(b, a % b) : a;
}

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
char dc[] = {'R', 'L', 'D', 'U'};
char dcc[] = {'L', 'R', 'U', 'D'};

int k,n,m;

void solvee(){
    cin >> n >> m;
    vector<long long> c(n+1);
    vector<long long> res(n+1);
    vector<vector<long long> > nxt(n+1);
    for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
    for(int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u,&v);
        res[u] += c[v];
        nxt[v].push_back(u);
    }
    long long ans = res[1];
    for(int i = 1; i <= n; i++) {

        for(int j = 1; j < (1<<nxt[i].size()); j++) {
            cout << i<< ' '<< j<<endl;
            long long sum = c[i];
            for(int k = 0; k < nxt[i].size(); k++) {
                if(j&(1<<k)) {
                    sum += res[nxt[i][k]]-c[i];
                }
            }
            cout << "sum = " <<sum<<endl;
            ans = gcd(ans, sum);
        }
    }

    cout << ans <<endl;
}

char s[1000000+10];

int main() {
    long long n,a,b;
    cin >> n>>a>>b;
    printf("%lld\n", n/(a+b)*a + min(a, n%(a+b)));
}




Measured memory_bytes: 256
from collections import deque

n = int(input())
q = deque(["a"])

# 最後に最新の文字数のセットだけ拾う
for i in range(n - 1):
    next_q = deque()
    for curr in q:
        suffix = ord(max(curr)) + 1
        for x in range(ord("a"), suffix + 1):
            next_q.append(curr + chr(x))
    q = next_q

print(*q, sep="\n")

Measured memory_bytes: 15212
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(15)]
for some in a:
    b[some//400]+=1
ans=0
for i in range(8):
    if b[i]>0:
        ans+=1
mini=ans
for i in range(8,15):
    ans+=b[i]
if mini==0:
    mini=1
print(mini,ans)



Measured memory_bytes: 3060
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();

		if(N-A>=0 && N-A<=B) System.out.println("YES");
		else System.out.println("NO");

	}
}

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

#define ll long long int
#define N 1000001

ll dp[1001][(1 << 12) + 1];

ll f(vector<ll>& c, vector<ll>& a, ll i, ll mask, ll n) {
    if(i == a.size())
        return (mask == ((1 << n) - 1)) ? 0 : 5e8;
    if(dp[i][mask] != -1)
        return dp[i][mask];
    ll option1 = a[i] + f(c, a, i + 1, mask | c[i], n);
    ll option2 = f(c, a, i + 1, mask, n);
    return dp[i][mask] = min(option1, option2);
}

int main() {
    ll n, m;
    cin >> n >> m;
    memset(dp, -1, sizeof dp);
    vector<ll> c(m);
    vector<ll> a(m);
    for(int i = 0; i < m; i++) {
        ll k;
        cin >> a[i] >> k;
        for(int j = 0; j < k; j++) {
            int u;
            cin >> u;
            c[i] |= (1 << (u - 1));
        }
    }
    ll ans = f(c, a, 0, 0, n);
    if(ans == 5e8)
        ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=22;
mat dp(N,vec(1<<N));
mat a(N,vec(N));
ll n;

int main() {
  cin >> n;
  for(ll i=0;i<n;i++) for(ll j=0;j<n;j++) cin >> a[i][j];
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<(1<<n);j++) {
      bitset<22> bit(j);
      if(bit.count()!=i) continue;
      for(ll k=0;k<n;k++) {
        if(!bit.test(k)&&a[i][k]) {
          (dp[i+1][j+(1<<k)]+=dp[i][j])%=mod;
        }
      }
    }
  }
  cout << dp[n][(1<<n)-1] << endl;
}

Measured memory_bytes: 754048
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    string ABC = "ABCDEFGHIJKLNMOPQRSTUVWXYZ";
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> s[i][j];
            if (s[i][j] == "snuke")
            {
                cout << ABC[j] << i + 1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7

from math import floor, sqrt
from bisect import bisect_right as bi_r
from collections import defaultdict

def prime_nums(n=10**6):
    sieve = set(range(2, n + 1))
    non_prime = set(range(2 * 2, n + 1, 2))
    sieve -= non_prime
    for i in range(3, floor(sqrt(n)) + 1, 2):
        if i in sieve:
            non_prime = set(range(i * 2, n + 1, i))
            sieve -= non_prime
    return sieve

p_nums = sorted(prime_nums())

def make_inv_table(n=10**6, p=MOD):
    fac = [None] * (n + 1)
    fac[0] = 1
    for i in range(n):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (n + 1)
    ifac[n] = pow(fac[n], p-2, p)
    for i in range(n, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    inv = [None] * (n + 1)
    for i in range(1, n+1):
        inv[i] = ifac[i] * fac[i-1] % p
    return inv

inv = make_inv_table()

n, *A = map(int, sys.stdin.read().split())

def main():
    facs = defaultdict(int)
    for a in A:
        if a == 1:
            continue
        for p in p_nums[:bi_r(p_nums, sqrt(a))]:
            cnt = 0
            while not a % p:
                cnt += 1
                a //= p
            facs[p] = max(facs[p], cnt)
            if a == 1:
                break
        else:
            facs[a] = max(facs[a], 1)
    
    lcm = 1
    for f, c in facs.items():
        lcm *= pow(f, c, MOD)
        lcm %= MOD
    
    ans = 0
    for a in A:
        ans += lcm * inv[a] % MOD
        ans %= MOD
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 131656
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		Collections.sort(list);
		int output = 0;
		for(int i = 0 ; i < N * 2; i += 2){
			output += list.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32864
#include <iostream>

#define rep(X, Y) for( int X = 0; X < Y; ++X )

typedef long long ll;

ll GCM( ll x, ll y ){
	while( 1 ){
		if( x > y ) x -= y;
		else if( x < y ) y -= x;
		else return x;
	}
}

ll LCM( ll x, ll y ){
	return x / GCM( x, y ) * y;
}

int main(){
	ll p[3], cnt[3], a[3], m[3], sum;

	while( 1 ){
		sum = 0;

		rep(i, 3){
			p[i] = 1, cnt[i] = 0;
			std::cin >> a[i] >> m[i];
			sum += a[i] + m[i]; 
		}

		if( sum == 0 ) break;

		rep(i, 3){
			do{
				cnt[i]++;
				p[i] = (p[i] % m[i] * a[i] % m[i]) % m[i];
			}while( p[i] != 1 );
		}

		ll lcm = 1;
		rep(i, 3) lcm = LCM( cnt[i], lcm );

		std::cout << lcm << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int n, ans;
int l[112];

int main() {
    cin >> n;

    rep(i,n) cin >> l[i];

    sort(l,l+n);

    ans = 0;

    int i = 0;
    int j, k;

    while (i < n-2){
        int next = 0;
        while (l[i] == l[i+next] && i+next < n-1){
            next++;
        }

        for (j = i+next; j < n-1; j++){
            int cnt_left = next;
            
            k = j+1;
            while (l[j] == l[k]){
                k++;
            }
            int cnt_right = 0;
            while (l[i] + l[j] > l[k] && k < n){
                cnt_right++;
                k++;
            }
            ans += cnt_left*cnt_right;
        }
        i += next;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int A, B;
	cin>>A>>B;
	if (A==1){
		A=14;
	}
	if (B==1){
		B=14;
	}
	if (A==B){
		cout << "Draw" << endl;
	}
	else if (A>B){
		cout << "Alice" << endl;
	}
	else{
		cout << "Bob" << endl;
	}
	
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), o(n), r;
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = n / 2; i < n; i++)
    o.at(i) = a.at(i);
  for(int i = n / 2; i > 0; i--) {
    int p = 0;
    for(int j = i * 2; j <= n; j += i)
      p += o.at(j - 1);
    p %= 2;
    o.at(i - 1) = (p + a.at(i - 1)) % 2;
  }
  for(int i = 0; i < n; i++)
    if(o.at(i))
      r.push_back(i + 1);
  cout << r.size() << endl;
  for(int i = 0; i < r.size(); i++)
    cout << r.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void){
	char s[11],t[11],u[11];
	int a,b;

	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",u);
	
	if(strcmp(s,u)==0){
		printf("%d %d",a-1,b);
	}else{
		printf("%d %d",a,b-1);
	}


	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<int,int> P;

const int kN = 1002, kInf = 1 << 28;
int N, A[kN], B[kN];
int dp[2][kN];

int solve() {
  int *prev = dp[0], *next = dp[1];
  rep(i,2) rep(j,kN) dp[i][j] = kInf;
  dp[1][0] = dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < kN; ++j) {
      if (prev[j] + A[i] <= B[i]) {
        next[j+1] = min(prev[j] + A[i], prev[j+1]);
      } else {
        next[j+1] = prev[j+1];
      }
    }
    swap(prev, next);
  }
  int ret = -1;
  rep(i,N+1) if (prev[i] != kInf) ret = max(ret, i);
  return ret;
}

int main() {
  while (scanf("%d", &N) != -1) {
    int a, b;
    vector<P> v;
    rep(i,N) {
      scanf("%d%d", &a, &b);
      v.push_back(P(b, a));
    }
    sort(v.begin(), v.end());
    rep(i,N) A[i] = v[i].second, B[i] = v[i].first;
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b;
    cin >> a >> b;
    if (a < b) {
        REP(i,0,b) cout << a;
        cout << endl;
    } else {
        REP(i,0,a) cout << b;
        cout << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

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

int main() {
  int n;
  int ans=0,cnt=0;
  int num;

  cin >> n;

  for(int i=1;i<=n;i++) {
    cnt=0;
    num = i;
    while(num!=0) {
      // cout << num << endl;
      num=num/10;
      cnt++;
    }
    if(cnt%2==1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
#define dl 30000000000000
lli maxi(lli a,lli b){
    if(a>=b)return a;
    return b;
}
lli mini(lli a,lli b){
    if(a<=b)return a;
    return b;
}

int main(){
    int n;
    cin>>n;
    vector<lli> arr(n,0);
    lli sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    vector<vector<lli>> b(n+1,vector<lli>(n+1,dl));
    vector<vector<lli>> c(n+1,vector<lli>(n+1,dl));
    for(int i=0;i<n;i++){
        if(i==0){
            b[i+1][i+1]=0;
            c[i+1][i+1]=arr[i];
            continue;
        }
        b[i][i+1]=arr[i-1]+arr[i];
         c[i][i+1]=arr[i-1]+arr[i];
        c[i+1][i+1]=arr[i];
        b[i+1][i+1]=0;
    }
   
    for(int cnt=3;cnt<=n;cnt++){
        for(int i=1;i<=n-cnt+1;i++){
            int j=i+cnt-1;
            
            for(int k=i;k<j;k++){
               lli m=b[i][k]+b[k+1][j]+c[i][k]+c[k+1][j];
                if(m<b[i][j]){
                    b[i][j]=m;
                    c[i][j]=c[i][k]+c[k+1][j];
                }
            }
            
        }
    }
    cout<<b[1][n]<<endl;
}

Measured memory_bytes: 2816
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int YL=1e9+7,N=2e6+5;
inline int MO(const int &x){return x>=YL?x-YL:x;}
int inv[N];
int main()
{
	int n=in(),ans=0;inv[1]=1;
	for(int i=2;i<=n;++i)inv[i]=YL-1ll*(YL/i)*inv[YL%i]%YL;
	for(int i=2;i<=n;++i)inv[i]=MO(inv[i]+inv[i-1]);
	for(int i=1;i<=n;++i)ans=(1ll*in()*(inv[i]+inv[n-i+1]-1)+ans)%YL;
	for(int i=2;i<=n;++i)ans=1ll*ans*i%YL;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main(){
	string input,ring;
	int N,ans=0;
	cin >> input >> N;
	for(int i=0;i<N;i++){
		cin >> ring;
		ring=ring+ring;
		if(ring.find(input)!=-1)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1212
import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print('\n'.join(map(str,A)))


Measured memory_bytes: 126040
import java.util.Scanner;
import static java.lang.Math.*;
public class Main {
	public static void main(String[] args) {
		Main m = new Main();
		m.start();
		m.flush();
	}

	private Scanner in;
	private double x = 0.0, y = 0.0, b = 90.0;
	public Main() {in = new Scanner(System.in);}
	private void start() {
		while(in.hasNext()) {
			String[] line = in.nextLine().split(",");
			solve( Integer.parseInt(line[0].trim()),
				   Integer.parseInt(line[1].trim()));
		}
	}
	private void solve(int m, int r) {
		x+=m*cos(b*PI/180.0);
		y+=m*sin(b*PI/180.0);
		b-=r;
	}
	private void flush() {
		System.out.printf("%d\n%d\n",(int)x,(int)y);
	}
}

Measured memory_bytes: 12000
import sys
read_=sys.stdin.buffer.readline

N,M,C=map(int,read_().split())
B=list(map(int,read_().split()))
A=[list(map(int,read_().split())) for _ in range(N)]

ans=0
for i in range(N):
    res=0
    for j in range(M):
        res+=A[i][j]*B[j]
    res+=C
    if res>0:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int N,L,min;
    scanf("%d%d",&N,&L);
    int taste_N0[N];
    int taste[N];
    int sum0=0;
    for(int i=0;i<N;i++){
        taste_N0[i]=L+i;
        sum0+=taste_N0[i];
    }
    
    
    int sum1=sum0-taste_N0[0];
    if(sum0-sum1<0)
        taste[0]=-(sum0-sum1);
    else
        taste[0]=sum0-sum1;
   
    min=taste[0];
    
    int j=0;
    for(int i=0;i<N;i++){
        
        sum1=sum0-taste_N0[i];
        
        if(sum0-sum1<0)
            taste[i]=-(sum0-sum1);
        else
            taste[i]=sum0-sum1;
        
        if(min>taste[i]){
            min=taste[i];
            j=i;
        }
    }
    printf("%d\n",sum0-taste_N0[j]);
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  bool check = false;
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) == A.at(i + 1)) {
      check = true;
    }
  }
  if (check) {
    cout << "NO";
  }
  else {
    cout << "YES";
  }
}

Measured memory_bytes: 1792
#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>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int n;
  cin >> n;
  vector<int> rabbits(n);
  rep(i,n) {
    int a;
    cin >> a;
    a--;
    rabbits[i] = a;
  }
  //print_array(rabbits);

  int res = 0;
  rep(i,n) {
    int a = rabbits[i];
    int b = rabbits[a];
    if(i == b) res++;
    //cout << a << " " << b << endl;
  }
  cout << res / 2 << endl;
  return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = list(map(int, input().split()))


def solve(x):
    if (x == 0).all():
        return "Yes"
    if len(x) % 3:
        return "No"
    x.sort()
    idx = len(x)//3
    if (x[:idx] == 0).all() and (x[idx:] == x[-1]).all():
        return "Yes"
    if x[0] ^ x[idx] ^ x[2*idx] == 0 and (x[:idx] == x[0]).all() and (x[idx:2*idx] == x[idx]).all() and (x[2*idx:] == x[2*idx]).all():
        return "Yes"
    return "No"


a = np.array(a)
ans = solve(a)
print(ans)


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

using namespace std;

int main(){
	int n;
	long long r = 0;
	scanf("%d", &n);
	long d[n][n];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			scanf("%ld", &d[i][j]);
	bool exist, fail = false;
	for(int i = 0; i < n && !fail; i++)
		for(int j = 0; j < n && !fail; j++){
			exist = true;
			for(int k = 0; k < n && !fail; k++){
				if(i != j && i != k && j != k){
					if(d[i][j] > d[i][k] + d[j][k])
						fail = true;
					else if(d[i][j] == d[i][k] + d[j][k])
						exist = false;
				}
			}
			if(exist)
				r += d[i][j];
		}
	cout << (fail ? -1 : r / 2);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void){
	int p, c, count, n, r, huda[200] = {0}, i, j;
	while (1) {
		scanf("%d %d", &n, &r);
		for (i = 0;i < n;i++) {
			huda[i] = i + 1;
		}
		if (n == 0 && r == 0) {
			break;
		}
		for (i = 0;i < r;i++) {
			scanf("%d %d", &p, &c);

			for (j = 0;j < c;j++) {
				huda[n + j] = huda[n - p -c+1+j];
				huda[n - p -c+1+j] = -1;
			//	printf("%d ",huda[n+j]);
			}


			count = 0;
			for (j = 0;j < n;j++) {

				/*if (count > n){
					break;
				}*/
				
				huda[j] = huda[count];
				if (huda[count] == -1) {
					j--;
				}
				count++;

			}
			/*for (j = 0;j < n;j++) {
				printf("%d ", huda[j]);
			}printf("\n");
			*/
		}
		printf("%d\n",huda[n-1]);
	}


	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
    int a, b, c, d;

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

    while(a > 0){
        c = c - b;
        if(c <= 0){
            printf("Yes\n");
            return 0;
        }
        a = a - d;
    }    
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
  //////
    // input from txt
    /*
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::ofstream out("output.txt");
    std::cout.rdbuf(out.rdbuf());
   ////
    */
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(abs(A-B) > (ll)1e18){
        cout << "Unfair" << endl;
        return 0;
    }
    if(K&1)
        cout << B-A << endl;
    else
        cout << A-B << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Problems problems = new Problems();
        problems.problemD_Knapsack1();
    }
}

class Problems {
    static void problemD_Knapsack1() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] weight = new int[N];
        long[] value = new long[N];
        for (int i = 0; i < N; i++ ){
            weight[i] = sc.nextInt();
            value[i] = sc.nextLong();
        }

        long[][] V = new long[N+1][W+1];
        for (int w = 0; w <= W; w++)
            V[0][w] = 0;
        if (N == 1) {
            if (weight[0] <= W) {
                System.out.println(value[0]);
                return;
            } else {
                System.out.println(0);
                return;
            }
        }
        for (int i = 1; i<=N; i++) {
            for (int w = 0; w <= W; w++) {
                if (weight[i-1] > w) // new item i is heavier than w -> not include i
                    V[i][w] = V[i-1][w];
                else
                    V[i][w] = Math.max(V[i-1][w],V[i-1][w-weight[i-1]] + value[i-1]);
            }
        }
        System.out.println(V[N][W]);
    }
}

Measured memory_bytes: 126420
#include<iostream>
using namespace std;
 
int main(void){
	int n, i, j;
	cin >> n;
	int n4, n7;
	n4 = n / 4;
	n7 = n / 7;
	for(i = 0; i < n4 + 1; i++){
		for(j = 0; j < n7 + 1; j++){
			if(i * 4 + j * 7 == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// Copyright 2017 wu_qing
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdint>
const int N = 2e3 + 10;
int n;
int64_t tot, ans = ~0ull >> 1, x, a[N], b[N];
int main() {
    memset(b, 127, sizeof b);
    scanf("%d%lld", &n, &x);
    for (int i = 0; i < n; i++)
        scanf("%lld", a + i);
    for (int i = 0; i < n; i++) {
        tot = i * x;
        for (int j = 0; j < n; j++)
            tot += (b[j] = std::min(b[j], a[(j - i + n) % n]));
        ans = std::min(ans, tot);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
def div_fc n, d
	[[1, n/d].max, [(n+d-1)/d, n-1].min]
end

s = gets.split.map(&:to_i)
p -[s, s.reverse].map{|h, w|
	div_fc(h, 3).map{|a|
		aa = a * w
		nh = h - a
		if nh==1
			[w/2, (w+1)/2, aa].minmax.reduce(:-)
		else
			[[(w/2)*nh, ((w+1)/2)*nh, aa], [(nh/2)*w, ((nh+1)/2)*w, aa]].map{|seq|
				seq.minmax.reduce(:-)
			}.max
		end
	}.max
}.max

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
using ll = long long;
int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    
    ll min, max;
    int flag = 0;
    for(int i = 0; i < N; ++i){
        min = C * i - D * (N - i - 1);
        max = D * i - C * (N - i - 1);
        if(min <= B - A && B - A <= max){
            flag = 1;
            break;   
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

int count_digits(ll N) {
    int digits = 0;
    while (N > 0) {
        N /= 10;
        digits++;
    }
    return digits;
}

void solve() {
    ll N;
    cin >> N;
    int ans = 20;
    for (ll a = 1; a * a <= N; a++) {
        if (N % a != 0) continue;
        const ll b = N / a;
        const int cur = max(count_digits(a), count_digits(b));
        if (ans > cur) ans = cur;
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
  char x,y,z; cin >> x >> y >> z;
  map<char,int>a;
    a['a']=1;
    a['b']=2;
    a['c']=3;
  cout << ( a[x]+a[y]+a[z]==6 ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// using namespace std;
typedef long long ll;
const int N=1e2+5;
int l[N];
int main(){
    // ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0);
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    if(true){
    // while(~scanf("%d",&n)){
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);
    if(x<0) x=-x;
    __int128 tot=(__int128)k*d;
    if(tot>=x){
        __int128 step=x/d;//正方向步数
        if(step%2^k%2){//不同
            printf("%lld",d-x%d);
        }
        else printf("%lld",x%d);
    }
    else{
        printf("%lld\n",(ll)(x-tot));
    }
    }return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long int a[200010],b[200010],c[200010],ans[300010];
long long int i,j,k,sum=0,n,a1,b1,c1,x,y;
long long int cmp(long long int x,long long int y)
{
    return x>y;
}
int main()
{
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a1,&b1,&c1);
    for(i=0;i<a1;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<b1;i++)
        scanf("%lld",&b[i]);
    for(i=0;i<c1;i++)
        scanf("%lld",&c[i]);
    sort(a,a+a1,cmp);
    sort(b,b+b1,cmp);
    sort(c,c+c1,cmp);
    for(i=0;i<x;i++)
        ans[i]=a[i];
    for(j=0;j<y;j++,i++)
        ans[i]=b[j];
    for(j=0;j<c1;j++,i++)
        ans[i]=c[j];
    sort(ans,ans+x+y+c1,cmp);

    for(i=0;i<x+y;i++)
        sum=sum+ans[i];
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 6528
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	char[] r = sc.next().toCharArray();
    	
    	int zero = 0;
    	int iti = 0;
    	
    	for(int i=0;i<r.length;i++){
    		if(r[i]=='0'){
    			zero += 1;
    		}
    		else{
    			iti += 1;
    		}
    	}
    	
    	System.out.println(2*Math.min(zero,iti));
    	
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io
	string s;
	char c;
	int q, t, f;
	deque<char> dq;

	cin >> s;
	for (int i = 0; i < s.size(); i++)
		dq.push_back(s[i]);
	cin >> q;
	int normal = 1;
	while (q--) {
		cin >> t;
		if (t == 1) {
			normal = 1 - normal;
		}
		else {
			cin >> f >> c;
			if (f == 1) {
				if (normal)
					dq.push_front(c);
				else
					dq.push_back(c);
			}
			else {
				if (normal)
					dq.push_back(c);
				else
					dq.push_front(c);
			}
		}
	}
	if (normal) {
		while (!dq.empty()) {
			cout << dq.front();
			dq.pop_front();
		}
		cout << "\n";
	}
	else {
		while (!dq.empty()) {
			cout << dq.back();
			dq.pop_back();
		}
		cout << "\n";	
	}
	return 0;
}

Measured memory_bytes: 976
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
ans = 0
for i in range(1,n):
    if a[i] == a[i-1]+1:
        ans += c[a[i-1]-1]
print(sum(b)+ans)

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	int n;
	int count = 0;
	bool flag = true;
	
	cin >> n;
	vector<string>s(n + 1);
	FOR(i, 1, n) {
		cin >> s[i];
		if (s[i] == "A") {
			count++;
		}
		else {
			if (count <= 0) {
				flag = false;
			}
			else {
				count--;
			}
		}
	}
	if (count != 0) {
		flag = false;
	}
	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 3172
N = int(input())
ls = [0]*(N+2)

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            t = i**2 + j**2 + k**2 + i*j + j*k + k*i 
            if t <= N :
                ls[t] += 1

for p in range(1,N+1):
    print(ls[p])

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

int main() {
  int n,m,f; 
  while(n+m+f!=-3){
    cin >>n>>m>>f;
    if(n+m+f==-3)break;
    if(n==-1||m==-1)cout<<"F"<<endl;
    else if(n+m>=80)cout<<"A"<<endl;
    else if(n+m>=65&&n+m<80)cout<<"B"<<endl;
    else if(n+m>=50&&n+m<65)cout<<"C"<<endl;
    else if(n+m>=30&&n+m<50){
      if(f>=50){
        cout<<"C"<<endl;
      }else{
        cout<<"D"<<endl;
      }
    } 
    else if(n+m<30)cout<<"F"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3088
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();

        for (int i = 0; i < h; i++) {
            System.out.print("#");
            System.out.print(sc.next());
            System.out.println("#");
        }

        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();
    }
}

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

int main() {
  
  int n,m;
  cin >> n >> m;
  
  vector<long long> h(n);
  for ( int i = 0; i < n; i++){
    cin >> h[i];
  }
  
  vector<int> c(n,1);
  
  int a,b;
  
  for ( int i = 0; i < m; i++){
    cin >> a >> b;
    if ( h[a-1]> h[b-1] ){
      c[b-1] = 0;
    }else if ( h[a-1] < h[b-1] ){
      c[a-1] = 0;
    }else{
      c[a-1] = 0;
      c[b-1] = 0;
    }
  }
  
  int cnt = 0;
  
  for ( int i = 0; i < n; i++){
    if ( c[i] == 1 ){
      cnt++;
    }
  }
  
  cout << cnt << endl;  
  
}


Measured memory_bytes: 4568
#include <stdio.h>
 
int main()
{
int n, car[10], i;
     
i = 0;
     
while (scanf("%d", &n) != EOF){
if (n != 0){
car[i++] = n;
}
else {
printf("%d\n", car[--i]);
}
}
return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
#define A first
#define B second

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    cout << max(K + 1, A + ((K - A + 1LL) / 2LL) * (-A + B) + (K - A + 1) % 2LL) << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
  a, b, c, d = map(int, input().split())
  for i in range(100):
    c -= b
    if c <= 0:
      print('Yes')
      return
    a -= d
    if a <= 0:
      print('No')
      return
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 9072
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

if sum(A) < sum(B):
    print(-1)
    exit()

positives = []
sum_negative = 0
num_negative = 0
for a, b in zip(A, B):
    if a > b:
        positives.append(a - b)

    elif a < b:
        sum_negative += b - a
        num_negative += 1


positives.sort(reverse=True)

num_positives = len(positives)
while positives and sum_negative > 0:
    p = positives.pop(0)
    sum_negative -= p

print(num_positives - len(positives) + num_negative)

Measured memory_bytes: 81388
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    int ans = 800 * N;
    while(N >= 15){
        ans -= 200;
        N -= 15;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define LL long long

bool cmp(LL a,LL b)
{
    return a>b;
}

int n;
LL a[100005],b[100005];
LL temp[100005];
map<LL,LL> c;

int main()
{
    while(~scanf("%d",&n))
    {
        map<LL,LL> sum;
        for(int i=0;i<n;++i)
        {
            scanf("%lld",&a[i]);
            temp[i]=a[i];
            sum[a[i]]++;
        }
        sort(temp,temp+n,cmp);
        int k=0;
        b[k++]=temp[0];
        for(int i=1;i<n;++i)
        {
            if(temp[i]!=temp[i-1]) b[k++]=temp[i];
        }
        b[k++]=0;

        LL max1=b[0],max2=b[1];
        LL last1=b[k-1],last2=b[k-2];
        int h=2;
        for(int i=n-1;i>=0;--i)
            c[a[i]]=i;

        //for(int i=0;i<k;++i) cout<<b[i]<<".."<<c[b[i]]<<endl;

        map<LL,LL> ans;
        while(max1!=last2&&max2!=last1)
        {//cout<<sum[max1]<<".."<<(max1-max2)<<endl;
            ans[c[max1]+1]+=sum[max1]*(max1-max2);
            sum[max2]+=sum[max1];
            if(c[max1]<c[max2]) c[max2]=c[max1];
            max1=max2;
            max2=b[h++];
        }
        ans[1]+=n*max1;
        for(int i=1;i<=n;++i)
            cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 22144
import queue

n, m = map(int, input().split())
paths = {key: [] for key in range(n)}
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    paths[a].append(b)
    paths[b].append(a)

# BFS
q = queue.Queue()
q.put(0)
guide = [-1] * n
guide[0] = 0
while True:
    if q.empty():
        break
    node = q.get()
    next_nodes = paths[node]
    for next_node in next_nodes:
        if guide[next_node] > -1:
            continue
        guide[next_node] = node
        q.put(next_node)

print('Yes')
for i in range(1, n):
    print(guide[i] + 1)


Measured memory_bytes: 98944
def m():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    if N == 1:
        return abs(a[0] - W)
    return max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W))


print(m())


Measured memory_bytes: 3188
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  let digits_l = digits 10 n [] in
  let sum = List.fold_left (+) 0 digits_l in

  Printf.printf "%s\n" @@
  if n mod sum = 0 then "Yes" else "No"


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

#define INF 100000000


int main() {
    int n, m; cin >> n >> m;
    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        q.push(x);
    }

    for(int i = 0; i < m; i++) {
        int top = q.top();
        q.pop();
        q.push(top / 2);
    }
    long long ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892