akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e3+1;
const ll mod = 1e9+7;


int main(){

    FASTIO;
    PRECISION; 

    int n,m;
    cin>>n>>m;

    vector<vector<int>>store(m);

    vector<int>comp(m);

    for(int i=0;i<m;i++){
        int sz;
        cin>>sz;
        store[i].resize(sz);
        for(int &x: store[i]){
            cin>>x;
            x--;
        }
    }
    for(int &x: comp){
        cin>>x;
    }
    int ans = 0;
    for(int mask=0;mask<(1<<n);mask++){
        int all = 1;
        for(int i=0;i<m;i++){
            int cntr = 0;
            for(int x: store[i]){
                if((1<<x)&mask){
                    cntr++;
                }
            }

            
            if(cntr%2!=comp[i]) all = 0;
        }
        ans+=all;

    }

    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

const int kN = 100 + 5;
int n;
char s[2][kN];
const int MOD = (int)1e9 + 7;
int dp[kN][3][3];

bool ok(int a, int b, int x, int y)
{
    return a == b && x == y || a != b && x != y;
}

int work()
{
    for (int i = 0; i < 3; ++ i) {
        for (int j = 0; j < 3; ++ j) {
            if (!ok(i, j, s[0][0], s[1][0])) continue;
            dp[0][i][j] = 1;
        }
    }
    for (int at = 1; at < n; ++ at) {
        for (int i = 0; i < 3; ++ i) {
            for (int j = 0; j < 3; ++ j) {
                if (!ok(i, j, s[0][at], s[1][at])) continue;
                for (int k = 0; k < 3; ++ k) {
                    if (!ok(i, k, s[0][at], s[0][at - 1])) continue;
                    for (int r = 0; r < 3; ++ r) {
                        if (!ok(k, r, s[0][at - 1], s[1][at - 1]) ||
                            !ok(j, r, s[1][at], s[1][at - 1]))
                            continue;
                        dp[at][i][j] += dp[at - 1][k][r];
                        if (dp[at][i][j] >= MOD)
                            dp[at][i][j] -= MOD;
                    }
                }
            }
        }
    }
    int ret = 0;
    for (int i = 0; i < 3; ++ i)
        for (int j = 0; j < 3; ++ j) {
            ret += dp[n - 1][i][j];
            if (ret >= MOD)
                ret -= MOD;
        }
    return ret;
}

int main()
{
    scanf("%d", &n);
    scanf("%s%s", s + 0, s + 1);
    printf("%d\n", work());
}
    

Measured memory_bytes: 128
#include <stdio.h>
 
int main(void){
    int i , max = 0 , count = 0 , buf , num[101] = {0} , c_num[101] = {0};
    while(scanf("%d" , &buf)!=EOF){
        num[buf]++;
    }
    for(i=1;i<=100;i++){
        if(num[i] > max){
            count++;
            c_num[i] = count;
            max = num[i];
        }else if(num[i] == max){
            c_num[i] = count;
        }
    }
    for(i=1;i<=100;i++){
        if(c_num[i] == count) printf("%d\n" , i);
    }
    return 0;
}
 

Measured memory_bytes: 596
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader();
        //InputStream inputStream = System.in;
        //Scanner in = new Scanner(inputStream);
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        long mod = (int)1e9+7;
        int n = in.nextInt();
        int[] arr = new int[3*n];
        for(int i=0;i<3*n;i++)
            arr[i] = in.nextInt();
        Arrays.sort(arr);
        long ans = 0;
        int right = 3*n-1;
        int left = 0;
        while(left<right){
            ans+=arr[right-1];
            left++;
            right-=2;
        }
        out.println(ans);
        out.close();
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }
}


Measured memory_bytes: 56200
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double out=0.5*(v[0]+v[1]);
    for(int i=2;i<N;i++){
        out = 0.5*(out+v[i]);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().strip(' ').split())
dx=tx-sx
dy=ty-sy
print(('R'*dx)+'U'*dy+'L'*dx+'D'*dy+'D'+('R'*(dx+1))+'U'*(dy+1)+'L'+'U'+'L'*(dx+1)+'D'*(dy+1)+'R')

Measured memory_bytes: 3060
count_5 = 0
count_7 = 0
for s in input().split():
    if s == '5':
        count_5 += 1
    if s == '7':
        count_7 += 1
if count_5 == 2 and count_7 == 1:
    print('YES')
else:
    print('NO')

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

int main(){
    ll n,h,w;
    cin>>n>>h>>w;
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll h1,w1;
        cin>>h1>>w1;
        if(h1>=h&&w1>=w)ans++;
    }
    cout<<ans<<endl;
}


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

int main(void){
	char a[6],b[8],c[6],d[2],e[2];
	scanf("%5s",a);
	scanf("%1s",d);
	scanf("%7s",b);
	scanf("%1s",e);
	scanf("%5s",c);
	printf("%s %s %s\n",a,b,c);
	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

exist = [0] * 102
for pp in p:
    exist[pp] = 1

res = 0
diff = abs(res - x)
for i in range(1, 102):
    if not exist[i] and (d := abs(i - x)) < diff:
        res = i
        diff = d
print(res)


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

using ll = long long;
using ld = long double;

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


class CStep {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    ll sum = 0;
    ll mx = a[0];
    for (int i = 0; i < n; ++i) {
      if (a[i] < mx) {
        sum += mx - a[i];
      }
      maxi(mx, a[i]);
    }
    cout << sum << endl;
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	CStep solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (h*w+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s[1000];
int dp[1000]= {0};
int main() {
	int maxx;
	scanf("%d",&maxx);
	for(int i=1; i<=maxx; i++)
		scanf("%d",&s[i]);
	sort(s+1,s+1+maxx);
	for(int i=0; i<=maxx; i++)
		for(int j=i-1; j>0; j--)
			if(dp[i]<dp[j]+1&&s[i]>s[j])
				dp[i]=dp[j]+1;
	printf("%d\n",dp[maxx]+1);
	return 0;
}

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

int main(){
    using namespace std;

    int K,X;

    cin >> K >> X;
    
    if ( K == 1) {
        cout << X <<endl;
        return 0;
    }

    for (int i = X - K + 1; i <= X + K - 1; i ++){
        cout << i << " " ;
    }
    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a, b, c;
	cin >> a >> b >> c;
  	int result;
    result = a + b + c;
  	if(result < 22)
      cout << "win" << endl;
  	else
      cout << "bust" << endl;
}

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

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int>
#define pal pair < ll, ll>
#define vi vector <int>
#define vl vector < ll >
#define vpai vector < pii >

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 200005;

ll tree[4*sze+1];
ll dp[sze];

int getMid(int s,int e){
    return (s+(e-s)/2);
}

void update(int ind,int ss,int se,int pos,ll val){

    if(ss==se){
        tree[ind]=val;
        dp[pos]=val;
        return;
    }
    int mid=getMid(ss,se);
    if(pos<=mid) update(2*ind,ss,mid,pos,val);
    else update(2*ind+1,mid+1,se,pos,val);

    tree[ind]=max(tree[2*ind],tree[2*ind+1]);
}

ll getMax(int ind,int ss,int se,int l,int r){
    if(l>se||r<ss) return 0;
    if(l<=ss&&se<=r) return tree[ind];

    int mid=getMid(ss,se);

    ll p1=getMax(2*ind,ss,mid,l,r);
    ll p2=getMax(2*ind+1,mid+1,se,l,r);

    return max(p1,p2);

}

void solve() {
    int n;
    cin>>n;
    int hei[n];
    ll be[n];
    rep(i,n) cin>>hei[i];
    rep(i,n) cin>>be[i];

    mem(tree);

    for(int i=0;i<n;i++){
        ll mx=getMax(1,1,n,1,hei[i]-1);
        update(1,1,n,hei[i],be[i]+mx);
    }
    //cout<<"hello\n";
    cout<<*max_element(dp,dp+sze)<<endl;


}

int main() {
    IOS;

    int t = 1;
    // cin >> t;
    while (t--) {
       solve();
    }

  return 0;
}


Measured memory_bytes: 13804
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; i++)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
  ios;
  int n;
  cin >> n;

  vector<int> x(n), y(n);
  forn(i, n) cin >> x[i] >> y[i];
  sort(all(x));
  sort(all(y));

  if (n & 1){
    int lo = x[n/2];
    int hi = y[n/2];
    cout << hi - lo + 1 << "\n";
  } else {
    int lo = x[n/2 - 1] + x[n/2];
    int hi = y[n/2 - 1] + y[n/2];
    cout << hi - lo + 1 << "\n";
  }
}


Measured memory_bytes: 4736
(* O(n) (n = length of list) *)
let rec list_find_fold_left f a = function
| [] -> a, false
| x :: xs ->
  let res, detected = f a x in
  if detected then
    res, detected
  else
    list_find_fold_left f res xs

(* O(n) *)
let can_view i h hs =
  list_find_fold_left
    (fun (res, j) h' ->
      if j >= i then
        (true, j), true
      else
        if h' > h then
          (res, j), true
        else
          (res, j + 1), false)
    (false, 0)
    hs |> fst |> fst

(* O(n^2) *)
let solve n hs =
  List.fold_left
    (fun (count, i) h ->
      if can_view i h hs then
        count + 1, i + 1
      else
        count, i + 1)
    (0, 0)
    hs |> fst

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  let hs = read_ints () in
  solve n hs |> string_of_int |> print_endline

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

int main(void) {
  int N;
  cin >> N;
  vector<int> s(N);
  vector<vector<bool>> dp(N + 1, vector<bool>(10001, false));
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  dp[0][0] = true;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10001; j++) {
      dp[i + 1][j + s[i]] = (dp[i + 1][j + s[i]] || dp[i][j]);
      dp[i + 1][j] = (dp[i + 1][j] || dp[i][j]);
    }
  }

  int ans = 0;
  for (int i = 10000; i >= 0; i--) {
    if (i % 10 != 0 && dp[N][i]) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=0,n;
    cin>>a>>b;
    int outlet=1;
    n=0;

    while(outlet<b)
    {
       --outlet;
       outlet+=a;
       ++c;
    }
    cout<<c<<endl;
    return 0;
}


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

const int N = 1e5+10;
int n,m;

vector<int> G[N], fake[N];
void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
   // G[u].push_back({v, 0, (int)G[v].size()});
   // G[v].push_back({u, 0, (int)G[u].size()-1});
}

bool used[N];
typedef pair<int,int> P;
vector<P> ans;
int deg[N], depth[N];
void dfs(int v, int p = -1) {
    used[v] = true;
    fake[v] = vector<int>(G[v].size());
    for (int i = 0; i < G[v].size(); i++) {
        int u = G[v][i];
        if (u == p) continue;
        if (used[u]) fake[v][i] = 1;
        else {
            depth[u] = depth[v] + 1;
            dfs(u, v);
        }
    }
}
int root = 1;
void getans(int v, int p = -1) {
    for (int i = 0; i < G[v].size(); i++) {
        int u = G[v][i];
        if (u == p || fake[v][i]) continue;
        getans(u, v);
    }   


    if (v != root) {
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            if (fake[v][i] && depth[u] < depth[v]) {
                deg[v] ^= 1;
                ans.push_back(P(v, u));
            }
        }   
          
        if (deg[v] == 1) {
            deg[v] ^= 1;
            ans.push_back(P(v, p));
        }
        else {
            deg[p] ^= 1;
            ans.push_back(P(p, v));
        }
    } 
}


int main() {
    int n,m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u, &v);
        add_edge(u, v);
    } 
    dfs(root);
    getans(root);
    //for (int i = 1; i <= n; i++) printf("%d%c", deg[i], " \n");
    
    if (deg[root] == 0) {
        assert(ans.size() == m);
        for (auto i: ans) {
            printf("%d %d\n", i.first, i.second);
        }
    }
    else puts("-1");
}

Measured memory_bytes: 23544
#include <stdio.h>

int lank[6], n, i;

int main(void)
{
	double h;
	
	scanf("%d", &n);
	
	for (i = 0; i < n ; i++){
		scanf("%lf", &h);
		
		if (h < 165.0){
			lank[0]++;
		}
		else if (h < 170){
			lank[1]++;
		}
		else if (h < 175){
			lank[2]++;
		}
		else if (h < 180){
			lank[3]++;
		}
		else if (h < 185){
			lank[4]++;
		}
		else{
			lank[5]++;
		}
	}
	for (n = 0; n < 6; n++){
		printf("%d:", n + 1);
		
		for (i = 0; i < lank[n]; i++){
			printf("*");
		}
		printf("\n");
	}
	return (0);
}
		
	

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int r;

    cin>>r;

    cout<<3*pow(r,2)<<endl;


    return 0;
}


Measured memory_bytes: 256
class UnionFind
  def initialize(n, &block)
    @par = Array.new(n,&:itself)
    @rank = Array.new(n,1)
    instance_eval(&block) if block_given?
  end

  def root(a)
    par = @par[a]
    a == par ? a : @par[a] = root(par)
  end

  def unite(a,b)
    a = root(a); b = root(b)
    return if a == b

    @rank[a] < @rank[b] ? @par[a] = b : @par[b] = a
    @rank[a] += 1 if @rank[a] == @rank[b]
  end

  def same(a,b)
    root(a) == root(b)
  end

  def roots
    @par.map{|a|root(a)}
  end
end

N,K,L = gets.split.map &:to_i

UnionFind.new(N) do
  K.times do
    a,b = gets.split.map{|v|v.to_i-1}
    unite(a,b)
  end
  UFK = roots
end

UnionFind.new(N) do
  L.times do
    a,b = gets.split.map{|v|v.to_i-1}
    unite(a,b)
  end
  UFL = roots
end

CT = Hash.new(0)
UFK.zip(UFL).each do |e|
  CT[e] += 1
end

puts UFK.zip(UFL).map{|e|CT[e]}.join(" ")

Measured memory_bytes: 44940
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def bin(arr, val):
    l,r = 0, len(arr)-1
    while l <= r:
        mid = (l + r)//2
        if arr[mid] == val: return 1
        elif arr[mid] <= val: l = mid + 1
        elif arr[mid] >= val: r = mid - 1
    return 0

x,n = imap()
p = sorted(iarr())

for i in range(n+1):
    a,b = x-i,x+i
    if not bin(p,a): ans = a; break
    if not bin(p,b): ans = b; break

if n==0: ans = x
print(ans)



Measured memory_bytes: 37768
#include <stdio.h>
#include <string.h>
#define N 100000

typedef struct{
	char name[10];
	int time;
}process;

process Q[N];
int head;
int tail;

void initialize(){
	head = tail = 0;
}

int isEmpty(){
	return head == tail;
}

int isFull(){
	return head == (tail + 1)%N;
}

void enqueue(char *name,int tim){
	if(isFull()){
		printf("error\n");
	}else{
		strcpy(Q[tail].name,name);
		Q[tail].time = tim;
		if(tail+1==N)tail=0;
		else tail++;
	}
}

int dequeue(){
	if(isEmpty()){
		printf("error\n");
	}else{
		int tmp = head;
		if(head+1==N)head=0;
		else head++;
		return tmp;
	}
}

int main()
{
	int q;
	int n;
	int t;
	int ti=0;
	char c[100];
	int i;
	scanf("%d %d",&n,&q);
	initialize();
	for(i=0;i<n;i++){
		scanf("%s %d",c,&t);
		enqueue(c,t);
	}
	while(!isEmpty()){
		int t = dequeue();
		Q[t].time -= q;
		ti += q;
		if(Q[t].time<=0){
			ti += Q[t].time;
			printf("%s %d\n",Q[t].name,ti);
		}else{
			enqueue(Q[t].name,Q[t].time);
		}
	}

	return 0;
}

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

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    for (int i = 0;; ++i) {
        if (i % 2 == 0) {
            C -= B;
            if (C <= 0) {
                cout << "Yes" << endl;
                break;
            }
        } else {
            A -= D;
            if (A <= 0) {
                cout << "No" << endl;
                break;
            }
        }
    }

    return 0;
}

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

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

l=1
r=10**9
import math
for i in range(100):
    temp=0
    m=(r+l)/2
    for j in a:
        temp+=j//m
    if temp<=k:
        r=m
    else:
        l=m

print(math.ceil(m))

Measured memory_bytes: 91748
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define ll long long
using namespace std;
const int inf=1e9; 
const int N=105;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){x=x*10+ch-'0',ch=getchar();}
	return f*x;
}
int n,a[N],s,t,cnt=1,dep[N],head[N];
ll ans;
struct edge{
	int to,nxt,flow;
}e[N*N<<1];
void add(int a,int b,int c){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
	e[cnt].flow=c;
}
bool bfs(){
	queue<int> q; 
	inc(i,s,t) dep[i]=-1;
	dep[s]=0;q.push(s);
	while(q.size()){
		int u=q.front();q.pop();
		edge(u){
			int v=e[i].to;
			if(dep[v]==-1&&e[i].flow){
				dep[v]=dep[u]+1;
				q.push(v);
			}
		}	
	}
	return dep[t]!=-1;
}
int dfs(int u,int flow){
	if(u==t) return flow;
	int res=flow,k;
	edge(u){
		int v=e[i].to;
		if(dep[v]==dep[u]+1&&e[i].flow){
			k=dfs(v,min(res,e[i].flow));
			if(!k) dep[v]=-1;
			res-=k;
			e[i].flow-=k;
			e[i^1].flow+=k;
			if(!res) return flow;
		}
	}
	return flow-res;
}
int main(){
	n=read();
	s=0,t=n+1;
	inc(i,1,n){
		a[i]=read();
		if(a[i]>0) ans+=a[i],add(i,t,a[i]),add(t,i,0);
		else if(a[i]<0) add(s,i,-a[i]),add(i,s,0);
	}
	inc(i,1,n){
		if(a[i]>0) continue;
		for(re int j=i+i;j<=n;j+=i){
			if(a[j]<0) continue;
			add(i,j,inf),add(j,i,0);
		}
	}
	while(bfs()) ans-=dfs(s,inf);
	printf("%lld",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}

int32_t main()
{
  desperate_optimization(true);
  //freopen("input.txt","r",stdin);
  int h,w;
  cin>>h>>w;
  vector<string> grid(h);
  for(int i=0;i<h;i++) cin>>grid[i];
  int dp[h][w];
  dp[h-1][w-1]=0;
  for(int i=h-1;i>=0;i--)
  {
    for(int j=w-1;j>=0;j--)
    {
      if(i==h-1&&j==w-1) {dp[i][j]=1; continue;}
      if(grid[i][j]=='#') {dp[i][j]=0; continue;}
      dp[i][j]=0;
      if(i<h-1) dp[i][j]+=dp[i+1][j];
      if(j<w-1) dp[i][j]+=dp[i][j+1];
      dp[i][j]%=1000000007; 
    }
  }
  cout<<dp[0][0];


  return 0;
}


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

struct point {
	bool w,x,y,z;
};
int main() {
	point a;
	a.x = false, a.y = false;
	a.w = false, a.z = false;
	char ch;
	while (cin >> ch) {
		if (ch == 'N')a.w = true;
		if (ch == 'S')a.x = true;
		if (ch == 'W')a.y = true;
		if (ch == 'E')a.z = true;
	}
	bool t = !(a.w ^ a.x);
	bool s = !(a.y ^ a.z);
	bool ans = t & s;
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0;
  cin>>n;
  for(int a=1;a<=9;a++){
    for(int b=1;b<=9;b++){
      if(a*b==n){
        count+=1;
      }
    }
  }
  if(count==0)
    cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
    
}
   

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

class myStack {
    //s[0]には何も入れない
    int size = 200;
    String[] s;
    int top;
    
    myStack() {
        s = new String[size];
        top = 0;
    }
    
    void initialize() {
        top = 0;
    }
    
    void push(String x) {
        if(isFull()) {
            System.out.println("stack overflow!");
            return;
        }
        s[++top] = x;
    }
    
    String pop() {
        if(isEmpty()) {
            System.out.println("stack is empty!");
            return null;
        }
        return s[top--];
    }
    
    boolean isEmpty() {
        return (top == 0);
    }
    
    boolean isFull() {
        return (top >= size - 1);
    }
    
    int eval() {
        String val = this.pop();
        if(isNumber(val)) {
            return Integer.parseInt(val);
        }
        
        int y = eval();
        int x = eval();
        
        switch(val) {
            case "+":
                return x + y;
            case "-":
                return x - y;
            case "*":
                return x * y;
        }
        return 0;
    }
    
    boolean isNumber(String x) {
        try {
            Integer.parseInt(x);
            return true;
        } catch(NumberFormatException e) {
            return false;
        }
    }
}

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        myStack ms = new myStack();
        
        for(String s : input) {
            ms.push(s);
        }
        
        //evalate
        while(ms.top != 1) {
            ms.push(String.valueOf(ms.eval()));
        }
        
        System.out.println(ms.pop());
    }
}


Measured memory_bytes: 24356
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;

    //
    //2019
    // 年
    //4
    // 月
    //30
    // 日

    string month = str.substr(5, 2);
    string day = str.substr(8, 2);

    int m = stoi(month);
    int d = stoi(day);


    if (m >= 5) {
        cout << "TBD" << endl;
        return 0;
    }

    if (m == 4 && d >= 31) {
        cout << "TBD" << endl;
        return 0;
    }

    cout << "Heisei" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m,d;
	cin>>n>>m>>d;
	double ans2;
	if(d==0){
		ans2 = (double)(m-1)/(double)n;
		printf("%.9lf\n",ans2);
		return 0;
	}
	ans2 = 2.0*(double)(m-1)/(double)n;
	ans2 *= double(n-d)/double(n);
	printf("%.9lf\n",ans2);
}


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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll dp[100100];

signed main() {
    LCIN(N, K);
    VL h(N);
    VECCIN(h);
    Fill(dp, LINF);
    dp[0] = 0;
    REP(i, N) FOR(j, 1, K + 1) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
    cout << dp[N - 1] << "\n";
}


Measured memory_bytes: 1792
MAX = 100005

class Node
	attr_accessor :p, :l, :r
	def initialize(p, l, r)
		@p = p; @l = l; @r = r
	end
end

$t = []
#$d = []

def my_print(u)
	if $t[u].p == nil
		#print("node ", u, ": parent = -1, depth = ", $d[u], ", ")
		print("node ", u, ": parent = -1, depth = ", getDepth(u), ", ")
	else
		print("node ", u, ": parent = ", $t[u].p, ", depth = ", getDepth(u), ", ")
	end
	if $t[u].p == nil
		print("root, ")
	elsif $t[u].l == nil
		print("leaf, ")
	else
		print("internal node, ")
	end
	print("[")
	i = 0
	c = $t[u].l
	while c != nil
		print(", ") if i > 0
		print c
		i += 1
		c = $t[c].r
	end
	print("]\n")
end

def getDepth(u)
	d = 0
	while $t[u].p != nil
		u = $t[u].p
		d += 1
	end
	return d
end

def rec(u, p)
	$d[u] = p
	rec($t[u].r, p) if $t[u].r != nil
	rec($t[u].l, p + 1) if $t[u].l != nil
end

n = gets.to_i
for i in 0...n do
	$t[i] = Node.new(nil, nil, nil)
end
for i in 0...n do
	line = gets.split.map &:to_i
	v, d = line.shift, line.shift
	l = 0
	for j in 0...line.size do
		if j == 0
			$t[v].l = line[j]
		else
			$t[l].r = line[j]
		end
		l = line[j]
		$t[line[j]].p = v
	end
end
for i in 0...n do
	r = i if $t[i].p == nil
end

#rec(r, 0)

for i in 0...n do
	my_print(i)
end

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    unordered_map<int64_t, int64_t> x;
    for (auto _ : irange(0L, n)) {
        int64_t xx;
        cin >> xx;
        x[xx]++;
    }

    unordered_map<int64_t, pair<int64_t, int64_t>> y;
    for (const auto& kv : x) {
        auto xx = kv.first;
        y[xx % m].first += kv.second;
        y[xx % m].second += kv.second / 2;
    }

    int64_t ans = 0;
    for (auto i : irange(1L, (m + 1) / 2)) {
        auto mi = min(y[i], y[m - i]);
        auto ma = max(y[i], y[m - i]);

        ans += mi.first + min((ma.first - mi.first) / 2, ma.second);
    }

    ans += y[0].first / 2;
    if (m % 2 == 0) {
        ans += y[m / 2].first / 2;
    }

    cout << ans << endl;
}

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


int main(){
    int n;
    cin>>n;
    int m=n;
    int sn=0;
    for(int i=1000000000;i>0;i/=10){
	int a=n/i;
	sn+=a;
	if(a>0)n-=i*a;
    }
    if(m%sn==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::*;

fn main() {
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let mut a: i64 = itr.next().unwrap().parse().unwrap();
    let mut b: i64 = itr.next().unwrap().parse().unwrap();
    let mut k: i64 = itr.next().unwrap().parse().unwrap();

    let eaten = std::cmp::min(a, k);
    a -= eaten;
    k -= eaten;
    b -= std::cmp::min(b, k);

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let ans = format!("{} {}", a, b);
    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;
const int inf = 99999999;

using namespace std;

void print2(ll a , ll b){cout << a << " : " << b << endl;}
void print3(ll a , ll b , ll c){cout << a << " : " << b << " : " << c << endl;}

int main(){
	ll n,x,m;
	cin >> n >> x >> m;
	
	vector<ll> v = {};
	vector<ll> memo(m+100,-1);
	
	ll r = 0 , l = 0 , now = x;

	for(ll i = 0; i < n; i++){
		if(i == 0){
			now = x;
		}else{
			now = now*now;
		}
		now %= m;
		if(memo[now] == -1){
			memo[now] = i;
			v.push_back(now);
			continue;
		}else{
			l = memo[now];
			r = i - memo[now];
			break;
		}
	}
	
	ll ans = 0;
	if(l == 0 && r == 0){
		for(ll i = 0; i < v.size(); i++){
			ans += v[i];
		}
		cout << ans << endl;
		return 0;
	}
	
	ll cnt = (n - l) / r;
	ll h = (n - l) % r;
	
	for(int i = 0; i < l; i++){
		ans += v[i];
	}
	
	ll temp = 0;
	for(int i = l; i < l + r; i++){
		temp += v[i];
	}
	ans += cnt * temp;
	
	for(int i = l; i < l + h; i++){
		ans += v[i];
	}
	
	cout << ans << endl;
	
	return 0;
}
 

Measured memory_bytes: 4636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    cout<<min(b,n*a)<<endl;
    

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<bool> v(n, false);

    while(--k >= 0){
        int d;
        cin >> d;
        while(--d >= 0){
            int a;
            cin >> a;
            v[a-1] = true;
        }
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        if(!v[i])
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
 
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
 
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
 
#define REP(i, j, k) for(ll i = j; i < k; i++)
#define PRINT(i) cout << i << endl;
#define PRINT2(i,j) cout << i << " " << j << endl;
 
int
main(void){
  ll n, k;
  cin >> n >> k;
  if(k == 0){cout << n*n << endl; return 0;}
 
  ll sum = 0L;
  REP(i, k+1, n+1){
    ll q = n/i;
    ll p = n%i;
    ll itmp = i-k;
    if(itmp > 0) sum += q*itmp;    
    if(p >= k) sum += p-k+1;    
    //cout << "r:" << r << " q:" << q << endl;    
    //PRINT2(i, sum);    
  }
  
  PRINT(sum);
  
  return 0;
}


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

namespace abc051_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = x[0];
            if (K > x[1])
            {
                K = x[1];
            }
            int S = x[1];
            int a = 0;
            for (int i = 0; i <= K; i++)
            {
                for (int j = i; j <= K; j++)
                {
                    for (int k = j; k <= K; k++)
                    {
                        if (i + j + k == S)
                        {
                            if (i == j && j == k)
                            {
                                a++;
                            }
                            else if (i == j || j == k)
                            {
                                a += 3;
                            }
                            else
                            {
                                a += 6;
                            }
                        }
                    }
                }
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 2776
#include <iostream>
#include<string.h>
using namespace std;
int main() 
{
	char str[11];
	while(cin>>str)
	{
		bool a=0,b=0,c=1;
		int m=strlen(str),count=0;;
		if(str[0]=='A')
		{
			a=1;
		}
		for(int i=2;i<m-1;i++)
		{
			if(str[i]=='C')
			{
				count++;
			}
		}
		if(count==1)
		{
			b=1;
		}
		for(int i=0;i<m;i++)
		{
			if(str[i]>=65&&str[i]<=90)
			{
				if(str[i]!='A'&&str[i]!='C')
				{
					c=0;
				}
			}
		}
		if(a==1&&b==1&&c==1)
		{
			cout<<"AC"<<endl;
		}
		else cout<<"WA"<<endl;
	}
	return 0;
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    int ans = 0;
    for (int i = 5; i <= n; i *= 5) {
      ans += n / i;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	for(int i = 1; i <= B; i++) {
		if(i * A % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        
        if(A == 5 && B == 7 && C == 5){
            System.out.println("YES");
        }else if(A == 5 && B == 5 && C == 7){
            System.out.println("YES");
        }else if(A == 7 && B == 5 && C == 5){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for (int i = 0; i < q; i++) {
    cin >> a.at(i);
  }

  vector<int> v(n, 0);
  for (int i = 0; i < q; i++) {
    v.at(a.at(i) - 1)++;
  }

  for (int i = 0; i < n; i++) {
    if (k + v.at(i) - q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

void merge(int arr[],int f,int l,int middle){

int right=l-middle;
int left=middle-f+1;

int le[left],ri[right];

for(int i=f,j=0;i<=middle;i++){
 le[j++]=arr[i];
}

for(int i=middle+1,j=0 ;i<=l;i++){
ri[j++]=arr[i];
}

int i=0,j=0,k=f;

while(i<left&&j<right){

if(le[i]<=ri[j]){arr[k++]=le[i++];}

else{arr[k++]=ri[j++];}

}

while(i<left){
 arr[k++]=le[i++];
}

while(j<right){
arr[k++]=ri[j++];
}


}


void merge_sort(int arr[],int f,int l){

if(f<l){
int middle=(f+l)/2;
merge_sort(arr,f,middle);
merge_sort(arr,middle+1,l);
merge(arr,f,l,middle);

}

}

int main()
{
int n,num,count=0;

cin>>n>>num;

int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}

merge_sort(arr,0,n-1);

for(int i=0;i<num;i++){
count+=arr[i];
}

cout<<count<<endl;



    return 0;
}


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

int main(){
    int a;
    string s;
    cin >> a;
    while(true){
	if(a == 1){
	    s.push_back('1');
	    break;	    
	}
	else if(a == 0){
	    s.push_back('0');
	    break;	    
	}

	if(a%2==0)
	    s.push_back('0');
	else{
	    s.push_back('1');
	    a--;
	}	
	a /= -2;
    }
    reverse(s.begin(), s.end());
    
    cout << s <<endl;
}




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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 1e5 + 2;
const int MOD = 998244353; //1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {printf("0\n"); return 0;}
#define FAIL1 {printf("-1\n"); return 0;}
#define FAILNO {printf("NO\n"); return 0;}

int N;
LL M;
pair<int,int> A[MAXN];

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d%lld",&N,&M);
    for (int i = 0; i < N; i++)
        scanf("%d%d", &A[i].fi, &A[i].se);

    sort(A,A+N);
    LL ans = 0;
    int i = 0;
    while(M && i < N) {
        LL buy = min(M, 1LL*A[i].se);
        ans += buy * A[i].fi;
        M -= buy;
        i++;
    }

    printf("%lld", ans);

    printf("\n");
	return 0;
}



Measured memory_bytes: 1024
n = int(input())
h = list(map(int,input().split())) + [float('inf')]#番兵

cnt = 0
ans = 0
for i in range(n):
    if h[i] >= h[i+1]:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
	int vital[2] = {};
	int attack[2] = {};

	std::cin >> vital[0] >> attack[0] >> vital[1] >> attack[1];

	for (int i = 0; i < 1000; ++i) {
		vital[(i + 1) % 2] -= attack[i % 2];

		if (vital[(i + 1) % 2] <= 0) {
			if (i % 2 == 0) {
				std::cout << "Yes" << std::endl;
			}
			else {
				std::cout << "No" << std::endl;
			}
			
			break;
		}

	}


	

	return 0;
}

int mainA() {
	int s = 0, w = 0;

	std::cin >> s >> w;

	if (s <= w) {
		std::cout << "unsafe" << std::endl;
	}
	else {
		std::cout << "safe" << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3636
N = int(input())
h = list(map(int, input().split()))


if len(h) == 1:
    print(h[0])
    exit()
    
cnt = 0
cnt_line = 0
v = h[0]
for i in range(1, N):
    if h[i] < v:
        cnt += v - cnt_line
        cnt_line = h[i]
    v = h[i]
if h[-1] >= h[-2]:
    cnt += h[-1] - cnt_line
print(cnt)

Measured memory_bytes: 3064