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

const long long MOD=998244353;

template<class Abel> struct BIT{
    vector<Abel> dat;
    long long n;
    Abel unity;

    BIT(long long n_origin, Abel SUM_UNITY):dat(n_origin +1,SUM_UNITY), n(n_origin), unity(SUM_UNITY){}

    Abel sum_from_first(long long i){//[1,i]
        Abel s=0;
        while(i>0){
            s+=dat[i];
            i-= (i&(-i));
        }
        return s;
    }

    Abel sum(long long i, long long j){//[i,j)
        if(i>=j) return unity;
        Abel vl = sum_from_first(i-1);
        Abel vr = sum_from_first(j-1);
        return vr-vl;
    }

    void add(long long i, Abel x){
        while(i <= n){
            dat[i] += x;
            i += (i&(-i));
        }
    }

    long long BIT_lower_bound(long long L, long long R, Abel val){//[L,R)
        long long M;
        while(L<R-1){
            M=(L+R)/2;
            if(sum_from_first(M)==val&&sum_from_first(M-1)==val){
                R=M;
            }else if(sum_from_first(M)>val){
                R=M;
            }else{
                L=M;
            }
        }
        return L;
    }
};

int main(){
    //input
    long long N;
    cin >> N;
    vector<pair<long long, long long> > for_y_sort;
    long long x,y;
    long long i;
    for(i=1; i<=N; i++){
        cin >> x >> y;
        for_y_sort.push_back(make_pair(y,x)); 
    }

    //calc
    sort(for_y_sort.begin(),for_y_sort.end());
    vector<pair<long long, long long> > for_x_sort;
    for(i=0; i<N; i++){
        x=for_y_sort[i].second;
        y=i+1;
        for_x_sort.push_back(make_pair(x,y));
    }
    sort(for_x_sort.begin(),for_x_sort.end());
    long long yza[N+1];
    for(i=0; i<N; i++){
        y=for_x_sort[i].second;
        yza[i+1]=y;
    }
    BIT<long long> BIT_left(N,0), BIT_right(N,0);
    long long LU[N+1], LD[N+1], RU[N+1], RD[N+1];
    for(i=1; i<=N; i++){
        LD[i]=BIT_left.sum(1,yza[i]);
        LU[i]=BIT_left.sum(yza[i]+1,N+1);
        BIT_left.add(yza[i],1);
    }
    for(i=N; i>=1; i--){
        RD[i]=BIT_right.sum(1,yza[i]);
        RU[i]=BIT_right.sum(yza[i]+1,N+1);
        BIT_right.add(yza[i],1);
    }
    long long nibeki[N+1];
    nibeki[0]=1;
    for(i=1; i<=N; i++){
        nibeki[i]=nibeki[i-1]*2;
        nibeki[i]%=MOD;
    }
    long long ans;
    ans=N-4+MOD;
    ans%=MOD;
    ans*=(nibeki[N]-1);
    ans%=MOD;
    for(i=1; i<=N; i++){
        ans+=nibeki[LU[i]];
        ans%=MOD;
        ans+=nibeki[LD[i]];
        ans%=MOD;
        ans+=nibeki[RU[i]];
        ans%=MOD;
        ans+=nibeki[RD[i]];
        ans%=MOD;
    }

    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 22116
N = int(input())
A = list(map(int, input().split()))

x = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i % 2 == 0:
        if tmp < 1:
            x += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            x += 1+tmp
            tmp = -1
y = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i % 2 == 1:
        if tmp < 1:
            y += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            y += 1+tmp
            tmp = -1
print(min(x,y))

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

int main(){
	int min = 1000000, max = -1000000, n, tmp, i;
	long sum = 0;
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> tmp;
		
		if ( tmp < min){
			min = tmp;
		}
		if ( tmp > max){
			max = tmp;
		}
		sum += tmp;
	}
	cout << min << " " << max << " " << sum <<endl;		
    return 0;
}

Measured memory_bytes: 3104
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s: Chars,
    };

    let mut rcv = vec![n; n]; // rcv[i] は i 以降の r の個数
    let mut gcv = vec![n; n];
    let mut bcv = vec![n; n];

    let mut rc = 0;
    let mut gc = 0;
    let mut bc = 0;
    for i in (0..n).rev() {
        match s[i] {
            'R' => rc += 1,
            'G' => gc += 1,
            'B' => bc += 1,
            _ => unreachable!(),
        }
        rcv[i] = rc;
        gcv[i] = gc;
        bcv[i] = bc;
    }

    // println!("{:?}", rcv);
    // println!("{:?}", gcv);
    // println!("{:?}", bcv);

    let mut ans = 0_usize;
    for i in 0..n - 2 {
        for j in i + 1..n - 1 {
            if s[i] == s[j] {
                continue;
            }
            if (s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G') {
                ans += rcv[j + 1]
                    - if j + (j - i) < n && s[j + (j - i)] == 'R' {
                        1
                    } else {
                        0
                    };
            } else if (s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R') {
                ans += gcv[j + 1]
                    - if j + (j - i) < n && s[j + (j - i)] == 'G' {
                        1
                    } else {
                        0
                    };
            } else if (s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R') {
                ans += bcv[j + 1]
                    - if j + (j - i) < n && s[j + (j - i)] == 'B' {
                        1
                    } else {
                        0
                    };
            } else {
                unreachable!();
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2280
Public Class Program
  Shared Sub Main()
    Const Alphabet As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim s As String = Console.ReadLine()
    Dim ans As String = ""
    For i As Integer = 0 To s.Length() - 1
      ans &= Alphabet(Array.IndexOf(Alphabet, s(i)) + n)
    Next
    Console.WriteLine(ans)
  End Sub
End Class

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

using namespace std;

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

int main(){

    int n,a,b;
    cin >> n >> a >> b;
    vector<int> c,d,e;
    int t;
    rep(i,n){
        cin >> t;
        if(t<=a){
            c.push_back(t);
        }else if(t<=b){
            d.push_back(t);
        }else{
            e.push_back(t);
        }
    }

    cout << min(e.size(),min(d.size(),c.size())) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int num[3];
	cin >> num[0] >> num[1] >> num[2];
	int count5 = 0, count7 = 0;
	for (int i = 0; i < 3; i++) {
		if (num[i] == 5) count5++;
		if (num[i] == 7) count7++;
	}
	if (count5 == 2 and count7 == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int N, V[20], C[20], D[20];

int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> V[i];
    }

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

    for(int i=0; i<N; i++){
        D[i]=V[i]-C[i];
    }
    int sum=0;
    for(int i=0; i<N; i++){
        if(D[i]>0){
          sum+=D[i];
        }
    }
  	cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

double a, b, c, d, e, f;
double x, y;

int main() {
	a = -10000;
	cin >> a >> b >> c >> d >> e >> f;

	while (a != -10000) {
		x = (c * e - f * b) / (a * e - d * b);
		y = (c * d - f * a) / (b * d - e * a);

		if (x > -0.001 && x <= 0) x = 0;
		if (y > -0.001 && y <= 0) y = 0;

		printf("%.3f %.3f\n", x, y);

		a = -10000;
		cin >> a >> b >> c >> d >> e >> f;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

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

int main(void){
 
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}

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

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

  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    if (i != 0) W.at(i) = W.at(i - 1);
    if (S.at(i) == 'W') W.at(i)++;
  }

  reverse(S.begin(), S.end());

  vector<int> E(N);
  for (int i = 0; i < N; i++) {
    if (i != 0) E.at(i) = E.at(i - 1);
    if (S.at(i) == 'E') E.at(i)++;
  }

  reverse(E.begin(), E.end());

  int ans = 1e9;

  for (int i = 0; i < N; i++) {
    ans = min(ans, W.at(i) + E.at(i));
  }

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

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

int main() {
  // ここにプログラムを追記
  
  int N,A,x;
  cin>> N >> A;
 x =N/500;
  if (A>= N-500*x) {
    cout<< "Yes" << endl;
  }
  else {
   cout<< "No" << endl; 
  }
}


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    char maze[10][10];
    rep(i, h) {
        rep(j, w) {
            cin >> maze[i][j];
        }
    }
    int ans = 0;

    rep(mr, (1 << h)) {
        rep(mc, (1 << w)) {
            int b = 0;
            rep(i, h) {
                rep(j, w) {
                    if (((mr >> i) & 1) == 0 && ((mc >> j) & 1) == 0 && maze[i][j] == '#') b++;
                }
            }
            if (b == k) ans++;
        }
    }

    cout << ans << endl;

    return(0);
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    long long x, y, n;
    long long ans = 1;
    cin >> x >> y;
    n = x;
    while(n <= y){
        n = 2 * n;
        if(n <= y){++ans;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define REP(i,n) for(int i = 0 ; i < n ; i ++) 
#define ms(a,c) memset(a,c,sizeof a)
void min_self(int&x , int y) {x = min(x,y);}
int n , *a , *b , *c;
int dp[100001][4];
int f(int i , int prev) {
    if(i==n) {
        return 0;
    }
    int &ret = dp[i][prev];
    if(ret!=-1){
        return ret;
    }
    int op1 = INT_MIN , op2 = INT_MIN , op3 = INT_MIN;
    if(prev!= 1) {
        op1 = a[i] + f(i+1,1);
    }
    if(prev!= 2) {
        op2 = b[i] + f(i+1,2);
    }
    if(prev!= 3) {
        op3 = c[i] + f(i+1,3);
    }
    return ret = max({op1,op2,op3});
}
int32_t main() {
    cin >> n ;
    a = new int[n];
    b = new int[n];
    c = new int[n];
    REP(i,n) {
        cin >> a[i] >> b[i] >> c[i] ;
    }
    ms(dp,-1);
    cout << f(0,0) << endl;
    return 0;
}

Measured memory_bytes: 12032
x = list(input())
end = 0
for i in range(len(x)-1):
    if x[i] == x[i+1]:
        print(i+1,i+2)
        end += 1
        break
if end == 0:
    for j in range(len(x)-2):
        if x[j] == x[j+2]:
            print(j+1,j+3)
            end += 1
            break
if end == 0:
    print(-1,-1)

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int a,b;
	cin>>a>>b;
	for(int i=b*10;i<(b+1)*10;i++){
		if(i*8/100==a){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main() {
  string s;
  bool flag;
  cin >> s;
  sort(s.begin(),s.end());
  flag = (s[0]==s[1])&(s[1]!=s[2])&(s[2]==s[3]);
  cout << (flag?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def factorization(n: int):
    if n == 1:
        return []  # 1は素数ではない
    # 素因数分解
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):  # ここにバグがないか心配
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))

    if arr == []:
        arr.append((n, 1))

    return arr


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N = read_a_int()

# どれとも異なるという条件がなければ、簡単(肩の数を足し合わせるだけ)

# 以前のどの整数とも異なるという条件はどう管理する？
# あるpについてeは1,2,3と取って行ったほうがよい

fact = factorization(N)
# print(fact)
ans = 0
for p, e in fact:
    sub = 1  # いくつ引くか
    while sub <= e:
        ans += 1
        e -= sub
        sub += 1
print(ans)


Measured memory_bytes: 66864
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

vector<ll> v[28];
vector<ll> v2;

int dp[100001]={};
const ll INF=1000000000000000001;
int main() {

	string s;
	cin>>s;
	int ls=s.length();
	bool flg=false;
	for(int i=1;i<ls;++i){
		if(s[i]=='C'&&s[i-1]=='A')flg=true;
	}
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k-1);
    }
};


int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    ll sum = (a+b)%mod;
    a *= modpow(sum, mod-2, mod);   a %= mod;
    b *= modpow(sum, mod-2, mod);   b %= mod;
    c = 100*modpow(100-c, mod-2, mod)%mod;

    vector<ll> ax(200001), bx(200001);
    ax[0] = bx[0] = 1;
    for(int i = 1; i < 200001; i++) ax[i] = (ax[i-1]*a)%mod;
    for(int i = 1; i < 200001; i++) bx[i] = (bx[i-1]*b)%mod;
    
    ModComb mc(200001);

    ll ans = 0;
    for(int k = n; k <= 2*n-1; k++){
        ans += (ax[n]*bx[k-n]+ax[k-n]*bx[n])%mod*c%mod*k%mod*mc.nCk(k-1,n-1)%mod;
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
# -*- coding: utf-8 -*-
A = input()
N = input()
if len(N)%2 != 0:
    print("No")
else:
    for i in range(int(len(N)/2)):
        if N[i] != N[i+int(len(N)/2)]:
            print("No")
            break
    else:
        print("Yes")
        


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

int N;
vector<int> A;

int main() {
  cin >> N;
  int A_min, A_max;
  for(int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    A.emplace_back(a);
    if(i == 1) {
      A_min = a;
      A_max = a;
    } else {
      if(a < A_min) A_min = a;
      if(a > A_max) A_max = a;
    }
  }
  int answer = A_max - A_min;
  cout << answer << endl;
}
  


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

int n;
int odd;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		int t;
		scanf("%d", &t);
		if(t % 2 == 1) odd++;
	}

	if(odd % 2 == 0) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X[] = new int[N+1];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
}

Measured memory_bytes: 36160
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-04-29 14:38
# @url:https://atcoder.jp/contests/abc163/tasks/abc163_b
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    nm=list(map(int,input().split()))
    a=list(map(int,input().split()))
    n,m=nm[0],nm[1]
    if n>=sum(a):
        print (n-sum(a))
    else:
        print (-1)
if __name__ == "__main__":
    main()

Measured memory_bytes: 68504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll h[100010];
#define REP(i, N) for(int i=0,i##_len=(N);i<i##_len;i++)
int main() {
  int N;
  cin >> N;
  REP(i,N) cin >> h[i];
  for (int i=1;i<N;i++) {
    if(h[i-1] < h[i]){
      h[i] -= 1;
    }
    if(h[i-1] > h[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll m;
string S,T;
ll d;
ll ans;
ll dp[205][205];
ll M = 1000000007;
vector<ll> so;
ll ac,wa,tle,re;

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

Measured memory_bytes: 3636
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	long long k;
	string input;
	int place=0;
	cin>>input>>k;
	for(int i=0;i<input.size();i++)
	{
		int current = int(input[i])-48;
		if(current==1)
		{
			place = place + 1;
			if(place==k)
			{
				cout<<1;
				return 0;

			}
		}
		if(current!=1)
		{
			cout<<current;
			return 0;

		}
	}
	
	
}

Measured memory_bytes: 256
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }

  sort(p.begin(), p.end());
  ll ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	bool flag;
	if(s.length()==t.length()-1){
		flag = true;
	}
	else{
		flag = false;
	}
	if(flag==true){
		for(int i=0;i<s.length();i++){
			if(s[i]!=t[i]){
				flag = false; break;
			}
		}
	}
	if(flag==true){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
const int MAXA = 1e6 + 5;

int gcd(int a,int b){ return b? gcd(b,a%b): a;}

int a[MAXN], t[MAXA];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	for(int i=1; i<=n; ++i)
		++t[a[i]];
	
	bool flag = 1;
	for(int i=2; i<MAXA; ++i)
	{
		int cnt = 0;
		for(int j=i; j<MAXA; j+=i)
		{
			cnt += t[j];
			if(cnt>1) break;
		}
		if(cnt>1)
		{
			flag = 0;
			break;
		}
	}
	
	if(flag) printf("pairwise coprime");
	else
	{
		int res = a[1];
		for(int i=1; i<=n; ++i)
			res = gcd(res, a[i]);
		if(res == 1) printf("setwise coprime");
		else printf("not coprime");
	}
	return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if (a >= k) cout << k*1 << endl;
  if (a < k) {
    for (int i = 0; i < a; i++) {
      ans++;
    }
    if (b >= k-a) {
      cout << ans << endl;
    }
    if (b < k-a) {
      for (int j = 0; j < k-a-b; j++) {
        ans--;
      }
      cout << ans << endl;
    }
  }
} 

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
    int m, f, b;
    cin >> m >> f >> b;
    if(b > m+f) {
        cout << "NA" << endl;
        return 0;
    }
    if(b-m > 0) {
        cout << b-m << endl;
    }else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3116
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1000005
const int mod=1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,d,h;
int f[maxn];

inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k){
	int ret=1;
	for (;k;k>>=1,a=1ll*a*a%mod) if (k&1) ret=1ll*ret*a%mod;
	return ret;
}

int main(){
	n=read(),h=read(),d=read(); int fac=1,val=0;
	for (int i=1;i<=n;i++) fac=1ll*fac*i%mod,val=(val+fac)%mod;
	f[0]=1; int sum=f[0];
	for (int i=1,j=0;i<=h;i++){
		f[i]=1ll*sum*val%mod;
		sum=(sum+f[i])%mod; if (i-j==d) sum=(sum-f[j])%mod,++j;
	}
	int ans=1ll*f[h]*fac%mod*power(val,mod-2)%mod;
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main() {
    set<ll> myset;
    int a, b, c;
    cin >> a >> b >> c;
    myset.insert(a);
    myset.insert(b);
    myset.insert(c);

    if (len(myset) == 2) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B, C, K; std::cin >> A >> B >> C >> K;
  int k=0;
  for(; k<K;) {
    if ( A < B ) break;
    B *= 2;
    k++;
  }
  if ( A >= B ) {
    std::cout << "No" << std::endl;
    return 0;
  }
  for(; k<K;) {
    if ( B < C ) break;
    C *= 2;
    k++;
  }
  if ( B >= C ) {
    std::cout << "No" << std::endl;
    return 0;
  }
  std::cout << "Yes" << std::endl;

  return 0;
}



Measured memory_bytes: 3632
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
itn = int

sys.setrecursionlimit(10 ** 8)

N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

ans = 0
for i in range(100):
    ans = max(ans, sum(A1[0:i+1]) + sum(A2[i:100]))
print(ans)


Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m;
  	cin >> n >> m;
  
  	if(n > m) {
    	for(int i = 0; i < n; i++) {
        	cout << m;
        }
        }else{
        	for(int i = 0; i < m; i++) {
            	cout << n;
            }
        }
        return 0;
    }


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      Cout(a*b-(a+b-1));
     

       
return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

typedef complex<double> P;

int main(){
	int n,m,x,y;
	vector<vector<P> > vp;
	P rot[] = {P(1,0), P(0,1), P(0,1)*P(0,1), P(0,1)*P(0,1)*P(0,1)};
	
	while(scanf("%d",&n),n){
		vp.clear();
		rep(i,n+1){
			vector<P> v;
			int px,py;
			scanf("%d",&m);
			rep(j,m){
				scanf("%d %d",&x,&y);
				if( j>0 ){
					v.push_back(P((double)(x-px), (double)(y-py)));
				}
				px = x;
				py = y;
			}
			vp.push_back(v);
		}
#if DEB
		printf("n:%d\n",n);
		rep(i,vp.size()){
			printf("sz:%d  i:%d\n",vp.size(),i);
			rep(j,vp[i].size()){
				cout << vp[i][j] << "  180: " << vp[i][j]*P(1,0) << endl;
			}
			puts("");
		}
#endif		

		REP(i,1,vp.size()){
			if( vp[0].size() != vp[i].size() )continue;
			rep(k,4){
				bool f = true;
				rep(j,vp[0].size()){
					if( vp[0][j]!=vp[i][j]*rot[k] ){
						f = false;
						break;
					}
				}
				if( f ){
					printf("%d\n",i);
					break;
				}
				int sz = vp[0].size();
				f = true;
				rep(j,vp[0].size()){
#if DEB
					if( i==3 ){
						cout << vp[0][j] << " and " << vp[i][sz-j-1] << endl;
					}
#endif
					
					if( vp[0][j]!=vp[i][sz-j-1]*rot[k] ){
						f = false;
						break;
					}
				}
				if( f ){
					printf("%d\n",i);
					break;
				}
			}
		}
		printf("+++++\n");
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  if(n==2){
    cout<<-1<<endl;
    return 0;
  }
  if(n==3){
    cout<<".aa"<<endl<<"b.."<<endl<<"b.."<<endl;
    return 0;
  }
  if(n==6){
    cout<<"aabb.."<<endl<<"b..zz."<<endl<<"ba...."<<endl<<".a..aa"<<endl<<"..a..b"<<endl<<"..a..b"<<endl;
    return 0;
  }
  if(n==7){
    cout<<".aabbcc"<<endl<<"d.ee.ff"<<endl<<"dg..h.."<<endl<<"ig..h.."<<endl<<"i.jj.kk"<<endl<<"lm..n.."<<endl<<"lm..n.."<<endl;
    return 0;
  }
  if(n==11){
    cout<<"aabc......."<<endl<<"ddbc......."<<endl<<"efgg......."<<endl<<"efhh......."<<endl<<".....aabbcc"<<endl<<"....d.ee.ff"<<endl<<"....dg..h.."<<endl<<"....ig..h.."<<endl<<"....i.jj.kk"<<endl<<"....lm..n.."<<endl<<"....lm..n.."<<endl;
    return 0;
  }
  vector<string> vec(n);
  string s="";
  for(int i=0;i<n;i++){
    s+='.';
  }
  for(int i=0;i<n;i++){
    vec.at(i)=s;
  }
  int a,b;//4a+5b=n
  for(int i=0;i<6;i++){
    if((n-5*i)%4==0){
      b=i;
      a=(n-5*i)/4;
      break;
    }
  }
  for(int i=0;i<a;i++){
    vec[4*i][4*i]='a',vec[4*i][4*i+1]='a',vec[4*i][4*i+2]='b',vec[4*i][4*i+3]='c';
    vec[4*i+1][4*i]='d',vec[4*i+1][4*i+1]='d',vec[4*i+1][4*i+2]='b',vec[4*i+1][4*i+3]='c';
    vec[4*i+2][4*i]='e',vec[4*i+2][4*i+1]='f',vec[4*i+2][4*i+2]='g',vec[4*i+2][4*i+3]='g';
    vec[4*i+3][4*i]='e',vec[4*i+3][4*i+1]='f',vec[4*i+3][4*i+2]='h',vec[4*i+3][4*i+3]='h';
  }
  int x=4*a;
  for(int i=0;i<b;i++){
    vec[x][x]='a',vec[x][x+1]='a',vec[x][x+2]='b',vec[x][x+3]='b',vec[x][x+4]='c';
    vec[x+1][x]='e',vec[x+1][x+1]='.',vec[x+1][x+2]='d',vec[x+1][x+3]='d',vec[x+1][x+4]='c';
    vec[x+2][x]='e',vec[x+2][x+1]='f',vec[x+2][x+2]='.',vec[x+2][x+3]='.',vec[x+2][x+4]='g';
    vec[x+3][x]='h',vec[x+3][x+1]='f',vec[x+3][x+2]='.',vec[x+3][x+3]='.',vec[x+3][x+4]='g';
    vec[x+4][x]='h',vec[x+4][x+1]='i',vec[x+4][x+2]='i',vec[x+4][x+3]='j',vec[x+4][x+4]='j';
    x+=5;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<vec[i][j];
    }
    cout<<endl;
  }
}

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

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

  vector<long long> a(N+1,0);
  for(int i = 1;i <= N;i++) {
    cin >> a.at(i);
    a.at(i) += a.at(i-1);
  }
 

  sort(a.begin(),a.end());
  long long num = 1,ans = 0;
  for(int i = 0;i < N;i++) {
    if(a.at(i) == a.at(i+1)) num++;
    else {
      ans += num*(num-1) / 2;
      num = 1;
    }
  }
  ans += num*(num-1)/2;
  cout << ans << endl;

  

  

}




Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  double ans=0;
  rep(i,n){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY")ans+=x;
    else ans+=380000*x;
  }
  cout<<ans;
}

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


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

int main(){
  int N,sum;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sum=N;
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
    if(vec[i] == vec[i+1]) sum -= 1;
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstdio>
#define ll long long
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;
ll a[maxn];
ll r=0, l = 1;
ll n, b, s,sum=0;
int run(ll x)
{
	ll tmp = b - s;
	ll num = x*s;
	sum = 0;
	for (int i = n-1;i >= 0;i--)
	{
		
		if (a[i] - num > 0)
		{
			if ((a[i] - num) % tmp)
				sum += (a[i] - num) / tmp + 1;
			else
				sum += (a[i] - num) / tmp;
		}
	}
	if (sum > x)
		return 1;
	else
		return 0;
}
int main()
{
	cin >> n >> b >> s;
	for (int i = 0;i < n;i++)
	{
		scanf("%lld", &a[i]);
		r += a[i] / s + 1;
	}
	sort(a, a + n);
	while (l < r)
	{
		ll mid = (r + l) / 2;
		if (run(mid))
			l = mid + 1;
		else
			r = mid;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, x, t; cin >> n >> x >> t;
    cout << t * ((n+x-1) / x) << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  for(int i=0;i<n;i++){
    cin >>b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >>c[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=b[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i+1]-a[i]==1){
      ans+=c[a[i]-1];
     
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, MOD = 1e9 + 7;

int cnt[30];
char s[N];
int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    for(int i = 0; i < n; i++) cnt[s[i] - 'a']++;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int tmp = 1;
        for(int k = 0; k < 26; k++)
            if(k + 'a' != s[i] && cnt[k])
                tmp = (long long) tmp * (cnt[k] + 1) % MOD;
        cnt[s[i] - 'a']--;
        ans = (ans + tmp) % MOD;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

/*================================================
	GCD function
================================================*/
ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

ll A, B, C, D;
#define modCD(n) ( (n) / (C) + (n) / (D) - (n) / ((C) * (D) / gcd(C, D)) )
#define nmodCD(n) ( (n) - modCD(n) )

int main()
{
	cin >> A >> B >> C >> D;
	cout << nmodCD(B) - nmodCD(A - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace atcoder;
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int n, q, t, u, v;
int main(){
	scanf("%d%d", &n, &q);
	dsu d(n);
	rep(i,q){
		scanf("%d%d%d", &t, &u, &v);
		if(t == 0) d.merge(u, v);
		else puts(d.leader(u) == d.leader(v) ? "1" : "0");
	}
}

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

ll _0_1_Knapsack(int *w,ll *p,int n,int k,ll **dp)
{
    if(n<0)
        return 0;
    if(dp[n][k]!=-1)
        return dp[n][k];
    if(w[n]>k)
    {
        dp[n][k]=_0_1_Knapsack(w,p,n-1,k,dp);
        return dp[n][k];
    }
    else
    {
        dp[n][k]=max(_0_1_Knapsack(w,p,n-1,k-w[n],dp)+p[n],_0_1_Knapsack(w,p,n-1,k,dp));
        return dp[n][k];
    }
}
int main()
{
    int n,k;
    cin>>n>>k;
    int w[n];
    ll p[n];
    for(int i=0;i<n;i++)
        cin>>w[i]>>p[i];
    ll **dp;
    dp=new ll*[n];
    for(int i=0;i<n;i++)
        dp[i]=new ll [k+1];
    for(int i=0;i<n;i++)
        for(int j=0;j<=k;j++)
            dp[i][j]=-1;
    cout<<_0_1_Knapsack(w,p,n-1,k,dp);
    return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;

int main(void)
{
    int32_t ab, bc, ca;
    cin >> ab >> bc >> ca;

    cout << ab * bc * 0.5;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct segtree {
public:
	const int SIZE = 1 << 18;
	VI seg, lazy;
	//seg:区間の合計値 lazy:区間に対して、加える値でまだ遅延しているもの

	segtree() :seg(SIZE * 2), lazy(SIZE * 2) {}
	void lazy_evaluate(int k, int l, int r) {
		if (lazy[k] != 0) {
			seg[k] += lazy[k];
			//区間[l,r)にすべて同じ値を追加することになっていて、
			//segには合計値が入っているので、加える値を足す
			if (r - l > 1) {
				lazy[k * 2 + 1] += lazy[k];
				lazy[k * 2 + 2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}

	void update(int a, int b, int k, int l, int r, int x) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			lazy_evaluate(k, l, r);
		}
		else {
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
		}
	}
	int query(int a, int b, int k, int l, int r) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return seg[k];
		int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return x + y;
	}

	void update(int a, int b, int x) { update(a, b, 0, 0, SIZE, x); }
	//update(a,b,x) := [a,b)を全てxを加える
	int query(int a, int b) { return query(a, b, 0, 0, SIZE); }
	//query(a,b) := [a,b)に対する合計値を求める

};

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

	int A, B, ans = 0;
	cin >> A >> B;
	eFOR(i, A, B) {
		if (i % 10 == i / 10000 && (i / 1000) % 10 == (i % 100) / 10)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, k = map(int, input().split())
if N == k:
    print(1)
    for i in range(N-1):
        print(0)
    exit()

for i in range(1, k+1):
    t = N-k+1
    if i > t:
        print(0)
        continue
    count = cmb(t, i) * cmb(k-1, i-1) % (10**9 + 7)
    print(count)


Measured memory_bytes: 3944
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string direction;
	cin >> direction;
	bool n = false;
	bool w = false;
	bool s = false;
	bool e = false;
	
	for(int i = 0; i < direction.length(); i++){
		if (direction[i] == 'N') n = true;
		if (direction[i] == 'W') w = true;
		if (direction[i] == 'S') s = true;
		if (direction[i] == 'E') e = true;
	}
	
	if(n == s && w == e) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

const double INF = 1e99;

struct Edge {
  int from, to, cost, cap;
  Edge(int from_, int to_, int cost_, int cap_)
    : from(from_), to(to_), cost(cost_), cap(cap_) { }
};

int main() {
  cout.setf(ios::fixed);
  cout.precision(4);
  while(true) {
    int N, M; cin >> N >> M;
    if(N == 0) break;
    int S, G; cin >> S >> G;
    --S, --G;
    vector<Edge> g;
    for(int i = 0; i < M; ++i) {
      int x,y,d,c; cin >> x >> y >> d >> c;
      --x, --y;
      g.emplace_back(x,y,d,c);
      g.emplace_back(y,x,d,c);
    }
    M *= 2;
    // [from][to][speed]
    double d[N][N][31];
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < N; ++j)
        for(int c = 0; c < 31; ++c)
          d[i][j][c] = INF;
    for(int i = 0; i < M; ++i) {
      if(g[i].from == S) {
        d[S][g[i].to][1] = min(d[S][g[i].to][1], 1.0 * g[i].cost);
      }
    }
    while(true) {
      bool update = false;
      for(int i = 0; i < M; ++i) {
        for(int u = 0; u < N; ++u) {
          if(g[i].to == u) continue;
          if(g[i].from == u) continue;
          for(int c = 1; c <= 30; ++c) {
            for(int dc = -1; dc <= 1; ++dc) {
              int nc = c + dc;
              if(nc <= 0 || nc > g[i].cap) continue;
              if(d[g[i].from][g[i].to][nc] > d[u][g[i].from][c] + 1.0 * g[i].cost / nc) {
                d[g[i].from][g[i].to][nc] = d[u][g[i].from][c] + 1.0 * g[i].cost / nc;
                update = true;
              }
            }
          }
        }
      }
      if(!update) break;
    }
    double ans = INF;
    for(int u = 0; u < N; ++u) ans = min(ans, d[u][G][1]);
    if(ans == INF) {
      cout << "unreachable" << endl;
    }
    else {
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1516
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  ll n,m;
  std::cin >> n>>m;
  ll a=(m-2*n)/2;
  ll ans=0ll;
 // std::cout << a << std::endl;
  if(a<0){std::cout << m/2 << std::endl;exit(0);}
  else{for (ll i = max(a-5,0ll); i < a+5ll; i++) {
 //   std::cout << a << std::endl;
   // std::cout << min(n+i/2,(m-i)/2) << std::endl;
    ans=max(ans,min(n+i/2ll,(m-i)/2ll));
   // std::cout << ans << std::endl;
  }}
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256