akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int a,b;
        char c;
        cin>>a>>c>>b;
        if(c=='?'){
            break;
        }
        else if(c=='+'){
            cout<<a+b<<endl;
        }
        else if(c=='-'){
            cout<<a-b<<endl;
        }
        else if(c=='*'){
            cout<<a*b<<endl;
        }
        else{
            cout<<a/b<<endl;
        }
    }
}


Measured memory_bytes: 3032
while line = gets
  a1, m1, a2, m2, a3, m3 = line.chomp.split.map(&:to_i)
  break if a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0
  x, y, z = [1, 1, 1]

  i = 0
  loop do
    x = a1 * x % m1
    i += 1
    break if x == 1
  end

  j = 0
  loop do
    y = a2 * y % m2
    j += 1
    break if y == 1
  end

  k = 0
  loop do
    z = a3 * z % m3
    k += 1
    break if z == 1
  end

  puts k.lcm(j.lcm(i))
end

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

int main()
{
    int arr[100000], pen[100000], i;
    for(i =0; i< 100000; i++)
    {
        arr[i]=0;
        pen[i]=0;
    }
    int n, m, penal= 0, score =0, num;
    string s;
    scanf("%d %d", &n, &m);
    getchar();
    for(i =0; i<m; i++)
    {
        scanf("%d", &num);
        getchar();
        cin >> s;
        getchar();
        if(arr[num]==0)
        {
            if(s[0]=='W')
                pen[num]++;
            else
            {
                arr[num]=1;
                penal+=pen[num];
                score++;
            }
        }
    }
    printf("%d %d", score, penal);

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define ll long long
#define lowbit(x) ((x)&-(x))
using namespace std;
const int N=2e5+5;
int n,k,tot,a[N],c[N];
ll sum[N],b[N],ans,tmp[N];
void add(int x,int y)
{
	for(;x<=tot;x+=lowbit(x)) c[x]+=y;
}
int query(int x)
{
	int ans=0;
	for(;x;x-=lowbit(x)) ans+=c[x];
	return ans;
}
void discrete()
{
	sort(tmp+1,tmp+1+n);
	tot=unique(tmp+1,tmp+1+n)-tmp-1;
	for(int i=1;i<=n;i++)
		b[i]=lower_bound(tmp+1,tmp+1+tot,b[i])-tmp;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++) tmp[i]=b[i]=sum[i]-1ll*k*i;
	for(int i=1;i<=n;i++) ans+=b[i]>=0;
	discrete();
	for(int i=1;i<=n;i++){
		ans+=query(b[i]);
		add(b[i],1);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6528
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String str = sc.next();
      int sum = 0;
      for(int i = 0;i < 4; i++){
      	String s = str.substring(i,i+1);
        if(s.equals("+")) sum++;
        if(s.equals("-")) sum--;
      }
      System.out.println(sum);
      sc.close();
    }
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	string s;
	cin >> s;
	int ans = 0;
	int state = 0;
	REP(i, s.size()) {
		if (s[i] == 'T' && state == 0) ++ans;
		else if (s[i] == 'T') {
			--state;
		}
		else {
			++state;
		}
	}
	cout << ans + state << endl;





	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {
	 static int count(int n) {
		int cnt = 0;
		for(int i = 1; i <= n; i++) {
			if(n%i == 0) {
				cnt++;
			}
		}
		return cnt;
	}
	
	
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int cnt = 0;
		for(int i = 1; i <=n; i++) {
			if(i%2 == 0) {
				continue;
			}
			if(count(i)==8) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 23764
S = input()
count = 0

if S[0] == 'A':
    count += 1
if S[2:-1].count("C") == 1:
    count += 1
S = S.replace("C", "")
S=S[1:]
if S.islower():
    count += 1

if count == 3:
    print("AC")
else:
    print('WA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c))
	{
		a+b>=c?puts("Yes"):puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit

# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    b = k
    r = n - k

    def comb():
        com = [[0] * 2005 for _ in range(2005)]
        com[0][0] = 1
        for i in range(1, 2005):
            com[i][0] = 1
            for j in range(1, 2005):
                com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % MOD
        return com

    com = comb()

    for i in range(1, k + 1):
        res = com[r + 1][i] * com[b - 1][i - 1]
        res %= MOD
        print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75484
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#define INF 2139062143
#define inf -2139062144
#define ll long long
#include<queue>
using namespace std;
struct point {
	vector<int> adj;
	int turn,du;

};
point po[200005],temp[200005];

int n,maxn = 200005;

struct Edge {
	int from,to,dist;
	Edge(int u, int v, int d):from(u),to(v),dist(d)  {}
};
struct HeapNode {
	int d,u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};
struct Dijkstra {
	int n,m;
	vector<Edge> edges;
	vector<int> G[200005];
	bool done[200005];
	int d[200005];
	int p[200005];     //×î¶ÌÂ·ÖÐµÄÉÏÒ»Ìõ»¡
	vector<int> path;
	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++) G[i].clear();
		edges.clear();
	}

	void addEdge(int from, int to, int dist) {
		edges.push_back(Edge(from,to,dist));
		m = edges.size();
		G[from].push_back(m-1);
	}

	void dijkstra(int s) {	//´Ósµã¿ªÊ¼
		priority_queue<HeapNode> Q;
		for (int i = 0; i < n; i++) d[i] = INF;
		d[s] = 0;
		memset(done,0,sizeof(done));
		Q.push((HeapNode) {
			0,s
		});
		while (!Q.empty()) {
			HeapNode x = Q.top();
			Q.pop();
			int u = x.u;
			if (done[u]) continue;
			done[u] = true;
			for (int i = 0; i < G[u].size(); i++) {
				Edge& e = edges[G[u][i]];
				if (d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					p[e.to] = G[u][i];
					Q.push((HeapNode) {
						d[e.to],e.to
					});
				}
			}
		}
	}
	void findpath(int x) {
		path.clear();
		findd(x);
	}
	void findd(int x) {
		if(x==0)
			return;
		else {
			path.push_back(this->edges[this->p[x]].from);
			findd(this->edges[this->p[x]].from);
		}
	}
};
Dijkstra dij;
int zijie(int x,int last) {
	int i,j;
	
	for(i=0; i<temp[x].adj.size(); i++) {
		if(temp[x].adj[i] != last) {
			temp[temp[x].adj[i]].du--;
			temp[x].du += zijie(temp[x].adj[i],x);
			
		}
	}
	return temp[x].du;
}

int main() {

	int a,b,i;
	scanf("%d",&n);
	dij.init(n);
	for(i=0; i<n-1; i++) {
		scanf("%d%d",&a,&b);
		po[a].adj.push_back(b);
		po[b].adj.push_back(a);
		po[a].du++;
		po[b].du++;
		dij.addEdge(a-1,b-1,1);
		dij.addEdge(b-1,a-1,1);
	}

	dij.dijkstra(0);
	for(i=1; i<=n; i++)	temp[i] = po[i];
	zijie(1,-1);

//	for(i=1; i<=n; i++)	printf("%d ",temp[i].du);
//	printf("\n");
	dij.findpath(n-1);

//	for(i=0; i<longp; i++)	printf("%d ",pathn[i]);
//	printf("\n");
//	ll ans1 = 0,ans2 = 0;
	int count = (dij.path.size()+1)/2;
	int path[n+5],pn = 0;
	for(i=dij.path.size()-1;i>=0;i--)	path[pn++] = dij.path[i];
	path[pn++] = n-1;
//for(i=0;i<pn;i++)	printf("%d ",path[i]+1);
count = (pn+1) / 2;
//printf("\n%d\n",path[count]+1);
ll ans1 = temp[1].du - temp[path[count]+1].du;
ll ans2 = temp[1].du + 1 - ans1;
	if(ans1>ans2)	printf("Fennec\n");
	else	printf("Snuke\n");
	return 0;
}

Measured memory_bytes: 38192
from itertools import permutations
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
na=list(permutations(a,n))
ans=0
for i in range(len(na)):
  for j in range(n-1):
    ans+=((na[i][j][0]-na[i][j+1][0])**2+(na[i][j][1]-na[i][j+1][1])**2)**.5
print(ans/len(na))

Measured memory_bytes: 8180
from collections import deque
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
d = [(0,1),(1,0),(0,-1),(-1,0)]
q = deque()
cnt = h*w
t = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      q.append((i,j))
      a[i][j] = 0
      cnt -= 1
while cnt:
  y,x = q.popleft()
  for dx,dy in d:
    if 0 <= x+dx < w and 0 <= y+dy < h and a[y+dy][x+dx] == ".":
      a[y+dy][x+dx] = a[y][x] + 1
      cnt -= 1
      q.append((y+dy,x+dx)) 
for i in range(h):
  m = max(a[i])
  t = max(t,m)
print(t)

Measured memory_bytes: 138076
#include<stdio.h>
#include<string.h>
char s1[1000];
char s2[1000];
int main(){
	scanf("%s%s",s1,s2);
	int flag = 0;
	int sum = 0;
	int t = strlen(s1);
	int T = strlen(s2);
	if(t<T){
		printf("LESS\n");
	}
	else if(t>T){
		printf("GREATER\n");
	}
	else if(t==T){
		for(int i = 0;i<t;i++){
				if(s1[i]>s2[i]){
					printf("GREATER\n");
					flag = 1;
					break;
				}
				else if(s1[i]<s2[i]){
					printf("LESS\n");
					flag = 1;
					break;
				}
				else if(s1[i]==s2[i]){
					sum++;
					if(sum==t){
						printf("EQUAL\n");
						break;
					}
				}
			}		
		}
	}

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

int main(){
  int num;
  int divider=0;
  
  cin >> num;
  int tmp = num;

  for(int i = 100000000; i != 0; i/=10){
    divider += tmp / i;
    tmp %= i;

  }

  if(num % divider){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func factorial(n int) int {
	if n == 1 {
		return 1
	}
	return n*factorial(n-1)
}
func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println(factorial(n))
}


Measured memory_bytes: 1092
#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[21];
    int i;

    scanf("%s", str);

    for (i = strlen(str) - 1; i >= 0; i--){
        printf("%c", str[i]);
    }
    printf("\n");
    return (0);
}

Measured memory_bytes: 524
//メモリと記述を減らしてみる
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m=1e9+7;
  cin>> n;
  vector<int> one(60);
  for (int i=0; i<n; i++){
    int64_t var; cin>> var;
    bitset<60> bs(var);
    for (int j=0; j<60; j++){
      one[j]+=bs[j];
    }
  }
  int64_t ans=0;
  for (int i=0; i<60; i++){
    ans=(ans+(int64_t)pow(2,i)%m*one[i]%m*(n-one[i])%m)%m; //剰余の優先順位わかりにくい
  }
  cout<< ans << endl;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc145/tasks/abc145_c

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

double dist(PL a, PL b) {
  return sqrt((b.first - a.first) * (b.first - a.first) +
              (b.second - a.second) * (b.second - a.second));
}

void solve() {
  ll N;
  cin >> N;
  VPL ps(N);

  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    ps[i] = {x, y};
  }

  double distSum = 0;

  rep(j, N) rep(i, j) { distSum += dist(ps[i], ps[j]) * 2; }

  double res = distSum / N;

  cout << fixed << setprecision(10) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a[20],ans = 10000000000000000;
int main(){
	int i,j,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)<k) continue;
		long long h = 0,res = 0;
		for(j=0;j<n;j++){
			if((1<<j)&i){
				if(h>=a[j]){
					res += h + 1 - a[j];
					h++;
				}
			}
			h = max(h,a[j]);
		}
		ans = min(ans,res);
	}
	cout << ans << endl;
}
			

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,l;
  cin>>n>>l;
  int ans=0;
  if(0<(1+l-1)){
    for(int i=2;i<=n;i++){
      ans+=i+l-1;
    }
  }
  else if(0>(n+l-1)){
    for(int i=1;i<n;i++){
      ans+=i+l-1;
    }
  }
  else {
    for(int i=1;i<1-l;i++){
      ans+=i+l-1;
    }
    for(int i=2-l;i<=n;i++){
      ans+=i+l-1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>() - 1;
    let s = read::<String>();
    println!(
        "{}{}{}",
        s[0..k].to_string(),
        s[k..k + 1].to_string().to_lowercase(),
        s[k + 1..].to_string()
    );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define int long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int a,b;
    cin>>a>>b;
    int gcd=__gcd(a,b);
    int lcm=(a*b)/gcd;
    cout<<lcm;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
if n<105
  puts 0
else
  ans=1
  for i in 106..n
    cnt=0
    next if (i%2).zero?
    ((i**0.5).to_i).times do|j|
      cnt+=2 if (i% (j+1)).zero?
    end
    ans+=1 if cnt==8
  end
  puts ans
end

Measured memory_bytes: 2172
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, j, n) for (int i = j; i < n; i++)
#define rep_nested(i, s, n) for (int i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1e9 + 7;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

template <class T>
float points_distance(T a) {
	return sqrt(a);
}

template <class T>
T is_integer(T a) {
	return floor(a) == a;
}

int main() {
	int n, d, r;
	
	cin >> n >> d;
	
	r = n / (2 * d + 1);
	r += (n % (2 * d + 1) > 0);
	
	cout << r << endl;
	
    return 0;
}

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

struct node{
  long key;
  struct node *parent,*left,*right;
};

struct node *root,*NIL;

void insert(long k){
  struct node *y = NIL,*x = root,*z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

struct node* find(struct node *v,long k){
  while(v != NIL && k != v->key){
    if(k < v->key) v = v->left;
    else v = v->right;
  }
  return v;
}

void inorder(struct node *v){
  if(v == NIL)return;
  inorder(v->left);
  printf(" %d",v->key);
  inorder(v->right);
}

void preorder(struct node *v){
  if(v == NIL)return;
  printf(" %d",v->key);
  preorder(v->left); 
  preorder(v->right);
}

int main(){
  int m;
  long k,f;
  int i,j = 0,l = 0;
  char com[10];
  
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",com);
    
    if(strcmp(com,"find") == 0){
      scanf("%ld",&f);
      struct node *p = find(root,f);
	if(p!=NIL)printf("yes\n");
	else printf("no\n");  
    }
    
    if(strcmp(com,"insert") == 0){
      scanf("%ld",&k);
      insert(k);
    }
     
    else if(strcmp(com,"print") == 0){      
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      continue;
    }
  }
  
  return 0;  
}



Measured memory_bytes: 20608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //  //   freopen("output.txt", "w", stdout);
    //  //  freopen("error.txt", "w", stderr);
    // #endif
    int n;
    cin >> n;
    string s[n];
    map<string, int> m;
    rep(i, 0, n)
    {
        cin >>
            s[i];
        m[s[i]]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;

    cout << "TLE x " << m["TLE"] << endl;

    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(l,k,h) for(int l = k; l <= h; ++l)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    string s;
    cin >> s;
    int one = 0,zero = 0;
    // if 0 and 1 are one or more, they are next to each other, so there is no one of 0 or 1
    rep(i,s.length()) {
        if(s[i] == '1') {
            one++;
        } else {
            zero++;
        }
    }
    cout << min(one,zero) * 2 << endl;
    return 0;
}

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

typedef long long ll;

ll gcd(ll x, ll y){return y ? gcd(y, x%y) : x;}

vector<pair<ll, int>> factorize(ll n)
{
    vector<pair<ll, int>> res;
    for(ll i = 2; i*i <= n; ++i){
        if(n % i)continue;
        res.emplace_back(i, 0);
        while(n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n, 1);
    return res;
}



int main(void){
    // Your code here!
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans <<  endl;
    return 0;

}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll N;
ll K;
std::vector<ll> a;

void solve() {
  vector<ll> dp(K + 1, 0);
  FOR(i, 1, K + 1) {
    rep(j, N) {
      if (i - a.at(j) >= 0 && dp.at(i - a.at(j)) == 0) {
        dp.at(i) = 1;
      }
    }
  }

  if (dp.at(K) == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%lld", &N);
  scanf("%lld", &K);
  a.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve();
  return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int a[SIZE];
ll K;

int main()
{
	cin >> N;
	int amin = INF,amax=-INF;
	int argmin,argmax;
	rep(i,0,N){
		cin >> a[i];
		if(amin > a[i]){
			amin = a[i];
			argmin = i;
		}
		if(amax < a[i]){
			amax = a[i];
			argmax = i;
		}
	}
	cout << (N-1)*2 << endl;
	if(abs(amax) >= abs(amin)){
		rep(i,0,N) if(i != argmax){
			cout << argmax+1 << " " << i+1 << endl;
		}
		rep(i,0,N-1){
			cout << i+1 << " " << i+1+1 << endl;
		}
	}else{
		rep(i,0,N) if(i != argmin){
			cout << argmin+1 << " " << i+1 << endl;
		}
		rep(i,0,N-1){
			cout << N-i << " " << N-i-1 << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 256
word = input()
judge = []
ans = 0
for i in range(len(word)):
    judge.append(word.count(word[i]))
#print(judge)
for i in range(len(judge)):
    if judge[i] %2 == 0:
        ans += 0
    else:
        ans += 1
if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
X = int(input())
capacity = 1000000
# initialize
dp = [0 if i==0 else -1 for i in range(X + 1)]
N = 6
a = [i for i in range(100, 106)]
m = [capacity for i in range(N)]

# DP
for i in range(N):
    dp_tmp = []
    for j in range(X + 1):
        if (dp[j] >= 0):
            dp_next = m[i]
        elif ((j < a[i]) or (dp_tmp[j-a[i]] <= 0)):
            dp_next = -1
        else:
            dp_next = dp_tmp[j-a[i]] - 1
        dp_tmp.append(dp_next)
    dp = dp_tmp

if dp[-1] >= 0:
    print("1")
else:
    print("0")

Measured memory_bytes: 7560
n,k = gets.split.map(&:to_i)
as = []
n.times do
  as << gets.split.map(&:to_i)
end

as.sort!{|a,b| a[0] <=> b[0]}

dp = [[as[0][1], as[0][0]]]
n.times do |i|
  break if as[i+1].nil?
  a, b = as[i+1]
  prev = dp[i]
  dp[i+1] = [prev[0] + b, a]
end


a = dp.bsearch{|a| a[0] >= k}
puts a[1]

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


int main(void){
  ll a,b,k; cin >> a >> b >> k;
  if(a > k) cout << a - k << " " << b << endl;
  else if(b + a> k) cout << 0 << " " << a + b - k << endl;
  else cout << 0 << " " << 0 << endl;
  return 0;
}


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

int main(){
  int a,b,c,d,e[10000],v=0;
  cin >> a >> b >> c >> d;

    e[0]=1;
    e[1]=9;
    e[2]=7;
    e[3]=4;
  for(int i=0;i<4;i++){
    if(a==e[i]){v++;continue;}
    if(b==e[i]){v++;continue;}
    if(c==e[i]){v++;continue;}
    if(d==e[i]){v++;continue;}

  }
  if(v==4){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  vector<ll> l(n),r(n);
  rep(i,n)cin >> l[i] >> r[i];
  sort(ALL(l));
  sort(ALL(r));
  if(n & 1){
    cout << r[(n)/2]-l[(n)/2]+1 << endl;
  }else{
    cout << fixed<< setprecision(20);
    long double k = (r[(n-1)/2]+r[(n)/2])/2.0-(l[n/2]+l[(n-1)/2])/2.0;
    k *= 2;
    k = k+1;
    ll res = k;
    cout << res << endl;
    if(k >= 100000)
    while(res-k)k;
  }




  




  return 0;
}


Measured memory_bytes: 6376
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

template<typename T>
void counting_sort(const vector<T> &A, vector<T> &B, int32_t k) {
    vector<T> C(k+1);
    fill(C.begin(), C.end(), 0);

    for (T i : A) {
        C[i]++;
    }

    for (int32_t i = 1; i <= k; i++) {
        C[i] = C[i] + C[i-1];
    }

    for (int32_t i = A.size()-1; i >= 0; i--) {
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }

    return;
}

int main() {
    int32_t n, k = 0;

    cin >> n;
    vector<int32_t> A(n), B(n);
    for (int32_t i = 0; i < n; i++) {
        cin >> A[i];
        k = max(k, A[i]);
    }

    counting_sort(A, B, k);

    for (int32_t i = 0; i < n; i++) {
        cout << B[i];
        if (i == n - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 18344
#include <bits/stdc++.h>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define pb push_back
  #define f first
  #define se second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    ll n=0,m=0,k=0,x=0,t1=0,t2=0,t3=0,f=0,sum=0,count=0;

    cin>>n>>k;
    ll arr[n+1],dp[n+1];
    arr[0]=inf; dp[0]=0; 
   
    for (ll i = 1; i <= n; ++i){
      cin>>arr[i];
    }
    dp[1]=0;

    for (ll i = 2; i <= n; ++i)
    {
      dp[i]=INT_MAX;
      for (ll j = 1; j <=k; ++j)
      {
        if(i-j>=1)
         dp[i]=min(abs(arr[i]-arr[i-j])+dp[i-j],dp[i]);
      }
    }

    cout<<dp[n]<<endl;

    return 0;
  }



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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = pow(r, 2);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];
    let mut b: Vec<bool> = vec![false; 8];
    let mut minv: i64 = 0;
    let mut maxv: i64 = 0;
    for _ in 0..n {
        let ai = read();
        a.push(ai);
    }

    for i in 0..a.len() {
        let ai = a[i];
        if ai / 400 < 8 {
            b[(ai / 400) as usize] = true;
        } else {
            maxv += 1;
        }
    }

    for i in 0..b.len() {
        let bi = b[i];
        if bi {
            minv += 1;
            maxv += 1;
        }
    }
    if minv == 0 {
        println!("{} {}", 1, maxv);
    } else {
        println!("{} {}", minv, maxv);
    }
}


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

int main() {
//  要素のデータ型　配列名[要素の個数];
	int a[3];
//  3つの整数
	cin >> a[0] >> a[1] >> a[2];
//sort(a, a + N); a[0], a[1], ..., a[N-1] を小さい順にsort
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}




Measured memory_bytes: 3148
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif
    string s;
    string t;
    cin >> s >> t;
    int mn = 100000;
    for (int i = 0; i < s.size(); i++) {
        if (i + t.size() > s.size()) continue;
        int tot = 0;
        for (int j = 0; j < t.size(); j++) {
            if (t[j] != s[i + j]) tot++;
        }
        mn = min(tot, mn);
    }
    cout << mn << endl;
}


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

class Program
{
  static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var A = Console.ReadLine().Split().Select(x => int.Parse(x));
    
    int count = 0;
    
    while(A.All( x => x%2 == 0 ))
    {
      A = A.Select( i => i/2 );
      count++;
    }

    Console.WriteLine(count);
  }
}

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

ll mod;
class mint {
    ll x;
public:
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    ll get(){
        return x;
    }
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int main(){
    cin >> mod;
    if(mod % 2 == 0 || mod % 5 == 0){
        cout << -1 << endl;
        return(0);
    }

    mint p(7);
    ll i=1;
    while(i<mod){
        if(p.get() == 0){
            break;
        }
        p *= 10;
        p += 7;
        i++;
    }

    cout << i << endl;

    return(0);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  v.push_back(2e9);
  
  int mx = 0;
  int cnt = 0;
  int pre = -1;
  for (int a : v) {
    if (a <= pre) {
      ++cnt;
    } else {
      mx = max(mx, cnt);
      cnt = 0;
    }
    pre = a;
  }
  cout << mx << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
long long int h[100000];
long long int h2[100000];
long long int n;
long long int m;
int main(){
	cin >> n;
	cin >> h[0];
	h2[0] = 0;
	for(long long int i = 1;i < n;i++){
		cin >> h[i];
		if(h[i] <= h[i - 1]){
			h2[i] = h2[i - 1] + 1;
			m = max(m, h2[i]);
		}else{
			h2[i] = 0;
		}
	}
	cout << m << endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020

@author: saito
"""

# %% import phase

# %% define phase
# %% input phase
s = input()

# %% process phase
ans = 0
cnt = 0
for i in s:
    if i == 'R':
        cnt += 1
    else:
        cnt = 0
    ans = max(ans,cnt)

# %%output phase
print(ans)

Measured memory_bytes: 9028
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = count(s.begin(), s.end(), 'E');
  int y = 0;
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E') {
      x--;
    }
    ans = min(ans, x + y);
    if (s[i] == 'W') {
      y++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    int n;
    scanf("%d", &n);

    vector< int > a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    
    vector<int> b(n, 0);
    int min = a[n-1];
    for(int i = n-1; i>=0; i--) {
        if (min > a[i]) {
            min = a[i];
        }
        b[i] = min;
    }

    int ans = true;
    for(int i=0; i<n; i++) {
        if(a[i] -1 <= b[i]) {
            ans = true;
        } else {
            ans = false;
            break;
        }
    }
    if (ans) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

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

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

  long long sum = 0;
  
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;

  return 0;
}


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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char SMAX(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char SMIN(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 1e5 + 7;

int n, a[N], b[N];
ll ans;

struct cmp {
	int operator () (const int &x, const int &y) const {
		return a[x] + b[x] < a[y] +b[y]; 
	}
};
std::priority_queue<int, std::vector<int>, cmp> q;

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]), read(b[i]), q.push(i);
	for (int i = 1; i <= n; ++i) if (i & 1) ans += a[q.top()], q.pop(); else ans -= b[q.top()], q.pop();
	printf("%lld\n", ans);
}

Measured memory_bytes: 1528
///Happy copying <3

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n,cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;

        if(s=="AC")
            cnt1++;
        else if(s=="WA")
            cnt2++;
        else if(s=="TLE")
            cnt3++;
        else if(s=="RE")
            cnt4++;
    }



    cout<<"AC x "<<cnt1<<endl;
    cout<<"WA x "<<cnt2<<endl;
    cout<<"TLE x "<<cnt3<<endl;
    cout<<"RE x "<<cnt4<<endl;

    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main() {
	int N, A;
	
	scanf("%d", &N);
	scanf("%d", &A);
	
	while(N >= 500) {
		N -= 500;
	}
	
	if(N <= A) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	void reset(int n){
		dsu.clear();
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		if(getsum(u) < getsum(v)) swap(u, v);
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vi p(n);
	rep(i, n) cin >> p[i], p[i]--;
	vi x(m), y(m);
	DSU dsu(n);
	rep(i, m) cin >> x[i] >> y[i], x[i]--, y[i]--, dsu.merge(x[i], y[i]);
	int ans = 0;
	rep(i, n) if(dsu.sameset(i, p[i])) ans++;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3572
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] v = new int[n];
	foreach (i; 0..n) {
		scanf("%d", &v[i]);
	}

	int ans = 0;
	int memkey = -1;
	int memdiff = 0;
	foreach (p; 0..2) {
		int[int] counter;
		for (int i = p; i < n; i += 2) {
			if (!(v[i] in counter)) {
				counter[v[i]] = 0;
			}
			counter[v[i]]++;
		}
		int first = 0, second = 0, firstkey = -1;
		foreach (key, val; counter) {
			if (second < val) {
				second = val;
				if (first < val) {
					swap(first, second);
					firstkey = key;
				}
			}
		}
		ans += first;
		if (p == 0) {
			memkey = firstkey;
			memdiff = first-second;
		} else if (memkey == firstkey) {
			int diff = first-second;
			ans -= min(memdiff, diff);
		}
	}
	writeln(n-ans);
}

Measured memory_bytes: 5116
#include<iostream>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	long long int a,b;
	while(cin>>a>>b){
		if(a % 2 == 0 or b % 2 == 0){
			cout<<"Even"<<endl;
		}
		else{
			cout<<"Odd"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;

using namespace std;




int main(void) {
	int n;
	cin >> n;
	cout << n * 32 << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define inf 10000000
using namespace std;
int main(){
  int n,d[101][101],a[101],ans=0,c[101]={};
  cin>>n;
  for(int i=0;i<n;i++)a[i]=inf;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      cin>>d[i][j];
      if(d[i][j]==-1)d[i][j]=inf;    
    }
  a[0]=0;
  int s=0;
  while(1){
    c[s]=1;
    ans+=a[s];
    int mn=inf,ns=-1;
    for(int i=0;i<n;i++)
      a[i]=min(a[i],d[s][i]);

    for(int i=0;i<n;i++)
      if(!c[i]&&a[i]<mn)ns=i,mn=a[i];

    if(ns==-1)break;
    s=ns;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
long long int x[200005], h[200005];
int asc(const void* a, const void* b)
{
	if (x[*(long long int*)a] > x[*(long long int*)b])return 1;
	if (x[*(long long int*)a] < x[*(long long int*)b])return -1;
	return 0;
}
long long int fmax(long long int a, long long int b)
{
	if (a > b)
		return a;
	else
		return b;
}
long long int seg[800005], ss;
void getmax(long long int a, long long int k, long long int l, long long int r)
{
	if (2 * k + 2 < 2 * ss - 1)
	{
		seg[2 * k + 1] += seg[k];
		seg[2 * k + 2] += seg[k];
		seg[k] = 0;
	}
	if (a < l || r <= a)
		return;
	if (l + 1 == r)
		return;
	if ((r + l) / 2 > a)
		getmax(a, 2 * k + 1, l, (l + r) / 2);
	else
		getmax(a, 2 * k + 2, (l + r) / 2, r);
	return;
}
void set(long long int a, long long int b, long long int x, long long int k, long long int l, long long int r)
{
	if (r <= a || b <= l)
		return;
	if (a <= l && r <= b)
	{
		seg[k] -= x;
		return;
	}
	set(a, b, x, 2 * k + 1, l, (l + r) / 2);
	set(a, b, x, 2 * k + 2, (l + r) / 2, r);
	return;
}
int main()
{
	long long int n, d, a;
	scanf("%lld %lld %lld", &n, &d, &a);
	long long int i;
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &x[i], &h[i]);
	long long int c[200005];
	for (i = 0; i < n; i++)
		c[i] = i;
	qsort(c, n, sizeof(long long int), asc);
	ss = 1;
	while (ss < n)
		ss *= 2;
	for (i = 0; i < 2 * ss - 1; i++)
		seg[i] = 0;
	for (i = 0; i < n; i++)
		seg[i + ss - 1] = h[c[i]];
	int min, mid, max;
	long long int ans = 0;
	for (i = n - 1; i >= 0; i--)
	{
		getmax(i, 0, 0, ss);
		if (seg[i + ss - 1] < 0)
			seg[i + ss - 1] = 0;
		ans += (seg[i + ss - 1] + a - 1) / a;
		min = 0;
		max = i;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (x[c[mid]] + 2 * d < x[c[i]])
				min = mid;
			else
				max = mid;
		}
		if (x[c[min]] + 2 * d < x[c[i]])
			min++;
		set(min, i + 1, (seg[i + ss - 1] + a - 1) / a * a, 0, 0, ss);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9964
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int k[]=new int[2001];
		int cnt[]=new int[4001];
		
		for(int i=0;i<=1000;i++)
			for(int j=0;j<=1000;j++)
				k[i+j]++;

		for(int i=0;i<=2000;i++)
			for(int j=0;j<=2000;j++)
					cnt[i+j]+=k[i]*k[j];
		
		while(in.hasNext())
			System.out.println(cnt[in.nextInt()]);
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

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

double getLength(double x1, double y1, double x2, double y2){
  return sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
}

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

  vector<int> cities(N);
  for(int i = 0; i < N; i++) cities[i] = i;

  vector<vector<int>> coordinates(N, vector<int>(2));
  for(int i = 0; i < N; i++) cin >> coordinates[i][0] >> coordinates[i][1];

  double sum = 0;
  do {
    for(int i = 0; i < N-1; i++){
      sum += getLength(coordinates[cities[i]][0], coordinates[cities[i]][1],
                       coordinates[cities[i+1]][0], coordinates[cities[i+1]][1]);
    }
  } while(next_permutation(cities.begin(), cities.end()));

  int fact = 1;
  for(int i = 2; i <= N; i++) fact *= i;

  printf("%lf\n", sum/fact);
  return 0;
}


Measured memory_bytes: 256