akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,X = inputIL()

if X>A+B or X<A:
  print("NO")
else:
  print("YES")


Measured memory_bytes: 63980
//************************
//*  Date: 2018.9.8      *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,x;
vector <int> v,g;

int main()
{
	cin>>n>>x;
	rep(i,n)
	{
		int y;
		scanf("%d",&y);
		v.pb(y);
	}
	v.pb(x);
	sort(v.begin(),v.end());
	rep(i,v.size()-1) g.pb(v[i+1]-v[i]);
	int ans=g[0];
	repn(i,g.size()-1) ans=__gcd(ans,g[i]);
	printf("%d\n",ans);
	rt0;
}

Measured memory_bytes: 1400
#include <cstdio>
static_assert(sizeof(long) >= 8, "long too short");
using namespace std;
struct Node {
    Node *ch[2];
    Node() = default;
};
void insert(Node *n, char *s) {
  	while (*s) {
      	auto &ch = n->ch[*s++ - '0'];
        if (!ch)
            ch = new Node();
      	n = ch;
    }
}
long solve(Node *n, long m) {
    return n ? solve(n->ch[0], m - 1) ^ solve(n->ch[1], m - 1) : m & -m;
}
char s[100001];
int main() {
    int n;
    long m;
    scanf("%d %ld", &n, &m);
    Node *root = new Node();
    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        insert(root, s);
    }
    puts(solve(root, m + 1) ? "Alice" : "Bob");
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
using namespace std;
int main(){
  
  string s1,s2;
  cin >> s1 >> s2;
  s2.pop_back();
  if(s1==s2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
      }
}

Measured memory_bytes: 3592
// https://qiita.com/drken/items/dc53c683d6de8aeacf5a#a-%E5%95%8F%E9%A1%8C---frog-1
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> h(N); REP(i, N) cin >> h[i];

  vector<int> dp(100010);
  ll INF = pow(10, 9) + 7;
  REP(i, 100010) {
    dp[i] = INF;
  }

  dp[0] = 0;

  for(int i = 1; i < N; ++i) {
    for(int k = i - K; k < i; ++k) {
      if(k < 0) continue;
      chmin(dp[i], dp[k] + abs(h[i] - h[k]));
    }
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
def color_check(n):
    if n < 400:
        return "grey"
    elif n < 800:
        return "brown"
    elif n < 1200:
        return "green"
    elif n < 1600:
        return "cyan"
    elif n < 2000:
        return "blue"
    elif n < 2400:
        return "yellow"
    elif n < 2800:
        return "orange"
    elif n < 3200:
        return "red"
    else:
        return "any"

colors_so_far = set()
cany = 0
n = input()
c = map(int, input().split())

for i in c:
    color = color_check(i)
    if color != "any":
        colors_so_far.add(color)
    else:
        cany += 1

x = len(colors_so_far)
if x < 1:
    print(1, cany)
else:
    print(x, len(colors_so_far)+cany)


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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

struct item{
	double value,weight;
};

const int MAXN=1e5+10, MOD=1e9+7;
int n;double W;
vector<item> v;

signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>W;
	for(int i=0; i<n; i++){
		double val,wei; cin>>val>>wei;
		v.push_back({val,wei});
	}
	sort(all(v),[](item a,item b){ return (a.value*b.weight)>=(b.value*a.weight);});
	double cnt=0;
	for(auto itm : v){
		auto mnw = itm.weight;
		if(W-mnw>=0){
			cnt += itm.value;
			W-=mnw;
		}
		else{
			auto rmw = W;
			cnt += ((1.0*rmw)/itm.weight)*itm.value;
			W-=rmw;
			break;
		}
	}
	cout<< fixed << setprecision(10)<<cnt; br;
}


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

using namespace std;

int main() {
	int n, h, x, y;

	cin >> n;

	vector<int> data(n);

	for (int i = 0; i < n; i++) {
		cin >> data[i];
	}

	x = 0;
	y = 0;

	for (int i = 0; i < n; i++) {
		if (data[i] % 4 == 0) {
			y++;
		}
		else if (data[i] % 2 == 0) {
			x++;
		}
	}

	h = n / 2;

	if (y >= h) {
		cout << "Yes" << endl;
	}
	else if (x == n) {
		cout << "Yes" << endl;
	}
	else if (n - (y * 2) <= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict


N = int(input())
counter = defaultdict(int)
for a in map(int, input().split()):
    if a % 4 == 0:
        counter[2] += 1
    elif a % 2 == 0:
        counter[1] += 1
    else:
        counter[0] += 1
if counter[1] == 0:
    print('Yes') if counter[0] <= counter[2] + 1 else print('No')
else:
    print('Yes') if counter[0] <= counter[2] else print('No')


Measured memory_bytes: 11436
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int x = Integer.parseInt(a+b);
        int s = 0;
        String str = "No";

        while(x > Math.pow(s, 2)){
            s++;
            if (x == Math.pow(s, 2)){
                str = "Yes";
            }
        }

        System.out.println(str);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;



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

map<ll, int> exp_mp;

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

  // N!を素因数分解する
  for (int i = 2; i <= n; i++)
  {
    auto primes = factorize(i);
    for (auto p : primes)
    {
      exp_mp[p.first] += p.second;
    }
  }

  int ans = 0;
  // p^74の場合
   for(auto p = exp_mp.begin(); p != exp_mp.end(); ++p){
    if(p->second >= 74) ans++;
  }

  // p^24*p^2 || p^14*p^4
  for(auto p = exp_mp.begin(); p != exp_mp.end(); ++p){
  for(auto q = exp_mp.begin(); q != exp_mp.end(); ++q){
     if(p->first ==q->first) continue;
     if( p->second >= 24 && q->second >= 2) ans++;
     if( p->second >= 14 && q->second >= 4) ans++;
    }  
  }

  // p^2*p^4*p^4
  for(auto p = exp_mp.begin(); p != exp_mp.end(); ++p){
  for(auto q = exp_mp.begin(); q != exp_mp.end(); ++q){
  for(auto r = exp_mp.begin(); r != exp_mp.end(); ++r){
       if(p->first == q->first || r->first == p->first || q->first>=r->first) continue;
     if( p->second >= 2 && q->second >=4 && r->second>=4) ans++;
    }  
  }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
fum=0
for i in range(1,N):
  if (A[i]<A[i-1]):
    B=A[i-1]-A[i]
    A[i]=A[i]+B
    fum = fum+B
  else:
    fum=fum
print(fum)

Measured memory_bytes: 32192
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N+2];
        A[0] = 0;
        A[N+1] = 0;
        for(int i = 1; i <= N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();
        int sum = 0;
        for(int i = 0; i < N+1; i++){
            sum += Math.abs(A[i+1] - A[i]);
        }

        for(int i = 1; i <= N; i++){
            int change = Math.abs(A[i+1]-A[i-1])
                        - Math.abs(A[i] - A[i-1])
                        - Math.abs(A[i+1] - A[i]);
            System.out.println(sum + change);
        }
    }
}

Measured memory_bytes: 62676
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
int main() {

    int N;
    cin >> N;
    int ans = 0;
    
    for(int i = 1; i <= N; i += 2){
        int seven = 0;
        
        for(int j = 1; j <= 200; j++){
            if(i % j == 0) seven++;
        }
        if(seven == 8) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,ans=0;//数字
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++){
        string c=to_string(i); 
        if(c[0]==c[4]&&c[1]==c[3]) 
            ans++;         
        if(i==100000)
            exit(0);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a;
	int b;
	for (a=1;a<=9;a++)
	{
		for(b=1;b<=9;b++)
		{
			cout << a << "x" << b << "=" << a*b << endl;
		}
	}	
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
using namespace std;
const int nmax=112;


int n,k,res;

int main()
{
    scanf("%d %d",&n,&k);
    res=(n+1)/2;
    if(res>=k)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }

    return 0;
}


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

class A
{
	static void Main()
	{
		var a = Console.ReadLine().OrderBy(c => c).ToArray();
		Console.WriteLine(a[0] == a[1] && a[2] == a[3] && a[0] != a[2] ? "Yes" : "No");
	}
}


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

using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int b1[3][10],b2[3][10],b3[3][10],b4[3][10];
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            b1[i][j]=b2[i][j]=b3[i][j]=b4[i][j]=0;
        }
    }
    
    int n; cin>>n;
    while(n--){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        f--; 
        r--;
        switch(b){
            case 1: b1[f][r] += v; break;
            case 2: b2[f][r] += v; break;
            case 3: b3[f][r] += v; break;
            case 4: b4[f][r] += v; break;
        }
    }
    
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            printf(" %d",b1[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            printf(" %d",b2[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            printf(" %d",b3[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){
            printf(" %d",b4[i][j]);
        }
        printf("\n");
    }
    

    return 0;
    
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    
    ll genkin = 1000%a[0];
    ll kabu = 1000/a[0];
    for(ll i = 0; i < n-1; i++) {
        if (a[i] > a[i+1]) {
            genkin += kabu*a[i];
            kabu = 0;
        }
        if (a[i] < a[i+1]) {
            kabu += genkin/a[i];
            genkin %= a[i];
        }
    }

    ll res = genkin+kabu*a[n-1];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3576
#!/usr/bin/env python3
N, M = map(int, input().split())
S = [[*map(int, input().split())] for _ in range(N)]
C = [[*map(int, input().split())] for _ in range(M)]
for a, b in S:
    mi = 10**9
    ans = 51
    for i in range(M):
        c, d = C[i]
        if abs(a - c) + abs(b - d) < mi:
            ans = i + 1
            mi = abs(a - c) + abs(b - d)
    print(ans)


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

using namespace std;

int n, m, g, d;
int position[12];
bool lotsData[32][12];

void initPosition() {
	for (int i = 0; i < n; ++i) {
		position[i] = i;
	}
}

void judgePosition()
{
	for (int i = 0; i < d; ++i)
	{
		for (int j = 0; j < n - 1; ++j)
		{
			if (lotsData[i][j])
				swap(position[j], position[j + 1]);
		}
	}
}

int main()
{
	int row, col;
	char buf[16];
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (scanf("%d", &n), n) {
		initPosition();
		scanf("%d%d%d", &m, &g, &d);
		--m;
		--g;
		
		for (int i = 0; i < d; ++i)
		{
			scanf("%s", buf);
			for (int j = 0; buf[j] != '\0'; ++j) {
				lotsData[i][j] = (buf[j] == '1');
			}
				
		}

		judgePosition();
		if (position[g] == m)
		{
			puts("0");
			continue;
		}

		bool flag = false;
		for (row = 0; row < d; row++)
		{
			for (col = 0; col < n - 1; col++)
			{
				if(lotsData[row][col]
					|| (col != 0 && lotsData[row][col - 1])
					|| (col != n - 2 && lotsData[row][col + 1])) {
					continue;
				}
		
				lotsData[row][col] = true;
				initPosition();

				judgePosition();
				if (position[g] == m)
				{
					flag = true;
					break;
				}
				lotsData[row][col] = false;
			}
			if (flag) {
				break;
			}	
		}
		if (flag) {
			printf("%d %d\n", row + 1, col + 1);
			//cout << row + 1 << ends << col + 1 << endl;
		}
		else {
			puts("1");
		}
	}

	return 0;
}


Measured memory_bytes: 3116
N, T = map(int, input().split())
ans = 10 ** 4
root = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    if root[i][1] > T:
        continue
    else:
        ans = min(ans, root[i][0])

print("TLE" if ans == 10 ** 4 else ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
 
    vvl G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
 
    vl c(n);
    rep(i, n) {
        cin >> c[i];
    }
    sort(all(c));

    vl deg(n);
    queue<ll> Q;
    rep(i, n) {
        deg[i] = G[i].size();
        if(deg[i] == 1) {
            Q.push(i);
        }
    } 
 
    vl d(n);    
    rep(i, n) { 
        ll v = Q.front();
        Q.pop();
        d[v] = c[i];
        for(auto u : G[v]) {
            deg[u]--;
            if(deg[u] == 1) {
                Q.push(u);
            }
        }
    }

    ll M = 0;
    rep(i, n-1) {
        M += c[i];
    }

    out(M);
    rep(i, n) {
        cout << d[i] << " ";
    }
 
    cout << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '+')
      ans++;
    else
      ans--;
  }

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


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    vector<pair<int,int> > pairs(N);
   for(int i=0;i<N;i++) pairs[i]=make_pair(A[i],i+1);
    sort(pairs.begin(),pairs.end());
    for(int i=0;i<N;i++){
        cout<<pairs[i].second<<" ";
    }
return 0;
}

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

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

  if (A == B) {
    cout << C;
  } else if (B == C) {
    cout << A;
  } else if (C == A) {
    cout << B;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include  <stdio.h>

int def(int a, int b) {
	if (a > b) return a - b;
	else return b - a;
}

int main(void) {
	int x, a, b;

	scanf("%d %d %d", &x, &a, &b);

	if (def(x, a) > def(x, b)) printf("B\n");
	else printf("A\n");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a, x, y;
    scanf("%d %d", &x, &y);
    if(y>x){
        a=y, y=x, x=a;
    }

    int z=x%y;
    
    while(z!=0){
        x=y, y=z, z=x%y;
    }
    printf("%d\n", y);
    return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double length = 2 * r * pi;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28124
#include <stdio.h>

int main(void) {
	int A, B, C, D;
	scanf("%d%d%d%d",&A, &B, &C, &D);
	if (A*B <= C * D) {
		printf("%d", C*D);
	}
	else {
		printf("%d", A*B);
	}
	return 0;

}

Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<u32> = read_as_vec();
    let (n, m) = (line[0], line[1]);

    let mut v: Vec<(u32, u32, u32, u32)> = Vec::new();
    for i in 0..m{
        v.push({let line: Vec<u32> = read_as_vec();
        (i, line[0], line[1], 0)});
    }
    v.sort_by_key(|t| t.2);
    let mut indices: Vec<u32> = vec![1;(n+1) as usize];

    for pair in &mut v{
        pair.3 = indices[pair.1 as usize];
        indices[pair.1 as usize] += 1;
    }
    v.sort_by_key(|t| t.0);

    for pair in &v{
        println!("{:06}{:06}", pair.1, pair.3);
    }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    double l; cin >> l;

    double ans = (l * l * l) / 27;

    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define ll long long
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
const ll mod=1e9+7;
#define maxn 300005
int main()
{
	string s;
	s.clear();
	cin>>s;
	if(s=="AAA"||s=="BBB")
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}

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

void Main()
{
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<long>> map(R, vector<long>(C));
    vector<vector<vector<long>>> sum(R, vector<vector<long>>(C, vector<long>(4, -1e15)));
    vector<int> r(K), c(K), v(K);
    for (int i = 0; i < K; i++)
    {
        cin >> r[i] >> c[i] >> v[i];
        r[i]--; c[i]--;
        map[r[i]][c[i]] = v[i];
    }
    sum[0][0][0] = 0;
    sum[0][0][1] = map[0][0];
    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 0; k <= 3; k++)
            {
                if(i > 0) {
                    sum[i][j][0] = max(sum[i-1][j][k], sum[i][j][0]);
                    sum[i][j][1] = max(sum[i-1][j][k] + map[i][j], sum[i][j][1]);
                }
                if(j > 0) {
                    sum[i][j][k] = max(sum[i][j-1][k], sum[i][j][k]);
                    if(k > 0) sum[i][j][k] = max(sum[i][j-1][k-1] + map[i][j], sum[i][j][k]);
                }
            }
        }
    }
    
    long ans = 0;
    for (int k = 0; k <= 3; k++)
    {
        ans = max(sum[R-1][C-1][k], ans);
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 708892
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	ss := make([]int, n)
	tt := make([]int, m)

	dp := make([][]int, n+1)

	for i := 0; i < n; i++ {
		dp[i] = make([]int, m+1)
		ss[i] = getNextInt(scanner)
	}
	dp[n] = make([]int, m+1)
	for i := 0; i < m; i++ {
		tt[i] = getNextInt(scanner)
	}
	dp[0][0] = 1
	for i := 0; i <= n; i++ {
		for ii := 0; ii <= m; ii++ {
			if i == 0 || ii == 0 {
				dp[i][ii] = 1
				continue
			}
			dp[i][ii] += dp[i][ii-1]
			dp[i][ii] += dp[i-1][ii]
			if ss[i-1] != tt[ii-1] {
				dp[i][ii] -= dp[i-1][ii-1]
				
			}
          dp[i][ii] = mint(dp[i][ii])

		}
	}
	fmt.Fprintln(writer, dp[n][m])

	writer.Flush()
}

func mint(a int) int {
	mod := a % 1000000007
	if mod < 0 {
		mod += 1000000007
	}
	return mod
}


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

using namespace std; 

const int maxn = 1e6; 
int n; 
char s[maxn + 5], t[maxn + 5]; 
int sum[maxn + 5]; 
int ans; 

int main() {
    scanf("%d %s %s", &n, s + 1, t + 1); 
    int p = n, k = 0, f = 0; 
    for (int i = n; i >= 1; i--) {
        f += sum[i + k]; 
        if (t[i] != s[p] or p > i) {
            while (p >= 1 && (p > i or s[p] != t[i])) p--; 
            if (p <= 0) {
                puts("-1");
                return 0; 
            }
            if (p == i) continue ; 
            k++, f++; 
            sum[i + k - 1] = 0; sum[p + k - 1]--; 
        }
        ans = max(ans, f); 
    }
    cout << ans << '\n'; 
    return 0; 
}

Measured memory_bytes: 5888
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N, K = map(int, input().split())
n = N*2
r = min(N, K+1)
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, n + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

ans = 0
for i in range(r):
    ans += cmb(N, i, mod) * cmb(N-1, i, mod)
if K == 1:
    ans -= 1
print(ans % mod)


Measured memory_bytes: 56712
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s = "aaaaaaaaaaaaa" ;
	for(int i=0;i<13;i++){
		if(i==4) s.at(i) = ' ' ;
		else{
			char c ; cin >> c ;
			s.at(i) = c ;
		}
	}
	cout << s << endl ;
}


Measured memory_bytes: 256
def main():
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    A = int(buflist[0])
    B = int(buflist[1])
    buf = input()
    buflist = buf.split()
    P = list(map(int, buflist))
    group_count = [0, 0, 0]
    for i, score in enumerate(P):
        if score <= A:
            group_count[0] += 1
        elif score <= B:
            group_count[1] += 1
        else:
            group_count[2] += 1
    print(min(group_count))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]
new = []
for i in range(n):
    sort = sorted(data[i])
    sorting = "".join(sort)
    new.append(sorting)
new.sort()
score = 0
s = 0
count  = 0
while s<n-1:
    daburi = 1
    for p in range(s,n-1):
        if new[p] == new[p+1]:
            daburi += 1
        else:
            break
    score += daburi*(daburi-1)//2
    count += daburi
    s = count
print(score)

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

n,d = map(int, input().split())
points = [list(map(int, input().split())) for i in range(n)]

points = [points[i][0]**2 + points[i][1]**2 for i in range(n)]

cnt = 0
for i in points:
    if i <= d**2:
        cnt += 1

print(cnt)

Measured memory_bytes: 112724
#include <iostream>

using namespace std;

int ans;
int sum;

void dfs(int i,int n,int s){
    if(n==0){
        if(sum==s){
            ans++;
        }
        return;
    }
    if(i==10)return;
    dfs(i+1,n,s);
    dfs(i+1,n-1,s+i);
}

int main(void){
    int n;
    while(cin>>n>>sum,n!=0||sum!=0){
        ans=0;
        dfs(0,n,0);
        cout<<ans<<endl;
    }
    return(0);
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"

using namespace std;

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

int main(){
    int i;
    //入力
    long n;
    cin>>n;
    long a,m,count=1;
    cin>>m;
    rep(i,n-1){
        cin>>a;
        if(m>=a){
            count++;
            m=a;
        }
    }
    //処理
    //出力
    cout<<count<<endl;
}

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

#define inf 1e18
#define mod 1000000007

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll T;cin >> T;while(T--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b;
	cin >> a >>b;
	cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3652
s = input()
back = ""
q = int(input())
rev = False
for i in range(q):
    inpt = input().split( )
    if len(inpt)>1:
        fi,ci = inpt[1],inpt[2]
        if not ((fi == "1") ^ rev):
            s += ci
        else:
            back += ci
    else:
        rev = not rev
back = back[::-1]
ans = back+s
if not rev:
    print(ans)
else:
    ans = ans[::-1]
    print(ans)


Measured memory_bytes: 4312
// {{{ by unolight
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}
// }}}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, qq;
    string s;
    cin >> n >> s >> qq;
    while ( qq-- ) {
        int k;
        cin >> k;
        long long l=0, c1=0, c2=0, res=0, ans=0;
        for ( int i=0; i<n; i++ ) {
            if ( s[i]=='D' ) c1++;
            if ( s[i]=='M' ) {
                res+=c1;
                c2++;
            }
            if ( s[i]=='C' ) {
                while ( l<i && l+k<=i ) {
                    if ( s[l]=='D' ) {
                        res-=c2;
                        c1--;
                    }
                    if ( s[l]=='M' ) {
                        c2--;
                    }
                    l++;
                }
                ans+=res;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 4244
l = r = 1
gets.to_i.times do
  a, b = gets.split.map(&:to_i)
  coef = 1
  if l > a
    coef = l / a + (l % a == 0 ? 0 : 1)
  end
  if r > b
    coef = [coef, r / b + (r % b == 0 ? 0 : 1)].max
  end
  l = a * coef
  r = b * coef
end
puts l + r


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462643383279502884493992780d
int main() {
    int a, b, h, m;
    double da, db;
    cin >>a >> b >> h >> m;
    da = (double)a;
    db = (double)b;
    double ta = ((double)h + (double)m / 60.0d)/ 12.0d * PI * 2.0d;
    double tb = ((double)m/60.0d)*PI * 2.0d;
    printf("%-.18lf",sqrt(da*da + db*db-2*da*db*cos(ta-tb)));
    return 0;
}


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

int n;
int A[10];
bool dfs(int a,int b,int i){
	if(i==9) return a<A[i] || b<A[i];
	if(a<=A[i] && !(b<=A[i])) return dfs(A[i],b,i+1);
	else if(b<=A[i]) return dfs(a,A[i],i+1);
	else return false;
}
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin >> A[j];
		}
		if(dfs(0,0,0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3012
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 998244353
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
   
    
    ll n,m;
    cin >> n >> m;
    map<ll,ll> ma;
    ll ac = 0,wa = 0;
    vector<pair<ll,string>> kk;
    for(ll i = 0; i < m; ++i)
    {
        ll x;
        string s;
        cin >> x >> s;
        kk.pb({x,s});
        if(s[0] == 'A')
          ma[x] = 1;
    }
    ac = ma.size();
    // map<ll,ll> mp;
    for(auto x : kk)
    {
        if(x.sec[0] == 'W' and ma.count(x.fi) >= 1)
        {
            wa++;
        }
        if(x.sec[0] == 'A')
        {
          ma.erase(x.fi);
        }

    }
    cout << ac << " " << wa;



    return 0;
    
}

Measured memory_bytes: 12784
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
import Data.Int (Int64)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] <- BS.words <$> BS.getLine
  let Just (a',_) = BS.readInteger a
      a'' = fromIntegral a' :: Int64
      b' = read @Double (BS.unpack b)
  print $ a'' * round (b' * 100) `quot` 100


Measured memory_bytes: 4112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int solve(int a, int b) {
    if(b == 1) return 0;
    int ans = 1;
    while(a*ans-(ans-1) < b) {
        ++ans;
    }
    return ans;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;
    cout << solve(a, b) << endl;
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110][100000] = {};
long long int cnt[110000] = {};

int main(){
    long long int N, K;
    cin >> N >> K;
    long long int sq;
    for(sq = 0; sq <= N + 100; sq++){
        if(sq * sq > N){
            sq -= 1;
            break;
        }
    }
    for(int i = 0; i < sq; i++){
        cnt[i] = 1;
    }
    for(int i = sq + 1; i < 2 * sq; i++){
        long long int num = 2 * sq - i;
        long long int n1 = N / num, n2 = N / (num + 1);
        cnt[i] = n1 - n2;
    }
    long long int R = N / sq, L = max(N / (sq + 1), sq);
    cnt[sq] = R - L;
    for(int i = 0; i <= 2 * sq; i++){
        DP[0][i] = 1;
    }
    for(int i = 1; i < K; i++){
        long long int S = 0;
        for(int j = 0; j < 2 * sq; j++){
            S += DP[i - 1][j] * cnt[j];
            S %= MOD;
            DP[i][2 * sq - j - 1] = S;
            //cout << i << " " << 2 * sq - j - 1 << " " << S << endl;
        }
    }
    long long int ans = 0;
    for(int i = 0; i < 2 * sq; i++){
        ans += DP[K - 1][i] * cnt[i];
        ans %= MOD;

        //cout << DP[K - 1][i] << " " << cnt[i] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79488
s=input()
a=int("".join(s[0:2]))
b=int("".join(s[2:4]))
ans=0
if b<13 and b!=00:
    ans+=1
if a<13 and a!=00:
    ans+=2
if ans==3:
    print("AMBIGUOUS")
elif ans==2:
    print("MMYY")
elif ans==1:
    print("YYMM")
else:
    print("NA")

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

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

int main(){
  int n,m;
  cin>>n>>m;
  int ans=0,x;
  REP(i,m){
    cin>>x;
    ans += (x>m);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <string>
using namespace std;
int main() {
  string line;
  while (getline(cin, line)) {
    while (line.find("the") == string::npos && line.find("this") == string::npos
      && line.find("that") == string::npos)
      for (auto& c : line)
        if (c == 'a') c = 'z';
        else if (c != '.' && c != ' ') c -= 1;
    cout << line << endl;
  }
}

Measured memory_bytes: 1180
#include<cstdio>
#include<ctype.h>
#include<string.h>
#define ll long long
int n, tot, a[26];
ll ans=1;
char s[200005];
int main() {
	n=fread(s, 1, 200000, stdin);
	while(!islower(s[n-1])) --n;
	for(register int i=0; i<n; ++i) ans+=tot++-a[s[i]-'a']++;
	return printf("%lld", ans), 0;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

var slice []int
var dp []float64

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, k := nextInt(), nextInt()
	slice = make([]int, n+k)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	dp = make([]float64, 1000000)
	for i := 0; i < len(dp); i++ {
		dp[i] = math.Inf(1)
	}

	dp[0] = 0.0
	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			chmin(&dp[i+j], dp[i]+float64(abs(slice[i]-slice[i+j])))
		}
	}

	fmt.Println(int(dp[n-1]))

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}

	return a
}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 9984
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)

from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
G=[[]for i in range(n)]
for i in range(n-1):
  u,v=map(int,input().split())
  G[u-1].append(v-1)
  G[v-1].append(u-1)

lis=[a[0]]
stack=[]
ans=[1]*n
def dfs(cur,p=-1):
  for nx in G[cur]:
    if nx==p:continue
    idx=bisect_left(lis,a[nx])
    if idx==len(lis):
      stack.append((idx,-1))
      lis.append(a[nx])
    else:
      stack.append((idx,lis[idx]))
      lis[idx]=a[nx]
    
    ans[nx]=len(lis)

    dfs(nx,cur)

    idx,v=stack.pop()
    if v<0:
      lis.pop()
    else:
      lis[idx]=v

dfs(0)
print(*ans,sep="\n")

Measured memory_bytes: 282740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll N, M, K, count=0, conb;

	cin >> N >> M >> K;
	vector<ll> a(N), b(M), numa(N+1), numb(M+1);

	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	for (int i = 0; i < M; i++){
		cin >> b[i];
	}

	numa[0] = 0;
	numb[0] = 0;
	for (int i = 0; i < N; i++){
		numa[i + 1] = numa[i] + a[i];
	}
	for (int i = 0; i < M; i++){
		numb[i + 1] = numb[i] + b[i];
	}

	conb = M;
	for (int i = 0; i <= N; i++){
		if (numa[i] > K) break;
		for (int j = conb; j >=0; j--){
			if (numb[j] <= (K-numa[i])){
				conb = j;
				j = -1;
			}
			else if (j == 0){
				conb = 0;
			}
		}
		if (count < (i + conb))
			count = i + conb;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void solve(){
    int n;
    cin>>n;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                int g = __gcd(i, j);
                sum+=__gcd(g, k);
            }
        }
    }   
    cout<<sum;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

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

    int n, a;
    double ans = 0.0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        ans += 1.0 / a;
    }
    ans = 1.0 / ans;
    cout << ans;

    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = (int)s.size() + 1;
  vector <int> mx(n);
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] == '<') mx[i + 1] = max(mx[i + 1], mx[i] + 1);
  }
  for (int i = n - 2; i >= 0; --i) {
    if (s[i] == '>') mx[i] = max(mx[i], mx[i + 1] + 1);
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) ans += mx[i];
  cout << ans << '\n';
}



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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){

    REP(i,0,N){
        lli minL = INF;
        lli minI;
        REP(j,0,M){
            lli diff = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(diff<minL){
                minI = j;
                minL = diff;
            }
        }
        cout<<minI+1<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> c(M);
    std::vector<long long> d(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    func(N, M, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
 
A, B = [int(x) for x in input().split(" ")]
 
print(lcm(A, B))

Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <numeric>
#include <cctype>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define pb push_back
#define mp make_pair

typedef unsigned uint;
typedef long long ll;
typedef unsigned long ulong;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

typedef double Real;
const Real eps = 1e-9;
const Real inf = 1<<30;

int main(){
    int w, h;
    while (cin >> h >> w, w | h){
        vs G(h);
        vvi dp(h,vi(w));
        rep(y, h){ cin >> G[y]; }
        rep(y,h)rep(x,w){
            if(G[y][x] == '.') {
                if(x!=0) dp[y][x] = dp[y][x-1]+1;
                else dp[y][x] = 1;
            } else {
                dp[y][x] = 0;
            }
        }

        int res = 0;
        rep(x,w)rep(y,h){
            int tw = 0;
            int tmin = inf;
            loop(cy,y,h){
                tw++;
                tmin = min(tmin, dp[cy][x]);
                res = max(res, tw * tmin);
            }
        }
        cout << res << endl;
    }
}

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

using namespace std;

int main()
{
    int N, T;
    cin >> N >> T;
    
    vector<int> Vt;
    for(int ii = 0; ii < N; ++ii){
        int in;
        cin >> in;
        Vt.push_back(in);
    }
    
    int X = 0;
    for(int ii = 0; ii < N; ++ii){
        X += T;
        if( ii > 0 && Vt[ii] < Vt[ii-1] + T){
            X -= Vt[ii-1]+T - Vt[ii];
        }
    }
    
    cout << X << endl;
    
    return 0;
}

Measured memory_bytes: 1400