akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll t(n), a(n);
  REP(i, n) cin >> t.at(i);
  REP(i, n) cin >> a.at(i);
  vll high(n, 0);
  ll ans = 1;
  rep(i, 1, n-1) {
    if (t.at(i) != t.at(i-1)) {
      if (a.at(i) != a.at(i+1) && t.at(i) != a.at(i)) {
        ans = 0; break;
      } else if (a.at(i) < t.at(i)) {
        ans = 0; break;
      }
    } else if (a.at(i) != a.at(i+1)) {
      if (t.at(i) != t.at(i-1) && t.at(i) != a.at(i)) {
        ans = 0; break;
      } else if (t.at(i) < a.at(i)) {
        ans = 0; break;
      }
    } else {
      ans *= min(a.at(i), t.at(i));
      ans %= MOD;
    }
  }
  if (a.at(0) != t.at(n-1)) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
def gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/gcd(c, d))
a_cd = (a-1)//int((c*d)/gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))

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

int w, h;
char tile[21][21];

const int mx[] = {0, 0, 1, -1};
const int my[] = {1, -1, 0, 0};

int func(int x, int y){
	if(x < 0 || x >= w || y < 0 || y >= h || tile[y][x] == '#'){
		return 0;
	}
	int res = 1;
	tile[y][x] = '#';
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 4; ++j){
			res += func(x + mx[i], y + my[i]);
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin >> w >> h && w != 0 && h != 0){
	
		int sx = 0, sy = 0;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cin >> tile[i][j];
				if(tile[i][j] == '@'){
					sy = i;
					sx = j;
				}
			}
		}
		
		cout << func(sx, sy) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  int ans=1;
  rep(i,N) cin>>A[i];
  sort(all(A));
  if(A[N-1]<K) ans=0;
  else{
    while(A[0]!=A[N-1]){
      rep(i,N){
        if(A[i]%A[0]) A[i]%=A[0];
        else A[i]=A[0];
      }
      sort(all(A));
    }
    if(K%A[0]) ans=0;
  }
  cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    string s; cin >> s;
    if(s[1] == 'R') s[1] = 'B';
    else s[1] = 'R';
    cout << s << endl;
    return 0;
}

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

const long int mod = 1e9+7;
long int dp[100005][2];

int main(){
    string S;
    cin >> S;
    int i,j;
    int L=S.length();
    dp[0][0]=1;
    dp[0][1]=2;
    for(i=0;i<L-1;i++){
        dp[i+1][0]=(dp[i][0]*3)%mod;
        if(S[i+1]=='1'){
            dp[i+1][1]=(dp[i][1]*2)%mod;
            dp[i+1][0]=(dp[i+1][0]+dp[i][1])%mod;
        }
        else dp[i+1][1]=dp[i][1];
    }
    cout << (dp[L-1][0]+dp[L-1][1])%mod << endl;
}

Measured memory_bytes: 2048
import sys
input = sys.stdin.readline

h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(list(input()))

res = 0

for r in range(1<<h):
    for g in range(1<<w):
        tmp = 0
        for i in range(h):
            for j in range(w):
                if c[i][j] == '#' and (r>>i)&1 == 1 and (g>>j)&1 == 1:
                    tmp += 1
        if tmp == k:
            res += 1

print(res)

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


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

  ll n,w;
  cin >> n >> w;
  vector<ll> wei(n), v(n);
  REP(i, n){
    cin >> wei[i] >> v[i];
  }

  vector<vector<ll>> dp(n+100, vector<ll>(w+100));
  REP(i, n+100){
    REP(j, w+100){dp[i][j] = 0;}
  }

  REP(i, n){
    REP(sum_w, w+100){
      if (sum_w >= wei[i]) {chmax(dp[i+1][sum_w], dp[i][sum_w - wei[i]] + v[i]);}
      chmax(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[n][w] << endl;
  return 0;
}



Measured memory_bytes: 157824
#include<iostream>
using namespace std;
int main()
{
    int N;  //number
    int D;  //days
    int X; //remain
    int i,j;
    int a[100]={0};
    cin>>N>>D>>X;
    for(i=0;i<N;i++)
    {
        cin>>a[i];
    }
    int sum=X;
    for(i=0;i<N;i++){
        for(j=0;j<100;j++)
        {
            if(j*a[i]+1<=D)
                sum+=1;
        }
    }
    cout<<sum;
    return 0;
}


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> pairs(N);
  for (int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  sort(pairs.begin(), pairs.end(), compare_by_b);
  // 多分　締め切りが一番近いかつからやるといいと思う
  int time = 0;
  for (int i=0; i<N; i++){
    // printf("%d\t%d\n", pairs[i].first, pairs[i].second);
    time += pairs[i].first;
    if (time > pairs[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, x, t;
    cin >> n >> x >> t;
    int tmp = n / x;
    if(n % x != 0) ++tmp;
    cout << tmp * t << endl;
    return 0;
}



Measured memory_bytes: 3648
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);
$sum = [];
$f = [0 => [$S[0] => 1]];
$b = [$N - 1 => [$S[$N - 1] => 1]];
for ($i = 1; $i < $N; $i++) {
    $f[$i] = $f[$i - 1];
    $f[$i] += [$S[$i] => 1];
    $b[$N - $i - 1] = $b[$N - $i];
    $b[$N - $i - 1] += [$S[$N - $i - 1] => 1];
}
for ($i = 1; $i < $N - 1; $i++) {
    //printf("%d %s %s\n", $i, implode("", array_keys($f[$i])), implode("", array_keys($b[$i])));
    foreach (array_keys($f[$i - 1]) as $n1) {
        foreach (array_keys($b[$i + 1]) as $n2) {
            $x = strval($n1 . $S[$i] . $n2);
            //printf("%d\n", $x);
            $sum[$x] = 1;
        }
    }
}
echo count($sum);


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pic = pair<int, char>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

static const ll NIL=-1;
static const ll INF=__LONG_LONG_MAX__/3;
static const ll WHITE=0;
static const ll GRAY=1;
static const ll BLACK=2;

vector<pll> ls[100010];
ll color[100010];
ll d[100010],p[100010];
ll n;

void dijkstra(ll s)
{
    for(ll i = 0; i < n; i++)
    {
        color[i]=WHITE;
        p[i]=-1;
        d[i]=INF;
    }
    d[s]=0;
    priority_queue<pii,vector<pll>,greater<pll>> pq; //cost, to
    pq.push(make_pair(0,0));

    while(pq.empty()==false){
        pii f = pq.top();
        pq.pop();
        ll u = f.second;
        color[u]=BLACK;
        if(d[u]<f.first) continue;

        for(ll j = 0; j < ls[u].size(); j++)
        {
            ll v = ls[u][j].second;
            ll c = ls[u][j].first;
            if(color[v]!=BLACK && d[u]+c<d[v])
            {
                d[v]=d[u]+c;
                color[v]=GRAY;
                pq.push(make_pair(d[v],v));
            }
        }
        
    }
}

int main(){
    m0(ls);
    m0(color);
    cin>>n;

    for (ll i = 0; i < n-1; i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        u--;
        v--;
        ls[u].push_back(make_pair(w,v));
        ls[v].push_back(make_pair(w,u));
    }
    
    dijkstra(0);

    for (ll i = 0; i < n; i++)
    {
        cout<<d[i]%2<<endl;
    }
    
    
    return 0;
}

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

int main()
{
    ll N, T, ans = 0;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t[i];
    for (int i = 1; i < N; i++)
    {
        ans += min(t[i] - t[i - 1], T);
    }
    ans += T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

double round_at(double n,int dig){
    return ((int)(round(n*pow(10,dig))))/pow(10,dig);
}

int main(){
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        x = (c*e-b*f)/(a*e-b*d);
        y = (a*f-c*d)/(a*e-b*d);
        x = round_at(x,3);
        y = round_at(y,3);
        printf("%.3lf %.3lf\n",x,y);
    }
}

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

using namespace std;

int main() {
    vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout << a[0] + a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
sunuke = list()
cnt = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    sunuke.extend(a)
for j in range(1, n + 1):
    if j not in sunuke:
        cnt += 1
print(cnt)


Measured memory_bytes: 9180
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, X, Y = MAP()

ans = INF

ma = max(X, Y)
t = ma * C * 2
ans = A * X + B * Y
# print(ans, t)
# exit()
mi = min(X, Y)
mi_X = X - mi
mi_Y = Y - mi
tmp = mi_X * A + mi_Y * B + C * mi * 2
ans = min(ans, tmp, t)
print(ans)
exit()

# for i in range():
# print(ans)
for i in range(min(X, Y) + 1):
    tmp = A * (X - i) + B * (Y - i) + C * 2 * i
    print(tmp)
    ans = min(tmp, ans)
print(ans)




# i = 0
# new = 0
# while new < ans:
#     new = A * (X - i) + B * (Y - i) + C * 2 * i
#     ans = min(ans, new)
#     print(ans)
#     i += 1
# print(ans)
    # if new < ans:
    #     ans = new
    #     i += 1
    # else:
    #     print(ans)
    #     break

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {

	ll N,M;
	cin >> N >> M;
	cout << abs(N-2) * abs(M-2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a[1001][1001];
	scanf("%d", &n);

	int i, j;
	for (i = 1; i <= n; i++)
	{
		for (j = 0; j < n - 1; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	int next[1001] = {0};        // next_idx[i]:選手iが次に戦う選手が書いてあるa[i][k]のインデックスk
	int judge, matches;             //　試合数
	judge = matches = 0;
	while (judge == 0)
	{
		int played[1001] = {0};			 // played[i]:選手iがを試合を行なっていたら1
		for (i = 1; i <= n - 1; i++)
		{
			j = a[i][next[i]];
			if (played[i] == 0 && played[j] == 0 && a[j][next[j]] == i)
			{
				judge = 1;
				played[i] = played[j] = 1;
				next[i]++; next[j]++;
			}
		}
		if (judge == 0) 
		{
			printf("-1\n");
			return 0;
		}
		judge = 1;
		for(i = 1; i <= n; i++) {
			if (next[i] != n - 1) {
				judge = 0;
				break;
			}
		}
		matches++;
	}
	printf("%d\n", matches);
	return 0;
}

Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C solver = new C();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class C
	{
		public void solve(int n, MyScanner in, PrintWriter out)
		{
			int mod = (int) 1e9 + 7;
			
			int N = in.nextInt();
			int[] a = new int[N];
			long sum = 0;
			for( int i=0; i<N; i++ )
			{
				a[i] = in.nextInt();
				sum += a[i];
			}
			long ans = 0;
			for( int i=0; i<N; i++ )
			{
				sum -= a[i];
				long add = ((sum % mod) * a[i]) % mod;
				ans = (ans + add) % mod;
			}
			out.println(ans);
		}
	}
	
	static class B
	{
		public void solve(int n, MyScanner in, PrintWriter out)
		{
			String S = in.next();
			String T = in.next();

			char[] s = S.toCharArray();
			char[] t = T.toCharArray();
			
			int min = t.length;
			for( int i=0; i<=s.length - t.length; i++ )
			{
				int cnt = 0;
				for( int j=0; j<t.length; j++ )
				{
					if( s[i+j] != t[j] ) cnt++;
				}
				min = Math.min(min, cnt);
			}
			out.println(min);
		}
	}
	
	static class A
	{
		int D;
		int T;
		int S;
		
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{
			D = in.nextInt();
			T = in.nextInt();
			S = in.nextInt();
			out.println(D <= T*S ? "Yes" : "No");
		}
	}
	
	static class MyScanner
	{
		private BufferedReader in;
		private StringTokenizer st;
		
		public MyScanner(InputStream stream)
		{
			in = new BufferedReader(new InputStreamReader(stream));
		}
		
		public String next()
		{
			while( st == null || !st.hasMoreTokens() )
			{
				try
				{
					String rl = in.readLine();
					if( rl == null )
					{
						return null;
					}
					st = new StringTokenizer(rl);
				}
				catch( IOException e )
				{
					return null;
				}
			}
			return st.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 55164
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

x = int(input())

while True:
	if is_prime(x) == True:
		break
	else:
		x += 1

print(x)

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    char S;
    cin >> S ;
    cout << (char)(S+1) << endl;
    
    return 0;
}

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

int main() {
    int n,k;
    int ans;
    bool isNA;
    
    while (scanf("%d", &n) && n) {
        ans = 1;
        isNA = true;
        
        for (int i = 0; i < n; i++) {
            scanf("%d", &k);
            
            if (k > 0) {
                ans++;
            }
            if (k > 1) {
                isNA = false;
            }
        }
        
        if (isNA)
            printf("NA\n");
        else
            printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (110)
struct data{
	int x,y;
}a[N];
int n,nx[N];
ll ans;

bool cmp(data o1,data o2){
	return atan2(o1.y,o1.x)<atan2(o2.y,o2.x);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",&a[i].x,&a[i].y);
	for (int i=1;i<=n;++i) nx[i]=i+1; nx[n]=1;
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;++i){
		ll x=a[i].x,y=a[i].y;
		ans=max(ans,x*x+y*y);
		for (int j=nx[i];j!=i;j=nx[j]){
			x+=a[j].x,y+=a[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
	printf("%.10lf",sqrt(ans));
}
/*
将这n个二元组看做n个向量。
移动方式遵循平行四边形定则。
所以两个向量夹角越小，相加形成的和向量模长就越大。
所以将这些向量按照极角排序。
选择的向量肯定是一个区间。
枚举左右端点，求最大值即可。
*/

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

vector<int>v;
int main(void){
    int n,b;
    cin>>n;
    bool flag=0;
    for(int i=1;i<=n;i++){
        cin>>b;
        if(b>i){
            flag=1;
            break;
        }
        else v.insert(v.begin()+b-1,b);
    }
    if(flag) cout<<-1<<endl;
    else for(int i=0;i<n;i++) cout<<v[i]<<endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 2) {
    cout << "No" << endl;
  } else {
    y /= 2;
    int a = y - x;
    int b = x - a;
    cout << (a >= 0 && b >= 0 ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll d;

	ll n;
	cin>>n>>d;
	ll cnt= 0;
	for(i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		ld k = a*a + b*b;
		k = sqrt(k);
		if(k<=d)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	
	
	


	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	char x, y; cin >> x >> y;
	if ('0'<=x && x<='9') x -= '0';
	if ('0'<=y && y<='9') y -= '0';
	if ('A'<=x && x<='Z') x -= 'A'-10;
	if ('A'<=y && y<='Z') y -= 'A'-10;
	if (x > y){
		cout << ">\n";
	}else if(x == y){
		cout << "=\n";
	}else{
		cout << "<\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n;
string s ;
map<pair<string , string > , ll > cnt1 , cnt2 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    
    cin >> n ;
    
    cin >> s ;
	ll ans = 0 ;
	reverse(s.begin() , s.begin() + n) ;
    for (int mask = 0 ; mask < (1 << n) ; mask ++) {
    	string a = "" , b = "" ;
    	for (int i =0  ; i < n ; i ++) {
    		if (mask & (1 << i)) a += s[i] ;
    		else b += s[i] ;
		}
		cnt1[{a , b}] ++ ;
	}
	for (int mask = 0 ; mask < (1 << n) ; mask ++) {
    	string a = "" , b = "" ;
    	for (int i =0  ; i < n ; i ++) {
    		if (mask & (1 << i)) a += s[n + i] ;
    		else b += s[n + i] ;
		}
		cnt2[{a , b}] ++ ;
	}

	for (auto u : cnt1) {
		ans += cnt1[u.F] * cnt2[u.F] ;
	}
    cout << ans ;
    
    return (0) ;
}

Measured memory_bytes: 108288
import math
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b= map(int, input().split())
if a*b%2==1:
    print("Odd")
else:
    print("Even")


Measured memory_bytes: 2940
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> Enum.sort(:asc)
    |> process()
    |> IO.puts()
  end
  
  defp process([a, b, c]) when a + b == c, do: "Yes"
  defp process(_), do: "No"
end

Measured memory_bytes: 30656
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


class unionfind
{
private:
	vector<long long> par;
	vector<long long> rank;
public:
	void init(long long n);
	long long find(long long x);
	void unite(long long x, long long y);
	bool same(long long x, long long y);
};

// 初期化
void unionfind::init(long long n) {
	for (long long i = 0; i < n; i++) {
		par.push_back(i);
		rank.push_back(0);
	}
}

// 木の根を求める
long long unionfind::find(long long x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

// xとyの属する集合を併合
void unionfind::unite(long long x, long long y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rank[x] < rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank[x] == rank[y]) {
			rank[x]++;
		}
	}
}

// xとyが同じ集合に属していたらtrue
bool unionfind::same(long long x, long long y) {
	return find(x) == find(y);
}

int main() {
    ll n, m;
    cin >> n >> m;
    unionfind uni;
    uni.init(n + m);
    REP(i, n){
        ll k;
        cin >> k;
        REP(j, k){
            ll l;
            cin >> l;
            l--;
            uni.unite(i, n + l);
        }
    }
    REP(i, n){
        if(!uni.same(0, i)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 3564
#include<stdio.h>

int main(){
  int n=0;
  int x=0;
  int y=0;

  scanf("%d",&n);

  for(int i=1;i<=n;i++){
    x=x+800;
    if(i%15==0) y=y+200;
  }

  printf("%d\n",x-y);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split("");
    for(int i=0; i<str.length; i=i+2) {
      System.out.print(str[i]);
    }
    System.out.println();
  }
}

Measured memory_bytes: 48092
#129_E
l = input()
x = len(l)
mod = 10 ** 9 + 7

dp = [[0 for _ in range(2)] for _ in range(x)]
dp[0][1] = 2
dp[0][0] = 1
for i in range(1, x):
    if l[i] == '0':
        dp[i][1] = (dp[i][1] + dp[i-1][1]) % mod
    else:
        dp[i][1] = (dp[i][1] + dp[i-1][1] * 2) % mod
        dp[i][0] = (dp[i][0] + dp[i-1][1]) % mod
        
    dp[i][0] = (dp[i][0] + dp[i-1][0] * 3) % mod
print((dp[x-1][0] + dp[x-1][1]) % mod)

Measured memory_bytes: 21220
def insertion_sort(A: list, N: int):
    print(*A, sep=" ")
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A, sep=" ")


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    insertion_sort(A, N)



Measured memory_bytes: 5976
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;

#define MAX_N 32
#define MAX_M 10
#define INF 114514114514.1919810893

double dp[MAX_N][1 << MAX_M], t[MAX_N];
int n, m, p, a, b, x, y, z;
double s[MAX_N][MAX_N];

double solve() {
	dp[a][0] = 0.0;
	for (int i = 0; i < m; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			for (int k = 0; k < (1 << n); k++)
			{
				if (dp[j][k] < INF)
				{
					for (int l = 1; l <= m; l++)
					{
						if (s[j][l] < INF)
						{
							for (int o = 0; o < n; o++) {
								int d = (k / (1 << o)) % 2;
								if (d == 0) {
									dp[l][k + (1 << o)] = min(dp[l][k + (1 << o)], dp[j][k] + 1.0*s[j][l] / t[o]);
								}
							}
						}
					}
				}
			}
		}
	}
	double minx = INF;
	for (int i = 0; i < (1 << n); i++) {
		minx = min(minx, dp[b][i]);
	}
	return minx;
}

int main() {
	while (true) {
		cin >> n >> m >> p >> a >> b;
		if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> t[i];
		}
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < MAX_N; j++) {
				s[i][j] = INF;
			}
		}
		for (int i = 0; i < p; i++) {
			cin >> x >> y >> z;
			s[x][y] = z;
			s[y][x] = z;
		}
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < (1 << MAX_M); j++) {
				dp[i][j] = INF;
			}
		}
		double e = solve();
		if (e >= INF) { cout << "Impossible" << endl; }
		else { cout << fixed << setprecision(15) << e << endl; }
	}
}

Measured memory_bytes: 1552
x, y = map(int, input().split())

ans = int(1e11)

# B(0) --> A --> B(0)
if x <= y:
    ans = min(ans, y - x)

# B(1) --> A --> B(0)
if -x <= y:
    ans = min(ans, y + x + 1)

# B(0) --> A --> B(1)
if x <= -y:
    ans = min(ans, -y - x + 1)

# B(1) --> A --> B(1)
if -x <= -y:
    ans = min(ans, -y + x + 2)

print(ans)

Measured memory_bytes: 38384
N, M = gets.split.map(&:to_i)
As, Bs = N.times.map{gets.strip}, M.times.map{gets.strip}

puts [*0 .. N - M].repeated_permutation(2).any?{|x, y| As[y, M].map{|s| s[x, M]} == Bs} ? 'Yes' : 'No'


Measured memory_bytes: 2044
#include <stdio.h>

int main()
{
  int n;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  char s[100000][3];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s", s[i]);
    if(s[i][0] == 'A'){
      AC++;
    }else if(s[i][0] == 'W'){
      WA++;
    }else if(s[i][0] == 'T'){
      TLE++;
    }else{
      RE++;
    }
  }

  printf("AC x %d\n", AC);
  printf("WA x %d\n", WA);
  printf("TLE x %d\n", TLE);
  printf("RE x %d\n", RE);
}

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

ll f(ll b,ll n){
    if(n<b) return n;
    ll ret = f(b,n/b) + n%b;
    return ret;
}

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

    ll n,s;
    cin>>n>>s;
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    if(s>(n+1)/2){
        cout<<-1<<endl;
        return 0;
    }
    /*for(int i=2;i<=150;i++){
        cerr<<f(i,n)<<endl;
    }*/
    ll k=0;
    for(ll i=2;i*i<=n;i++){
        if(f(i,n)==s){
            cout<<i<<endl;
            return 0;
        }
        k=i;
    }
    k++;
    if(s==1){
        cout<<n<<endl;
        return 0;
    }
    for(ll i=k;i>=1;i--){
        ll t=n/i;
        ll r=n/(i+1);
        if(n%(i+1)==0){
            //cerr<<i<<endl;
            r++;
        }
        ll l=t-r;
        ll md = s-f(t,n);
        if(md>=0 && md%i==0 && md<=l*i){
            ll ans=-md/i;
            //cerr<<i<<" "<<ans<<" "<<t<<" "<<r<<" "<<l<<endl;
            ans+=t;
            if(ans<k) continue;
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

}

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

typedef long int lint;
typedef long long int llint;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  int n, l;
  cin >> n >> l;
  string str[101], res;

  REP(i, n) cin >> str[i];
  sort(str, str + n);
  
  REP(i, n) res += str[i];
  cout << res << endl;
}



Measured memory_bytes: 256
n = int(input())
dishes = []
for _ in range(n):
    a, b = map(int, input().split())
    dishes.append((a, b, a + b))
dishes.sort(key=lambda dish: dish[2], reverse=True)

x = y = 0
for i in range(n):
    a, b, _ = dishes[i]
    if i % 2 == 0:
        x += a
    else:
        y += b

print(x - y)

Measured memory_bytes: 22140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

void solve()
{
  int a, b, c; cin >> a >> b >> c;
  int sum = 100 * a + 10 * b + c;
  if(sum%4 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;

}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAXN=300005;
int tree[4*MAXN],kiri[MAXN],kanan[MAXN];
pii a[MAXN];

int query(int now,int L,int R,int x,int y){
	if(L>=x && R<=y)return tree[now];
	if(L>y || R<x)return 0;
	int mid=(L+R)/2;
	return max(query(2*now,L,mid,x,y),query(2*now+1,mid+1,R,x,y));
}

void update(int now,int L,int R,int pos,int val){
	if(L==R){
		tree[now]+=val;
		return;
	}
	int mid=(L+R)/2;
	if(pos<=mid)update(2*now,L,mid,pos,val);
	else update(2*now+1,mid+1,R,pos,val);
	tree[now]=max(tree[2*now],tree[2*now+1]);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m,k;
	cin >> n >> m >> k;
	for(int i=1;i<=k;i++){
		cin >> a[i].first >> a[i].second;
	}
	sort(a+1,a+k+1);
	for(int i=1;i<=k;i++){
		if(kiri[a[i].first]==0)kiri[a[i].first]=i;
		kanan[a[i].first]=i;
	}
	for(int i=1;i<=k;i++)update(1,1,m,a[i].second,1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(kiri[i]==0)continue;
		for(int j=kiri[i];j<=kanan[i];j++)update(1,1,m,a[j].second,-1);
		ans=max(ans,kanan[i]-kiri[i]+1+query(1,1,m,1,m));
		for(int j=kiri[i];j<=kanan[i];j++)update(1,1,m,a[j].second,1);
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 12444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
    static int h;
    public static void main (String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int[] a = new int[2000000];
	h = 0;
	StringBuilder sb = new StringBuilder();
	String[] command;
	int max;
	while (true) {
	    command = br.readLine().split(" ");
	    if (command[0].equals("end")) {
		break;
	    } else if (command[0].equals("insert")) {
		int element = Integer.parseInt(command[1]);
		a[++h] = element;
		int i = h;
		int tmp;
		while (i > 1 && a[i/2] < a[i]) {
		    tmp = a[i];
		    a[i] = a[i/2];
		    a[i/2] = tmp;
		    i /= 2;
		}
	    } else if (command[0].equals("extract")) {
		sb.append(a[1] + "\n");
		a[1] = 0;
		int tmp = a[1];
		a[1] = a[h];
		a[h] = tmp;
		maxHeapify(a, 1);
		h--;
	    }
	}
	System.out.print(sb);
    }

    static void maxHeapify (int[] a, int i) {
	int left = i * 2;
	int right = i * 2 + 1;
	int largest = 0;
	if (left <= h && a[left] > a[i]) {
	    largest = left;
	} else {
	    largest = i;
	}
	if (right <= h && a[right] > a[largest]) {
	    largest = right;
	}
	if (largest != i) {
	    int tmp = a[i];
	    a[i] = a[largest];
	    a[largest] = tmp;
	    maxHeapify(a, largest);
	}
    }
}

Measured memory_bytes: 195824
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
   //  String[] S=sc.nextLine().split(" ");

int n=Integer.parseInt(nyuA);

//int N=Integer.parseInt(S[0]);
//int M=Integer.parseInt(S[1]);

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);

long res=1;
long war=1000000007;
for(int i=1;i<=n;i++){
res*=i;
res%=war;
}


System.out.println(res);


	}
}

Measured memory_bytes: 21844
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}



/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	ll cost = 0;
	ll tmp = (ll)min(x, y);
	c *= 2;
	if (a + b > c) {
		cost += (ll)c * tmp;
	}
	else {
		cost += a * tmp;
		cost += b * tmp;
	}
	x -= tmp;
	y -= tmp;

	if (x) {
		if (a > c) {
			cost += (ll)c * (ll)x;
		}
		else {
			cost += (ll)a * x;
		}
	}
	else {
		if (b > c) {
			cost += (ll)c * (ll)y;
		}
		else {
			cost += (ll)b * y;
		}
	}
	printf("%lld\n", cost);

	return 0;
}


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

ll N, Q, A[100000], X[100000];
ll sum[100001], se[100001], so[100001];

bool ok(ll x, ll a, ll b) {
  if (!(0 <= a && a < N)) return true;
  if (!(0 <= b && b < N)) return false;
  ll da = abs(A[a] - x);
  ll db = abs(A[b] - x);
  if (db < da) return true;
  if (db == da) return b < a;
  return false;
}

ll solve(ll x) {
  ll l = 1, h = N + 1;
  while (h - l > 1) {
    ll m = (l + h) / 2;
    ll p = (m + 1) / 2;
    ll q = m / 2;
    if (ok(x, N - m, N - p)) h = m;
    else l = m;
  }

  ll u = N - (l + 1) / 2;
  ll v = N - l;

  return (sum[N] - sum[u]) + (((l % 2) + (v % 2)) % 2 == 0 ? so[v] : se[v]);
}

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

  REP(i, 0, N) {
    sum[i + 1] = sum[i] + A[i];
    se[i + 1] = se[i] + (i % 2 == 0 ? A[i] : 0);
    so[i + 1] = so[i] + (i % 2 == 1 ? A[i] : 0);
  }

  REP(i, 0, Q) {
    cout << solve(X[i]) << endl;
  }
}

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

namespace abc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
           
            string a = input[0].Substring(0,1);
            string b = input[1].Substring(0, 1);
            string c = input[2].Substring(0, 1);
            string s1 = a + b + c;
            Console.WriteLine(s1.ToUpper());
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
<?php

$classes = array('light fly' => 0.0, 'fly' => 48.0, 'bantam' => 51.00, 'feather' => 54.0, 'light' => 57.0, 'light welter' => 60.0, 'welter' => 64.0, 'light middle' => 69.0, 'middle' => 75.0, 'light heavy' => 81.0, 'heavy' => 91.0);
while (true) {
    fscanf(STDIN, '%f', $w);
    if (feof(STDIN)) {
        break;
    }
    $class = '';
    foreach ($classes as $c => $v) {
        if ($w > $v) {
            $class = $c;
        }
    }
    echo $class . PHP_EOL;
}

Measured memory_bytes: 6600
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n,n){
        vi v(n,0);rep(i,n)cin>>v[i];int ans=0;
        rep(j,n-1)rep(i,n-1)if(v[i]>v[i+1]){swap(v[i],v[i+1]);ans++;}
        cout<<ans<<endl;
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if(4 * m * a.at(i) >= sum) cnt++;  
  }
  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> p(N);
   for(int i = 0; i < N; i++){
     cin >> p[i];}
  int cnt = 0;
  for(int i = 0 ; i <= N - 3; i++){
    if( p[i] <= p[i+1] && p[i+1] <= p[i+2] ){ cnt++;}
    else if( p[i] >= p[i+1] && p[i+1] >= p[i+2] ) { cnt++; }}
  
  cout << cnt << endl; return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main() {
  int N;cin >> N;
  vector<ll> a(N*3);
  for(int i=0;i<N*3;i++) cin >> a[i];

  vector<ll> s(N*2+1,0);
  priority_queue<long long, vector<long long>, greater<long long>> que1;
  for (int i = 0; i < N; ++i) {
    s[i+1] = s[i] + a[i];
    que1.push(a[i]);
  } 
  for (int i = N; i < N*2; ++i) {
        long long mi = que1.top();
        if (a[i] > mi) {
            s[i+1] = s[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else s[i+1] = s[i];
  }
  vector<long long> T(N*2+ 1, 0);
    priority_queue<long long> que2;
    for (int i = 0; i < N; ++i) {
        T[i+1] = T[i] + a[N*3-1 - i];
        que2.push(a[N*3-1 - i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long ma = que2.top();
        if (a[N*3-1 - i] < ma) {
            T[i+1] = T[i] - ma + a[N*3-1 - i];
            que2.pop();
            que2.push(a[N*3-1 - i]);
        }
        else T[i+1] = T[i];
    }

    // 集計
    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, s[i] - T[N*3-i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 8052
x, k, d = map(int, input().split())

bigger = 0
smaller = 0

if x >= 0:
    bigger = x - min(x // d, k) * d
    smaller = bigger - d
else:
    smaller = x + min((-x) // d, k) * d
    bigger = smaller + d

if abs(x) // d >= k:
    bigger = abs(bigger)
    smaller = abs(smaller)
    
    if x >= 0:
        print(bigger)
    else:
        print(smaller)
else:
    k -= abs(x) // d
    bigger = abs(bigger)
    smaller = abs(smaller)

    if x >= 0:
        if k % 2 == 0:
            print(bigger)
        else:
            print(smaller)
    else:
        if k % 2 == 0:
            print(smaller)
        else:
            print(bigger)

Measured memory_bytes: 9164
#include <stdio.h>
#include <queue>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
const int INF = 100000000;
int H,W;
char b[50][51];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int d[50][50];
int cnt = 0;
int bfs(){
	queue<P> que;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j] = INF;
		}
	}
	que.push(P(0,0));
	d[0][0] = 0;
	while(que.size()){
		P p = que.front();
		que.pop();
		if(p.first == H-1 && p.second == W-1)break;
		for(int i=0;i<4;i++){
			int nx = p.first + dx[i],ny=p.second+dy[i];
			if(0 <= nx && nx < H && 0 <= ny && ny < W && b[nx][ny] != '#' && d[nx][ny] == INF){
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second]+1;
			}
		}
	}
	return d[H-1][W-1];
}

int main(void){
	scanf("%d %d",&H,&W);
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> b[i][j];
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(b[i][j] == '#'){
				cnt++;
			}
		}
	}
	int res = bfs();
	if(res == INF){
		printf("-1\n");
		return 0;
	}
	res += 1;
	res = W*H-res-cnt;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	if N % 10 == 9 || N / 10 == 9 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
package main

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

func main() {
	scan_init()
	x := abs(scanInt())
	k := scanInt()
	d := scanInt()
	// x:= 初期値
	// d = 変数
	keisan := x / d //回数
	min := x
	check := keisan % 2 ==  k % 2
	// fmt.Println("check", check)
	if k > keisan {
		min = x % d
		if !check {
			if  abs(min - d) < min + d {
				min = -(min - d)
			} else {
				min  += d
			}
		}
	} else if k == keisan {
		min = x - k * d
		if min < 0 {
			min = -min
		}
	} else {
		min = x - k * d
	}
	fmt.Println(abs(min))
}

var sc = bufio.NewScanner(os.Stdin)

func abs (a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}
func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 1788
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
set <string> s;
map <string, int> m;
string a[N];
void solve () {
	int n;
	cin >> n;
	int maxi = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		m[a[i]] ++;
		maxi = max (maxi, m[a[i]]);
	}	
	for (int i = 1; i <= n; i ++) {
		if (m[a[i]] == maxi) {
			s.in (a[i]);
		}
	}
	for (auto it : s) cout << it << endl;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 36864
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<queue>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
map<string,int> d;
int dx[]={1,-1,4,-4};
queue<string> que;
//d["01234567"]=0;
char num[9];
void bfs()
{
	que.push("01234567");
	while(que.size())
	{
		string str=que.front();
		que.pop();
		int t=str.find("0");
		string strr;
		rep(i,4)
		{
			int next;
			next=t+dx[i];
			if(next>=0&&next<=7&&!((next==3&&t==4)||(next==4&&t==3)))
			{
				strr=str;
				swap(strr[next],strr[t]);
				if(d.find(strr)==d.end())
				{
					que.push(strr);
					d[strr]=d[str]+1;
				}
			}
		}
	}
}
int main()
{
	string s;
	while(getline(cin,s))
	{
		string t;
		rep(i,s.size())
		{
			if(s[i]!=' ')t+=s[i];
		}
		bfs();
	cout<<d[t]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3432
def main():
    N = int(input())
    ans = [str(N) + ':']
    
    while not N % 2:
        N //= 2
        ans.append(2)
        
    i = 3
    while i ** 2 <= N:
        while not N % i:
            N //= i
            ans.append(i)
            
        i += 2
        
    if N != 1: ans.append(N)
    
    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5596