akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int circumference;
  std::cin >> circumference;
  
  int n_houses;
  std::cin >> n_houses;
  
  std::vector<int> pos_list;
  for (int i = 0; i < n_houses; ++i){
    int pos_of_house;
    std::cin >> pos_of_house;
    pos_list.push_back(pos_of_house);
  }
  
  pos_list.push_back(pos_list.at(0) + circumference);
  
  std::vector<int> dist_list;
  for (int i = 0; i < n_houses; ++i){
    int dist_between_two_houses = pos_list.at(i+1) - pos_list.at(i);
    dist_list.push_back(dist_between_two_houses);
  }

  std::vector<int>::iterator
    max_it = std::max_element(dist_list.begin(), dist_list.end());
  dist_list.erase(max_it);
  
  int min_dist = 0;
  for (int i = 0; i < dist_list.size(); ++i){
    min_dist += dist_list.at(i);
  }

  std::cout << min_dist << std::endl;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;

int main() {
	int a;
	string b;
	
	cin >> a >> b;

	for (int i = 0; i < b.size(); i++)
	{
		//アルファベットの何文字目か
		int x = b[i] - 'A';
		x = (x + a) % 26;
		putchar('A' + x);
	}




}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()

    count = 0
    for i in range(N-1, -1, -1):
        if S[i] == ")":
            count +=1
        else:
            if count:
                count -= 1
            else:
                S += ")"
    S = "("*count + S
    print(S)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9064
#include <iostream>
#include <cstdio>
#include <cmath>
using std::cin;
using std::cout;
int main()
{
    int X;
    cin >> X;
    int ans;
    for(int i = 1;i <= 50;i++)
    {
        for(int j = 2; j<= 10;j++)
        {
            if(pow(i,j) <= X && pow(i,j) > ans)
            ans = pow(i,j);
        }
    }
    cout << ans;
    return 0;
}

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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());

    int max_d = 0; 
    for(int i = 0; i < n; i++) {
        int left_d;
        int right_d;
        if(i == 0) {
            left_d = a[i] + k - a[n-1]; 
        } else {
            left_d = a[i] - a[i-1];
        }
        if(i == n-1) {
            right_d = a[0] + k - a[i]; 
        } else {
            right_d = a[i+1] - a[i];
        }

        //cout << (left_d) << " " << (right_d) << endl;
        if(left_d > max_d) {
            max_d = left_d;
        }
        if(right_d > max_d) {
            max_d = right_d;
        }
    }

    cout << k - max_d << endl;
}

Measured memory_bytes: 1024
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$K = $key->A[1];
$ary = array();
$cnt=0;
$res=0;
$ary=array();
//K番目の数ではなくK番目に小さい数
foreach($key->X as $r) {
  $ary[$r[0]]+=$r[1];
}
ksort($ary);
if ($K <= count($ary)) {
  //出てきた数値の個数以下なら
  //配列のキーから取り出せる
  $cnt=1;
  while($c = current($ary)) {
    if ($K == $cnt) {
      printf("%d\n",key($ary));
      exit;
    }
    next($ary);
    $cnt++;
  }
}
else {
  //出てきた個数の数値より大きければ
  //何番目になるのか数える必要がある
  $cnt=0;
  foreach($ary as $k => $v) {
    if ($K <= ($cnt + $v)) {
      printf("%d\n",$k);
      exit;
    }
    $cnt+=$v;
  }
}


Measured memory_bytes: 96884
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int a[N];
string x = "bust";
string y = "win";

int32_t main(){_

   int sum = 0;
   for (int i = 0; i < 3; ++i)
   {
      cin>>a[i];
      sum += a[i];
   }

   if (sum >= 22){
      cout<<x;
      exit(0);
   }
   
   cout<<y;
   

   return 0;
}

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

std::map<char, std::string> map;
const char before[32] = {
	' ', '\'', ',', '-', '.', '?',
	'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
	'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
	'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
	'Y', 'Z'
};
const std::string after[32] = {
	"101", "000000", "000011", "10010001", "010001", "000001",
	"100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000",
	"0111", "10011000", "0110", "00100", "10011001", "10011110", "00101", "111",
	"10011111", "1000", "00110", "00111", "10011100", "10011101", "000010",
	"10010010", "10010011", "10010000"
};

void Initialize() {
	map.insert(std::make_pair('A', "00000"));
	map.insert(std::make_pair('B', "00001"));
	map.insert(std::make_pair('C', "00010"));
	map.insert(std::make_pair('D', "00011"));
	map.insert(std::make_pair('E', "00100"));
	map.insert(std::make_pair('F', "00101"));
	map.insert(std::make_pair('G', "00110"));
	map.insert(std::make_pair('H', "00111"));
	map.insert(std::make_pair('I', "01000"));
	map.insert(std::make_pair('J', "01001"));
	map.insert(std::make_pair('K', "01010"));
	map.insert(std::make_pair('L', "01011"));
	map.insert(std::make_pair('M', "01100"));
	map.insert(std::make_pair('N', "01101"));
	map.insert(std::make_pair('O', "01110"));
	map.insert(std::make_pair('P', "01111"));
	map.insert(std::make_pair('Q', "10000"));
	map.insert(std::make_pair('R', "10001"));
	map.insert(std::make_pair('S', "10010"));
	map.insert(std::make_pair('T', "10011"));
	map.insert(std::make_pair('U', "10100"));
	map.insert(std::make_pair('V', "10101"));
	map.insert(std::make_pair('W', "10110"));
	map.insert(std::make_pair('X', "10111"));
	map.insert(std::make_pair('Y', "11000"));
	map.insert(std::make_pair('Z', "11001"));
	map.insert(std::make_pair(' ', "11010"));
	map.insert(std::make_pair('.', "11011"));
	map.insert(std::make_pair(',', "11100"));
	map.insert(std::make_pair('-', "11101"));
	map.insert(std::make_pair('\'', "11110"));
	map.insert(std::make_pair('?', "11111"));
}

int main(){

	Initialize();

	std::string bestr;

	while (std::getline(std::cin, bestr)){

		std::string afstr, res;

		for (int i = 0; i < bestr.size(); i++){
			afstr += map[bestr[i]];
		}

		std::string check;
		for (int i = 0; i < afstr.size(); i++){
			check += afstr[i];

			int it = std::find(&(after[0]), &(after[32]), check) - after;
			if (it != 32){
				res += before[it];
				check.clear();
			}

		}

		std::cout << res << std::endl;

	}
	return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
const ll N = 1e7 + 10;
const int M = 1e9 + 7;
const double eps = 1e-9;

bool cmp(int a, int b) {
    return abs(a) > abs(b);
}

int main() {
    int n;
    cin >> n;
    vll v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(all(v), greater());
    ll ans = v[0];
    auto comp = [](pair<ll, ll> a, pair<ll, ll> b) { return min(a.first, a.second) < min(b.first, b.second); };
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, decltype(comp)> pq(comp);
    pq.push({v[0], v[1]});
    for (int i = 2; i < n; ++i) {
        auto tp = pq.top();
        if (i > 2)
            pq.pop();
        ans += min(tp.first, tp.second);
        pq.push({v[i], tp.first});
        pq.push({v[i], tp.second});
    }
    cout << ans << endl;
}


Measured memory_bytes: 8984
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int a = num.nextInt();
        int b = num.nextInt();
        int c = num.nextInt();
        int d = 0;

        if(a > b){
            d = a;
            a = b;
            b = d;
        }
        if(b > c){
            d = b;
            b = c;
            c = d;

        }
        if(a > b){
            d = b;
            b = a;
            a = d;
        }
        System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int kotae=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+')kotae++;
    else kotae--;
  }
  cout<<kotae<<endl;
  return 0;
}
   

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    string s;
    cin>>s;
    ll n=s.size();
    ll m=n;
    while(s.substr(0,n/2)!=s.substr(n/2,n/2)||n==m){
        // cout<<s.substr(0,n/2)<<endl<<s.substr(n/2,n/2)<<endl;
        s=s.substr(0,n-2);
        n-=2;
    }
    cout<<n<<endl;
 
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],b[100005];
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	if(n>=m){
		cout<<0;
		return 0;
	}
	sort(a,a+m);
	for(int i=0;i<m;i++){
		b[i]=a[i+1]-a[i];
	}
	sort(b,b+m-1);
	int ans=a[m-1]-a[0];
	for(int i=m-2,a=0;a<n-1;a++,i--){
		ans-=b[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>

class UnionFind{
public:
  std::vector<int> par;
  UnionFind(int N):par(N)
  {
    for (int i = 0; i < N; i++) par.at(i) = i;
  }
  int root(int x)
  {
    if(par.at(x) == x) return x;
    else return par.at(x) = root(par.at(x));
  };
  bool same(int x,int y)
  {
    return (root(x)==root(y));
  };

  int unite(int x, int y)
  {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return 0;
    par.at(rx) = ry;
    return 0;
  }
};

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int> > AB(M, std::vector<int>(2));
  for (int i = 0; i < M; i++)
  {
    std::cin >> AB.at(i).at(0) >> AB.at(i).at(1);
    AB.at(i).at(0)--, AB.at(i).at(1)--;
  }
  long long total_inconvenience = N;
  total_inconvenience *= N-1;
  total_inconvenience /= 2;
  UnionFind islands(N);
  std::map<int, long long> groups;
  long long minus_ans = 0;
  std::vector<long long> ans(M);
  for (int i = M-1; i>= 0; i--)
  {
    ans.at(i) = total_inconvenience - minus_ans;
    // std::cout << "check: i = " << i << std::endl;
    // std::cout << "AB.at(i).at(0) = " << AB.at(i).at(0);
    // std::cout << ", AB.at(i).at(1) = " << AB.at(i).at(1) << std::endl;
    if (groups.count(islands.root(AB.at(i).at(0))))
    {
      if (!islands.same(AB.at(i).at(1), AB.at(i).at(0)))
      {
        // std::cout << "ifcheck: i = " << i << std::endl;
        minus_ans -= groups.at(islands.root(AB.at(i).at(0))) * (groups.at(islands.root(AB.at(i).at(0))) - 1) / 2;
        if (groups.count(islands.root(AB.at(i).at(1))))
        {
          minus_ans -= groups.at(islands.root(AB.at(i).at(1))) * (groups.at(islands.root(AB.at(i).at(1))) - 1) / 2;
          groups.at(islands.root(AB.at(i).at(0))) += groups.at(islands.root(AB.at(i).at(1)));
          groups.erase(islands.root(AB.at(i).at(1)));
          islands.unite(AB.at(i).at(1), AB.at(i).at(0));
          // std::cout << "if check if" << std::endl;
        }
        else
        {
          groups.at(islands.root(AB.at(i).at(0))) += 1;
          islands.unite(AB.at(i).at(1), AB.at(i).at(0));
        }
        // std::cout << "before minus" << std::endl;
        minus_ans += groups.at(islands.root(AB.at(i).at(0))) * (groups.at(islands.root(AB.at(i).at(0))) - 1) / 2;
        // std::cout << "after minus" << std::endl;
      }
    }
    else
    {
      // std::cout << "elsecheck: i = " << i << std::endl;
      if (groups.count(islands.root(AB.at(i).at(1))))
      {
        minus_ans -= groups.at(islands.root(AB.at(i).at(1))) * (groups.at(islands.root(AB.at(i).at(1))) - 1) / 2;
        groups.at(islands.root(AB.at(i).at(1)))++;
      }
      else groups[islands.root(AB.at(i).at(1))] = 2;
      islands.unite(AB.at(i).at(0), AB.at(i).at(1));
      minus_ans += groups.at(islands.root(AB.at(i).at(1))) * (groups.at(islands.root(AB.at(i).at(1))) - 1) / 2;
    }
  }
  for (int i = 0; i < M; i++) std::cout << ans.at(i) << std::endl;
}


Measured memory_bytes: 9472
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,box;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    if(a<b)
    {
        box=a;
        a=b;
        b=box;
    }
    if(b<c)
    {
        box=b;
        b=c;
        c=box;
    }
    if(c<d)
    {
        box=c;
        c=d;
        d=box;
    }
    if(d<e)
    {
        box=d;
        d=e;
        e=box;
    }
    if(a<b)
    {
        box=a;
        a=b;
        b=box;
    }
    if(b<c)
    {
        box=b;
        b=c;
        c=box;
    }
    if(c<d)
    {
        box=c;
        c=d;
        d=box;
    }
    if(a<b)
    {
        box=a;
        a=b;
        b=box;
    }
    if(b<c)
    {
        box=b;
        b=c;
        c=box;
    }
    if(a<b)
    {
        box=a;
        a=b;
        b=box;
    }
    printf("%d %d %d %d %d\n",a,b,c,d,e);
    return 0;
}

Measured memory_bytes: 596
#include<cassert>
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const double eps = 1e-10;

class Point{
public:
  double x,y,z;
  double dist(){
    return sqrt(x*x+y*y+z*z);
  }
  Point operator+(Point a)const{
    return (Point){x+a.x,y+a.y,z+a.z};
  }
  Point operator-(Point a)const{
    return (Point){x-a.x,y-a.y,z-a.z};
  }
  Point operator*(double a)const{
    return (Point){a*x,a*y,a*z};
  }
  Point operator/(double a)const{
    return (Point){x/a,y/a,z/a};
  };
};

//Lib
double dot(Point A,Point B){
  return A.x*B.x + A.y*B.y + A.z*B.z;
}

//Lib
Point CircumCenter(Point A,Point B,Point C){
  Point ret;
  double a=(B-C).dist(),b=(C-A).dist(),c=(A-B).dist();
  double cosA=dot(B-A,C-A)/(b*c);
  double s=(c-b*cosA)/(2*c*(1-cosA*cosA));
  double t=(b-c*cosA)/(2*b*(1-cosA*cosA));
  ret=(B-A)*s+(C-A)*t+A;
  return ret;
}

//Lib
Point normal_vector(Point a,Point b){
  Point ret =(Point){a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
  double len=ret.dist();
  ret=ret/len;
  return ret;
}

double isp(Point a,Point b,Point c){
  return (a-c).dist()+(b-c).dist() < (a-b).dist() + eps;
}

bool is_contain_all(Point a,double r,vector<Point> &in){
  rep(i,in.size()){
    if ((in[i]-a).dist() <r+eps);
    else return false;
  }
  return true;
}

double solve(Point cir,Point norm,vector<Point> &in,Point check,
	     double d,double f){//d=(A+B)/2).dist(),f=(cir-(A+B)/2)/dist()
  double l = 0,r=40;
  double mid,ret=1e6;
  //  while(r-l >eps){
  rep(i,100){
    double mid = (l+r)/2;
    Point vec = cir+norm*mid;
    double radius = (vec-check).dist();

    if (is_contain_all(vec,radius,in))r=mid-eps,ret=min(ret,radius);
    else l=mid+eps;
  }
  return ret;
}

double solve(vector<Point> & in){
  double ret = 1e6;
  
  rep(i,in.size()){
    REP(j,i+1,in.size()){
      REP(k,j+1,in.size()){
	if (isp(in[i],in[j],in[k])||isp(in[i],in[k],in[j])
	    ||isp(in[j],in[k],in[i])){
	  continue;
	}
	Point cir = CircumCenter(in[i],in[j],in[k]);
	double r =(cir-in[i]).dist();

	if (is_contain_all(cir,r,in))ret=min(ret,r);
	
	Point norm= normal_vector(in[j]-in[i],in[k]-in[i]);
	Point tmp = (in[i]+in[j])/2-in[i];
	Point tmp2= (cir-(in[i]+in[j])/2);
	ret=min(ret,solve(cir,norm,in,in[i],tmp.dist(),tmp2.dist()));
	norm=norm*-1;
	ret=min(ret,solve(cir,norm,in,in[i],tmp.dist(),tmp2.dist()));
	
      }
    }
  }
  
  rep(i,in.size()){
    REP(j,i+1,in.size()){
      Point center=(in[i]+in[j])/2;
      double r = (center-in[i]).dist();
      if (is_contain_all(center,r,in))ret=min(ret,r);
    }
  }

  return ret;
}

main(){
  int n;
  while(cin>>n && n){
    vector<Point> in;
    rep(i,n){
      double x,y,z;
      cin>>x>>y>>z;
      in.push_back((Point){x,y,z});
    }

    printf("%.8lf\n",solve(in));
  }
}

Measured memory_bytes: 984
#include <iostream>
#include <algorithm>
#include <utility>

#define MAX_N 200010
using namespace std;

long long bit[MAX_N+1],n;
pair<long long,int> p[MAX_N];
long long ans = 0,x = 0;

long long sum(long long i){
	long long s = 0;
	while(i>0){
		s += bit[i];
		i -= i&-i;
	}
	return s;
}

void add(long long i, int k){
	while(i<=n){
		bit[i] += k;
		i += i & -i;
	}
}


int main(){
	int i,k;
	long long a[MAX_N];
	cin >> n >> k;
	for(i=0;i<n;i++){
		bit[i] = 0;
	}
	
	for(i=0;i<n;i++){
		cin >> a[i];
		a[i] -= k;
		x += a[i];
		if(x>=0){
			ans += 1;
		}
		p[i] = make_pair(x,i);
	}
	
	sort(p,p+n);
	a[p[0].second] = 1;
	int j = 1;
	for(i=0;i<n-1;i++){
		if(p[i+1].first!=p[i].first){
			j++;
		}
		a[p[i+1].second] = j;
	}

	for(i=0;i<n;i++){
		ans += sum(a[i]);
		add(a[i],1);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <vector>
#include <iostream>
#include <unordered_map>

using namespace std;
using i64 = long long;
using f64 = double;

#define FOR(i, s, n) for (size_t i = (s); i < (size_t)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

template <typename T, typename U>
inline bool chmax(T &a, U b) {
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b) {
  return a > b ? (a = b, true) : false;
}

int main() {
  auto map = unordered_map<string, int>();
  vector<string> keys = {
    "AC", "WA", "TLE", "RE"
  };

  for (auto k : keys) {
    map[k] = 0;
  }

  int n;
  cin >> n;
  string s;
  REP(_, n) {
    cin >> s;   
    map[s]++; 
  }

  for (auto k : keys) {
    cout << k << " x " << map[k] << endl;
  }

  return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()

int main()
{
    Imposter

    ll n,d;
    cin>>n>>d;ll c=0;
    f(n)
    {
        ll x,y;
        cin>>x>>y;
        ll p=x*x;
        ll q=y*y;
        ll z=p+q;
        double ans=sqrt(z);
        if(ans<=d)
            c++;

    }
    cout<<c;

    return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll cnt, x, y, n, m;
ll h[maxn];
bool f[maxn];
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(n);
	qread(m);
	for(int i = 1;i <= n;i++){
		qread(h[i]);
	}
	for(int i = 1;i <= m;i++){
		qread(x);
		qread(y);
		if(h[x] <= h[y]){
			f[x] = 1;
		}
		if(h[y] <= h[x]){
			f[y] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		if(!f[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4500
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll binpow(int a, int b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
	int n;
	cin>>n;
	ll a[n],x,cnt[1000001]={0},mod=1e9+7,k=1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x=a[i];
		for(int j=2;j*j<=x;j++)
		{
			if(x%j==0)
			{
				ll c=0;
				while(x%j==0)
				c++,x=x/j;
				cnt[j]=max(cnt[j],c);
			}
		}
		if(x!=1)
		cnt[x]=max(cnt[x],k);
	}
	ll inv[1000001];
	inv[1] = 1;
for(int i = 2; i <=1e6 ; ++i)
    inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	ll ans=1,f=0;
	for(int i=2;i<=1e6;i++)
	ans=(ans*binpow(i,cnt[i],mod))%mod;
	for(int i=0;i<n;i++)
	f=(f+(ans*inv[a[i]])%mod)%mod;	
	cout<<f;
	return 0;
}

Measured memory_bytes: 16000
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, ans;
	scanf("%d%d%d", &a, &b, &c);
	ans = (a-c)/(b+c);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#N = int(input())
INF = 1000000007
N,M = map(int,input().split())
a_list = [-1]
for i in range(M):
    a_list.append(int(input()))
a_list.append(N+1)
a_list.sort()
sa_list = []
for i in range(1,M+2):
    sa_list.append(a_list[i]-a_list[i-1])

#def fibonacci(n):
#    if (n<=1):
#        return (n)
#    else:
#        return(fibonacci(n-1) + fibonacci(n-2))
n=max(sa_list)+2
fib_list = []

a, b = 0, 1
for i in range(n):
    fib_list.append(a)
    a, b = b, a + b

#fib_list = [i for i in fib(n)]
#for i in range(n-1):
#    fib_list.append(fibonacci(i))
ans = 1
for sa_i in range(len(sa_list)):
    sa = sa_list[sa_i]
#    print(sa)
    ans = ans*fib_list[sa-1]
    ans = ans % INF
print(ans)

Measured memory_bytes: 460148
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    //vector<vector<char>> s(H, vector<char>(W));



    ll diff = B - A;

    if(diff % 2 == 0 ){
      cout << "Alice" << endl;
    }else if(diff % 2 == 1 ){
      cout << "Borys" << endl;
    }else{
      cout << "Draw" << endl;
      //cout << diff << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int a,b,c;
  cin >> a>>b>>c;
  bool flag = false;
  if(a == 7&&b ==5&&c==5) flag =true;
  else if(b ==7 && c ==5&&a ==5) flag =true;
  else if(c ==7 && a ==5&&b ==5) flag =true;

  if(flag) cout <<"YES"<<endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
def main():
    num = [int(i) for i in input().split()]
    h = num[0]
    a = num[1]
    return attack(h, a)

def attack(h,a):
    if h % a == 0:
        return h // a
    elif h % a >= 1:
        return (h//a) + 1

print(main())


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi vals(N);
    vll pref(N + 1);

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

    ll ans = LLONG_MAX;
    for (int sp = 2; sp <= N - 2; sp++) {
        ll left = pref[sp], right = pref[N] - pref[sp];

        ll ldiff = LLONG_MAX;
        {
            int inx = lower_bound(all(pref), (left + 1) / 2) - pref.begin() - 1;
            if (inx > 0) ldiff = min(ldiff, abs(2 * pref[inx] - left));
            if (inx < sp - 1) ldiff = min(ldiff, abs(2 * pref[inx + 1] - left));
        }

        ll rdiff = LLONG_MAX;
        {
            int inx = lower_bound(all(pref), left + ((right + 1) / 2)) - pref.begin() - 1;
            if (inx > sp) rdiff = min(rdiff, abs(2 * (pref[inx] - left) - right));
            if (inx < N - 1) rdiff = min(rdiff, abs(2 * (pref[inx + 1] - left) - right));
        }

        ll diff = max(ldiff, rdiff);
        diff = max(diff, abs((left - ldiff) / 2 - (right + rdiff) / 2));
        diff = max(diff, abs((left + ldiff) / 2 - (right - rdiff) / 2));
        ans = min(ans, diff);
    }


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 1000000007
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

int main()
{
    fastIO;
    
    int h, w;
    cin >> h >> w;
    
    ll dp[h][w] = {0};
    fop(i,0,h){
        fop(j,0,w){
            char in;
            cin >> in;
            if(in == '#'){
                dp[i][j] = 0;
                continue;
            }
            if(i==0 && j==0) dp[i][j] = 1;
            else if(i==0) dp[i][j] = dp[i][j-1];
            else if(j==0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
        }
    }
    cout << dp[h-1][w-1];
    
    return 0;
}


Measured memory_bytes: 11460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a[1000],b=0,c=0;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    c+=a[i];
  }for(int i=0;i<n;i++){
    if(a[i]*4*m>=c){
      b++;
    }
  }if(b>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,l;
  int n,k;
  cin>>n>>k;
  vi v[50];
  rep(i,k){
    int m,b;
    cin>>m;
    rep(j,m){
      cin>>b;
      v[i].push_back(b);
    }
  }
  int r;
  cin>>r;
  int rel[55][55]={};
  rep(i,r){
    int p,q;
    cin>>p>>q;
    rel[p][q]++;
    rel[q][p]++;
  }
  int ans=0;
  rep(i,k){
    rep(j,v[i].size()){
      rep(l,v[i].size())
        if(rel[v[i][j]][v[i][l]]){
          ans++;
          break;
        }
    }
  }
  cout<<ans<<endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x[2];
    cin >> x[0] >> x[1];
    int64 ans = 0;
    REP(i,2){
        if(x[i] == 1){
            ans += 300000;
        }else if(x[i] == 2){
            ans += 200000;
        }else if(x[i] == 3){
            ans += 100000;
        }
    }
    if(x[0] == 1 && x[1] == 1){
        ans += 400000;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >>N;
    double v[N];
    for(int i=0;i<N;i++) cin >> v[i];
    sort(v, v+N);
    double ans = (v[0]+v[1])/2;
    for(int i=1;i<N-1;i++){
        ans = (ans+v[i+1])/2;
    }
    cout << ans << endl;
}

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

int main(void){
  int b[4] = {0};
  for(string t ; getline(cin,t) ;){
    int i;
    for(i = 0 ; t[i] != ','; i ++);
    i++;
    if(t.size() - i == 2){b[2]++;continue;}
    if(t[i] == 'A')b[0]++;
    if(t[i] == 'B')b[1]++;
    if(t[i] == 'O')b[3]++;
  }
  for(int i = 0 ; i < 4 ; i ++)
    cout<<b[i]<<endl;
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<string>
#include<map>

using namespace std;

int main(){
  int s1,s2;
  vector<pair<string,int>> conclusion;

  while(1){
    pair<string,int> result;
    cin>>s1>>s2;
    if(s1==0 && s2==0) break;
    result.first="A";
    result.second=s1+s2;

    cin>>s1>>s2;
    if(s1==0 && s2==0) break;
    if(s1+s2>result.second){
      result.first="B";
      result.second=s1+s2;
    }

    cin>>s1>>s2;
    if(s1==0 && s2==0) break;
    if(s1+s2>result.second){
      result.first="C";
      result.second=s1+s2;
    }

    cin>>s1>>s2;
    if(s1==0 && s2==0) break;
    if(s1+s2>result.second){
      result.first="D";
      result.second=s1+s2;
    }

    cin>>s1>>s2;
    if(s1==0 && s2==0) break;
    if(s1+s2>result.second){
      result.first="E";
      result.second=s1+s2;
    }

    conclusion.push_back(result);

  }

  for(auto i:conclusion)
    cout<<i.first<<" "<<i.second<<endl;
}

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

int main(void){
  int X,Y; cin >> X >> Y;
  int i,j;
  for(i=0; i<=X; ++i)
    for(j=0; j<=(X-i); ++j)
      if( (((i*4)+(j*2))==Y) && (i+j)==X ){
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int judge(int n,int k,int amari){
  if(amari<=1){
    return 0;
  } else {
    for(double i=2;;i++){
      if((n-amari)/i<=k) return i;
      if(amari<=i) return 0;
    }
  }
}

int main(){
  int n,k;
  cin >> n >> k;
  int num=k+1;
  int amari=n-num;
  
  for(;;){
    if(n<=k){
      num = n;
      break;
    } else if(n==k){
      num=n;
      break;
    } else if(judge(n,k,amari)==0){
      break;
    } else{
      num++;
      amari-=judge(n,k,amari);
    }
  }

  cout << num << endl;
  
  return 0;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int a,b; cin >> a >> b;
	cout << a * b;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>

int main(){
	std::string s;
	while (std::getline(std::cin, s)){
		for (int i = 0; i < 26; ++i){
			if (s.find("this") == std::string::npos && s.find("the") == std::string::npos && s.find("that") == std::string::npos){
				for (int j = 0; j < s.size(); ++j){
					if (s[j] != ' '&&s[j] != '.'){
						if (s[j] == 'z')s[j] = 'a';
						else s[j] += 1;
					}
				}
			}
			else{
				std::cout << s << std::endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
s = gets.to_i
x, y = s/100, s%100
if 0<x && x<13
  if 0<y && y<13
    puts "AMBIGUOUS"
    exit
  else
    puts "MMYY"
    exit
  end
elsif 0<y && y<14
  puts "YYMM"
  exit
end
puts "NA"

Measured memory_bytes: 14376
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
  int a, b, c, x, count = 0;
  cin >> a >> b >> c >> x;

  for (int i = 0; i <= a; i++)
  {
    for (int j = 0; j <= b; j++)
    {
      for (int k = 0; k <= c; k++)
      {
        if(i * 500 + j * 100 + k * 50 == x)
        {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
ST= list(input())

S = [0 for i in range(N)]
T = [0 for i in range(N)]
for i in range(N):
    S[i] = ST[i]
for i in range(N):
    T[i] = ST[i+1+N]
newlist = [0 for i in range(2*N)]
i = 0
while i < N:
    newlist[i*2] = S[i]
    newlist[i*2+1] = T[i]
    i += 1
print("".join(newlist))

Measured memory_bytes: 38256
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")
}

#[allow(dead_code)]
struct FenwickTree {
    seq: Vec<i64>,
}
#[allow(dead_code)]
impl FenwickTree {
    fn new(n: usize) -> FenwickTree {
        FenwickTree {
            seq: vec![0; n + 2],
        }
    }
    fn add(&mut self, index: i32, value: i64) {
        let mut index = (index + 3) as i32;
        while (index as usize) < self.seq.len() {
            self.seq[index as usize] += value;
            index += index & -index;
        }
    }
    // inclusive
    fn sum(&self, index: i32) -> i64 {
        let mut ret = 0;
        let mut index = (index + 3) as i32;
        while index > 0 {
            ret += self.seq[index as usize];
            index -= index & -index;
        }
        ret
    }
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let q = read::<usize>();
    let mut rls = vec![(0, 0); m];
    for i in 0..m {
        rls[i].1 = read::<usize>() - 1;
        rls[i].0 = read::<usize>() - 1;
    }
    rls.sort();
    let mut queries = vec![(0, 0, 0); q];
    for i in 0..q {
        queries[i].1 = read::<usize>() - 1;
        queries[i].0 = read::<usize>() - 1;
        queries[i].2 = i;
    }
    queries.sort();
    let mut anss = vec![0; q];
    let mut ftree = FenwickTree::new(n + 10);
    let mut rls_index = 0;
    for i in 0..q {
        let r = queries[i].0;
        while rls_index < rls.len() && rls[rls_index].0 <= r {
            ftree.add(rls[rls_index].1 as i32, 1);
            rls_index += 1;
        }
        let l = queries[i].1;
        let index = queries[i].2;
        anss[index] = rls_index - ftree.sum(l as i32 - 1) as usize;
    }
    for i in 0..q {
        println!("{}", anss[i]);
    }
}


Measured memory_bytes: 15228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int r;
	cin >> r;
	cout << 3 * r * r << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

int main(){
  long long int n, k; cin >> n >> k;
  long long int h[n];
  for(int i = 0; i < n; i++) cin >> h[i];
  sort(h, h + n);
  long long int sum = 0;
  for(int i = 0; i < n - k; i++) sum += h[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn dfs(e: &Vec<Vec<(usize, usize)>>, cur: usize, par: usize, par_color: usize, colors: &mut Vec<usize>) {
    let mut color = 1;
    for &(nd, index) in e[cur].iter() {
        if nd != par {
            if color == par_color {
                color += 1;
            }
            colors[index] = color;
            dfs(e, nd, cur, color, colors);
            color += 1;
        }
    }
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      abs: [(usize1, usize1); n-1],
    }

    let mut e = vec![vec![]; n];
    for i in 0..n-1 {
        let (a, b) = abs[i];
        e[a].push((b, i));
        e[b].push((a, i));
    }

    let mut colors = vec![0; n-1];
    colors[0] = 1;
    dfs(&e, 0, n, n+2, &mut colors);
    let mut k: Vec<_> = colors.iter().cloned().collect();
    // debug!(colors);
    k.sort();
    k.dedup();
    puts!("{}\n", k.len());
    for c in colors {
        puts!("{}\n", c);
    }
}


Measured memory_bytes: 18812
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h,w;
        while(true){
            h = scan.nextInt();
            w = scan.nextInt();
            if(h == 0 && w == 0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i % 2 == 0){
                        if(j%2 == 0) System.out.print("#");
                        else System.out.print(".");
                    }
                    else {
                        if(j%2 == 0) System.out.print(".");
                        else System.out.print("#");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34832
ABC= list(map(int, input().split()))
M = max(ABC)
ans = 0
for i in range(3):
    ABC[i] = M - ABC[i]
    ans += ABC[i] // 2
    ABC[i] = ABC[i] % 2

if sum(ABC) == 2:
    ans += 1
elif sum(ABC) == 1:
    ans += 2
else:
    ans += 0
print(ans)


Measured memory_bytes: 9100
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

map<char, int>nummp;
map<char, int>suitmp;
int main() {
	for (int i = 2; i <= 9; ++i) {
		nummp['0' + i] = i;
	}
	nummp['T'] = 10;
	nummp['J'] = 11;
	nummp['Q'] = 12;
	nummp['K'] = 13;
	nummp['A'] = 14;


	while (1) {
		char tramp; cin >> tramp;
		if (tramp == '#')break;
		vector<vector<pair<int, char>>>cards(4, vector<pair<int, char>>(13));
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 13; ++j) {
				string st; cin >> st;
				const int num = nummp[st[0]];
				cards[i][j] = make_pair(num, st[1]);
			}
		}
		int fp = 0;
		vector<int>points(4);
		for (int trick = 0; trick < 13; ++trick) {
			char fst = cards[fp][trick].second;
			vector<int>powers(4);
			for (int p = 0; p < 4; ++p) {
				int apower = cards[p][trick].first;
				if (cards[p][trick].second == tramp)apower += 10000;
				if (cards[p][trick].second == fst)apower += 100;
				powers[p] = apower;
			}
			int winner = max_element(powers.begin(), powers.end())-powers.begin();
			points[winner]++;
			fp = winner;

		}
		if (points[0] + points[2]>6) {
			cout << "NS " << points[0] + points[2] - 6 << endl;
		}
		else {
			cout << "EW " << 7-(points[0] + points[2]) << endl;

		}

	}
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>

int d[10]={0};

int haa(int n){
	int a;
	while(n>0){
		a=n%10;
		if(d[a]==1){
			return 0;
		}
		n/=10;
	}
	return 1;
}

int main()
{
	int n,k,i,j;
	scanf("%d%d",&n,&k);
	for(j=0;j<k;j++){
		scanf("%d",&i);
		d[i]=1;
	}
	
	for(i=n;;i++){
		if(haa(i)==1){
			printf("%d\n",i);
			return 0;
		}
	}
}	


Measured memory_bytes: 128
day=input()

if day=='SUN':
  print('7')
if day=='SAT':
  print('1')
if day=='FRI':
  print('2')
if day=='THU':
  print('3')
if day=='WED':
  print('4')
if day=='TUE':
  print('5')
if day=='MON':
  print('6')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

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

}


int main(){
  
  ll N,Q;
  cin>>N>>Q;
  
  vector<ll>a(N-1);
  vector<ll>b(N-1);
  
  vector<ll>p(Q);
  vector<ll>x(Q);
  vector<pair<ll,ll>>PX(N-1);
  vector<ll>point(N);//それぞれのポイントで何を足すか
  vector<ll>ans(N);
  
  rep(i,N-1){
    cin>>a[i]>>b[i];
    PX[i].first=a[i];
    PX[i].second=b[i];
  }
  
  rep(i,Q){
    cin>>p[i]>>x[i];
    point[p[i]-1]+=x[i];
  }

  
  
 sort(all(PX));
  
  ans[0]=point[0];
  
  for(ll i=0;i<N-1;i++){
    ans[PX[i].second-1]=ans[PX[i].first-1]+point[PX[i].second-1];
  }
  
  rep(i,N){
    cout<<ans[i]<<" ";
  }
  
  cout<<endl;
}

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

int main() {

  int64_t a, b, k;
  cin >> a >> b >> k;
  
  if (a >= k) {
    cout << a - k << ' ' << b;
  } else {
    if ((a + b) <= k) {
      cout << 0 << ' ' << 0;
    } else {
      cout << 0 << ' ' << a + b - k;
    }
  }
   
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 2 9");
            //8
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 2 7");
            //7
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 2 8");
            //8
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];
        int A = wkArr[1];
        int B = wkArr[2];

        Console.WriteLine(Math.Min(N * A, B));
    }
}


Measured memory_bytes: 13396
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
tmp = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            tmp = 500 * i + 100 * j + 50 * k
            if tmp == x:
                ans += 1
    tmp = 0
print(ans)

Measured memory_bytes: 3188
import scala.io.StdIn

object Main extends App {
  val Array(n, m) = StdIn.readLine.split(" ").map(_.toInt)

  val ans = (n to m).count(i => {
    val s = i.toString
    s(0) == s(4) && s(1) == s(3)
  })

  println(ans)
}


Measured memory_bytes: 33400
Sa=list(input())
Sb=list(input())
Sc=list(input())
Sa.append("*")
Sb.append("*")
Sc.append("*")
table=[Sa,Sb,Sc]

#print(table)
#input()
id=0
while True:
    if table[id][0]=="*":
        print(chr(id+65))
        break
    newid=ord(table[id][0])-97
    table[id]=table[id][1:]
    #print(table)
    id=newid


Measured memory_bytes: 38384