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

using namespace std;
#define ll long long int
#define X first
#define Y second
const int MAXN = 1e5 + 5;
int n, dp[MAXN][4], a[MAXN], b[MAXN], c[MAXN];

int solve(int idx = 1, int last = 3)
{
	if (idx > n) return 0;

	int &ret = dp[idx][last];
	if (~ret) return ret;
	ret = 0;

	if (last != 0) ret = max(ret, solve(idx + 1, 0) + a[idx]);
	if (last != 1) ret = max(ret, solve(idx + 1, 1) + b[idx]);
	if (last != 2) ret = max(ret, solve(idx + 1, 2) + c[idx]);

	return ret;
}

int main()
{
	int k;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
	memset(dp, -1, sizeof dp);
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 7680
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	int a, b;
	int ans = 0;

	for (int i = 0;i < n;i++) {
		cin >> a >> b;
		if (a >= h && b >= w) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
for i in range(h):
    a[i] = [aij % 2 for aij in a[i]]

cnt, ans = 0, []
for i, ai in enumerate(a):
    for j in range(w)[::(i % 2) * (-2) + 1]:
        if cnt == 1:
            ans.append([bi + 1, bj + 1, i + 1, j + 1])
            ai[j] += 1
        cnt = int(ai[j] == 1)
        bi, bj = i, j

print(len(ans))
for q in ans:
    print(*q)


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

int main(){
  int N;
  cin >>N;
  vector<int> Q(81);
  int k=0;
  bool TF = true;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j == N){
        TF = false;
      }
      if(TF == false){
        break;
      }
    }
    if(TF == false){
      break;
    }
  }
  if(TF == false){
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }
}
  


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

int main(){
	int n,a[100];
	long long ans=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (a[i]==a[i-1]){
			ans++;
			a[i]=10000;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, s := nextInt(), next()

	cnt := make([][3]int, n)
	for i := 0; i < n; i++ {
		if i > 0 {
			for j := 0; j < 3; j++ {
				cnt[i][j] = cnt[i-1][j]
			}
		}
		var index int
		if s[i] == 'R' {
			index = 0
		} else if s[i] == 'G' {
			index = 1
		} else {
			index = 2
		}
		cnt[i][index]++
	}

	ans := 0
	// index := func(si, sj byte) int {
	// 	m := map[byte]bool{}
	// 	m[si], m[sj] = true, true
	// 	if !m['R'] {
	// 		return 0
	// 	} else if !m['G'] {
	// 		return 1
	// 	}
	// 	return 2
	// }
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			if s[i] == s[j] {
				continue
			}
			m := map[byte]bool{}
			m[s[i]], m[s[j]] = true, true
			var need byte
			var index int
			if !m['R'] {
				need, index = 'R', 0
			} else if !m['G'] {
				need, index = 'G', 1
			} else {
				need, index = 'B', 2
			}
			ans += cnt[n-1][index] - cnt[j][index]
			if 2*(j+1)-(i+1)-1 < n && s[2*(j+1)-(i+1)-1] == need {
				ans--
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 1896
#include <iostream>
#include<bits/stdc++.h>
#include <iomanip>
 
#define array_size(a) (sizeof(a)/sizeof(a[0]))
#define lpi(n) for(int i=0; i<n; i++)
#define lpiv(v,n) for(int i=v; i<n; i++)
#define lpj(n) for(int j=0; j<n; j++)
#define lpjv(v,n) for(int j=v; j<n; j++)
#define iii pair<int,pair<int,int>>
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int>>
#define pqig priority_queue<int>
#define pqil priority_queue<int, vector<int>, greater<int>>
#define filein(ff) freopen(ff, "r", stdin)
#define fileout(ff) freopen(ff, "w", stdout)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); 
using namespace std;
 
typedef long long ll;
 
 
ll fastpow(ll nodess, ll num) {
    if (!num)
        return 1;
    if (num % 2)
        return nodess * fastpow(nodess, num - 1)/*%mod*/;
    ll p = fastpow(nodess, num / 2);
    // p %= mod;
    p *= p;
    // p %= mod;
    return p;
}
 
ll my_mod(ll num, ll mod) {
    ll reto = num % mod;
    while (reto < 0)
        reto += mod;
    return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
 
ll dist(pair<ll, ll> u, pair<ll, ll> v) {
    return abs(u.fi - v.fi)  + abs(u.se - v.se);
}

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}

int main(int argc, const char * argv[]) {
 
    fastio;

    int n,mw;
    cin >> n>>mw;
    ll dp[n+1][mw+1];
    vector<pair<ll,ll>> wvv;
    ll inw,inv;
    wvv.pb({0,0});

    lpi(n){
        cin >> inw >> inv;
        wvv.pb({inw,inv});
    }

    sort(wvv.begin(), wvv.end());

    for(int i =0; i <= n; i++){
        for(int j = 0; j <= mw; j++){
            if(i==0||j==0){
                dp[i][j]=0;
                continue;
            }
            if(j<wvv[i].fi){
                dp[i][j]=dp[i-1][j];
            } else {
                dp[i][j]=max(dp[i-1][j], wvv[i].se + dp[i-1][j-wvv[i].fi]);
            }
        }
    }

    cout <<  dp[n][mw] << endl;

    return 0; 
}   

Measured memory_bytes: 79232
main(){
int t,n,m,r;
for(scanf("%d",&t);t--;){
scanf("%d%d",&n,&m);
for(r=0;m-n;m/=2,n/=2)r+=(n%2+2)%2+(m%2+2)%2,n+=(n%2+2)%2,m-=(m%2+2)%2;
printf("%d\n",r);
}
exit(0);
}

Measured memory_bytes: 600
inp = [int(i) for i in input().split()]
li =[]
li2 =[]

for k in range(1,inp[0]+1):
  f = inp[0] / k
  if f.is_integer():
    li.append(k)

for m in range(1,inp[1]+1):
  h = inp[1] / m
  if h.is_integer():
    li2.append(m)
    
li3 = list(set(li) & set(li2))
li3.sort()
print(li3[-inp[2]])

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  getLine
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute as
  print ans

compute :: [Int] -> Int
compute (a:as) = ans where (ans,_,_) = foldl step (1,EQ,a) as

-- カウント、上昇中/下降中/不明、前の値
type Acc = (Int,Ordering,Int)
step :: Acc -> Int -> Acc
step (n,o,z) a = case (o,compare z a) of
  (EQ, o') -> (n, o', a)
  (LT, GT) -> (succ n, EQ, a)
  (GT, LT) -> (succ n, EQ, a)
  _        -> (n, o, a)


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      A -= A % 2;
      A /= 2;
      B += A;
    } else {
      B -= B % 2;
      B /= 2;
      A += B;
    }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
n = gets.to_i
adj = Array.new(n){ Array.new(n,0) }
n.times do
  l = gets.split.map(&:to_i)
  l[2..-1].each{ |i| adj[l[0]-1][i-1]=1 }
end
adj.each{ |v| puts v.join(" ")}

Measured memory_bytes: 8764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ans;
	double dm=m/60.0;
	double rad=(max((h+dm)/12.0,dm)-min((h+dm)/12.0,dm))*2.0*M_PI;
	ans=sqrt(a*a+b*b-2*a*b*cos(rad));
	printf("%.11f\n",ans);
}

Measured memory_bytes: 4248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = "";
			while ((str = Console.ReadLine()) != null)
			{
				var d = int.Parse(str);
				long r = 0;
				for (int i = d; i < 600; i += d)
				{
					r += (long)i * (long)i * (long)d;
				}
				Console.WriteLine(r);
			}
		}
	}
}

Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <functional>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int all = a.at(0) ;
    for (int i = 1; i < n; i++)
    {
        all = all ^ a.at(i) ;
    }
    for (int i = 0; i < n-1; i++)
    {
        cout << (all ^ a.at(i)) << " " ;
    }
    cout << (all ^ a.at(n-1)) << endl ;
     
}

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


using namespace std;
ifstream f("subarbore.in");
ofstream g("subarbore.out");
int a,b,c,d,turn;

int main()
{
    cin>>a>>b>>c>>d;
    turn=0;
    while(a>0&&c>0)
    {
        if(turn==0)
            c-=b;

        else
            a-=d;
               turn=1-turn;
    }

    if(a<=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
using namespace std;

struct Pos {
    double x,y;
};


void kock(int n, Pos p1, Pos p2) {
    if(n==0){
        return;
    }
    Pos s,t,u;
    double th = 60*M_PI/180;

    s.x=(2.0*p1.x+1.0*p2.x)/3.0;
    s.y=(2.0*p1.y+1.0*p2.y)/3.0;
    t.x=(1.0*p1.x+2.0*p2.x)/3.0;
    t.y=(1.0*p1.y+2.0*p2.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    kock(n-1, p1, s);
    printf("%.8f %.8f\n", s.x,s.y);
    kock(n-1, s, u);
    printf("%.8f %.8f\n", u.x,u.y);
    kock(n-1, u, t);
    printf("%.8f %.8f\n", t.x,t.y);
    kock(n-1, t, p2);
}

int main(){
    int n;
    Pos p1,p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    
    scanf("%d", &n);
    
    printf("%.8f %.8f\n", p1.x, p1.y);
    kock(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
}


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

#define pb push_back

using namespace std;

int ban,cnt;
bitset<55> hsh;
vector<int> gph[55];
vector<pair<int,int> > edgelist;

void dfs(int node)
{
  if (!hsh[node])
  {
    cnt++;
    hsh[node]=true;
    for(int c=0;c<gph[node].size();c++)
    {
      if ((node==edgelist[ban].first&&gph[node][c]==edgelist[ban].second)||
      (node==edgelist[ban].second&&gph[node][c]==edgelist[ban].first))continue;
      dfs(gph[node][c]);
    }
  }
}

int main()
{
    int n,m,ans=0,iu,iv;

    scanf("%d%d",&n,&m);
    for(int c=0;c<m;c++)
    {
      scanf("%d%d",&iu,&iv);
      gph[iu].pb(iv);
      gph[iv].pb(iu);
      edgelist.pb({iu,iv});
    }
    for(int c=0;c<m;c++)
    {
      hsh.reset();
      cnt=0;
      ban=c;
      dfs(1);
      if (cnt<n)ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
Am=[-a for a in A]
heapq.heapify(Am)
for m in range(M):
    a = int(heapq.heappop(Am) / 2)
    heapq.heappush(Am, a)
print(-sum(Am))

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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define forn for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back
template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

void min_self(int &a, int b){
	a = min(a, b);
}
void max_self(int &a, int b){
	a = min(a,b);
}

const ll INF = 1e18L+5;

void solve(){
	int n, w;
	cin >> n >> w;
	vi wt(n), vl(n);
	ll mxv = 0;
	forn{
		cin >> wt[i] >> vl[i];
		mxv += vl[i];
	}
	//min weight for val i
	vll dp(mxv + 1, INF);
	dp[0] = 0;
	forn{
		for(int val= mxv-vl[i]; ~val; --val){
			chmin(dp[val+vl[i]], dp[val]+wt[i]);
		}
	}
	ll ans = INF;
	for(int val=mxv; ~val; val--){
		if(dp[val]<=w){
			cout << val << en;
			break;
		}
	}
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stack>
using namespace std;
int main(void){
	int i;
	string s;
	cin >> s;
	int k = s.size();
	pair<int, int> p;
	stack<pair<int, int> > P;// ????§???´?????¨????????´???
	int n = 0;//?°´??????????????°
	int m[10000] = {0};//??¢???
	stack<int> S;
	
	for(i=0;i<k;i++){
		if(s[i] == '\\') {
			S.push(i);
		}else if(s[i] == '/'){
			if(! S.empty()){
				p.first = S.top();
				S.pop();
				p.second = i;
				while(! P.empty()){
					if(P.top()<=p)break;
						P.pop();
						n--;				
				}
				P.push(p);
				n++;	
					
			}
		}
	}
	
	for(i=0;i<n;i++){
		
		int d = 0;
		pair<int, int> q = P.top();
		P.pop();
	//	cout << q.first << q.second << endl;
		for(int j = q.first; j <= q.second; j++){
			if(s[j] == '\\'){
				d=d+2;
				m[i] += d-1;
			}else if(s[j] =='/'){
				d=d-2;
				m[i] += d+1;
			}else {
				m[i] += d;
			}
		}
	}
	for(i=0;i<n;i++){
		m[i]=m[i]/2;
		}
	int mall = 0;
	for(i=0;i<n;i++){
		mall +=m[i];
	}
	
	cout << mall <<endl;
	cout << n;
	
	for(i=n-1;i>=0;i--){
		cout << " " <<m[i];
	}
	cout << endl;
				
	
	return 0;
}
		 
		
		

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec a(N);
    rep(i, N) cin >> a[i];

    sort(all(a));
    reverse(all(a));
    
    int res = 0;
    rep(i, N){
        if(i == 0) res += a[i]/2;
        else res += a[i];
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve2(string s) {
        string pad[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
        s += "0";

//        char nowc = '';
        int nowkey = 0;
        int cnt = -1;
        string ans = "";
        for (int i = 0; i < s.size(); ++i) {
            char c = s[i];
            if (c == '0') {
                if (cnt >= 0) {
                    ans += pad[nowkey][cnt % pad[nowkey].size()];
                }
                nowkey = 0;
                cnt = -1;
            } else {
                if (nowkey == 0) {
                    nowkey = c - '0';
                }
                cnt++;
            }
        }
        cout << ans << endl;
    }

    void solve() {
        input();
        int n;
        cin >> n;
        rep(i,0,n){
            string s;
            cin >> s;
            solve2(s);
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S,T;
    cin >> S >> T;
    int len = S.size();
    int ans = 0;
    rep(i,len){
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3860
/*input
425 48
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=2005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=924844033LL;
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

vector<ll> f[maxn];

vector<ll> poly={1};
ll tmp[maxn*4];

void mul(int u){
	//cout<<u<<'\n';
	REP(i,SZ(poly)) REP(j,SZ(f[u])){
		tmp[i+j]+=poly[i]*f[u][j]%MOD;
		if(tmp[i+j]>=MOD) tmp[i+j]-=MOD;
	}
	int deg=SZ(poly)-1+SZ(f[u]);
	poly.resize(deg);
	REP(i,deg) poly[i]=tmp[i];
	REP(i,deg) tmp[i]=0;
}

ll fac[maxn]={1};

int main()
{
	IOS;
	f[0].pb(1);
	f[1]={1,1};

	for(int i=1;i<maxn;i++){
		fac[i]=fac[i-1]*i%MOD;
	}

	for(int i=2;i<maxn;i++){
		f[i]=f[i-1];
		for(int j=0;j<SZ(f[i-2]);j++){
			if(j+1<SZ(f[i])){
				f[i][j+1]+=f[i-2][j];
				if(f[i][j+1]>=MOD) f[i][j+1]-=MOD;
			}
			else f[i].pb(f[i-2][j]);
		}
	}

	int n,k;
	cin>>n>>k;

	for(int i=0;i<k;i++){
		int cnt=0;
		int x=i,y=i+k;
		while(x<n&&y<n){
			if(x<y) x+=k+k;
			else y+=k+k;
			cnt++;
		}
		mul(cnt);
		mul(cnt);
	}	
	while(SZ(poly)<=n) poly.pb(0);
	ll ans=0;
	for(int i=0;i<=n;i++){
		if(i%2==0) ans+=poly[i]*fac[n-i]%MOD;
		else ans-=poly[i]*fac[n-i]%MOD;
		if(ans<0) ans+=MOD;
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


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

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

    int ans = 0;

    for (int i = 0; i < N - 2; i++) {
        string subStr = S.substr(i, 3);
        if (subStr == "ABC")ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

argmin_diff = None
min_diff = 100
mean_a = sum(a) / len(a)
for i, val in enumerate(a):
    diff = abs(val - mean_a)
    if diff < min_diff:
        min_diff = diff
        argmin_diff = i
print(argmin_diff)

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, M;
    cin >> N >> M;

    ll ans = 0;
    if (N == 1 && M == 1)
        ans = 1;
    else if (N == 1 || M == 1)
        ans = (ll)N * M - 2;
    else
        ans = (ll)(N - 2) * (M - 2);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e6 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, k, arr[maxn], l, r;
char str[maxn];
bool mark[maxn];

void printAns() {
	for (int i = l; i < r; i++)
		cout << (arr[i] ? 'A' : 'B');
	cout << endl;
}

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

	cin >> n >> k >> str;
	for (int i = 0; i < n; i++) {
		arr[i] ^= (str[i] == 'A');
		arr[i + 1] ^= (str[i] == 'A');
	}

	l = 0, r = n;
	mark[0] = true;
	for (int i = 0; i < min(3 * n, k); i++) {
		if (!mark[l]) {
			mark[l] = true;
			arr[l] ^= arr[l - 1];
		}
		if (arr[l]) {
			arr[l] ^= 1;
			arr[l + 1] ^= 1;
		}
		else {
			l++;
			r++;
			arr[l] ^= 1;
			arr[r] ^= 1;
		}

		int sum = 0;
	}
	for (int i = l + 1; i < r; i++)
		arr[i] = (arr[i] + arr[i - 1]) & 1;

	if (k < 3 * n) {
		printAns();
	}
	else {
		if (n & 1) {
			if ((k - 3 * n) & 1) {
				if (!arr[l]) {
					l++;
					r++;
					for (int i = l; i < r; i++)
						arr[i] = (arr[i] + 1) & 1;
				}
				else {
					arr[l] = 1 - arr[l];
				}
			}
			printAns();
		}
		else {
			printAns();
		}
	}
}



Measured memory_bytes: 3840
import java.util.*;
import java.math.BigInteger;

public class Main {
   public static void main(String[] args) throws Exception {
	   
       String [] unit = {"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
       BigInteger k = BigInteger.valueOf(10000);
       Scanner sc = new Scanner(System.in);
       while(sc.hasNextInt()){
           BigInteger m = sc.nextBigInteger();
           int n = sc.nextInt();
           if(m.equals(BigInteger.ZERO) && n==0) break;
           BigInteger b = m.pow(n);
           String ans = "";
           for(int i=0;i<18;i++){
        	   BigInteger digit = b.remainder(k);
        	   if(!digit.equals(BigInteger.ZERO)){
        		   ans = digit + unit[i] + ans ;
        	   }
               b = b.divide(k);
           }
           System.out.println(ans);
       }
   }
}


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

int main() {
	int n;
	scanf("%d", &n);
	int ans = 100;
	rep(i, n) {
		int a;
		scanf("%d", &a);
		ans = min(ans, __builtin_ctz(a));
	}
	printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;

    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            if(i + j == x && 2 * i + 4 * j == y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if((10*b+c)%4==0) co("YES");
  else co("NO");
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
an = list(map(int, input().split()))
enable = 0

if not 1 in an:
  enable = 1
  
count = 0
block = 1
for i in range(N):
  if an[i] != block:
    count += 1
  else:
    block += 1
    
if enable == 1:    
  print(-1)
else:
  print(count)

Measured memory_bytes: 24744
import java.util.Scanner;

public class Main {

	static int[][] days = new int[13][32];
	static int youbi = 3;
	static{
		for(int i = 1; i <= 12; i++){
			if(i==2){
				for(int j = 1;j <= 29 ;j++){
					days[i][j] = youbi++%7;				
				}
			}
			else if(i==4||i==6||i==9||i==11){
				for(int j = 1;j <= 30; j++){
					days[i][j] = youbi++%7;				
				}
			}
			else{
				for(int j = 1;j <= 31; j++){
					days[i][j] = youbi++%7;				
				}
			}
				
		}
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		String[] yo = { "Monday", "Tuesday", "Wednesday", "Thursday"
				, "Friday", "Saturday", "Sunday"};
		
		while(true){
			int a = cin.nextInt();
			int b = cin.nextInt();
			if(a+b==0){
				break;
			}
			System.out.println(yo[days[a][b]]);
			
		}
	}

}

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

int main(void){
  int N, h_before, h;
  cin >> N;
  int count = 0;
  for(int i = 0; i < N; i++){
    cin >> h;
    if(h >= h_before){
      h_before = h;
      count++;
    }
  }
  cout << count;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
using namespace std;

int N, M;
string A[50];
string B[50];

bool included(int p, int q) {
  REP(i, 0, M)
    REP(j, 0, M)
      if(A[p + i][q + j] != B[i][j]) return false;
  return true;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N) cin >> A[i];
  REP(i, 0, M) cin >> B[i];

  REP(i, 0, N - M + 1)
    REP(j, 0, N - M + 1)
      if(included(i, j)) {
        cout << "Yes" << endl;
        return 0;
      }

  cout << "No" << endl;
  return 0;
}


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



using namespace std;








int main(){
    int N;
    int D;
    cin >> N >> D;
    int r = D*2+1;
    if(N%r==0){
        cout << N/r << endl;
    }else{
        cout << N/r + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, m;
  cin >> n >> m;

  map<ll, vector<Pl>> pref;
  rep(i, m) {
    ll p, y;
    cin >> p >> y;
    pref[p].push_back(Pl(y, i));
  }

  vector<Pl> city(m);

  for (auto var : pref) {
    vector<Pl> cityList = var.second;
    sort(cityList.begin(), cityList.end());
    rep(i, ll(cityList.size())) {
      city[cityList[i].second] = Pl(var.first, i+1);
    }
  }

  rep(i, m)
    printf("%06lld%06lld\n", city[i].first, city[i].second);

  return 0;
}


Measured memory_bytes: 13952
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
MAX = 10**5 + 100
MOD = 10**9 + 7

def COMinit():
    """
    逆元テーブルをつくる前処理
    計算量はO(n)
    1 <= k <= n <= 1e7程度
    p: 素数
    """
    fac = [0]*MAX
    finv = [0]*MAX
    inv = [0]*MAX

    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[0], inv[1] = 1, 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
    return fac, finv, inv



def comb(n, k):
    """
    nCk mod MODを求める.
    O(1)
    """
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return int(fac[n] * (finv[k] * finv[n-k] % MOD) % MOD)

fac, finv, inv = COMinit()


counter = dict(Counter(A))
dual = 0 # 重複してる数字
for key, value in counter.items():
    if value == 2:
        dual = key
        break

L = A.index(dual)
R = N - A.index(dual, L+1)

for K in range(1, N+2):
    ans = comb(N+1, K) - comb(L+R, K-1)
    
    print(ans%MOD)

Measured memory_bytes: 109284
import java.io.*;

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int a=Integer.parseInt(s[0]),b=Integer.parseInt(s[1]),c=Integer.parseInt(s[2]);
        int k=Integer.parseInt(bu.readLine());
        while(k!=0 && b<=a) {b*=2; k--;}
        while(k!=0 && c<=b) {c*=2; k--;}
        if(a<b && b<c && k>=0) sb.append("Yes\n");
        else sb.append("No\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 32460
count = gets.to_i
strs = Hash.new(0)
count.times do
    strs[gets.chomp] += 1
end
strs = strs.sort_by{ | k, v | v }.reverse
dic_strs = Array.new
max = strs[0][1]
strs.each do |str|
  if  max == str[1]
    dic_strs.push(str[0])
  else
    break
  end
end
dic_strs.sort!
puts(dic_strs)


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

int main(){
    int x,n;
    cin>>x>>n;
    set<int>se;
    rep(i,n){
        int p; cin>>p;
        se.insert(p);
    }
    int mn=1e9,ans=0;
    for(int i=-101; i<=101; ++i){
        if(se.find(i)==se.end()){
            if(mn>abs(x-i)){
                mn=abs(x-i);
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	string S;
	cin>>S;
	int f=1;
	for(int i=0;i<S.size();i++){
		if(f==1&&S[i]=='C')f++;
		if(f==2&&S[i]=='F')f++;
	}
	if(f==3)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    unsigned long long h, c=0;
    scanf("%llu", &h);

    while (h>0)
    {
        h >>= 1;
        ++c;
    }

    printf("%llu\n", ((unsigned long long)(1) << c)-1);
    return 0;
}

Measured memory_bytes: 128
/*
[yahoo-procon2019-qual] B - Path
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int a[3], b[3];
int cnt[4];

bool solve() {
    for (int i = 0; i < 3; i++) {
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    for (int i = 0; i < 4; i++) {
        if (cnt[i] >= 3) {
            return false;
        }
    }

    return true;
}

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

    cout << (solve() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cassert>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <memory>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 4000000000000000000LL
#define INF 1000000000
#define EPS 1e-8
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcountll(a)

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b);
  return 0;
}


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

int main() 
{
    int n;
    cin >> n;
    int a,b,c,d;
    a = n % 10;
    b = (n % 100) / 10;
    c = (n % 1000) / 100;
    d = n / 1000;
    if((a == b && b== c) || (b == c && c == d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3576
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    p: usize,
    q: usize,
    r: usize
    }
    let ans = min(p + q, min(q + r, r + p));
    println!("{}", ans);
}


Measured memory_bytes: 2192
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Map<String, Integer> blue = new HashMap<>();
        Map<String, Integer> red = new HashMap<>();
        int S = sc.nextInt();
        String[] s = new String[S];
        for(int i = 0; i < S; i++){
            s[i] = sc.next();
            if(blue.containsKey(s[i]))
                blue.put(s[i], blue.get(s[i]) + 1);
            else
                blue.put(s[i], 1);
            red.put(s[i], 0);
        }
        int T = sc.nextInt();
        for(int i = 0; i < T; i++){
            String t = sc.next();
            if(red.containsKey(t))
                red.put(t, red.get(t) + 1);
            else
                red.put(t, 1);
        }
        int ans = 0;
        for(int i = 0; i < S; i++)
            ans = Math.max(ans, blue.get(s[i]) - red.get(s[i]));
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const int MN = 3012;
const ld eps = 1e-9;
int n;
ld p[MN], dp[MN][MN];
ld ds (int k, int w) {
    if (dp[k][w] > -1.0) return dp[k][w];
    ld& res = dp[k][w];
    if (k == 0 and w == 0) return res = 1.0;
    if (w == 0) return res = ds(k-1,w)*(1.0-p[k]);
    if (k == w) return res = ds(k-1,w-1)*(p[k]);
    return res = ds(k-1,w-1)*p[k] + ds(k-1,w)*(1.0-p[k]);
}
int main (void) {
    for (int i = 0; i < MN; i++)
        for (int j = 0; j < MN; j++)
            dp[i][j] = -1.0;
    ios::sync_with_stdio(false);cin.tie(0);
    cout << fixed << setprecision(15);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> p[i];
    ld ans = 0.0;
    for (int i = n/2+1; i <= n; i++)
        ans += ds(n,i);
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 142208
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Weighted Union-Find Forest.
class WeightedUnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;
  std::vector<int> weight_;

 public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1, weight_[i]=0.
  WeightedUnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y(weight is w).
  // If x and y already have been united, return false.
  // Weight(y)-Weight(x)=w
  bool Unite(int x, int y, int w);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
  // Get the weight of node q.
  int Weight(const int &q);
  // Get the weights' difference of node x and y(Weight(y)-Weight(x)).
  int Diff(const int &x, const int &y);
};

WeightedUnionFindForest::WeightedUnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  weight_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
    weight_[i] = 0;
  }
}
int WeightedUnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}
int WeightedUnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    const int r = Root(parent_[q]);
    weight_[q] += weight_[parent_[q]];
    return parent_[q] = r;
  }
}

bool WeightedUnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

int WeightedUnionFindForest::Weight(const int &q) {
  Root(q);  // compress path
  return weight_[q];
}
int WeightedUnionFindForest::Diff(const int &x, const int &y) {
  if (Root(x) != Root(y)) {
    cerr << "WeightedUnionFindForest: Error" << endl;
    cerr << "Roots of node x and y aren't same" << endl;
    return INT32_MAX;
  }
  return Weight(y) - Weight(x);
}

bool WeightedUnionFindForest::Unite(int x, int y, int w) {
  w += Weight(x);
  w -= Weight(y);
  x = Root(x);
  y = Root(y);

  if (x == y) return false;
  if (rank_[x] < rank_[y]) {
    weight_[x] = w * (-1);
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    weight_[y] = w;
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
  return true;
}


int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;

  WeightedUnionFindForest WUFF(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (WUFF.IsSame(l, r)) {
      if (WUFF.Diff(l, r) == d) {
        // no conflict
      } else {
        // conflict
        cout << "No" << endl;
        exit(0);
      }
    } else {
      WUFF.Unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define N 100001

typedef struct{
  int parent;
  int left;
  int right;
} Tree;
 
Tree T[N];
 
int sibilings(int);
int degree(int);
int depth_c(int);
int hight(int);
void print(int);
 int sibilings(int a){
  if(T[a].parent == -1){
    return -1;
  }
  else if(T[T[a].parent].left == a){
    return T[T[a].parent].right;
  }
  else return T[T[a].parent].left;
}
 
int degree(int b){
  if(T[b].left ==-1 && T[b].right == -1){
    return 0;
  }
  else if(T[b].left !=-1 && T[b].right != -1){
    return 2;
  }
  else
    return 1;
}
 
int depth_c(int c){
  int count = 0;
  if(T[c].parent == -1){
    return 0;
  }
  else{
    count = depth_c(T[c].parent) + 1;
    return count;
  }
}
 
int hight(int z){
  int ah = 0, bh = 0;
  if(T[z].left != -1){
    ah = hight(T[z].left) + 1;
  }
   if(T[z].right != -1){
    bh = hight(T[z].right) + 1;
  }
   if(ah < bh){
     return bh;
   }
   else
     return ah;
}
 
void print(int f){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",f, T[f].parent, sibilings(f),degree(f));
  printf("depth = %d, height = %d, ",depth_c(f),hight(f));
  if(T[f].parent == -1){
    printf("root\n");
  }
  else if(T[f].left == -1 && T[f].right == -1){
    printf("leaf\n");
  }
  else
    printf("internal node\n");
}

main(){
  int i,j,p,l,r,n;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  for(i=0; i<n; i++){
    scanf("%d%d%d",&p,&l,&r);
    T[l].parent = p;
    T[r].parent = p;
    T[p].left = l;
    T[p].right = r;
   }
  for(i=0; i<n; i++){
    print(i);
   }
  return 0;
}
 

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

int main() {
  int n, s = 0;
  cin >> n;
  vector<int> v(n), c(n);
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  for(int i = 0; i < n; i++) {
    cin >> c.at(i);
    s += max(0, v.at(i) - c.at(i));
  }
  cout << s << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 課題1
{
    class Program
    {
        public static void Main(string[] args)
        {
            //入力した値を数値変換する
            int num = int.Parse(Console.ReadLine());

            int lcm = Lcm(num, 2);

            Console.WriteLine(lcm);


        }

        // 最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }


}


Measured memory_bytes: 27340
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
l = []

for i in range(N):
    sp = input().split()
    l.append((i, sp[0], int(sp[1])))

l.sort(key=lambda t: (t[1], -t[2]))

for i, _, _ in l:
    print(i+1)

Measured memory_bytes: 38512
#include<stdio.h>
int main(void)
{
	int i,d[12];
	float n,SM[12]={128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.5, 0.25, 0.125, 0.0625};
	while(1){
		for(i=0;i<12;i++)
			d[i] = 0;
		scanf("%f",&n);
		if(n == -1.0)
			break;

		for(i=0;i<12;i++){
			if(n >= SM[i]){
				d[i] = 1;
				n = n - SM[i];
			}
		}
		if(n == 0.0){
			for(i=0;i<12;i++){
				printf("%d",d[i]);
				if(i == 7)
					printf(".");
			}
			printf("\n");
		}
		else
			printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
	int N;
	scanf("%d",&N);
	N=N+1;
		while(N--){
		if((int)sqrt(N)==sqrt(N)){
		printf("%d\n",N);
		break;
		}
	}
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define EPS 1e-10

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

int main()
{
	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) return 0;
		double x[10], y[10], l[10];
		for(int i=0; i<n; i++){
			int x1, y1, l1;
			scanf("%d %d %d", &x1, &y1, &l1);
			x[i]=(double)x1, y[i]=(double)y1, l[i]=(double)l1;
		}
		if(n==1){
			printf("%.7lf\n", l[0]);
			continue;
		}
		double h1=1.0, h2=300.0;
		for(int t=0; t<100; t++){
			double h=(h1+h2)/2.0;
			bool e=0;
			double r[10];
			for(int i=0; i<n; i++){
				if(l[i]<h+EPS){
					e=1;
					break;
				}
				r[i]=sqrt(l[i]*l[i]-h*h);
			}
			if(e==1){
				h2=h;
				continue;
			}
			bool nn[10]={};
			for(int i=0; i<n; i++){
				for(int j=i+1; j<n; j++){
					double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
					if(abs(r[i]-r[j])>=d-EPS){
						if(r[i]>r[j]){
							nn[i]=1;
						}else{
							nn[j]=1;
						}
					}
					if(r[i]+r[j]<d+EPS){
						e=1;
					}
				}
			}
			if(e==1){
				h2=h;
				continue;
			}
          int count=0;
          for(int i=0; i<n; i++){
            if(nn[i]==0) count++;
          }
          if(count<=2){
            h1=h;
            continue;
          }
			for(int i=0; i<n; i++){
				for(int j=i+1; j<n; j++){
                  if(i==j) continue;
					if(nn[i]==1 || nn[j]==1) continue;
					double s=x[i]*x[i]-x[j]*x[j]+y[i]*y[i]-y[j]*y[j]-l[i]*l[i]+l[j]*l[j];
					double x1, y1, x2, y2;
					if(abs(y[i]-y[j])<EPS){
						x1=s/(2.0*(x[i]-x[j]));
						x2=x1;
						if(l[i]*l[i]-h*h<(x1-x[i])*(x1-x[i])+EPS){
							y1=y[i], y2=y[i];
						}else{
							y1=sqrt(l[i]*l[i]-h*h-(x1-x[i])*(x1-x[i]))+y[i];
							y2=-sqrt(l[i]*l[i]-h*h-(x1-x[i])*(x1-x[i]))+y[i];
						}
					}else{
						double t1=(x[i]-x[j])/(y[i]-y[j]);
						s/=(y[i]-y[j]);
                      	s/=2.0;
						double a=1.0+t1*t1;
						double b=x[i]+t1*(s-y[i]);
						double c=x[i]*x[i]+(s-y[i])*(s-y[i])-l[i]*l[i]+h*h;
						if(b*b<a*c+EPS){
							x1=b, x2=b;
						}else{
							x1=(b+sqrt(b*b-a*c))/a;
							x2=(b-sqrt(b*b-a*c))/a;
						}
						y1=-t1*x1+s;
						y2=-t1*x2+s;
					}
					bool e1=0;
					for(int k=0; k<n; k++){
                      if(k==i || k==j || nn[k]==1) continue;
						if((x1-x[k])*(x1-x[k])+(y1-y[k])*(y1-y[k])>l[k]*l[k]-h*h-EPS){
							e1=1;
							break;
						}
					}
					if(e1==0){
						e=1;
						break;
					}
					e1=0;
					for(int k=0; k<n; k++){
                      if(k==i || k==j || nn[k]==1) continue;
						if((x2-x[k])*(x2-x[k])+(y2-y[k])*(y2-y[k])>l[k]*l[k]-h*h-EPS){
							e1=1;
							break;
						}
					}
					if(e1==0){
						e=1;
						break;
					}
				}
				if(e==1) break;
            }
			if(e==1){
				h1=h;
			}else{
				h2=h;
			}
		}
		printf("%.7lf\n", h1);
	}
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    if (2*k-1>n) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256