akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int s[1000000],n;
int binarySearch(int key){
	int left=0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;

		if(key>s[mid]){
			left=mid+1;
		}else if(key<s[mid]){
			right=mid; 
		}else{
			return 1;
		}
	}
	

	return 0;
}

int main(void){
	int i,q,count=0;
	int t[1000000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&t[i]);
	}
	for(i=0;i<q;i++){
		if(binarySearch(t[i])){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 2252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

int main()
{
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  transform(&S[K-1], &S[K], &S[K-1], ::tolower);

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string N;
  cin >> N;
  if(N[0]=='9' || N[1]=='9') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
let arr = [|1; 1; 1; 2; 1; 2; 1; 5; 2; 2; 1; 5; 1; 2; 1; 14; 1; 5; 1; 5; 2; 2; 1; 15; 2; 2; 5; 4; 1; 4; 1; 51|]
let () = Scanf.scanf "%d" (fun k -> arr.(k-1)) |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int n; cin>>n;
    bool flag=true;
    for(int i=0;i<n;++i){
        int x; cin>>x;
        if(x%2==0&&x%3!=0&&x%5!=0) flag=false;
    }
    cout<<(flag?"APPROVED":"DENIED")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
int main() {
	int a,b,c,d;

	std::cin >> a>>b>>c>>d;

	if ((a + b) == (c + d)) {
		std::cout << "Balanced" << std::endl;
	}
	else {
		if (a + b > c + d) {
			std::cout << "Left" << std::endl;
		}
		else {
			std::cout << "Right" << std::endl;
		}
	}
	
}

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

using namespace std;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if(min(B,D) >= max(A,C))
     cout << min(B,D) - max(A,C) << endl;

  else
    cout << "0" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 200010;
ll n, k, ans;
ll presum[N], sufsum[N];
int main() {
	cin >> n >> k;
	for (ll i = 0; i <= n; i++) {
		presum[i] = presum[i - 1] + i;
	}
	for (ll i = n; i >= 0; i--) {
		sufsum[i] = sufsum[i + 1] + i;
	}
	for (ll i = k; i <= n + 1; i++) {
		ans = (ans + (sufsum[n - i + 1] - presum[i - 1] + 1)) % mod;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6212
#include <stdio.h>
#include <stdlib.h>
 
void solve(long **G, int n, int u, long *d, int t) {
  int i;
  char *flag;
  flag = (char*)malloc(sizeof(char) * n);
  for (i = 0; i < n; i++) {
    if(G[u][i] != -1 && (d[i] == -1 || d[i] > t+G[u][i])) {
      flag[i] = 1;
      d[i] = t+G[u][i];
    }
    else flag[i] = 0;
  }
  for (i = 0; i < n; i++) {
    if(flag[i] == 1) {
      solve(G,n,i,d,t+G[u][i]);
    }
  }
  free(flag);
}
 
int main()
{
  int n;
  int i,j,u,k,v;
  long **G,c;
  long *d;
  scanf("%d",&n);
  G = (long**)malloc(sizeof(long*) * n);
  for (i = 0; i < n; i++) {
    G[i] = (long*)malloc(sizeof(long) * n);
    for(j = 0; j < n; j++) G[i][j] = -1;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d %ld", &v, &c);
      G[u][v] = c;
    }
  }
  d = (long*)malloc(sizeof(long) * n);
  d[0] = 0;
  for (i = 1; i < n; i++) {
    d[i] = -1;
  }
  solve(G,n,0,d,0);
  for (i = 0; i < n; i++) {
    printf("%d %ld\n", i, d[i]);
  }
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  rep(i,n) {
    if (i==0) continue;
    ans += a[i/2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4768
#include <stdio.h>
int main(void){
    int n,i,cnt=1;
    int a[20];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    int max=a[0];
    for(i=1;i<n;i++){
        if(max<=a[i]){
            cnt++;
            max=a[i]; 
        }
    }
    printf("%d",cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int cnt[200005];
int n,a[200005];
long long k;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	vector<int> v;
	int x=1;
	do
	{
		v.push_back(x);
		cnt[x]=v.size();
		x=a[x];
	}
	while(!cnt[x]);
	int head=cnt[x]-1,round=v.size()-head;
	if(k<head)
	{
		cout<<v[k]<<endl;
		return 0;
	}
	k-=head;
	k%=round;
	cout<<v[k+head]<<endl;
	return 0;
}


Measured memory_bytes: 5756
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100005;

ll A[MAXN];

ll Ans = INFLL + INFLL;
int N, K;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i = 1; i <= N; i++) cin >> A[i];
	for(int s = 1, e = K; e <= N; s++, e++) {
		if(A[e] <= 0) {
			upmin(Ans, -A[s]);
		} else if(0 <= A[s]) {
			upmin(Ans, A[e]);
		} else {
			upmin(Ans, A[e] * 2 - A[s]);
			upmin(Ans, (-A[s]) * 2 + A[e]);
		}
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int X = scan.nextInt();
    int T = scan.nextInt();
    int ans = 0;
    if(N % X == 0){
      ans = (N / X) * T;
    }
    else{
      ans = (N / X);
      ans = (ans + 1 ) * T;
    }
    System.out.println(ans);
  }
}
     
     

Measured memory_bytes: 35868
N, K = map(int, input().split())
P = list(map(int, input().split()))

sum_ans = sum([(i+1)/2 for i in P[0:K]])
result = [sum_ans]
for i in range(K,N):
    result.append(result[-1] + (P[i]+1)/2 - (P[i-K]+1)/2)

print(max(result))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<double> v(n);
	double bunshi = 1.;
	REP(i, n) {
		cin >> v[i];
		bunshi *= v[i];
	}

	double bunbo = 0;
	REP(i, n){
		bunbo += bunshi / v[i];
	}

	cout << Decimal << bunshi / bunbo << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	char str[20];
	int i, len=0;

	cin >> str;

	while (str[len]) 
		len++;

	for (i = len - 1; i >= 0; i--)
		cout << str[i];

	putchar('\n');

	return 0;

}

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

int main(void)
{
    unsigned int x,sum=0;
    cin >> x;

    for (unsigned int i = 1; i < 50000; i++)
    {
        sum += i;
        if(sum>=x){
            cout << i << endl;
            break;
        }
    }

        return 0;
}

Measured memory_bytes: 256
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())

    
if T[0] =="?":
    if len(T) ==1 :
        T[0] ="D"
    elif T[1] =="?":
        T[0] ="P"
        T[1] ="D"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

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

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(m1 != m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N = INT()

A = LIST()

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(A))


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

bool i(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

int main() {
	ll x;
	cin>>x;
	for(ll j=x;j<=10000000;j++)
	{
		if(i(j)!=0)
		{
			cout<<j;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * Since g++10 is released, some characters is not valid inside #if 0 :(
 * So, why not using clang++? :D

 * Date:
  echo -n '  ' && date +%Y.%m.%d

 * Solution:
  To be updated.

 * Digression:

 * CopyRight:
          ▁▃▄▄▄▃▃▃▃▄▶
        ▗▇▀▔    ▔▔▔▔
       ▄▛   ▃▅━━■▄▂
      ▟▊   ▐▘     ▀▙
     ▟▜▌   ▐▖   ▋  ▐▍
    ▟▘ ▜   ▝▀▇▆●▘  ▐▌
  ▗▟▘   ▜▃       ▁▅▛
  ▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔
        ▔▔▔▔▔▔
 */

#include <cstdio>
#include <algorithm>
#include <string>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef std::string str;

struct _{
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 3000;
char s[maxn * 2 + 5];
int apos[maxn + 5], bpos[maxn + 5];
str f[maxn + 5], g[maxn + 5];

int main () {
	int n = read;
	scanf("%s", s + 1);

	for (int i = 1, ap = 0, bp = 0; i <= n * 2; i ++) {
		if (s[i] == 'a') apos[++ ap] = i;
		if (s[i] == 'b') bpos[++ bp] = i;
	}

	for (int i = n; i; i --) {
		if (apos[i] < bpos[i]) {
			int j = i;
			while (j <= n and apos[j] < bpos[i]) ++ j;
			f[i] = "ab" + g[j];
		}
		if (apos[i] > bpos[i]) {
			int j = i;
			while (j <= n and bpos[j] < apos[i]) ++ j;
			for (int k = 0; k < j - i; k ++) f[i] += 'b';
			f[i] += 'a' + (i + 1 == j ? g[i + 1] : f[i + 1]).substr(
					size_t(j - i - 1), str::npos);
		}
		g[i] = std::max(f[i], g[i + 1]);
	}

	puts(g[1].c_str());
}


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

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

  if(N-((N/10)*10)==9 || N/10==9){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
#define NMAX 100005*2


ll tab[NMAX];
ll tabdiff[NMAX];
ll tabsum[NMAX];
int main(){
    int n;
    ll count=0;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>tab[i];
        if(i-tab[i] >=0){
            tabdiff[i-tab[i]]++;
        }
        if(i+tab[i] < n){
            tabsum[i+tab[i]]++;
        }
    }

    for (int i = 0; i < NMAX; ++i)
    {
        count += tabsum[i] * tabdiff[i];
    }

    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 8268
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int add = 0;
		for(int i = 0; i < s.length(); i++) {
			int cur = Integer.parseInt(s.substring(i, i + 1));
			add += cur;
		}
		if(add % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const ll INF = 1000000000000;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
const int N = 1e5 + 7;
int dist1[N],dist2[N];
int n;
vector<int> v[N];
void dfs1(int vertex,int depth){
	if (dist1[vertex] != -1) return;
	dist1[vertex] = depth;
	for(int x : v[vertex]){
		dfs1(x,depth + 1);
	}
}

void dfs2(int vertex,int depth){
	if (dist2[vertex] != -1) return;
	dist2[vertex] = depth;
	for(int x : v[vertex]){
		dfs2(x,depth + 1);
	}
}
int main() {
	ios_base::sync_with_stdio(0);	
	cin >> n;
	
	forn(i,n - 1){
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	memset(dist1,-1,sizeof dist1);
	memset(dist2,-1,sizeof dist2);
	
	dfs1(1,0);
	dfs2(n,0);
	
	int a = 0;
	int b = 0;
	for(int i = 1; i <= n; i++)
		if (dist1[i] <= dist2[i])
			a++;
		else
			b++;
	if (a > b){
		cout << "Fennec\n";
	}
	else {
		cout << "Snuke\n";
	}
	return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int r = Integer.parseInt(scan.next());
	int g = Integer.parseInt(scan.next());
	int b = Integer.parseInt(scan.next());

	int num = 100*r + 10*g + b;
	String ans = (num%4 == 0 ? "YES" : "NO");
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include<unordered_map>
#define M 1000000007
#define T 998244353
#define PI 3.142
#define ll long long

using namespace std;

int dpj[100001][101];
int dp[100001];

int jump(int a, int k, int h[], int n)
{
    if(a==n){
        return 0;
    }
    if(dp[a]!=-1){
        return dp[a];
    }
    int min=INT32_MAX, i, x;
    for(i=a+1; i<=a+k && i<=n; i++){
        if(dpj[i][k]!=-1){
            x = dpj[i][k];
        }
        else {
            x = jump(i, k, h, n);
            dpj[i][k]=x;
        }
        x += abs(h[i]-h[a]);
        if(min>x){
            min=x;
        }
    }
    dp[a]=min;
    return min;
}

void ini()
{
    for(int i=0; i<100001; i++){
        dp[i]=-1;
        for(int j=0; j<101; j++){
            dpj[i][j]=-1;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, i;
    cin >> n >> k;
    int h[n+1];
    for(i=1; i<=n; i++){
        cin >> h[i];
    }
    ini();
    cout << jump(1, k, h, n) << "\n";
    return 0;
}

Measured memory_bytes: 51456
#include <stdio.h>
int main(void){
    int N,M;
    int ans[100]={};
    int kari1,kari2;
    scanf("%d %d",&N,&M);
    for(int i=0;i<M;i++){
    scanf("%d %d",&kari1,&kari2);
    ans[kari1]++;
    ans[kari2]++;
    }
    for(int i=1;i<=N;i++){
        printf("%d\n",ans[i]);
        
    }
    return 0;
}


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

int main(void) {
    int five = 0, seven = 0;
    for (int i = 0; i < 3; i++) {
        int in;
        cin >> in;
        if (in == 5) five++;
        else if (in == 7) seven++;
    }
    cout << ((five == 2 && seven == 1) ? "YES" : "NO") << endl;
}


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

using namespace std;

using llint = long long int ;
using ullint = unsigned long long int;


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

    ullint n, x, y;
    x=y=-1;

    cin >> n;

    for(ullint a=1; a*a<=n; a++){
        if(n%a==0){
            x=a;
        }
    }
    y=n/x;

    cout << (x - 1) + (y - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <chrono>

#define endl "\n"

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

template<typename T>
void printArray(T a) {
    for(auto i : a)
        cout << i << " ";

    cout << endl;
}

template<typename T>
void print2DArray(T a) {
    for(auto i : a) {
        for(auto j : i)
            cout << j << " ";

        cout << endl;
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n = 1;
    int m = 0;
    cin >> n >> m;

    vector<bool> ac = vector<bool>(n);
    vector<int> wa = vector<int>(n);

    ulli numAC = 0;
    ulli numP = 0;

    for (size_t i = 0; i < m; i++) {
        int p = 1;
        string ans = "";

        cin >> p >> ans;

        if (ac[p]) {
            continue;
        }
        if (ans == "AC") {
            ac[p] = true;
            numAC++;
            numP += wa[p];
        }
        else if (ans == "WA") {
            wa[p]++;
        }
    }

    cout << numAC << " " << numP << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  cout<<10*a.at(2)+a.at(0)+a.at(1)<<endl;
}

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

struct UnionFind{
  vector<int> data;
  UnionFind(int n) : data(n, -1) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x != y){
      if(data[y] < data[x]) swap(x,y);
      data[x] += data[y];//???????????´??°
      data[y] = x;//????????´??°
    }
    return x != y;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
};

struct Edge{
  int cost, from, to;
  Edge(int cost, int from, int to):
    cost(cost), from(from), to(to) {}
};

bool operator<(const Edge& a, const Edge& b){
  return a.cost != b.cost ? a.cost < b.cost : a.from != b.from ? a.from < b.from : a.to < b.to;
}

int main(){
  int n, m, INF = 1000000000;
  while(cin >> n >> m, n){
    int a, b, w;
    vector<Edge> E;
    for(int i = 0; i < m; ++i){
      cin >> a >> b >> w;
      --a;
      --b;
      //E.emplace_back(w,a,b);
      E.push_back(Edge(w,a,b));
    }
    sort(E.begin(),E.end());
    int ans = INF;
    
    for(int i = 0; i < m; ++i){
      int e = n-1;
      UnionFind uf(n);
      bool f = true;
      for(int j = i; j < m; ++j){
        int cost = E[j].cost, from = E[j].from, to = E[j].to;
        if(!uf.same(from,to)){
          --e;
          uf.unite(from,to);
        }
        if(!e){
          ans = min(ans,cost-E[i].cost);
          f = false;
          break;
        }
      }
      if(f) break;
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin>>a>>b;
    
    if (a+b >= 10)cout << "error" << endl;
    else cout << a+b <<endl;
    
    return 0;
}



Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll X, K, D;
	cin >> X >> K >> D;

	X = abs(X);

	ll ans;
	if (K <= X / D) {
		ans = X - D * K;
	} else {
		ll k = X / D;

		if (k % 2 == K % 2) {
			ans = X - D * k;
		} else {
			ans = abs(X - D * (k + 1));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3588
using System;

namespace ABC105_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int n;
          n = a % b;
            if(n == 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}


Measured memory_bytes: 13140
<?php
$n = trim(fgets(STDIN));
$s = [];
$tmp = [];
$s_sorted = [];
$counts = [];
for ($i = 0; $i < $n; $i++) {
    $s[$i] = trim(fgets(STDIN));
    for ($j = 0; $j < 10; $j++) {
        $tmp[$i][$j] = $s[$i][$j];
    }
    sort($tmp[$i]);
    $s_sorted[$i] = implode('', $tmp[$i]);
}
$counts = array_count_values($s_sorted);

$ans = 0;
foreach ($counts as $count) {
    if ($count === 1) {
        continue;
    }
    $ans += combination($count, 2);
}

echo $ans . PHP_EOL;

function permutation(int $n, int $k) : int
{
    if ($k > $n) return 0;
    elseif (0 < $k && $k <= $n)
        return array_reduce(range($n - $k + 1, $n), function ($c, $v) { return $c *= $v; }, 1);
    else return 1;
}

function factorial(int $n) : int
{
    return permutation($n, $n - 1);
}

function combination(int $n, int $k) : int
{
    return intval(permutation($n, $k) / factorial($k));
}


Measured memory_bytes: 132976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
template<class T>
struct FT{
    vector<T> d;
    FT(size_t n):d(n+1){}
    T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;}
    T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);}
    void add(size_t i,T x){for(++i;i<d.size();i+=i&-i)d[i]+=x;}
};
int dp[2020][2020] = {};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  map<tii, int> m;
  rep(i,2*n){
    char c; int a; cin >> c >> a;
    m[tii{c,a}] = i;
  }
  fill_n(dp[0], 2020*2020, INF);
  dp[0][0] = 0;
  FT<int> memo(2*n);
  rep(i,n+1){rep(j,n+1){ // i : B <-> j : W
    int db = m[tii{'B', i+1}] + memo.sum( m[tii{'B', i+1}], 2*n) - (i+j);
    if(db < 0) db = 0;
    if(i != n)
      dp[i+1][j] = min(dp[i+1][j], dp[i][j] + db);
    int dw = m[tii{'W', j+1}] + memo.sum( m[tii{'W', j+1}], 2*n) - (i+j);
    if(dw < 0) dw = 0;
    if(j != n)
      dp[i][j+1] = min(dp[i][j+1], dp[i][j] + dw);
    memo.add(m[tii{'W',j+1}],1);
    //cerr << i << " " << j << " " << dp[i][j] << " " << memo.sum( m[tii{'B', i+1}], 2*n) << endl;
  }
  rep(j,n+1)  memo.add(m[tii{'W', j+1}], -1);
  memo.add(m[tii{'B',i+1}],1);
  }
  cout << dp[n][n] << endl;
}

Measured memory_bytes: 16512
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,j,k,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3608
#import pysnooper
import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy

setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
s=Counter(["".join(sorted(list(stdin.readline().rstrip()))) for _ in range(n)]).most_common()
cnt=0
for i in s:
    cnt+=sum(range(1,i[1]))
print(cnt)

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

int main(){
	string str;
	cin>>str;
	int len = str.length();
	int mid = len/2;
	int r,l;
	if(len%2 != 0){
			r = mid+1;l=mid-1;
		}
	else {
			 l = mid-1;r=mid;
		}
	int count(0);	
	while(r != len || l != -1){
			if(str[l]!=str[r])count++;
			l--;r++;
		}	
	cout<<count;	
	return 0;
	}


Measured memory_bytes: 3608
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	
	public static void main(String[]__){
		int x=getInt(),a=getInt(),b=getInt();
		
		System.out.println(b-a<=0?"delicious":b-a<=x?"safe":"dangerous");
	}
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, D;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    for (int i = 0; i < N; ++i) cin >> X[i] >> Y[i];
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        if (pow(pow(X[i], 2)+pow(Y[i], 2), 0.5) <= D) ++res;
    }
    cout << res << endl;
    return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

    return 0;
}


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


bool dfs(int x, int y, vector<string> const& v, vector<vector<bool>>& used) {
    if(y == v.size()-1 && x == v[0].size()-1) {
        for(int i=0; i<v.size(); ++i) {
            for(int j=0; j<v[0].size(); ++j) {
                if(v[i][j] == '#' && !used[i][j]) {
                    return false;
                }
            }
        }
        return true;
    }
    int dx[2] = {0, 1}, dy[2] = {1, 0};
    bool ret = false;
    for(int i=0; i<2; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if(nx < v[0].size() && ny < v.size() && v[ny][nx] == '#') {
            used[ny][nx] = true;
            ret |= dfs(nx, ny, v, used);
            used[ny][nx] = false;
        }
    }
    return ret;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0; i<h; ++i) {
        cin >> v[i];
    }
    vector<vector<bool>> used(h, vector<bool>(w, false));
    used[0][0] = true;
    cout << (dfs(0, 0, v, used) ? "Possible" : "Impossible") << endl;
}


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100000 + 5;
int a[N], f[N];
int main(){
	int n;
	while(cin >> n) {
		rep(i,1,n+1) cin >> a[i];
		memset(f, 0, sizeof(f));
		int pos = 1, cnt = 0;
		bool flag = false;
		for(;;) {
			f[pos] = 1;
			pos = a[pos];
			cnt++;
			if(f[pos]) {
				flag = false;
				break;
			} else if(pos == 2){
				flag = true;
				break;
			}
		}
		if(flag) cout << cnt << endl;
		else cout << -1 << endl;
	}
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define nmax 5005

using namespace std;

int n,k;
int a[nmax];
bool pre[nmax][nmax]={}, suf[nmax][nmax]={};


int main(){
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		a[i]=min(a[i],k);
	}

	pre[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<k;j++){
			pre[i][j]=pre[i-1][j];
			if(j>=a[i]){
				pre[i][j]|=pre[i-1][j-a[i]];
			}
		}

		for(int j=0;j<=k;j++){
			if(pre[i-1][j] &&j+a[i]>=k){
				pre[i][k]=1;
			}
		}
	}
	suf[n+1][0]=1;
	for(int i=n;i>=1;i--){
		for(int j=0;j<k;j++){
			suf[i][j]=suf[i+1][j];
			if(j>=a[i]){
				suf[i][j]|=suf[i+1][j-a[i]];
			}
		}

		for(int j=0;j<=k;j++){
			if(suf[i+1][j] &&j+a[i]>=k){
				suf[i][k]=1;
			}
		}
	}

	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==k){
			continue;
		}

		int req = k-a[i];
		int val = INT_MAX, ind=0;
		for(int j=k;j>=0;j--){
			if(pre[i-1][j]){
				while(ind<=k && ((!suf[i+1][ind]) || j+ind<req)){
					ind++;
				}
				if(ind<=k){
					val=min(val,j+ind);
				}
			}
		}
		if(val>=k){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49152
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int c[501];
int s[501];
int f[501];

int main()
{
    int n, t;
    cin >> n;

    for (int i = 1; i < n; i++)
    {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int j = 1; j <= n; j++)
    {
        t = 0;
        for (int i = j; i < n; i++)
        {
            if (t < s[i])
            {
                t = s[i];
            }
            else
            {
                if (t % f[i] != 0)
                    t += f[i] - (t % f[i]);
            }
            t += c[i];
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp

#include <iostream>
using namespace std;
int n,m;
int number[201];

void cut(int k){
	int Numbers[201]={};
	for(int i=0;i<k;i++){
		Numbers[2*n-k+i] = number[i];
	}
	for(int i=0;i<2*n-k;i++){
		Numbers[i] = number[i+k];
	}
	for(int i=0;i<201;i++){
		number[i] = Numbers[i];
	}
}
void shaffle(){
	int array1[101]={},array2[101]={};
	for(int i=0;i<n;i++){
		array1[i] = number[i];
	}
	for(int i=n;i<2*n;i++){
		array2[i-n] = number[i];
	}
	for(int i=0;i<n;i++){
		number[2*i] = array1[i];
		number[2*i+1] = array2[i];
	}
}

int main(){
	int order[1001];
	cin >> n >> m;
	for(int i=1;i<=200;i++){
		number[i-1] = i;
	}
	for(int i=0;i<m;i++){
		cin >> order[i];
	}
	
	for(int i=0;i<m;i++){
		if(order[i] == 0){
			shaffle();
		}else{
			cut(order[i]);
		}
	}
	
	for(int i=0;i<2*n;i++){
		cout << number[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3068
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[400][400];
int dy[4] = {1,-1,0,0}, dx[4] = {0,0,1,-1};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	memset(dp, -1, sizeof(dp));
	ll ans = 0;
	rep(i,h)rep(j,w){
		if(s[i][j] == '.') continue;
		if(dp[i][j] != -1){
			ans += dp[i][j];
			continue;
		}
		ll cnt = 0;
		vector<P> v;
		queue<P> que;
		que.push(P(i, j));
		dp[i][j] = 0;
		while(!que.empty()){
			int y = que.front().first;
			int x = que.front().second;
			que.pop();
			rep(k,4){
				int ny = y + dy[k];
				int nx = x + dx[k];
				if(ny < 0 || h <= ny) continue;
				if(nx < 0 || w <= nx) continue;
				if(s[y][x] == s[ny][nx]) continue;
				if(dp[ny][nx] != -1) continue;
				que.push(P(ny, nx));
				dp[ny][nx] = dp[y][x];
				if(s[ny][nx] == '.') ++cnt;
				else v.emplace_back(ny, nx);
			}
		}
		ans += cnt;
		for(auto p : v){
			dp[p.first][p.second] = cnt;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(y%2==1) cout<<"No"<<endl;
  else{
    if(2*x<=y&&y<=4*x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  set<int> X, Y;
  for (int i = 0; i <= F; i++) {
    for (int j = 0; j <= F; j++) {
      int x = 100*A*i + 100*B*j;
      if (x <= F) X.insert(x);
      int y = C*i + D*j;
      if (y <= F) Y.insert(y);
    }
  }

  int best_x = 0, best_y = 0;
  for (int x : X) {
    for (int y : Y) {
      if (F < x + y || x*E < 100*y) continue;
      if (best_x == 0) best_x = x;
      if (best_y == 0) best_y = y;
      #ifdef LOCAL
      cout << x << ' ' << y << ' ' << best_x << ' ' << best_y << endl;
      #endif
      if (best_y*(x+y) < y*(best_x+best_y)) {
        best_x = x;
        best_y = y;
      }
    }
  }
  cout << best_x + best_y << ' ' << best_y << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if (A >= 13){
        ans = B;
    }
    else if (A <= 5){
        ans = 0;
    }
    else {
        ans = B / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>


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


map<string, int> mp;

int main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    long a[100000];
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = a[0 + k - 1] - a[0];
    rep(i, n + 1 - k) {
        int c = a[i + k - 1] - a[i];
        if (ans >= c)ans = c;
    }
    cout << ans << endl;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};

int main( void ){
	initialize();
	ll A, B, C, D;
	cin >> A >> B;
	if (A < 10){
		cout << B + 100 * ( 10 - A );
	}
	else
		cout << B;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	cin.tie( 0 );
	ios::sync_with_stdio( false );
}


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

int main() {

  int N;
  string S,T;
  vector<char> result;
  cin >> N;
  cin >> S >> T;


  for(int i=0;i<N;i++){
    result.push_back(S[i]);
    result.push_back(T[i]);
  }

  for(int i=0;i<result.size();i++){
    cout << result.at(i);
  }
  cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);

  REP(i, n) cin >> a[i];

  ll ans = 0LL;

  REP(i, n){
    ans += a[i]-1;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    
    rep(i, n) {
        ans = min(ans + k, ans * 2);
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

main(){
  int n,x,y;
  int i,j;
  cin >> n >> x >> y;
  
  int dist[n-1] = {0};
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      int distance[3] = { abs(j-i), abs(x-i)+1+abs(j-y) };
      sort(distance,distance+2);
      ++dist[ distance[0]-1 ];
  	}
  }
  for(i=0;i<n-1;i++){
    cout << dist[i] <<endl;
  }
  
  return 0;
}
     

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long int L,R, divL, divR;
	long long int minimo=2018, temp=0;
	
	cin>>L>>R;
	
	divL=(int) ((L-1)/2019);
	divR=(int) (R/2019);
	
	L=L%2019;
	R=R%2019;
	
	if (divL != divR)
	{
		cout<<0<<endl;
		return 0;
	}
	
	for (int i=L; i<R; i++)
	{
		for ( int j=i+1; j<=R; j++)
		{
			temp=(i*j)%2019;
			minimo=min(minimo,temp);
		}
	}
	cout<<minimo<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
const int N=2e5+5;
const int M=1e9+7;

vector<int> v[N];

int val[N],l[N],rep[N];

multiset<int> ms;

void dfs(int node,int par){

	ms.insert(val[node]);

	auto it=ms.lower_bound(val[node]);

	++it;

	if(it!=ms.end()){
		rep[node]=*it;
		ms.erase(it);
	}
	else
		rep[node]=-1;

	l[node]=ms.size();

	for(int x:v[node]){
		if(x==par)
			continue;
		dfs(x,node);
	}

	ms.erase(val[node]);

	if(rep[node]!=-1){
		ms.insert(rep[node]);
	}
}



int main(){	
	
	int n;
	sfi(n)

	f(i,1,n+1){
		sfi(val[i])
	}

	f(i,0,n-1){
		int x,y;
		sfi(x) sfi(y)
		v[x].push_back(y);
		v[y].push_back(x);
	}

	dfs(1,1);

	for(int i=1;i<=n;i++){
		cout<<l[i]<<endl;
	}
	return 0;	
}

Measured memory_bytes: 31348
#include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
struct k{
	int x,y,c;
};
queue<k> q;
int m[1002][1002],p[1002][1002];
int main(void) {
	k g,k;
	char d;
	int h,w,i,j,z,dx[8]={0,0,-1,1,-1,1,-1,1},dy[8]={-1,1,0,0,-1,-1,1,1};
	cin >> h >> w;
	for (i = 0; i <= h+1; i++) {
		for (j = 0; j <= w+1; j++)
			m[i][j]=0;
	}
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++){
			cin >> d;
			switch(d){
				case '.':
					m[i][j]=0;
					break;
				case '1':
					m[i][j]=1;
					break;
				case '2':
					m[i][j]=2;
					break;
				case '3':
					m[i][j]=3;
					break;
				case '4':
					m[i][j]=4;
					break;
				case '5':
					m[i][j]=5;
					break;
				case '6':
					m[i][j]=6;
					break;
				case '7':
					m[i][j]=7;
					break;
				case '8':
					m[i][j]=8;
					break;
				case '9':
					m[i][j]=9;
					break;
			}
		}
	}
		for(i=1;i<=h;i++){
			for(j=0;j<=w;j++){
				if(p[i][j]<=0)
					p[i][j]=0;
			}
		}
		for(i=1;i<=h;i++){
			for(j=0;j<=w;j++){
				if(m[i][j]==0){
					for(z=0;z!=8;z++)
						p[i+dy[z]][j+dx[z]]++;
				}
			}
		}
		for(i=1;i<=h;i++){
			for(j=0;j<=w;j++){
				if(m[i][j]!=0&&m[i][j]<=p[i][j]){
					m[i][j]=0;
					g.c=1;
					g.x=i;
					g.y=j;
					q.push(g);
				}
			}
		}
		while(!q.empty()){
			g=q.front();
		//	cout<<g.x<<" "<<g.y<<" "<<g.c<<endl;
			q.pop();
			for(i=0;i!=8;i++){
				p[g.x+dx[i]][g.y+dy[i]]++;
				if(m[g.x+dx[i]][g.y+dy[i]]-p[g.x+dx[i]][g.y+dy[i]]==0){
					m[g.x+dx[i]][g.y+dy[i]]=0;
					k.c=g.c+1;
					k.x=g.x+dx[i];
					k.y=g.y+dy[i];
					q.push(k);
				}
			}
		}
	cout<<g.c<<endl;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
int A[N];
string s;
int32_t main(){
    fast;
    cin >> s;
    int n = s.size() , ans = 0 , c = 0 ;
    for(int i = 0; i < n ; ++i){
        if(s[i]=='B') c++;
        else ans += c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	int x, a, b;
	cin >> x >> a >> b;

	if(a>=b){
		cout << "delicious";
	}else if((a+x)<b){
		cout << "dangerous";
	}else{
		cout << "safe";
	}
	cout << endl;
	return;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,c=0;
    double b=0;
    scanf("%d",&n);
    for(i=n; i>0; i--)
    {
        if(i%2!=0)
        {
            c++;
        }
    }
    b= (double) c/n;

    printf("%.10lf\n",b);
}


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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    int n;
    cin >> n;
    ll yen500 = n / 500;
    n -= (yen500 * 500);
    ll yen5 = n / 5;
    ll happiness = (yen500 * 1000) + (yen5 * 5);
    cout << happiness << "\n";
}


Measured memory_bytes: 3568