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

typedef vector< vector< int > > Graph;

inline void dfs(int idx, const Graph& graph, vector< bool >& used, vector< int >& order){
  if(used[idx]) return;
  used[idx] = true;
  for(int i = 0; i < graph[idx].size(); i++) {
    dfs( graph[idx][i], graph, used, order);
  }
  order.push_back(idx);
}
inline void rdfs(int idx, const Graph& rgraph, vector< int >& cmp, const int& cnt){
  cmp[idx] = cnt;
  for(int i = 0; i < rgraph[idx].size(); i++) {
    if(cmp[rgraph[idx][i]] == -1) rdfs( rgraph[idx][i], rgraph, cmp, cnt);
  }
}
 
size_t StronglyConnectedComponents(const Graph& graph, const Graph& rgraph, vector< int >& cmp){
  size_t cnt = 0;
  cmp.assign( graph.size(), -1);
  static vector< bool > used(graph.size(), false);
  vector< int > order;
  for(int i = 0; i < graph.size(); i++) {
    dfs(i, graph, used, order);
  }
  reverse( order.begin(), order.end());
  for(int i = 0; i < order.size(); i++) {
    if(cmp[order[i]] == -1) rdfs( order[i], rgraph, cmp, cnt), cnt++;
  }
  return cnt;
}

typedef pair< int , int > Pi;

int main(){
  int n, m;
  cin >> n;
  cin >> m;
  Graph graph(n), rgraph(n); //先頭にくる人が強さある
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    rgraph[b].push_back(a);
  }
  vector< int > cmp;
  int sz = StronglyConnectedComponents( graph, rgraph, cmp);

  vector< Pi > ret(n);
  for(int i = 0; i < n; i++){
    ret[i] = make_pair( cmp[i], i);
  }
  sort( ret.begin(), ret.end());
  bool flag = false;
  for(int i = 0; i < n; i++){
    cout << ret[i].second + 1 << endl;
  }

  for(int i = 0; i < n - 1; i++){
    bool judge = false;
    for(int j = 0; j < graph[ret[i].second].size(); j++){
      if(graph[ret[i].second][j] == ret[i + 1].second){
        judge = true;
        break;
      }
    }
    if(!judge){
      cout << 1 << endl;
      return(0);
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T=1;
	//cin >> T;
	ll t=0;
	while(t++<T){
		ll n,k;
		cin>>n>>k;
		vll a(n);
		fo(i,n)cin>>a[i];
		ll lo=1,hi=*max_element(all(a)),ans;
		ll m;
		while(lo<hi){
			m=(lo+hi)/2;
			ll req=0;
			fo(i,n){
				if(a[i]%m==0)req+=a[i]/m-1;
				else req+=a[i]/m;
			}
			if(req<=k){hi=m;}
			else lo=m+1;
		}
		cout<<lo<<endl;
	}
return 0;
}


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

int main(){
    string s; cin >> s;
    string t;
    
    for(int i = 0; i < s.size(); i+=2){
        t.push_back(s[i]);
    }

    put(t);
}

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

    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            int ans = 0;
            if (n % 1000 != 0)
            {
                ans = 1000 - (n % 1000);
            }
            Output(ans.ToString());
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }


Measured memory_bytes: 27524
#include <stdio.h>

int main()
{
    long long int n,sn=0,nt=1;
    scanf("%d", &n);
    for(int i = 0; i <= 9; i++){
        sn += (n/nt)%10;
        nt *= 10;
    }
    if(n%sn==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String[] a = new String[]{"SUN","MON","TUE","WED","THU","FRI","SAT"};
        for(int i=0; i<7; i++) {
            if(a[i].equals(s)) {
                System.out.println(7-i);
            }
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int N;
int L[101];
int ans;
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> L[i];
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (L[i] == L[j]) continue;
			for (int k = j + 1; k <= N; k++) {
				if (L[i] == L[k] || L[j] == L[k]) continue;
				if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) {
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  
  vector<vector<bool>> bingo(3, vector<bool>(3, false));
  for (int i = 0; i < b.size(); i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b.at(i) == A.at(j).at(k)) {
          bingo.at(j).at(k) = true;
        }
      }
    }
  }
  
  bool isBingo = false;
  bool num1, num2, num3;
  for (int i = 0; i < 3; i++) {
    num1 = bingo.at(i).at(0);
    num2 = bingo.at(i).at(1);
    num3 = bingo.at(i).at(2);
    if (num1 && num2 && num3) isBingo = true;
  }
  
  for (int i = 0; i < 3; i++) {
    num1 = bingo.at(0).at(i);
    num2 = bingo.at(1).at(i);
    num3 = bingo.at(2).at(i);
    if (num1 && num2 && num3) isBingo = true;
  }
  
  if (bingo.at(0).at(0) && bingo.at(1).at(1) && bingo.at(2).at(2)) {
    isBingo = true;
  }
  
  if (bingo.at(0).at(2) && bingo.at(1).at(1) && bingo.at(2).at(0)) {
    isBingo = true;
  }
  
  if (isBingo) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef unsigned long long LL;
int n;
inline LL gcd(LL a,LL b) { return b==0?a:gcd(b,a%b); }
inline LL lcm(LL a,LL b) { return a/gcd(a,b)*b; }
int main() {
    while (~scanf("%d",&n)) {
        LL t,a;
        LL ans_t=1,ans_a=1;
        for (int i=1;i<=n;i++) {
            scanf("%lld%lld",&t,&a);
            if (t!=a) {
                LL t1=t,a1=a;
                while (!(t>=ans_t && a>=ans_a)) {
                    LL tmp=1;
                    while (t+t1*tmp<ans_t || a+a1*tmp<ans_a) tmp<<=1;
                    tmp=((tmp>>1)==0?1:(tmp>>1));
                    t+=t1*tmp, a+=a1*tmp;
                }
                ans_t=t; ans_a=a;
            } else {
                ans_t=max(ans_t,ans_a);
                ans_a=ans_t;
            }
        }
        printf("%lld\n", ans_a+ans_t);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> p(n),q(n),r(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    rep(i,n) r[i]=p[i];
    sort(all(r));
    int a,b;
    int cntp=0,cntq=0,nump=0,numq=0;
    do{
        rep(i,n){
            if(p[i]==r[i]) cntp++;
            if(q[i]==r[i]) cntq++;
        }
        if(cntp==n) a=nump;
        else nump++;
        if(cntq==n) b=numq;
        else numq++;
        cntp=0;
        cntq=0;
    }while(next_permutation(all(r)));
    cout<<abs(a-b);
}

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

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,K,Q;
int nums[2009];

int calc(int x){
    vector<int> tmp,vec;
    rep(i,N+1){
        if(nums[i]<x){
            int sz=tmp.size();
            if(sz>=K){
                sort(all(tmp));
                rep(j,sz-K+1){
                    vec.push_back(tmp[j]);
                }
            }
            tmp.clear();
        }else{
            tmp.push_back(nums[i]);
        }
    }
    
    int sz=vec.size();
    if(sz<Q) return INF;
    sort(all(vec));
    return (vec[Q-1]-vec[0]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K>>Q;
    rep(i,N) cin>>nums[i];
    
    set<int> st;
    rep(i,N) st.insert(nums[i]);
    
    int mn=INF;
    for(auto a:st){
        chmin(mn,calc(a));
    }
    cout1(mn)
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int res = min(n, k) * x;
	res += (n - k) > 0 ? (n - k) * y : 0;
	print(res);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main () {
    char c; cin >> c;
    if (islower(c)) {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

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

    int f[m+1]= {}, k[n];

    for(int i=0; i<n; i++)
    {
        cin>> k[i];
        while (k[i]--)
        {
            cin>> t;
            f[t]++;
        }
    }

    sort (f, f+m+1, greater <int> ());

    int i=0;
    while ( f[i] ==n)
        i++;

    cout << i;
    nl;


    return 0;
}




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


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
const int mod = 1e9+7;
void solve(){
     int n;
     cin >> n;
     map<int,int> h;
     for(int i = 0 ; i < n ; i++){
        int temp;cin>>temp;
        h[temp]++;
     }
     ll ans = 1;
     if(n%2){

        for(int i = n-1 ; i > 0; i -=2 ){
           if(h[i] == 2)ans =(2*ans)%mod;
           else ans = 0;
        }
        if(h[0] == 1)cout<<ans<<"\n";
        else cout<<"0\n";
     }
     else {
        for(int i = n-1; i >= 1; i-=2){
           if(h[i] == 2)ans=(2*ans)%mod;
           else ans = 0;
        }
        cout<<ans<<"\n";
     }


}


int main(){
   solve();
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll H,W,M;
    cin >> H >> W >> M;
    vector<ll> y(H);
    vector<ll> x(W);
    map<P,ll> A;
    REP(i,M){
        P pair;
        cin >> pair.F >> pair.S;
        pair.F--;
        pair.S--;
        A[pair] = 1;
        y[pair.F]++;
        x[pair.S]++;
    }
    ll my = 0;
    ll mx = 0;
    REP(i,H){
        chmax(my,y[i]);
    }
    REP(i,W){
        chmax(mx,x[i]);
    }
    map<int,bool> ym;
    ll yy = 0;
    ll xx = 0;
    map<int,bool> xm;
    REP(i,H){
        if(y[i] == my){
            ym[i] = 1;
            yy++;
        }
    }
    REP(i,W){
        if(x[i] == mx){
            xm[i] = 1;
            xx++;
        }
    }
    bool non = 0;
    ll count = 0;
    for(auto itr = A.begin();itr != A.end();itr++){
        if(ym[(*itr).F.F] == 1&&xm[(*itr).F.S] == 1){
            count++;
        }
    }
    if(xx*yy != count)non = 1;
    cout << mx + my - 1 + non << "\n";
}

Measured memory_bytes: 54612
#include <iostream>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if( (a == 5 && b == 7 && c == 5) ||
      (a == 7 && b == 5 && c == 5) ||
      (a == 5 && b == 5 && c == 7) )
    cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
int min=INF,max=-INF;
long sum=0;
int n=ir.nextInt();
while(n-->0){
 int a=ir.nextInt();
 min=Math.min(min,a);
 max=Math.max(max,a);
 sum+=a;
}
out.println(min+" "+max+" "+sum);
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 25424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X, A;
		X = sc.nextInt();
		A = sc.nextInt();

		if (X < A) {
			System.out.println("0");
		} else if (A <= X) {
			System.out.println("10");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int a,b;
  int ans = 0;
  int d = 1;
  cin >> a >> b;
  if(a>=b){
	for(int i=0;i<a;i++){
	  ans += b*d;
      d *= 10;
    }
  }else{
    for(int i=0;i<b;i++){
	  ans += a*d;
      d *= 10;
    }
  }

  cout << ans;
  
  return 0;
}

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

string solve(int n){
	long long int sum=0;
	for(int i=1; i*i<=n; ++i){
		if(n%i==0&&n!=1){
			sum+=i;
			if(i!=n/i&&i!=1) sum+=n/i;
		}
	}
	//cout << sum << endl;
	if(sum<n) return "deficient number";
	else if(n<sum) return "abundant number";
	else return "perfect number";
}

int main(){
	int N;
	while(cin >> N&&N){
		cout << solve(N) << endl;
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <math.h>
using namespace std;


bool primeNum(int num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	for (int i = 3; i <= sqrt(num); i += 2) {
		if (num%i == 0)
			return false;
	}
        return true;
}

int main(void) {

	int n;
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (primeNum(a)) count++;
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


vector<int> pos;
vector<int> item;
int anss = 0;
string s;

long long dp[100010][10];

int cost(int a,int b){
	return !b ? a : (a*2) / 10 + (a*2)%10;
}
int main(){
	int n,m;
	cin >> n;
	cin >> s;
	reverse(s.begin(),s.end());
	cin >> m;
	for(int i = 0 ; i < m ; i++){
		int a;
		cin >> a;
		item.push_back(a);
	}
	dp[0][0] = 1;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < 10 ; j++){
			if( s[i] == '*' ){
				for(int k = 0 ; k < item.size() ; k++)
					dp[i+1][(j+cost(item[k],i%2))%10] += dp[i][j];
			}else{
				dp[i+1][(j+cost(s[i]-'0',i%2))%10] += dp[i][j];
			}
		}
	}
	cout << dp[n][0] << endl;
	
}

Measured memory_bytes: 9168
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD  = 1000000007LL;
const long long MOD2 = 1012455881LL;
const long long MOD3 = 930446593LL;
const long long INF = 1e16;
const int INT_INF   = 1e8;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long long fact[100005], arr[100005];

long long nck(int n, int k){
    return fact[n] * fast_exp(fact[k], MOD - 2) % MOD * fast_exp(fact[n - k], MOD - 2) % MOD;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k; cin >> n >> k;

    fact[0] = 1;
    for(int i = 1; i < 100005; ++i) fact[i] = fact[i - 1] * i % MOD;

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

    long long tot = 0;
    for(int i = k - 1; i < n; ++i){
        tot = (tot + arr[i] * nck(i, k - 1) - arr[n - i - 1] * nck(i, k - 1) + MOD) % MOD;
    }
    cout << tot << "\n";

    return 0;

}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        int cards[] = new int[n];
        Arrays.fill(cards, 0);
        for (int i = 0; i < m; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;

            cards[l]++;
            if (r + 1 < n) {
                cards[r + 1]--;
            }
        }

        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            cards[i + 1] += cards[i];
            if (cards[i + 1] == m) count++;
        }
        if (cards[0] == m) count++;

        System.out.println(count);
    }
}


Measured memory_bytes: 65296
n = int(input())
h = list(map(int,input().split()))
#print(n,h)

ans = [0]*n

for i in range(n):
  if i-2>=0:
    ans[i] = min(abs(h[i-1] - h[i]) + ans[i-1], abs(h[i] - h[i-2]) + ans[i-2])
  elif i-1>=0:
    ans[i] = abs(h[i] - h[i-1]) + ans[i-1]
  else:
    ans[i] = 0

#print(ans)
print(ans[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 10000
using namespace std;
typedef long long ll;
typedef pair<int,bool> P;
typedef pair<P,P> PP;

int N;
double W;
double w[100000], v[100000];
double ans = 0.0, now;
struct Q{
    double r, w, v;
    bool operator<( const Q& right) const {
        return r < right.r;
    }
    bool operator>( const Q& right) const {
        return r > right.r;
    }
};
vector<Q> p, m;
int ip, im;

int main(){
    cin >> N >> W;
    rep(i,N){
        cin >> w[i] >> v[i];
        if(w[i] <= 0.0){
            if(v[i] >= 0.0){
                W -= w[i];
                ans += v[i];
            } else{
                if(w[i] < 0.0){
                    Q tmp;
                    tmp.r = -1.0*v[i]/w[i];
                    tmp.w = -1*w[i]; tmp.v = -1*v[i];
                    m.push_back(tmp);
                }
            }
        } else{
            if(v[i] > 0){
                Q tmp;
                tmp.r = v[i]/w[i];
                tmp.w = w[i]; tmp.v = v[i];
                p.push_back(tmp);
            }
        }
    }
    sort(m.begin(),m.end(),greater<Q>());
    sort(p.begin(),p.end(),greater<Q>());
    while(ip < p.size()){
        if(p[ip].w >= W){
            ans += (W/p[ip].w)*p[ip].v;
            p[ip].v *= (1.0-W/p[ip].w);
            p[ip].w -= W;
            break;
        } else{
            ans += p[ip].v;
            W -= p[ip].w;
            ip++;
        }
    }
    now = ans;
    while(ip != p.size() && im != m.size()){
        if(p[ip].w >= m[im].w){
            now += p[ip].v*(m[im].w/p[ip].w);
            now -= m[im].v;
            p[ip].v *= (1.0-m[im].w/p[ip].w);
            p[ip].w -= m[im].w;
            im++;
        } else{
            now += p[ip].v;
            now -= m[im].v*(p[ip].w/m[im].w);
            m[im].v *= (1.0-p[ip].w/m[im].w);
            m[im].w -= p[ip].w;
            ip++;
        }
        ans = max(ans,now);
    }
    printf("%.9f\n",ans);
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<double> vec(n);
  double ans;
  for(int i=0; i<n; i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ans=vec.at(0);
  for(int i=1; i<n; i++){
    ans=(ans+vec.at(i) )/2;
  }
  cout << fixed << setprecision(5);
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}

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


int main(){
    vector<int> A(3);
    rep(i, 3) cin >> A[i];

    sort(A.begin(), A.end());
    cout << A[2]-A[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

/* プロセスを表す構造体 */
typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }  /* 最小値を返す */

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  /* 全てのプロセスをキューに順番に追加する */
  for ( i = 1; i <= n; i++ ) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  /* シミュレーション */
  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t);  /* q または必要な時間 u.t だけ処理を行う */
    u.t -= c;  /* 残りの必要時間を計算 */
    elaps += c;  /* 経過時間を計算 */
    if ( u.t > 0 ) enqueue(u);  /* 処理が完了していなければキューに追加 */
    else printf("%s %d\n", u.name, elaps);
  }

  return 0;
}


Measured memory_bytes: 11888
//============================================================================
// Author      : JCH
// Copyright   :
// Description : Contest ACM Div2
//============================================================================

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

#define ll long long

ll n, x;

int main() {

	cin >> n >> x;

	ll r = 3LL * (n - __gcd(n, x));

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    vector<int> v[10];
    
    int n;cin>>n;
    string s;cin>>s;
    rep(i,0,n){
        int u=s[i]-'0';
        v[u].push_back(i);
    }
    int ans=0;
    rep(i,0,1000){
        int y=i;
        int a=y%10;y/=10;
        int b=y%10;y/=10;
        int c=y%10;
        int r=0;
        if(v[c].size()==0||v[b].size()==0||v[a].size()==0)continue;
        int cc=v[c][0];
        int e=upper_bound(v[b].begin(),v[b].end(),cc)-v[b].begin();
        if(e==v[b].size())continue;
        e=v[b][e];
        if(v[a].back()>e){
            ans++;
           // cout<<i<<endl;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 512
import numpy as np
n = int(input())
A = np.array([list(map(int,input().split())) for _ in range(n)])
s = np.argsort(A[:,1])
# B基準でソート
A = A[s]
a = 0
ans = 'Yes'
for i in range(n):
    a += A[i,0]
    b = A[i,1]
    if a > b:
        ans = 'No'
        break
print(ans)

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

int main(){
  int n,a,b;
  cin >> n;
  cin >> a;
  b = a+(n-1);
  int s = (a+b)*n/2;
  if (a>0){
    s -= a;    
  } else if (b<0){
    s -= b; 
  }
  cout << s << endl;
  return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i = 1; i < N; i++){
        cin >> C.at(i) >> S.at(i) >> F.at(i);
    }

    for(int i = 1; i <= N; i++){
        int time = 0;
        for(int j = i; j < N; j++){
            if(time <= S.at(j)) time = S.at(j);
            else if(time % F.at(j) == 0);
            else {
                // int tmp = ( time - S.at(j) + F.at(j) - 1) / F.at(j);
                // time = S.at(j) + tmp * F.at(j);
                time = time + F.at(j) - time % F.at(j); 
            }
            time += C.at(j);
        }
        cout << time << endl;
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2e5 + 123;
int n, p, suf[N], cnt[N];
string s;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> p >> s;
    if (p == 2 || p == 5) {
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            if ((s[i - 1] - '0') % p == 0) {
                ans += i;
            }
        }
        cout << ans;
        return 0;
    }
    int tmp = 1;
    for (int i = n; i >= 1; i--) {
        suf[i] = (suf[i + 1] + tmp * (s[i - 1] - '0')) % p;
        tmp = (tmp * 10) % p;
    }
    ll ans = 0;
    for (int i = n + 1; i >= 1; i--) {
        ans += cnt[suf[i]];
        cnt[suf[i]]++;
    }
    cout << ans;
}


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


bool solve(){
	int n;
	cin >> n;
	if( n == 0 )return false;
	int now = 0;
	int le = 0,ri = 0,cnt = 0;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		if(s[0] == 'l'){
			if(s[1] == 'u')le = 1;
			else le = 0;
		}else{
			if(s[1] == 'u')ri = 1;
			else ri = 0;
		}
		if(le == 1 && ri == 1 && now == 0){
			now = 1;cnt++;
		}else if(le == 0 && ri == 0 && now == 1){
			now = 0;cnt++;
		}
	}
	cout << cnt << endl;
	return true;
}

int main(void){
	while(solve()){}


	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

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

void Main()
{
	int n;
	cin >> n;
	vector<LL> a(n);
	REP(i, n) cin >> a[i];
	
	vector<LL> x(n);
	x[0] = 0;
	REP(i,n){
		if(i%2 == 0){
			x[0] += a[i];
		}
		else{
			x[0] -= a[i];
		}
	}

	FOR(i,1,n){
		x[i] = 2*a[i-1] - x[i-1];
	}

	REP(i,n){
		if(i!=0){
			cout << " ";
		}
		cout << x[i];
	}
	cout << endl;



	

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 2944
R, C = list(map(int, input().split()))

dist = [[0] * C for i in range(R)]

count_white = 0

for i in range(R):
    c_str = input()
    for j in range(len(c_str)):
        if c_str[j]=='#':
            dist[i][j] = -1
        else:
            dist[i][j] = -2
            count_white += 1

def check(x, y):
    global dist
    
    if x < 0:
        return False
    if x >= len(dist):
        return False
    if y < 0:
        return False
    if y >= len(dist[0]):
        return False
    
    if dist[x][y]!=-2:
        return False
    
    return True
    
            
#start
q = [[0, 0]]
dist[0][0] = 0

while(q):
    x = q[0][0]
    y = q[0][1]
    
    if check(x-1,y):
        dist[x-1][y] = dist[x][y] + 1
        q.append([x-1, y])
    if check(x+1,y):
        dist[x+1][y] = dist[x][y] + 1
        q.append([x+1, y])
    if check(x,y-1):
        dist[x][y-1] = dist[x][y] + 1
        q.append([x, y-1])
    if check(x,y+1):
        dist[x][y+1] = dist[x][y] + 1
        q.append([x, y+1])
    
    q.pop(0)

if dist[-1][-1]==-2:
    print(-1)
else:
    print(count_white - dist[-1][-1] -1)


Measured memory_bytes: 41964
//解説参照済み

function main(input = "") {
    const K = 0 | input;
    let L = 9 * K;
    if (L % 2 === 0) { return -1; }
    if (L % 5 === 0) { return -1; }
    if (L % 7 === 0) { L = 0 | L / 7; }

    let res = 0;
    let mod = 10 % L;
    for(i = 1; i <= L; i++){
        if(mod === 1){
            res = i;
            break;
        }
        mod = mod * 10 % L;
    }
    return res;
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}

Measured memory_bytes: 32156
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
void cmax(int&x,const int&y){x=x>y?x:y;}
void cmin(int&x,const int&y){x=x<y?x:y;}
const int mod=1e9+7;
void add(int&x,const int&y){x+=y;if(x>=mod)x-=mod;}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int s=0;
	int n;
	cin>>n;
	vector<int>a(n);
	int ans=0;
	for(auto x:a){
		cin>>x;
		add(ans,1ll*x*s%mod);
		add(s,x);
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main() {
  string S;
  getline(cin,S);
  for (int i=0; i<S.size(); i++) {
      if ((int)'A'<=(int)S.at(i) && (int)'Z'>= (int)S.at(i)) cout << (char)((int)S.at(i)+(int)'a'-(int)'A') ;
      else if ((int)'a'<=(int)S.at(i) && (int)'z'>= (int)S.at(i)) cout << (char)((int)S.at(i)+(int)'A'-(int)'a');
      else cout << S.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 3164
#include<stdio.h>                                                               
#include<stdlib.h>
#define N 100000                 

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

pro ces[N];
int head=0,tail;

void enqueue (pro re){
    if(head==(tail+1)%N){
        fprintf(stderr,"over flow\n");
        exit(1);
    }
    ces[tail]=re;
    if(tail+1==N)tail=0;
    else tail++;

}

pro dequeue(void){

    pro de;

    de=ces[head];
    if(head+1==N)head=0;
    else head++;
    return de;
}


int main(){                                                                     
  int all=0,n,q,i,then;  
  pro de;                                                                                                                                      

    scanf("%d%d",&n,&q);

    for(i=0;i<n;i++){
        scanf("%s%d",ces[i].name,&ces[i].time);
}
tail=n;
    while(1){
        de=dequeue();
        then=de.time-q;
        if(then>0){
            all+=q;
            de.time=then;
            enqueue(de);
     }
        else{
             all+=de.time;
            printf("%s %d\n",de.name,all);
            if(head==tail)break;
        }
    }   
return 0;
}                  


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, Q;
  cin >> N >> K >> Q;
  int A[N];
  K = K-Q;
  FOR(i,0,N) A[i] = K;
  FOR(i,0,Q)
  {
    int Ai;
    cin >> Ai;
    ++A[--Ai];
  }
  FOR(i,0,N)
  {
    if(A[i] > 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 1024
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := []byte(getString())

	pos := 0
	cnt := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'W' {
			cnt += i - pos
			// out(cnt, i-pos, pos)
			pos++
		}
	}
	out(cnt)
}


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

int main(){

	ll n, m, x, c[20], a[20][20], skills[4096][12] = {0};
	vector< pair<ll, ll> > costs;
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++){
		cin >> c[i];
		for(int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	for(int i = 0; i < pow(2, n); i++){
		int j = 0, temp, cost = 0;
		while(j < n){
			temp = (i >> j)%2;
			if(temp == 1){
				cost += c[j];
				for(int k = 0; k < m; k++){
					skills[i][k] += a[j][k];
				}
			}
			j++;
		}
		costs.push_back(make_pair(cost, i));
	}
	sort(costs.begin(), costs.end());
	for(int i = 0; i < costs.size(); i++){
		int f = 1;
		for(int j = 0; j < m; j++){
			if(skills[costs[i].second][j] < x){
				f = 0;
				break;
			}
		}
		if(f == 1){
			cout << costs[i].first << endl;
			return 0;
		}
	}
	cout << "-1\n";


	return 0;
}

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

using namespace std;


void func()
{
	uint32_t N, maxAi(0), minAi(UINT32_MAX);
	cin >> N;
	for (size_t i = 0; i < N; ++i)
	{
		uint32_t Ai;
		cin >> Ai;
		maxAi = max(Ai, maxAi);
		minAi = min(Ai, minAi);
	}
	cout << maxAi - minAi << endl;
}

int main() {

//	while(1)
		func();
	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main()
{
	int p, n, s = 0, t = 0, c = 0;
	char b;
	while (1)
	{
		cin >> p;
		if (cin.eof()) break;
		cin >> b >> n;
		s += p * n;
		t += n;
		c++;
	}
	cout << s << endl << (int)((double)t / c + 0.5) << endl;
}

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

using namespace std;
#define pii pair<int, int>
#define x first
#define y second
const int Nmax = 50 + 5;
const int Dx[] = {-1, 0, 1, 0};
const int Dy[] = {0, -1, 0, 1};
int n, m, tt;
bool a[Nmax][Nmax];
int dp[Nmax][Nmax];
queue<pii>q;
bool ok(int i, int j)
{
    return i >= 1 && j>= 1 && i <= n && j <= m && !a[i][j];
}
int main()
{
    char c;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            cin >> c;
            dp[i][j] = 1 << 30;
            if(c != '.')
                a[i][j] = 1;
            if(!a[i][j])tt ++;
        }
    if(a[1][1] || a[n][m])
    {
        cout << -1;
        return 0;
    }
    dp[1][1] = 1;
    q.push({1, 1});
    while(!q.empty())
    {
        int i = q.front().x;
        int j = q.front().y;
        q.pop();
        for(int d = 0, xx, yy; d < 4; ++d)
        {
            xx = i + Dx[d];
            yy = j + Dy[d];
            if(ok(xx, yy) && dp[xx][yy] > dp[i][j] + 1)
            {
                dp[xx][yy] = dp[i][j] + 1;
                q.push({xx, yy});
            }
        }
    }
    if(dp[n][m] == 1 << 30)
        cout << -1;
    else cout << tt - dp[n][m];
    return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T uPow(T z,T n, T mod){
  T ans = 1;
  while(n != 0){
    if(n%2){
      ans*=z;
      if(mod)ans%=mod;
    }
    n >>= 1;
    z*=z;
    if(mod)z%=mod;
  }
  return ans;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	long long n;cin>>n;
  if(n==2){
    cout << 1 << endl;
    return 0;
  }
  // /→/→-→-→の順番になるので、
  long long N = n;
  long long ans = 0;
  for(long long i = 2; N >= i*i; i++){
    while(!(N%i)){
      N/=i;
    }
    ans += !((N-1)%i);
    N = n;
    long long j = N/i;
    if(j==N/j)continue;
    while(!(N%j)){
      N/=j;
    }
    ans += !((N-1)%j);
    N = n;
  }
  cout << 2+ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define fork(a,b) for(int k=a;k<b;k++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define seto(x,i) memset(x,i,sizeof x)
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pf first
#define ps second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,d[51],t;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("", "r", stdin);
    cin>>n;
    fori(0,n)
        cin>>d[i];
    fori(0,n)
        forj(0,i)
            t+=d[i]*d[j];
    cout<<t;
    return 0;
}


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

using namespace std;

const int Max = 1e5 + 5;

int main() {
	int n, sticks[Max], h = -1, w = -1;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> sticks[i];
	 sort(sticks, sticks + n,[](int i, int j){
	 	return i > j; 
	 });
	
	for (int i = 1; i < n;)
		if (sticks[i] == sticks[i - 1]){
			if (h != -1){
				w = sticks[i];
				break;	
			}
			if (h == -1)
				h = sticks[i];
			i += 2;
		} else
			++i;
	if (h == -1 || w == -1)
		cout << 0;
	else
		cout << 1LL * h * w;
	return 0;
}

Measured memory_bytes: 640