akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1000000

struct node{
  struct node *next;
  int v;
  int weight;
};
typedef struct node *Node;

int d[10001];
int color[10001];
int pi[10001];
int n;
Node head[10001];
void make1node(int,int,int);
int parent(int);
int left(int);
int right(int);
void minheapify(int *,int);
void buildminheap(int*);
void swap(int *,int *);
int heapextractmin(int *);
int H;

int main(){
  int i,j,mincost,u,sum=0,k,v,r,c;
  int A[10001];
  Node ni;
  
  scanf("%d",&n);
  H=n;
  
  for(i=0;i<10001;i++){
   
    head[i]=malloc(sizeof(struct node));
    head[i]->v=INF;
    head[i]->weight=INF;
    head[i]->next=NULL;
   
  }
    
  
    
  
  for(i=1;i<=n;i++){
    d[i]=INF;
    color[i]=WHITE;
    pi[i]=-1;
    scanf("%d%d",&r,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      /* printf("r=%d,v=%d\n",r,v);*/
      scanf("%d",&c);
      make1node(r,v,c);
    }
  }
  /* for(i=0;i<n;i++){
  for(ni=head[i]->next;ni!=NULL;ni=ni->next){
    printf("%d %d\n",ni->v,ni->weight);
  }
  printf("--\n");
  }*/
  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",A[i][j]);
    }
    printf("\n");
    }*/
d[0]=0;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      /*   for(ni=head[i]->next;ni!=NULL;ni=ni->next){*/
	  if(color[i]!=BLACK && d[i]<mincost){
	    mincost=d[i];
           u=i;
	  }
	 
	  /* }*/
    }
    
	if(mincost==INF) break;
	color[u]=BLACK;
	  for(ni=head[u]->next;ni!=NULL;ni=ni->next){
	    /* printf("ni->v=%d\nni->w=%d\n",ni->v,ni->weight);*/
	    if(color[ni->v]!=BLACK &&d[u]+ni->weight<d[ni->v]){
	      pi[ni->v]=u;
	      d[ni->v]=ni->weight+d[u];
	      /*  printf("d[%d]=%d\n",ni->v,d[ni->v]);*/
	      }
	  }
  }
  
    for(i=0;i<n;i++){
       printf("%d %d\n",i,d[i]);  
  }
  
    
  return 0; 
}
void make1node(int r,int a,int b){
  Node n;
  n=(Node)malloc(sizeof(struct node));
  n->v=a;
  n->weight=b;
  n->next=head[r]->next;
  head[r]->next=n;
  
}
void swap(int *p1,int *p2){
  int temp;
  temp=*p1;
  *p1=*p2;
  *p2=temp;
}
int parent(int i){
return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void minheapify(int A[],int i){
  int l,r,smallest;
  l=left(i);
  r=right(i);
  if(l<=H &&A[l]<A[i])smallest=l;
  else smallest=i;
  if(r<=H&&A[r]<A[smallest])smallest=r;

  if(smallest!=i){
    swap(&A[i],&A[smallest]);
    minheapify(A,smallest);
  }
}
void buildminheap(int A[]){
  int i;
  for(i=H/2;i>=1;i--){
    minheapify(A,i);
  }
}
int heapextractmin(int A[]){
  int min;
  if(H<1){
    printf("error\n");
      exit(0);
  }
  min=A[1];
  A[1]=A[H];
  H--;
  minheapify(A,1);
  return min;
}

  
  
      
	    
	
			
  



Measured memory_bytes: 17740
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	bool can = false;

	for (int i = 0; i * 7 <= N; i++)
		if ((N - i * 7) % 4 == 0) {
			can = true;
			break;
		}
	if (can)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //


unordered_map<ll , ll> factorize(ll x) {
	unordered_map<ll, ll> ans;

	for(ll m=2;m*m<=x;m++) {
		while (x % m == 0) {
			ans[m] = (ans[m] + 1) % MOD;
			x /= m;
		}
	}
	if(x > 1) { ans[x]++; ans[x]%=MOD;}
	return ans;
}

 
long long exponentiation(long long base, 
                        long long exp) 
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % N; 
  
    long long t = exponentiation(base, exp / 2); 
    t = (t * t) % N; 
  
    // if exponent is even value 
    if (exp % 2 == 0) 
        return t; 
  
    // if exponent is odd value 
    else
        return ((base % N) * t) % N; 
} 

ll NCR(ll n, ll r) {
	if (n < r ) return 0;
	if (r == 0) return 1;
	if (r > n / 2) return NCR(n, n - r);
	ll res = 1;
	for (ll k = 1; k <= r; ++k) {
		res = res*(n - k + 1) % MOD;
		res = res * exponentiation(k,MOD-2);
		res%=MOD;
	}
	return res;
}

ll count(ll x) {
	return NCR(x+n-1,n-1);
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	unordered_map<ll, ll> val = factorize(m);
	ll ans = 1;
	for (auto it : val) {
		ll xx = count(it.s);
		//cout<<xx<<" ";
		ans = (ans * xx) % MOD;
	}
	cout << ans;
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5968
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cfloat>
#include <queue>
#include <stack>

using namespace std;


#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define INF  INT_MAX

typedef long long LL;
typedef pair<int,int> P;
typedef vector<int,int> vii;


int main(){
    int n;cin>>n;
    while(n--){
        string s;cin>>s;
        char ans[2000];
        rep(i,2000) ans[i]='0';
        int now=1000;
        int start=1000,last=1000;
        //cout << s.length() << endl;
        for(int i=0;i<s.length();i+=3){
            //cout << i << endl;
            if(s[i]=='\n') break;
            ans[now]=s[i];
            if(s[i+2]=='>'){
                now++;
                if(now>last){
                    last=now;
                }
            }else if(s[i+1]=='<'){
                now--;
                if(start>now){
                    start=now;
                }
            }
        }
        //cout << start << endl;
        //cout << last << endl;
        for(int i=start;i<=last;i++){
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
K = int(input())
a = 0
d = 1
def snuke(x):
    a = 0
    while x>0:
        a += x%10
        x //= 10
    return a
for i in range(1, K+1):
    x = a + d
    y = a + 10*d
    if x/snuke(x) <= y/snuke(y):
        a = x
    else:
        a = y
        d *= 10
    print(a)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
ll modPow(ll x, ll n, ll mod = MOD){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;
 
        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}
const int MAX = 2000010;
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;
}

ll ans[10010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  ll N; cin >> N;

  
  for(int i=1; i<=500; i++){
    for(int j=1; j<=500; j++){
      for(int k=1; k<=500; k++){
        if(i*i+j*j+k*k+i*j+j*k+k*i <= 10000){
          ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
        }
      }
    }
  }
  for(int i=1; i<=N; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main(){
    int a,b,x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		for(b=1;b<=x;b++){
		    for(a=1;a<=y;a++){
			    printf("#");
		    }
			printf("\n");
		}
		printf("\n");
	}
			
	return 0;
}

Measured memory_bytes: 2588
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	char S[11];
	long long SUM=0;
	cin>>S;
	int len;
	for(len=0;S[len]!='\0';len++);
	for(int i=0;i<pow((double)2,len-1);i++){
		long long sum=0;
		long long temp=S[0]-'0';
		for(int j=1;j<len;j++){
			if(i&(1<<(j-1))){
				temp*=10;
				temp+=S[j]-'0';
			}
			else{
				sum+=temp;
				temp=0;
				temp+=S[j]-'0';
			}
		}
		sum+=temp;
		//cout<<sum<<endl;
		SUM+=sum;
	}
	cout<<SUM<<endl;
	return 0;
}

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

int main(void){
  long double B;
  long long A;
  cin >> A;
  cin >> B;
  long long c;
  
  c = A*B;
 
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3728
#include<iostream>

using namespace std;

#define ll long long int

ll dp[1001][1001];

const ll MOD = 1e9 + 7;

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

	int h,w; cin >> h >> w;

	char inp;

	dp[1][1] = 1;

	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			cin >> inp;
			
			if(inp == '.')
				dp[i][j] += (dp[i-1][j] + dp[i][j-1]) % MOD;
		}
	}

	cout << dp[h][w] << '\n';

	return 0;
}

Measured memory_bytes: 8064
import sys
s = input()
south = s.count('S')
north = s.count('N')
east = s.count('E')
west = s.count('W')

f = lambda x, y : x == 0 and y != 0 or x != 0 and y == 0

if f(south, north) or f(west, east):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String input = scanner.nextLine();
		
		String output = "";
		for(int i=0; i<input.length(); i++)
		{	
			if(i <= input.length()-5)
			{
				if(input.substring(i, i+5).equals("apple"))
				{
					output += "peach";
					i += 4;
				}
				else if(input.substring(i, i+5).equals("peach"))
				{
					output += "apple";
					i += 4;
				}
				else
				{
					output += input.substring(i, i+1);
				}
			}
			else
			{
				output += input.substring(i, i+1);
			}
		}
		
		System.out.println(output);
	}
}

Measured memory_bytes: 26520
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main(void){
  int count,n,i,r,max=0,maxnum=1;
  scanf("%d",&n);
  for(i=n;i>=1;i--){
    count=0;
    r=i;
    while(r>=1){
      if(r%2==1) break;
      count++;r=r/2;
    }
    if(count>max) {max=count;maxnum=i;}
  }
  printf("%d",maxnum);
  return 0;
}

Measured memory_bytes: 128
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# def main():
  

# # main()
# print(main())

n,a,b,c=LI()
l=[I() for _ in range(n)]
answer=inf

def f(lst,ind):
  global answer
  if ind==n:
    ac=lst.count(1)
    bc=lst.count(2)
    cc=lst.count(3)

    if ac==0 or bc==0 or cc==0:
      return min(answer,inf)

    _a=_b=_c=0
    for i,x in enumerate(lst):
      if x==1:
        _a+=l[i]
      elif x==2:
        _b+=l[i]
      elif x==3:
        _c+=l[i]
    # 合わなかった原因。短縮できることを忘れてた
    # if _a>a or _b>b or _c>c:
    #   return min(answer,inf)

    sm=0
    sm+=max(0,ac-1)*10
    sm+=max(0,bc-1)*10
    sm+=max(0,cc-1)*10
    sm+=abs(a-_a)
    sm+=abs(b-_b)
    sm+=abs(c-_c)

    return min(answer,sm)

  else:
    for i in range(4):
      lst[ind]=i
      answer=min(answer,f(lst,ind+1))

  return answer

lst=[-1]*n
print(f(lst,0))


Measured memory_bytes: 10804
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int getData(const vector<int>& data, int idx) {
  if (idx < 0 || idx >= data.size()) return 0;
  else return data[idx];
}

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> data;
  int cnt = 0;
  bool one = true;
  for (int i = 0; i < N; i++) {
    if (one && S[i] != '1') {
      if (cnt > 0) {
        data.push_back(cnt);
      }
      cnt = 1;
      one = false;
    } else if (!one && S[i] == '1') {
      if (cnt > 0) {
        data.push_back(cnt);
      }
      cnt = 1;
      one = true;
    } else {
      cnt++;
    }
  }
  if (cnt > 0) {
    data.push_back(cnt);
  }
  bool oneStart = S[0] == '1';

  int left = 0;
  if (S[0] == '0') left = -1;
  int len = 2 * K + 1;
  int right = left + len - 1;
  ll total = 0;
  for (int j = left; j <= right; j++) {
    total += getData(data, j);
  }
  ll ans = total;
  for (left++, right++ ; right <= data.size(); left++, right++) {
    total += getData(data, right);
    total -= getData(data, left-1);
    if ((oneStart && (right & 1) == 0) || (!oneStart && (right & 1) == 1)) {
      ans = max(ans, total);
    }  
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include<cstdio>
using namespace std;
int main()
{
	int a[10],b[10],i,w,k,x,j;
	x=10;
	for(i=0;i<10;i++)	scanf("%d",&a[i]);
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	for(i=0;i<10;i++)	scanf("%d",&b[i]);
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(b[i]<b[j]){
				x=b[i];
				b[i]=b[j];
				b[j]=x;
			}
		}
	}
	w=0;
	for(i=0;i<3;i++)	w+=a[i];
	k=0;
	for(i=0;i<3;i++)	k+=b[i];
	printf("%d %d\n",w,k);
	return 0;
}


Measured memory_bytes: 2716
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N;
ll A[200005];
map<ll,ll> mp;



int main(){
	cin>>N;
	Rep(i,N) cin>>A[i];
	ll sum[N+3]={};
  mp[0]=1;
  ll ans=0;
	Rep(i,N) {sum[i+1]=A[i]+sum[i];
           
                ans+=mp[sum[i+1]];
              mp[sum[i+1]]++;}
	
	cout<<ans<<endl;

	
	  return 0;
  }


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define FOR(i, N) for(int i = 0; i < (N); i++)
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int x;
	int l = 0;
	FOR(i, N) {
		cin >> x;
		l += min(abs(x - K), x) * 2;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>


class Cube {
    public :
    int a, b, c, d, e, f;
};

using namespace std;

int main() {
    Cube obj;
    Cube pre_obj;
    string s;
    int n;
    cin >> obj.a >> obj.b >> obj.c >> obj.d >> obj.e >> obj.f;
    cin >> s;
    n = s.size();
    //cout << obj.a << obj.b << obj.c << obj.d << endl;
    pre_obj = obj;


    for(int i = 0; i < n; i++){
        if(s[i] == 'S'){
            obj.a = pre_obj.e;
            obj.b = pre_obj.a;
            obj.c = pre_obj.c;
            obj.d = pre_obj.d;
            obj.e = pre_obj.f;
            obj.f = pre_obj.b;
        }
        else if(s[i] == 'N'){
            obj.a = pre_obj.b;
            obj.b = pre_obj.f;
            obj.c = pre_obj.c;
            obj.d = pre_obj.d;
            obj.e = pre_obj.a;
            obj.f = pre_obj.e;
        }
        else if(s[i] == 'E'){
            obj.a = pre_obj.d;
            obj.b = pre_obj.b;
            obj.c = pre_obj.a;
            obj.d = pre_obj.f;
            obj.e = pre_obj.e;
            obj.f = pre_obj.c;
        }
        else {
            obj.a = pre_obj.c;
            obj.b = pre_obj.b;
            obj.c = pre_obj.f;
            obj.d = pre_obj.a;
            obj.e = pre_obj.e;
            obj.f = pre_obj.d;
        }
        pre_obj = obj;
    }

    cout << obj.a << endl;
}


Measured memory_bytes: 3184
#include<iostream>
#include<vector>

using namespace std;

long modinv(long a, long mod){
    if(a == 0){
        perror("0 division");
        exit(1);
    }
    if(a == 1 || a%mod == 0){
        return 1;
    }
    
    else{
        long MOD = mod;
        long d = 0;
        long n = 0;
        vector<long> c(0);
        while( d != 1 ){
            n++;
            c.emplace_back(mod / a);
            d = mod % a;
            mod = a;
            a = d;
        } 
        long x = d;
        long y = -c[n-1];
        long temp;
        for(int i=n-2; i >= 0; i--){
            temp = y;
            y = x - c[i] * y;
            x = temp;
        }
        if(y>=0) return y;
        else return y + MOD;
    }
}

int main(){
    int mod = 1000000007;

    long N, K;
    cin >> N >> K;

    long ans = N-K+1;
    cout << ans <<endl;
    for(int i=2;i<=K; i++){
        ans = ans *(K-i+1) % mod * (N-K+2-i) %mod * modinv(i-1, mod)  %mod * modinv(i, mod) % mod;
        cout << ans%mod << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    long long int N,a[5],ans=0,m;
    cin >> N >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    ans += (N+a[0]-1) /a[0] + 4;
    m=a[0];
    for(int i=1;i<5;i++){
        if(a[i]<m){
            ans += (N+a[i]-1)/a[i] - (N+m-1)/m;
            m= a[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll mata[105][105], b[105], ans[105];
int main() {
    init();
    ll N, M;
    cin >> N >> M;
    rep(i, N) rep(j, M) cin >> mata[i][j];
    rep(i, M) cin >> b[i];

    rep(i, N) rep(j, M) ans[i] += mata[i][j] * b[j];

    rep(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 3184
#include<iostream>
#include<vector>
using namespace std;
struct Point { long double px, py; };
Point Minus(Point a, Point b) { Point C; C.px = a.px - b.px; C.py = a.py - b.py; return C; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int contain(vector<Point> v, Point p) {
    bool in = false;
    for (int i = 0; i < v.size(); ++i) {
        Point a = Minus(v[i], p), b = Minus(v[(i + 1) % v.size()], p);
        if (a.py > b.py) swap(a, b);
        if (a.py <= 0 && 0 < b.py)
            if (crs(a, b) < 0) in = !in;
        if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
    }
    return in ? 2 : 0;
}
int main() {
    vector<Point>vec;
    Point P;
    int n, q; cin >> n;
    vec.clear();
    for (int j = 0; j < n; j++) { cin >> P.px >> P.py; vec.push_back(P); }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> P.px >> P.py;
        int v = contain(vec, P); cout << v << endl;
    }
    return 0;
}


Measured memory_bytes: 3292
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
int n;cin>>n;
int d[n];
rep(i,n)cin>>d[i];
sort(d,d+n);
int mid=0;
mid=d[(n-1)/2];
int mid2=d[n/2];
int ans=mid2-mid;
cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef unsigned long long int ll;
#define INF LLONG_MAX

int main(){

    fastio ;

    ll n;
    vector<vector<ll>> dp(405 , vector<ll>(405,INF));
    vector<ll> a(405);
    vector<ll> prefix(405);

    cin >> n;
    for(ll i = 1; i <= n; i++) {
        cin >> a[i];
        if(i != 1) prefix[i] = prefix[i-1]+a[i];
        else prefix[i] = a[i];
    }
    // OPTIMAL SUB-PROBLEM :

    // dp[i][j] = minimum cost required to change from i...j

    // BASE CASE :

    for(ll i = 0 ; i <= n; i++) dp[i][i] = 0;

    // RECURSIVE RELATION :

    for(ll s = 1; s <= n-1; s++){
        for(ll i = 1; i <= n-s; i++){
            ll j = i+s;
            for(ll l = i; l <= j-1; l++){
                dp[i][j] = min(dp[i][j] , dp[i][l] + dp[l+1][j] + prefix[j]-prefix[i-1]);
            }
        }
    }

    // OPTIMAL SOLUTION :

     cout << dp[1][n];

}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;

    std::vector<int> vec(n);
    for (int i = 0; i<n; ++i)
        cin >> vec[i];

    i64 ans{0};

    for (int i=0; i<n; ++i) {
        for (int j = i+1; j<n; ++j) {
            ans += vec[i]*vec[j];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int k;
int min1=10000000;
void ssss(int is,int i)
{
    if(i==n)
    {
        min1=min(min1,is);
        return ;
    }
    ssss(is*2,i+1);
    ssss(is+k,i+1);
}
int main()
{
    cin>>n>>k;
    ssss(1,0);
    cout<<min1;
}


Measured memory_bytes: 256
import java.util.*;

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

    long total = 0;
    for (int i = 0; i < N; i++) {
      String x = sc.next();
      String u = sc.next();
      if ("JPY".equals(u)) {
        long value = Long.parseLong(x);
        total += (value*100000000);
      } else {
        long value = x100000000(x);
        total += (value*380000);
      }
    }
    
    System.out.println(divide100000000(total));
  }
  
  private static long x100000000(String x) {
    if (x.charAt(0) == '0') {
      // leading 0, skip 0 and '.'
      for (int i = 2; i < x.length(); i++) {
        if (x.charAt(i) != '0') {
          return Long.parseLong(x.substring(i, x.length()));
        }
      }
    } else {
      for (int i = 0; i < x.length(); i++) {
        if (x.charAt(i) == '.') {
          return Long.parseLong(x.substring(0, i) + x.substring(i+1, x.length()));
        }
      }
    }
    // not reach
    return 0;
  }
  
  private static String divide100000000(long value) {
    String v = Long.toString(value);
    if (v.length() > 8) {
      return v.substring(0, v.length() - 8) + "." + v.substring(v.length() - 8);
    } else {
      StringBuilder builder = new StringBuilder("0.");
      for (int i = 0; i < 8 - v.length(); i++) {
        builder.append('0');
      }
      return builder.append(v).toString();
    }
  }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < n-1; i++) {
        int x, y, k;
        cin >> x >> y >> k;
        x--;y--;
        g[x].push_back(make_pair(y, k));
        g[y].push_back(make_pair(x, k));
    }
    pair<int,int> start = g[0][0];
    queue<pair<int, int>> q;
    q.push(start);
    vector<bool> visited(n);
    visited[start.first] = true;
    vector<int> color(n);
    while (!q.empty()) {
        pair<int,int> pp = q.front();
        q.pop();
        int u = pp.first;
        for (auto v : g[u]) {
            int y = v.first;
            if (visited[y]) continue;
            int length1 = v.second;
            q.push(v);
            if (length1 % 2 == 0) color[y] = color[u];
            else color[y] = color[u] ^ 1;
            visited[y] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << color[i] << "\n";
    }


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; i++) cin >> W[i];

  bool ans = true;
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++)
      if (W[i] == W[j]) ans = false;

  for (int i = 0; i < N - 1; i++)
    if (W[i][W[i].size() - 1] != W[i + 1][0]) ans = false;

  if (ans) cout << "Yes" << endl; else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
S =input()
count =0

Bcount = S.count("B")
for i in range(0,N-1):
    for j in range(i+1,N):
        if (S[i] == "R" and S[j] == "G") or (S[i] == "G" and S[j] == "R") :
            count += Bcount
            if j+(j-i) <N  and S[j+(j-i)] == "B":
                count  -=1
            if i-(j-i) >=0 and S[i-(j-i)] =="B":
                count -=1
            if (i+j)%2 ==0 and S[int((i+j)/2)] == "B":
                count -=1
print(count)

Measured memory_bytes: 68900
def examA():
    N, M = LI()
    l = 1; r = N
    for _ in range(M):
        L, R = LI()
        l = max(L,l)
        r = min(R,r)
    ans = max(0,r-l+1)
    print(ans)
    return

def examB():
    N = I()
    S = [I()for _ in range(N)]
    rest = []
    for s in S:
        if s%10==0:
            continue
        rest.append(s)
    if sum(S)%10==0:
        if not rest:
            print(0)
            return
        ans = sum(S) - min(rest)
    else:
        ans = sum(S)
    print(ans)
    return

def examC():
    N, K = LI()
    K -= 1
    A = LI()
    L = A.index(1)
    #print(L)
    ans = (N-1+K-1)//K
    print(ans)
    return

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

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

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

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

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

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

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
const int MAX = 510000;
const int MOD = 1000000007;

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;
}
int main() {
	ll n,m,k;
	cin>>n>>m>>k;
    COMinit();
    ll ans=0;
    for(ll i=1;;i++){
    	if(n-i==0){
    		break;
    	}
    	ll cnt=COM(n*m-2,k-2);
    	cnt*=m*m;
    	cnt%=inf;
    	cnt*=i*(n-i);
    	cnt%=inf;
    	ans+=cnt;
    	ans%=inf;
    }
    for(ll i=1;;i++){
    	if(m-i==0){
    		break;
    	}
    	ll cnt=COM(n*m-2,k-2);
    	cnt*=n*n;
    	cnt%=inf;
    	cnt*=i*(m-i);
    	cnt%=inf;
    	ans+=cnt;
    	ans%=inf;
    }    
    cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 15564
#include<stdio.h>
int main(void){
    int n,a,b,c,i,j;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d%d%d",&a,&b,&c);
        if(a<b){
            j=a;
            a=b;
            b=j;
        }
        if(a<c){
            j=a;
            a=c;
            c=j;
        }
        if((a*a)==((b*b)+(c*c))){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
/* **********************************************

    File Name: main.cpp

    Auther: zhengdongjian@tju.edu.cn

    Created Time: 2015/8/26 ????????? ?????? 2:12:40

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

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

const int INF = 0xfffffff;
const int MAX = 307;
const int MAX_M = MAX * MAX << 1;

struct Edge {
	int to;
	int cap;
	int id;
	int nxt;
	int bakup;
	void set(int _to, int _cap, int _id, int _nxt) {
		to = _to;
		cap = _cap;
		id = _id;
		nxt = _nxt;
	}
} G[MAX_M];
int Q[MAX << 1];
int head[MAX], tot;
int level[MAX];
int iter[MAX];
int n, m, s, t;

inline void add_edge(int u, int v, int c, int id) {
	G[tot].set(v, c, id, head[u]);
	G[tot].bakup = c;
	head[u] = tot++;
	G[tot].set(u, c, -id, head[v]);
	G[tot].bakup = 0;
	head[v] = tot++;
}

bool bfs() {
	int le = 0, ri = 0;
	Q[ri++] = s;
	memset(level, -1, sizeof(level));
	level[s] = 0;
	while (le < ri) {
		int p = Q[le++];
		if (p == t) {
			return true;
		}

		for (int i = head[p]; ~i; i = G[i].nxt) {
			//puts("flag1");
			Edge& e = G[i];
			if (level[e.to] == -1 && e.cap > 0) {
				level[e.to] = level[p] + 1;
				Q[ri++] = G[i].to;
				//printf("push %d, level = %d\n", G[i].to, level[e.to]);
			}
		}
	}
	return false;
}

int dfs(int s, int t, int flow) {
	if (s == t) return flow;
	int sum = 0, tp;
	for (int& i = iter[s]; ~i; i = G[i].nxt) {
		Edge& e = G[i];
		if (e.cap > 0 && level[e.to] == level[s] + 1) {
			tp = dfs(e.to, t, min(flow, e.cap));
			flow -= tp;
			e.cap -= tp;
			G[i ^ 1].cap += tp;
			sum += tp;
			if (flow == 0) {
				break;
			}
		}
	}
	return sum;
}

int dinic() {
	int sum = 0;
	while (bfs()) {
		memcpy(iter, head, sizeof(int) * (n + 1));
		int tp;
		while ((tp = dfs(s, t, INF)) > 0) {
			sum += tp;
		}
	}
	return sum;
}

int main() {
	while (cin >> n >> m) {
		memset(head, -1, sizeof(int) * (n + 1));
		tot = 0;
		int u, v;
		for (int i = 0; i < m; ++i) {
			cin >> u >> v;
			add_edge(u, v, 1, i + 1);
		}
		/*
		for (int i = 1; i <= n; ++i) {
			printf("%d:", i);
			for (int j = head[i]; ~j; j = G[j].nxt) {
				printf(" %d", G[j].to);
			}
			puts("");
		}
		*/
		cin >> s >> t;
		int maxflow = dinic();
		cout << maxflow << endl;
		set<int> st;
		for (int i = 1; i <= n; ++i) {
			for (int j = head[i]; ~j; j = G[j].nxt) {
				Edge& e = G[j];
				if (e.bakup > 0) {
					if (e.cap > e.bakup) {
						st.insert(e.id);
					}
				}
			}
		}
		cout << st.size() << endl;
		for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
			cout << *it << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{

  int N;
  cin >> N;
  vector<long long> A(N + 1);
  vector<long long> B(N);

  for (int i = 0; i < N + 1; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }

  long long num = 0;
  for (int i = N - 1; i >= 0; --i) {
    long long n1 = min(A[i + 1] , B[i]);
    A[i + 1] -= n1;
    B[i    ] -= n1;
    long long n0 = min(A[i], B[i]);
    A[i] -= n0;
    B[i] -= n0;
    num += (n1 + n0);
  }
  cout << num;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<queue>
using namespace std;
signed main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> Q;
  for(int i=0; i<n; i++){
  	int a; cin >> a;
    Q.push(a);
  }
  while(m--){
  	int a; a = Q.top(); Q.pop();
    Q.push(a/2);
  }
  long long sum = 0;
  while(!Q.empty()){
  	int a; a = Q.top(); Q.pop();
    sum += a;
  }
  cout << sum << endl;
}


Measured memory_bytes: 892
n = int(input())
v = [[0]+[]*(n+1) for i in range(n+1)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    v[a].append([b,c])
    v[b].append([a,c])

q,k = map(int,input().split())
l = [k]
while l:
    now = l.pop()
    for i in v[now][1:]:
        if v[i[0]][0] == 0:
            v[i[0]][0] = i[1]+v[now][0]
            l.append(i[0])
            
for i in range(q):
    x,y = map(int,input().split())
    print(v[x][0]+v[y][0])

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

int main() {
  int n,count=0;
  cin >> n;
  vector<int> vec(n);
  vector<int> ans;
  rep(i,n){
    int h;
    cin >> h;
    vec[i] = h;
  }
  rep(i,n-1){
    if(vec[i]>=vec[i+1]){
      count++;
    }else{
      ans.push_back(count);
      count = 0;
    }
  }
  ans.push_back(count);
  sort(ans.begin(),ans.end(),greater<int>());
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fastin ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int n,a[110][2];
int main(){
	cin>>n;
	int flag=0;
	rep(i,1,n)	cin>>a[i][0]>>a[i][1];
	rep(i,3,n){
		if(a[i][0]==a[i][1]&&
		a[i-1][0]==a[i-1][1]&&
		a[i-2][0]==a[i-2][1]){
			flag=1;
		}
	}
	if(flag)	puts("Yes");
	else	puts("No");
	return 0;
}


Measured memory_bytes: 3628
function Main (input) {
  const s = input.split('')
  var c = 0
  for (var i = 0; i < s.length; i++) {
    if (s[i] === '1') {
      c++
    }
  }
  console.log(c)
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int[] a = new int[n];
      	int dp = 0;
      	int dp1 = 0;
     	int[] b = new int[n];
      	for(int i = 0; i < n; i ++){
        	a[i] = scan.nextInt();
          	b[i] = a[i];
        }
      	scan.close();
      	Arrays.sort(a);
      	dp = a[n-1];
      	dp1 = a[n-2];
      	
      	for(int i = 0; i < n; i ++){
          	if(b[i] == dp){
            	System.out.println(dp1);
            }
          	else{
            	System.out.println(dp);
            }
        }
    }	
}

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

int n,d,x[11][11];
int dis(int a,int b){
	int ans=0;
	for(int i=1;i<=d;i++)
		ans+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
	return ans;
}
bool judge(int a){
	for(int i=0;i<=127;i++)if(i*i==a)return 1;
	return 0;
}
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&x[i][j]);
			int sum=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(judge(dis(i,j)))sum++;
		}
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>
 
typedef vector<int> vec;
typedef long long int ll;
typedef unsigned long long ull;



int main(){
    fast_cin();
    int n;cin>>n;
    vec v(n+1, 0);
    rep(i, 0, n-1){
      int x;cin>>x;
      v[x]++;
    }
    rep(i, 1, n+1)
    cout<<v[i]<<endl;
}

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

int main(){
	unsigned int h,m,s;
	cin >> s;

	h = s / 3600;
	s -= h * 3600;

	m = s / 60;
	s -= m * 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

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

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

    vector<pair<int, string>> vp;
    rep(i, m){
        int p;
        string s;
        cin >> p >> s;
        vp.emplace_back(p, s);
    }

    vector<pair<int, int>> v(n, {0, 0});
    vector<bool> b(n, true);
    rep(i, m){
        if(vp[i].second == "WA" && b[vp[i].first-1]){
            v[vp[i].first-1].first++;
        }
        else if(vp[i].second == "AC"){
            v[vp[i].first-1].second++;
            b[vp[i].first-1] = false;
        }
    }

    int ac = 0, wa = 0;
    rep(i, n){
        if(v[i].second >= 1){
            ac++;
            wa += v[i].first;
        }
    }

    cout << ac << " " << wa << endl;

    return 0;
}

Measured memory_bytes: 7280
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string str; cin >> str;

    int n = str.size();
    int first = 0, last = 0;
    rep(i, n) {
        if (str[i] == 'A') {
            first = i;
            break;
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (str[i] == 'Z') {
            last = i;
            break;
        }
    }
    int len = last - first + 1;

    cout << len << endl;
}


Measured memory_bytes: 832
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;

ll solve(ll n, ll x, ll m){
    vector<int> isexist(m, 0);
    ll cur = x;
    int loopstart;
    int loopstepnum = -1;
    int initstep;
    for(int i = 1; i <= m+10; i++){
        if(isexist[cur] != 0){
            loopstart = cur;
            initstep = isexist[cur]-1;
            loopstepnum = i-isexist[cur];
            break;
        }else{
            isexist[cur] = i;
            cur = cur*cur;
            cur %= m;
        }
    }

    if(loopstepnum != -1){
        vector<ll> loopsum(loopstepnum+1, 0);
        {
            ll curnum = loopstart;
            for(int i = 1; i <= loopstepnum; i++){
                loopsum[i] = loopsum[i-1]+curnum;
                curnum = (curnum*curnum)%m;
            }
        }

        ll ans = 0;
        ll cur2 = x;
        for(int i = 0; i < min((ll)initstep, n); i++){
            ans += cur2;
            cur2 = (cur2*cur2)%m;
        }
        
        ans += loopsum[loopstepnum] * ((n-initstep)/loopstepnum);
        int laststep = (n-initstep) % loopstepnum;
        ans += loopsum[laststep];
        return ans;
    }else{
        return 0;
    }
}

int main(){
    ll n, x, m;
    cin >> n >> x >> m;
    
    cout << solve(n, x, m) << endl;
    return 0;
}

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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define sz s.size();
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<=n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int n;


void init(){
	si(n);
	LL pw = 0, m = 1;
	forq(i, 1, n)
	{
		pw = pow(1 , i);
		//printf("%lld\n", pw);
		m = (i * m) * pw;
		m %= MOD;

	}
	printf("%lld\n", m % MOD);
}

int main(){
	
	init();
	return 0;
}

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

int main() {
  int N;
  cin >>N;
  vector<long long> a(N);
  for(int i=0;i<N;i++){
    cin >>a[i];
    }
   long long ans = 0;
   bool flag = true;
  for(int i=0;i<N;i++){
    ans = max(a[i],ans);
    if(!(a[i] >= ans -1)){
      flag = false;
      break;
    }
  }
     
  if(flag) cout <<"Yes" <<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>





void solve(int a, int b, int c, int d) {
    int flag=1;
    while (1) {
        if (a<=0) {
            printf("No");
            break;
        }
        if (c<=0) {
            printf("Yes");
            break;
        }
        if (flag==1) {
            c-=b;
            flag=0;
        }
        else if (flag==0) {
            a-=d;
            flag=1;
        }
        // printf("\na %d b %d c %d d %d \n",a,b,c,d);
    }
}

int main () {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    solve(a,b,c,d);
}


Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x))%modulo)
#define Inf 10000000000000000

struct rolling_hash{
	vector<long long> h;
	vector<vector<long long>> t_hash;
	vector<vector<long long>> power;
	long long b;
	string t;
	
	rolling_hash(string &T){
		h.push_back(998244353);h.push_back(1000000007);h.push_back(1000000009);
		t_hash.resize(h.size(),vector<long long>(T.size()+1,0));
		power.resize(h.size(),vector<long long>(T.size()+1,1));
		b = 1010101;
		t=T;
		
		for(int i=0;i<h.size();i++){
			for(int j=1;j<=t.size();j++){
				power[i][j] = (power[i][j-1] * b)%h[i];
			}
		}
		
		for(int i=0;i<h.size();i++){
			for(int j=1;j<=t.size();j++){
				t_hash[i][j] = ((t_hash[i][j-1]*b + (long long)t[j-1]))%h[i];
			}
		}
			
		
	}
	
	//[l,r)
	vector<long long> get(int l,int r){
		vector<long long> ret(h.size());
		for(int i=0;i<h.size();i++){
			ret[i] = t_hash[i][r] - (t_hash[i][l] * power[i][r-l]);
			if(ret[i]>=0)ret[i]%=h[i];
			else{
				ret[i] = (-ret[i]%h[i]);
				ret[i] = (h[i]-ret[i])%h[i];
			}
		}
		return ret;
	}
	
};

int main(){
	
	string s,t;
	cin>>s>>t;
	
	rolling_hash ro_t(t);
	
	
	int sz = s.size();
	s = s+s;
	while(true){
		if(s.size()>=t.size()*2)break;
		s = s+s;
	}
	
	rolling_hash ro_s(s);
	

	vector<vector<int>> E(sz,vector<int>(0));
	vector<int> jisuu(sz,0);
	
	for(int i=0;i<sz;i++){
		if(ro_s.get(i,i+t.size())==ro_t.get(0,t.size())){
			int k = (i+(int)t.size())%sz;
			E[i].push_back(k);
			jisuu[k]++;
		}
	}
	queue<int> que;
	vector<int> sorted(0);
	
	for(int i=0;i<sz;i++){
		if(jisuu[i]==0){
			que.push(i);
		}
	}
	
	while(que.size()!=0){
		int x = que.front();
		que.pop();
		sorted.push_back(x);
		for(int i=0;i<E[x].size();i++){
			int a = E[x][i];
			jisuu[a]--;
			if(jisuu[a]==0)que.push(a);
		}
	}
	vector<int> dis(sz,-1);
	if(sorted.size()!=sz){
		cout<<-1<<endl;
		return 0;
	}
	
	for(int i=0;i<sz;i++){
		int now = sorted[i];
		vector<int> k(0);
		int cnt = 0;
		while(true){
			if(dis[now]!=-1){
				cnt += dis[now];
				break;
			}
			k.push_back(now);
			if(E[now].size()==0)break;
			cnt++;
			now = E[now][0];
		}
		for(int j=0;j<k.size();j++){
			dis[k[j]]=cnt-j;
		}
	}
	
	int ans = 0;
	for(int i=0;i<sz;i++)ans = max(ans,dis[i]);
	
	
	
	cout<<ans<<endl;
	
		
	
		
	
	return 0;
}


Measured memory_bytes: 153676
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string T;
	cin >> T;

	for (long long i = 0; i < T.length(); i++)
	{
		if (T[i] == '?')
		{
			T[i] = 'D';
		}
	}

	cout << T << endl;

}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
int a[100005];

int main(){
	scanf("%d",&n);
	fore(i,1,n+1)scanf("%d",a+i);
	n+=2;
	int s=0;
	fore(i,0,n-1)s+=abs(a[i]-a[i+1]);
	fore(i,1,n-1)printf("%d\n",s-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
	return 0;
}

Measured memory_bytes: 1664