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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define bet(min,max,n) if (! (min < n && n < max) )
#define rep(i,n) for (int i = 0; i < n; i++)

typedef long long unsigned int ll;
using namespace std;

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

    bet(0,14,A) {
        return -1;
    }
    bet(0,14,B) {
        return -1;
    }
    bet(0,14,C) {
        return -1;
    }

    if(A+B+C >= 22) {
        cout << "bust" << endl; 
    } else {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>

using namespace std;

//static const long long MOD = 1000000007;
//int **creat_map(int **map[], long long N);

int main() {
    long long N, Q, *counter;
    vector<pair<long long, long long> > ab, px;

    // input
    cin >> N >> Q;
    counter = new long long[N];
    memset(counter, 0, N);

    for (long long i = 0; i < N - 1; i++) {
        long long a, b;
        cin >> a >> b;
        ab.emplace_back(a, b);
    }
    for (long long i = 0; i < Q; i++) {
        long long p, x;
        cin >> p >> x;
        px.emplace_back(p, x);
    }

    // process
    sort(ab.begin(), ab.end());
//    sort(px.begin(), px.end());

//    int map[N][N];
//    for (long long i = 0; i < N - 1; i++) {
//        map[ab[i].first][ab[i].second] = 1;
//    }
//    map = creat_map(&map, N)
//    for (long long i = 0; i < N; i++) {
//        map[i][i] = 1;
//    }

    for (long long i = 0; i < Q; i++) {
        counter[px[i].first - 1] += px[i].second;
    }

    for (long long i = 0; i < N - 1; i++) {
        counter[ab[i].second-1] += counter[ab[i].first-1];
    }

    for (long long i = 0; i < N; i++) {
        cout << counter[i] << " ";
    }

    return 0;
}

//int **creat_map(int **map[], long long N) {
//    int **under_map;
//    for (long long i = 0; i < N; i++) {
//        for (long long j = 0; j < N; j++) {
//            if (*map[i][j] == 1) {
//                under_map = creat_map(map, N);
//                for (long long k = 0; k < N; k++) {
//                    *map[i][k] += *under_map[j][k];
//                }
//            }
//        }
//    }
//
//    return *map;


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

typedef struct{
	double x;
	double y;
}Point;

void koch(int n, Point a, Point b)
{
	if(n==0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.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;
	
	koch(n-1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n-1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n-1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n-1, t, b);
}


int main()
{
	Point a,b;
	int n;
	
	scanf("%d", &n);
	
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	
	return 0;
}



Measured memory_bytes: 2108
"""
dp[i][j] => マスi,jに到達するのに必要なワープ回数。
近隣5*5のマスから
"""


def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    H,W = map(int,input().split())
    Ch,Cw = map(int,input().split())
    Ch -= 1
    Cw -= 1
    Dh,Dw = map(int,input().split())
    Dh -= 1
    Dw -= 1
    maze = [list(input()) for _ in range(H)]

    que = deque([(Ch,Cw,0)])
    nxQue = deque([])
    adjecents = [(1,0),(0,1),(-1,0),(0,-1)]
    INF = 10**13
    for _ in range(INF):
        if not que:
            if nxQue:
                que = nxQue
                nxQue = deque([])
                continue
            else:
                break
        h,w,worp = que.popleft()
        if maze[h][w] == "#" or (maze[h][w]!="." and maze[h][w] <= worp):
            continue
        else:
            maze[h][w] = worp
            for a,b in adjecents:
                nxh,nxw = h+a,w+b
                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw]>worp):
                    que.append((nxh,nxw,worp))
                elif 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]=="#":
                    if b == 0:
                        for i in range(a,a*3,a):
                            for j in range(-2,3,1):
                                nxh,nxw = h+i,w+j
                                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw] > worp+1):
                                    nxQue.append((nxh,nxw,worp+1))
                    else:
                        for i in range(-2,3,1):
                            for j in range(b,b*3,b):
                                nxh,nxw = h+i,w+j
                                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw] > worp+1):
                                    nxQue.append((nxh,nxw,worp+1))
    
    if maze[Dh][Dw] == "#" or maze[Dh][Dw] == ".":
        print(-1)
    else:
        print(maze[Dh][Dw])
main()

Measured memory_bytes: 235348
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int N=4e5+10;
int n,ans2,cnt,now_r,b[N];ll L,t[N];
struct seg{ll l,r;}a[N];
int main(){
    scanf("%d%lld",&n,&L);
    rep(i,1,n) scanf("%lld%lld",&a[i].l,&a[i].r),t[++cnt]=a[i].l,t[++cnt]=a[i].r;
    sort(t+1,t+cnt+1);
    int w=unique(t+1,t+cnt+1)-t-1;
    rep(i,1,n) a[i].l=lower_bound(t+1,t+w+1,a[i].l)-t,a[i].r=lower_bound(t+1,t+w+1,a[i].r)-t,++b[a[i].l],--b[a[i].r];
    rep(i,1,w-1) b[i]+=b[i-1],ans2=max(ans2,n-b[i]);
    sort(a+1,a+n+1,[&](seg x,seg y){return x.l==y.l?x.r>y.r:x.l<y.l;});
    now_r=1;cnt=0;
    for(int i=1,j=1;i<=n;i=j){
        int tr=0;
        while(j<=n&&a[j].l<=now_r) tr=max(tr,(int)a[j].r),++j;
        now_r=tr;
        ++cnt;if(now_r==lower_bound(t+1,t+w+1,L)-t) break;
    }
    printf("%d %d\n",cnt,ans2+1);
    return 0;
}


Measured memory_bytes: 10756
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mx = max(a)
a.sort()
c = Counter(a)

dp = [0] * (mx+1)
for i in a:
    if dp[i] == 1:
        continue
    j = 2
    while i * j <= mx:
        dp[i*j] = 1
        j += 1

cnt = 0
for i in set(a):
    if dp[i] == 0 and c[i] == 1:
        cnt += 1

print(cnt)


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

int main(){

    while(1){

        //入力
        int n; cin >> n;
        if(!n) break;
        int ans = 0;

        char r, l;
        r = 'd';
        l = 'd';

        for(int i = 0; i < n; i++){
            string s; cin >> s;
            if(s == "lu") l = 'u';
            if(s == "ld") l = 'd';
            if(s == "rd") r = 'd';
            if(s == "ru") r = 'u';

            if(ans % 2 == 0){
                if(r == 'u' && l == 'u') ans++;    
            }else{
                if(r == 'd' && l == 'd') ans++;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
long double l;
/******* define variable end *******/
ll solve()
{
    cin >> l;
    cout << pow(l, 3) / 27 << endl;
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  final static int ONE_BTC_JPN_VALUE = 380000;

  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      double money = 0;

      for (int i = 0; i < N; ++i) {
        double x = in.nextDouble();
        String u = in.next();

        if (u.equals("JPY")) {
          money += x;
        } else {
          money += x * ONE_BTC_JPN_VALUE;
        }
      }

      System.out.println(money);
    }
  }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  200005
vi a[N];
int n, val[N], ans[N], visited[N];
vector<vector<int> > s;
vi dp(N, hell);

void dfs(int v)
{
	int i = lower_bound(all(dp), val[v]) - dp.begin();
	s.pb({i, dp[i]});
	dp[i] = val[v];
	int x = lower_bound(all(dp), hell) - dp.begin() - 1;
	ans[v] = x;
	visited[v] = 1;

	for(auto u: a[v])
		if(!visited[u])
			dfs(u);

	int m = sz(s);
	dp[s[m-1][0]] = s[m-1][1];
	s.pop_back();
	visited[v] = 0;
	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		cin >> n;

		rep(i, 0, n)
		cin >> val[i+1];

		rep(i, 0, n-1)
		{
			int x, y;
			cin >> x >> y;
			a[x].pb(y);
			a[y].pb(x);
		}

		dp[0] = -hell;
		memset(visited, 0, sizeof(visited));
		dfs(1);

		rep(i, 1, n+1)
		cout << ans[i] << endl;
	}
	return 0;
}


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

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int a1,a2,i,j;
    while(1)
    {
        scanf("%d%d",&a1,&a2);
        if(a1==0&&a2==0)
            break;
        for(i=0;i<a1;i++)
        {
            for(j=0;j<a2;j++)
            {
                if(i==0||i==a1-1||j==0||j==a2-1)
                    printf("#");
                else
                    printf(".");

            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}




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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

void amin(int &x, int y) {
  x = min(x, y);
}

void amax(int &x, int y) {
  x = max(x, y);
}

struct unionfind {
  vector<int> dat;

  unionfind(int n) : dat(n, -1) {}

  int find(int x) {
    if (dat[x] < 0) return x;
    return dat[x] = find(dat[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (dat[x] > dat[y]) swap(x, y);
    dat[x] += dat[y];
    dat[y] = x;
  }

  int size(int x) {
    return -dat[find(x)];
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<string> G(N);
  rep(i, N) cin >> G[i];
  vector<vector<int>> dist(N, vector<int>(N, 1e9));
  unionfind uf(N * 2);
  rep(i, N) dist[i][i] = 0;
  rep(i, N) rep(j, N) if (G[i][j] == '1' || G[j][i] == '1') {
    dist[i][j] = 1;
    uf.unite(i * 2 + 0, j * 2 + 1);
    uf.unite(i * 2 + 1, j * 2 + 0);
  }
  rep(i, N) {
    if (uf.find(i * 2 + 0) == uf.find(i * 2 + 1)) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep(k, N) rep(i, N) rep(j, N) {
    amin(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 0;
  rep(i, N) rep(j, N) amax(ans, dist[i][j]);
  cout << ans + 1 << endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++){
    int c = 0;
    for (int j = 0; i*pow(2, j) < k; j++){
      c++;
    }
    double x = (double)1 / (n * pow(2, c));
    ans += x;
  }
  cout << fixed << setprecision(10) << (double)ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String atCoder = scan.next();
		String s = scan.next();
		String contest = scan.next();
		System.out.println(atCoder.charAt(0) + "" + s.charAt(0) + "" + contest.charAt(0));
	}

}


Measured memory_bytes: 21204
class Node():
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1
        self.depth = 0
        self.sibling = -1
        self.degree = 0
        self.height = -1
        return

def getAncestor(t, n):
    for i in range(n):
        if t[i].parent == -1:
            return i

def preOrderWolk(t, u, load=[]):
    load.append(u)
    if t[u].left != -1:
        load = preOrderWolk(t, t[u].left, load)
    if t[u].right != -1:
        load = preOrderWolk(t, t[u].right, load)
    return load

def inOrderTreeWalk(t, u, load=[]):
    if t[u].left != -1:
        load = inOrderTreeWalk(t, t[u].left, load)
    load.append(u)
    if t[u].right != -1:
        load = inOrderTreeWalk(t, t[u].right, load)
    return load

def PostOrderTreeWalk(t, u, load=[]):
    if t[u].left != -1:
        load = PostOrderTreeWalk(t, t[u].left, load)
    if t[u].right != -1:
        load = PostOrderTreeWalk(t, t[u].right, load)
    load.append(u)
    return load
    

import sys

n = int(input())
t = []
for _ in range(n):
    t.append(Node())

for i in range(n):
    a = list(map(int, sys.stdin.readline().split()))
    m = a[0]
    t[m].left = a[1]
    t[m].right = a[2]
    if a[1] != -1:
        t[m].degree += 1
        t[a[1]].parent = m
        t[a[1]].sibling = a[2]
    if a[2] != -1:
        t[m].degree += 1
        t[a[2]].parent = m
        t[a[2]].sibling = a[1]

r = getAncestor(t,n)
ptw = preOrderWolk(t, r, [])
itw = inOrderTreeWalk(t, r, [])
post = PostOrderTreeWalk(t, r, [])

print('Preorder')
print('',*ptw)
print('Inorder')
print('',*itw)
print('Postorder')
print('',*post)

    


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

int main()
{
	int n,x,t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
	return 0;
}

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

N, T = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
ans = []

for i in range(N):
    if c[i][1] <= T:
        ans.append(c[i])

ans.sort(key=lambda x: x[0])

try:
    print(ans[0][0])
except:
    print('TLE')


Measured memory_bytes: 3060
s = input()
bef = s[:2]
aft = s[2:]

if 1 <= int(bef) <= 12:
    if 1 <= int(aft) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(aft) <= 12:
        print("YYMM")
    else:
        print("NA")

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    pair<int, int> A[N];
    rep(i, N){
        int a; cin >> a;
        A[i] = make_pair(a, i+1);
    }
    sort(A, A+N);
    rep(i, N){
        if(i == N-1) cout << A[i].second << endl;
        else cout << A[i].second << " ";
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 1536
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	string s; cin >> s;
	int n = s.length();
	int dp0 = 0, dp1 = 1;
	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		int dq0 = min(dp0 + d, dp1 + 10 - d);
		int dq1 = min(dp0 + d + 1, dp1 + 9 - d);
		dp0 = dq0;
		dp1 = dq1;
	}
	cout << dp0 << '\n';
	return 0;
}


Measured memory_bytes: 5252
<?php
$N = (int)fgets(STDIN);
$as = array_map('intval', explode(' ', trim(fgets(STDIN))));

function cost($as, $m) {
    return array_reduce($as, function($carry, $a) use ($m) {
        return $carry + ($a - $m) * ($a - $m);
    });
}

$min = min($as);
$max = max($as);

$minCost = PHP_INT_MAX;

for ($m = $min; $m <= $max; $m++) {
    $minCost = min(cost($as, $m), $minCost);
}

echo "$minCost\n";

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  bool second = true;
  for (int i = 0; i < N; i++){
    if (a[i] % 2 == 1){
      second = false;
    }
  }
  if (second){
    cout << "second" << endl;
  } else {
    cout << "first" << endl;
  }
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N, M;
int a[MAX_N], b[MAX_N];

                            
struct edge { int to, cost; };
const int MAX_V = MAX_N, INF = 1e9;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  d[s] = 0;
  pque.push(Pii(0, s));


  while (!pque.empty()) {
    Pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

int dfs(int v, int& radius) {
  int ma1 = -1, ma2 = -1;
  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i].to;
    if (d[u] > d[v]) {
      int t = dfs(u, radius);
      if (t >= ma1) {
        ma2 = ma1;
        ma1 = t;
      } else if (t >= ma2) {
        ma2 = t;
      }
    }
  }
  if (ma1 < 0) {
    return 1;
  } else if (ma2 < 0) {
    radius = max(radius, ma1+1);
    return ma1+1;
  } else {
    radius = max(radius, ma1+ma2+1);
    return ma1+1;
  }

}


int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  
  cin >> N;
  M = N-1;
  V = N;
  rep(i, M) cin >> a[i] >> b[i];
  
  rep(i, M) {
      add_edge(--a[i], --b[i], 1);
  }
  
  int root = 0;
  dijkstra(root);

  int radius = 0;
  dfs(root, radius);

  cerr << "radius: " << radius << endl;

  if (radius%3 == 2) {
      cout << "Second" << endl;
  } else {
      cout << "First" << endl;
  }
      
  return 0;
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = (ll)1e18;
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)

void warshall_floyd(vector<vector<ll>> &d) {
	ll N=d.size();
	for (ll k=0; k<N; k++) {
		for (ll i=0; i<N; i++) {
			for (ll j=0; j<N; j++){
				if(d[i][k] != INF && d[k][j] != INF && d[i][k] + d[k][j] < d[i][j]){
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
}

bool dfs(vector<vector<ll>> &d,ll v,ll p,vector<ll> &seen){
	rep(nextv,d.size()){
		if(d[v][nextv]!=1)continue;
		if(seen[nextv]!=0){
			if(seen[nextv]==seen[v])return false;
			else continue;
		}
		seen[nextv]=-1*seen[v];
		bool b=dfs(d,nextv,v,seen);
		if(!b)return false;
	}
	return true;
}

signed main() {
	ll N;
	cin>>N;
	vector<vector<ll>> d(N, vector<ll>(N, 0));
	for(ll i=0; i<N; i++) {
		for(ll j=0; j<N; j++) {
			if(i==j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}

	rep(i,N){
		string s;
		cin>>s;
		rep(j,s.size()){
			if(s[j]=='1'){
				d[i][j]=1;
			}
		}
	}

	vector<ll> seen(N,0);
	seen[0]=1;
	bool b=dfs(d,0,-1,seen);
	if(!b){
		cout<<-1<<endl;return 0;
	}

	ll maxval=0;
	warshall_floyd(d);
	for(ll i=0; i<N; i++) {
		for(ll j=0; j<N; j++) {
			maxval=max(maxval,d[i][j]);
		}
	}	
	cout<<maxval+1<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
  #include <algorithm>
  #include <vector>
  #include <cmath>
#include <string>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <iomanip>
  #include <stack>
  #include <queue>
  #include <deque>
  using namespace std;
   
  int main(){
      long long m,k;
      cin>>m>>k;
      if(k>=(1<<m)){
          cout<<-1;
          return 0;
      }
      if(k==0){
          for(int i=0;i<(1<<m);i++){
              cout<<i<<' '<<i<< ' ';
          }
          return 0;
      }
      int x=0;
      for(int i=0;i<(1<<m);i++){
          if(k!=i)x^=i;
      }
      if(x!=k){
          cout<<-1;
          return 0;
      }
      cout << k << ' ';
      for(int i=0;i<(1<<m);i++){
          if(i!=k)cout<<i<<' ';
      }
      cout<<k<<' ';
      for(int i=(1<<m)-1;i>=0;i--){
          if(i!=k)
          cout<<i<< ' ';
      }
      return 0;
  }


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<functional>
#include<algorithm>
typedef long long ll;
using namespace std;

vector<int> HP;

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    HP.push_back(tmp);
  }
  int flag = 1;
  int ans;
  while(flag){
    int min = 1000000000;
    int index;
    for(int i=0;i<N;i++){
      if(HP[i]!=0 && HP[i]<min){
        min = HP[i];
        index = i;
      }
    }
    //cout << min << endl;
    int miria=0;
    for(int i=0;i<N;i++){
      miria+=(HP[i]%min);
      if(i!=index){
        HP[i] = HP[i]%min;
      }
    }
    if(miria==0){
      ans = min;
      flag = 0;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    int sum = 0;
    for(int i = 0;i < N;i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    vector<int> div;
    for(int i = 1;i*i <= sum;i++){
        if(sum%i == 0){
            div.push_back(i);
            div.push_back(sum/i);
        }
    }
    sort(div.rbegin(), div.rend());
    vector<int> aa;
    int ans = 0;

    for(auto d : div){
        aa = a;
        bool f = false;
        for(int i = 0;i < N;i++)    aa[i] %= d;
        sort(aa.begin(), aa.end());
        int id = -1;
        for(int i = 0;i < N;i++){
            if(aa[i] > 0){
                id = i;
                break;
            }
        }
        if(id == -1){
            ans = d;
            break;
        }
        vector<int> lsum(N+1, 0);
        for(int i = N-1;i >= id;i--){
            lsum[i] += lsum[i+1]+(d-aa[i]);
        }

        int rsum = 0;
        for(int i = id;i < N;i++){
            rsum += aa[i];
            if(rsum > K)    break;
            if(rsum == lsum[i+1]){
                ans = d;
                f = true;
            }
        }
        if(f)   break;
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
n = int(input())

place = {}
for i in range(n):
  tmp = input().split()
  s = tmp[0]
  k = int(tmp[1])
  pt = (k, i)
  if s in place:
    place[s].append(pt)
  else:
    place[s] = [pt]

placek = sorted(place)

for i in placek:
  pts = sorted(place[i], reverse=True)
  for pt in pts:
    print(pt[1] + 1)

Measured memory_bytes: 38384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,l = inpl()
d = [[INF]*n for _ in range(n)]
for _ in range(m):
    a,b,c = inpl()
    d[a-1][b-1] = c
    d[b-1][a-1] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
e = [[INF]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            e[i][j] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            e[i][j] = min(e[i][j], e[i][k]+e[k][j])
q = inp()
for _ in range(q):
    a,b = inpl()
    ans = e[a-1][b-1]
    print(-1 if ans == INF else ans-1)


Measured memory_bytes: 87828
import sys
import os

def file_input():
    f = open('ABC167/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    A,B,C,K=map(int, input().split())

    sum=0
    if K>A:
        sum+=A
        K-=A
        if K>B:
            K-=B
            sum-=K        
    else:
        sum+=K

    print(sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

bool flush(ll n) {
  assert(1 <= n && n <= 1000000000000000000);
  cout << "? " << n << endl;
  char c;
  cin >> c;
  return (c == 'Y');
}

void answer(ll n) {
  assert(1 <= n && n <= 1000000000);
  cout << "! " << n << endl;
}

void solve1() {
  ll ask = 2;
  while (true) {
    if (flush(ask)) {
      answer(ask/2);
      return;
    } else {
      ask *= 10;
    }
  }
}

void solve2() {
  ll ask = 1e8;
  while (true) {
    if (flush(ask)) {
      break;
    } else {
      ask /= 10;
    }
  }
  ll lb = ask;
  ll ub = ask * 10 - 1;
  while (ub - lb > 1) {
    ll t = (ub + lb) / 2;
    if (flush(t * 10)) {
      ub = t;
    } else {
      lb = t;
    }
  }
  answer(ub);
}

int main () {
  if (flush(1e9)) {
    solve1();
  } else {
    solve2();
  }
}


Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647

int main() {
	ios_base::sync_with_stdio(false);
	long long n; cin >> n;

	long long a=0, b=0; 
	long long i=2;
	for (; i * i <= n; i++) {
		if (n % i == 0) {
			a = i; 
			b = n / i;
		}
	}

	if (a == 0 && b == 0) {
		cout << n - 1 << "\n";
	}
	else {
		cout << a - 1 + b - 1 << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll gcd(ll a, ll b)
{
    if (a < b)
        ll c = a, a = b, b = c;

    return a % b == 0 ? b : gcd(b, a % b);
}

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

    int n;
    ll m, a[112345];

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

    ll fst = a[0] / 2;
    for (int i = 1; i < n; i++)
    {
        fst = fst * (a[i] / 2) / gcd(fst, (a[i] / 2));

        if ((fst / (a[i] / 2)) % 2 == 0 || (fst / (a[i - 1] / 2)) % 2 == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ll al = a[0];
    for (int i = 1; i < n; i++)
    {
        al = al * a[i] / gcd(al, a[i]);
    }

    if (fst > m)
    {
        cout << 0 << endl;
        return 0;
    }

    cout << 1 + (m - fst) / al << endl;

    return 0;
}

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

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int n;cin>>n;
    ll a[n+1];
    rep(i,0,n+1)cin>>a[i];
    ll b[n];
    rep(i,0,n)cin>>b[i];

    ll ans=0;
    rep(i,0,n)
    {
        if(a[i]<b[i])
        {
            ans+=a[i];
            b[i]-=a[i];a[i]=0;
            if(a[i+1]<b[i])
                ans+=(a[i+1]),a[i+1]=0;
            else
                ans+=b[i],a[i+1]-=b[i];
        }
        else
            ans+=(b[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes\n";
  }
  else if(abs(a-b)<=d && abs(b-c)<=d)cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3600
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let x = nextInt()
    if(x == 0) console.log(1)
    if(x == 1) console.log(0)

}
Main()



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

int main(){
    string s ;
    cin >> s ;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s.at(i) == '?')
        {
            s.at(i) = 'D' ;
        }
        
    }
    
    cout << s << endl ;

}

Measured memory_bytes: 3724
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;


int main() {
	int x;
	cin >> x;
	vector<int> sosuu(100004);

	for (int i = 2;i <= 100003;i++) {
		sosuu[i] = 0;
	}

	for (int i = 2;i <= 100003;i++) {
		if (sosuu[i] == 0) {
			for (int j = i*2;j <= 100003;j = j + i) {
				sosuu[j]++;
			}
		}
	}

	for (int i = x;i <= 100003;i++) {
		if (sosuu[i] == 0) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

//BBBBBBBBBBBBBBBBBB
//int main() {
//	long long a, b, k;
//	cin >> a >> b >> k;
//
//	if (k > a) {
//		k -= a;
//		a = 0;
//		b -= k;
//		if (b < 0)b = 0;
//	}
//	else {
//		a -= k;
//	}
//
//	cout << a << " " << b << endl;
//
//	return 0;
//}

//AAAAAAAAAAAAAAAAA
//int main() {
//	string s, t;
//	cin >> s >> t;
//
//	cout << t << s << endl;
//
//	return 0;
//}

Measured memory_bytes: 3764
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void calc(){
	int n;
	cin>>n;
	vi b(n+2),he(n+2,inf);
	rep(i,n)cin>>b[i+1]>>he[i+1];
	b[n+1]=100;
	int m;
	cin>>m;
	vi f(m),a(m);
	rep(i,m)cin>>f[i]>>a[i];
	int q;
	cin>>q;
	while(q--){
		int p,t;
		cin>>p>>t;
		vi w(n+1);
		int sum=0;
		rep(i,m)rep(j,n+1)if(b[j]<f[i]&&f[i]<b[j+1]){
			w[j]+=a[i]*t;
			sum+=a[i]*t;
		}
		vi par=b,h=he;
		while(1){
			rep(i,w.size())if((par[i+1]-par[i])*30*min(h[i],h[i+1])<w[i]){
				int sum=(par[i+1]-par[i])*30*min(h[i],h[i+1]);
				if(h[i]<h[i+1]){
					if(w[i-1]==(par[i]-par[i-1])*30*min(h[i],h[i-1])&&h[i-1]>h[i]){
						par.erase(par.begin()+i);
						h.erase(h.begin()+i);
						w[i-1]+=w[i];
						w.erase(w.begin()+i);
					}else w[i-1]+=w[i]-sum,w[i]=sum;
				}else if(h[i]>h[i+1]){
					if(w[i+1]==(par[i+2]-par[i+1])*30*min(h[i+1],h[i])&&h[i+1]<h[i+2]){
						par.erase(par.begin()+i+1);
						h.erase(h.begin()+i+1);
						w[i+1]+=w[i];
						w.erase(w.begin()+i);
					}else w[i+1]+=w[i]-sum,w[i]=sum;
				}
				goto end;
			}
			break;
			end:;
		}
		rep(i,w.size())if(par[i]<p&&p<par[i+1]){
			cout<<shosu(5)<<min(50.,w[i]/30./(par[i+1]-par[i]))<<endl;
			break;
		}
	}
}
int main(){
	int data;
	cin>>data;
	while(data--)calc();
}










Measured memory_bytes: 3120
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int h = Integer.parseInt(sc.next());
		sc.next();
		for (int i = 0; i < h; i++) {
			String c = sc.next();
			out.println(c);
			out.println(c);
		}
		out.flush();
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string &str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }


//------------------------------------------------------------------------------------------------------------------------------


int main() {

	INPUT_INT(M);
	INPUT_INT(D);

	int res = 0;
	int d1, d10;
	for (int m = 1; m <= M; ++m) {
		for (int d = 1; d <= D; ++d) {
			d1 = d % 10;
			d10 = d / 10;

			if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) { ++res; }
		}
	}

	OUTPUT(res);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define cin (type == 0?cin:fin)
//#define cout (type == 0?cout:fout)
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define r_0 return 0
#define ll long long
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long N = 2e3 + 7;
const long long MrBeast = 1e9;

ll T = 1, n, m, x, a[N];
vector < ll > v, t;
int type = 0;
set< ll > st;
pair< ll ,ll > p[N];
int main()
{
    TIME
    //ifstream  fin("swap.in");
    //ofstream  fout("swap.out");
    cin >> n >> m;
    long double ans = 0;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        ans += a[i];
    }
    long double cnt = ans / ( 4 * m );
    for ( int i=0; i<n; i++ ){
        if ( a[i] >= cnt )
            x ++;
        if ( x == m )
            return cout << "Yes", 0;
    }
    cout << "No";
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


S = input()
N = len(S)


def palidrome(S):
    return all(a == b for a, b in zip(S, S[::-1]))


if palidrome(S) and palidrome(S[:(N - 1) // 2]) and palidrome(
        S[(N + 1) // 2:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    set <int> bad;
    forn (i, 0, m) {
        int t;
        cin >> t;
        bad.insert(t);
    }
    vector <int> dp(n + 2);
    dp[0] = 0, dp[1] = 1;
    const int MOD = 1e9 + 7;
    forn (i, 2, n + 2) {
        if (bad.find(i - 1) != bad.end())
            dp[i] = 0;
        else 
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    cout << dp[n + 1];
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define INF 1<<30
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

int h[maxn+2], dp[maxn+2], n, k;

void init(int n){
    for(int i=0;i<=n;i++) dp[i] = INF;
}

int solve(int cur){
    if(cur >= n) return INF;
    if(cur == n-1) return 0;

    if(dp[cur] != INF) return dp[cur];

    //int res = INF;
    for(int j=1;j<=k;j++) {
        dp[cur] = min(dp[cur] , solve(cur+j) + abs(h[cur+j] - h[cur]));
    }

    return dp[cur];
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    // #ifndef ONLINE_JUDGE
    //     fread();
    // #endif
    
    while(scanf("%d %d",&n, &k)==2){
        init(n);
        for(int i=0;i<n;i++) {
            scanf("%d",&h[i]);
        }
        printf("%d\n", solve(0));
    }    
    return 0;
}

Measured memory_bytes: 5760
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-03-07 21:03:03 +0900
# LastModified: 2020-03-07 21:05:30 +0900
#


import os


def main():
    S = input()
    if 'A' in S and 'B' in S:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,j,score[1000];
  double average,sum=0;
  while(1){
      scanf("%d",&n);
      if(n == 0) break;
      for(i=0;i<n;i++){
        scanf("%d",&score[i]);
        sum+=score[i];
      }
      average = sum/(double)n;
      sum=0;
      for(i=0;i<n;i++){
        sum+=((double)score[i]-average)*(score[i]-average);
      }
      average = sum/(double)n;
      sum=0;
      printf("%f\n",sqrt(average));
  }
  return 0;
}



Measured memory_bytes: 2128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    char s[111];
    int len;
    scanf("%s", s);
    len = strlen(s);
    for (int i = 0; i < len; i++)
    {
        printf("x");
    }
    return 0;
}

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

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var ary = Array.ConvertAll(line, int.Parse).OrderByDescending(x => x).ToArray();
        for (int i = 0; i < 5; i++)
        {
            Console.Write(ary[i]);
            if (i == 4) Console.WriteLine();
            else Console.Write(" ");
        }
    }
}

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

int main() {
	int n,w;
	cin>>n>>w;
	vector<pair<int,int>> v;
	int a,b;
	long long dp[n+1][w+1];
	
	for(int i=0;i<=n;i++)
	{
		cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	//sort(v.begin(),v.end());
	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			dp[i][j]=0;
		}
	}
	int t,val;;
	for(int i=1;i<=n;i++){
		t=v[i-1].first;
		val=v[i-1].second;
		for(int j=1;j<=w;j++){
			if(j-t<0){dp[i][j]=dp[i-1][j];
			continue;}
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-t]+val);
		}
	}
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
package main

import (
	"fmt"
	"math"
	"os"
	"strings"
)

const DEBUG_ENABLE = false

func debug(format string, a ...interface{}) (n int, err error) {
	if DEBUG_ENABLE {
		return fmt.Fprintf(os.Stdout, format, a...)
	} else {
		return 0, nil
	}
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	//var N = 3
	allFactors := make(map[int]int) //N!の素因数分解
	for num := 2; num <= N; num++ {
		factors := factoring(num)
		debug("factoring of %d = %s\n", num, printFactoring(factors))
		for k, v := range factors {
			_, ok := allFactors[k]
			if ok {
				allFactors[k] += v
			} else {
				allFactors[k] = v
			}
		}
	}
	debug("%d! = %s\n", N, printFactoring(allFactors))
	//N!の約数(M)の約数の個数が75個になるのは、以下の4パターン
	//M=p^4q^4r^2 (5*5*3=75), p^24q^2 (25*3=75), p^4q^14 (5*15=75), p^74 (75)

	//N!の素因数分解の結果を使って、カウントする

	//約数の数

	ret := countNum(4, allFactors)*(countNum(4, allFactors)-1)*(countNum(2, allFactors)-2)/2 + countNum(24, allFactors)*(countNum(2, allFactors)-1) + countNum(14, allFactors)*(countNum(4, allFactors)-1) + countNum(74, allFactors)

	fmt.Printf("%d\n", ret)
}

func countNum(keyCount int, factors map[int]int) int {
	//keyCount以上の値に持つkeyの数を数える
	count := 0
	for k, v := range factors {
		if v >= keyCount {
			debug("prime -> %d\n", k)
			count++
		}
	}
	debug("%d count -> %d\n", keyCount, count)
	return count
}

//階乗
func fact(num int) int {
	ret := 1
	for i := 2; i <= num; i++ {
		ret *= i
	}
	return ret
}

//素因数分解
func factoring(num int) map[int]int {
	debug("factoring %d BEGIN\n", num)
	if num == 1 {
		return make(map[int]int)
	}
	ret := make(map[int]int)
	//sqrt := int(math.Ceil(math.Sqrt(float64(num))))
	//debug("sqrt = %d\n", sqrt)
	maxPrime := num
	for num%2 == 0 {
		ret[2]++
		num = num / 2
	}
	for p := 3; p <= maxPrime; p = p + 1 {
		debug("maxPrime is %d\n", maxPrime)
		if num == 1 {
			break
		}
		if isPrime(p) {
			debug("%d is Prime\n", p)
			debug("%d rem %d = %d\n", num, p, num%p)
			for num%p == 0 {
				debug(" counting of %d num\n", p)
				_, ok := ret[p]
				if ok {
					ret[p]++
				} else {
					ret[p] = 1
					debug("ret[%d] = %d\n", p, ret[p])
				}
				num = num / p
			}
		}
	}
	return ret
}

func printFactoring(factors map[int]int) string {

	strs := make([]string, 0)
	for k, v := range factors {
		strs = append(strs, fmt.Sprintf("%d^%d", k, v))
	}
	return strings.Join(strs, " * ")

}
func isPrime(num int) bool {
	if num == 2 {
		return true
	}
	if num%2 == 0 {
		return false
	}
	sqrt := int(math.Ceil(math.Sqrt(float64(num))))
	for i := 3; i <= sqrt; i = i + 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 768