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

int main() {
    int N;
    int D;
    int count = 0;
    cin >> N;
    cin >> D;
    vector<vector<int>> data(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
     cin >> data.at(i).at(j);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++){
      float distance = 0;
      for (int k = 0; k < D; k++)
      {
        distance += (data.at(i).at(k) - data.at(j).at(k))*(data.at(i).at(k) - data.at(j).at(k));
      }
      if(sqrt(distance) == floor(sqrt(distance)))
      count++;
    }
  }

    
    

    cout << count << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

n = ni()

graph = [[] for _ in range(n)]

for _ in range(n-1):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c, b))
    graph[b].append((c, a))

q,k = li()
k -= 1

query = []
for _ in range(q):
    x, y = li_()
    query.append((x, y))
    
dist = dijkstra(graph, n, k)
    
for qx, qy in query:
    print(dist[qx] + dist[qy])

Measured memory_bytes: 61108
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Measured memory_bytes: 27112
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var input: [Int] = []
for _ in 0..<5 {
    input.append(readInt()!)
}
var sum = 0
var overTime: [Int] = []
for i in input {
    let time = (i + 9) / 10 * 10
    sum += time
    overTime.append(time - i)
}
print(sum - overTime.max()!)


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

int main(){
  int n;
  cin >> n;
  vector <int>vec(n);
  for(int i = 0; i < n-1; i++){
    int a;
    cin >> a;
    vec[a-1] ++;
  }
  for(int i = 0; i< n;i++){
    cout << vec[i] << endl;
  }
    
  return 0;
}

Measured memory_bytes: 4048
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	vector <int> x;
	vector <int> y;
	vector <int> inf;
	double dist = 0;
	double doub = 0;
	int num = 0;
	int size = 0;

	scanf("%d", &size);
	for (int i = 0; i < size; i++) {
		scanf("%d", &num);
		x.push_back(num);
	}
	for (int i = 0; i < size; i++) {
		scanf("%d", &num);
		y.push_back(num);
	}
	for (int i = 0; i < size; i++) {
		num = abs(x[i]-y[i]);
		inf.push_back(num);
		dist += num;
	}
	printf("%f\n", dist);
	dist = 0;
	for (int p = 2; p <= 3; p++) {
		doub = 0;
		for (int i = 0; i < size; i++) {
			doub += pow(abs(x[i] - y[i]), p);
		}
		dist = pow(doub, 1.0/p);
		printf("%.6f\n", dist);
	}
	num = inf[0];
	for (int i = 1; i < size; i++) {
		if (num < inf[i]) {
			num = inf[i];
		}
	}
	printf("%d", num);
}


Measured memory_bytes: 2976
//
// Noszály Áron 9a Debreceni Fazekas Mihály Gimnázium
//
#include<bits/stdc++.h>
#include<cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

#define all(s) (s).begin(),(s).end()
#define pb push_back
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define INF std::numeric_limits<int>::max()
#define MINF std::numeric_limits<int>::min()
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define xx first
#define yy second
#define sz(x) (int)(x).size()

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

const long double PI = acos(-1);

int d1[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int d2[8][2]={{1,0},{0,1},{0,-1},{-1,0},{1,1},{-1,1},{1,-1},{-1,-1}};

int main()
{
	IO;
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	
	int ans=INF;
	for(int e=-100;e<=100;++e)
	{
		int cost=0;
		for(int i=0;i<n;++i)
		{
			cost+=(a[i]-e)*(a[i]-e);
		}
		ans=min(ans,cost);
	}
	cout<<ans<<"\n";
	return 0;
	
}



Measured memory_bytes: 256
import sys

def to_jpy(x, u):
    x = float(x)
    if u == 'BTC':
        x *= 3.8 * 10 ** 5
    return x

n, *xu = sys.stdin.read().split()
xu = zip(*[iter(xu)] * 2)

def main():
    res = 0
    for x, u in xu:
        res += to_jpy(x, u)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

using namespace std;


int main() {
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int sum = accumulate(a.begin(),a.end(),0);
    if(sum >= h) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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

using namespace std;

const int INF = INT_MAX;

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

int *dat;
int R, C, W;

void update(int r, int c, int x){
	r += R - 1;
	c += C - 1;
	dat[r * W + c] = x;
	int cc = c;
	while(cc > 0){
		cc = (cc - 1) / 2;
		dat[r * W + cc] = min(dat[r * W + cc * 2 + 1], dat[r * W + cc * 2 + 2]);
	} // end while

	while(r > 0){
		r = (r - 1) / 2;
		cc = c;
		while(true){
			dat[r * W + cc] = min(dat[(r * 2 + 1) * W + cc], dat[(r * 2 + 2) * W + cc]);
			if (cc == 0) break;
			cc = (cc - 1) / 2;
		} // end while
	} // end while
}

int query(int r1, int c1, int r2, int c2, int r, int rl, int rr, int c, int cl, int cr){
	if (rr <= r1 || r2 <= rl || cr <= c1 || c2 <= cl) return INF;
	if (r1 <= rl && rr <= r2 && c1 <= cl && cr <= c2) return dat[r * W + c];
	if (r1 <= rl && rr <= r2){
		int v1 = query(r1, c1, r2, c2, r, rl, rr, c * 2 + 1, cl, (cl + cr) / 2);
		int v2 = query(r1, c1, r2, c2, r, rl, rr, c * 2 + 2, (cl + cr) / 2, cr);
		return min(v1, v2);
	}else{
		int v1 = query(r1, c1, r2, c2, r * 2 + 1, rl, (rl + rr) / 2, c, cl, cr);
		int v2 = query(r1, c1, r2, c2, r * 2 + 2, (rl + rr) / 2, rr, c, cl, cr);
		return min(v1, v2);
	} // end if
}

int main()
{
	int RR, CC, Q;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while(cin >> RR >> CC >> Q){
		R = 1, C = 1;
		while(R < RR) R *= 2;
		while(C < CC) C *= 2;
		W = C * 2 - 1;

		dat = new int[(R * 2 - 1)*(C * 2 - 1)];

		rep (i, RR){
			rep (j, CC){
				int x; cin >> x;
				update(i, j, x);
			} // end rep
		} // end rep
 		rep (i, Q){
			int r1, c1, r2, c2;
			cin >> r1 >> c1 >> r2 >> c2;
			int ans = query(r1, c1, r2 + 1, c2 + 1, 0, 0, R, 0, 0, C);
			cout << ans << endl;
		} // end rep

		delete[] dat;
		dat = 0;

	} // end while

	return 0;
}

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

int main() {
    string S;
    cin >> S;
    if(S.find("A") != string::npos && S.find("B") != string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

//厚さとパティの枚数のメモ化
ll t[51], p[51];

//レベルnの厚さ
ll thickness(int n) {
    if (t[n])return t[n];
    return t[n] = thickness(n - 1) * 2 + 3;
}

//レベルnのパティの枚数
ll patty(int n) {
    if (p[n])return p[n];
    return p[n] = patty(n - 1) * 2 + 1;
}

//レベルnの下からx層にあるパティの枚数
ll ans(int n, ll x) {
    if (n == 0) {
        if (x <= 0)return 0LL;
        return 1LL;
    }

    if (x <= 1 + thickness(n - 1)) {
        return ans(n - 1, x - 1);
    }
    if (x == 2 + thickness(n - 1)) {
        return patty(n - 1) + 1;
    }
    if (x <= 2 + thickness(n - 1) * 2) {
        return patty(n - 1) + 1 + ans(n - 1, x - 2 - thickness(n - 1));
    }
    if (x == 3 + thickness(n - 1) * 2) {
        return patty(n - 1) * 2 + 1;
    }
}

int main() {
    init();

    t[0] = 1, p[0] = 1;
    int n; ll x; cin >> n >> x;
    cout << ans(n, x) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
class Disjointset {
public:
  vector<int> rank,p;
  Disjointset(){}
  Disjointset(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
  void link(int x,int y){
    if(rank[x]>rank[y]) {
      p[y]=x;
    }else {
      p[x]=y;
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  int findSet(int x){
    if(x!=p[x]) p[x]=findSet(p[x]);
    return p[x];
  }
  
};

int main(){
  int n,q,i;
  cin >> n >> q;
  Disjointset ds = Disjointset(n);
  for(i=0;i<q;i++){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==1) cout << (ds.same(x,y) ? 1:0) << endl;
    else ds.unite(x,y);
  }
}

Measured memory_bytes: 1276
#include<iostream>
#include<stdio.h>
#include<math.h>

int main(void){

	double r, S, l;

	scanf("%lf", &r);

	S = r*r*M_PI;
	l = 2 * r*M_PI;
	
	printf("%lf %lf\n", S, l);

	return 0;
}

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

//typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		40010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//




//
int main(){
	int N;cin>>N;

	cout << (ll)N*(N-1)/2 << endl;

	return 0;
}




Measured memory_bytes: 256
n = int(input())
start_end = [[0] * 10 for _ in range(10)]
for i in range(1,n+1):
    start = int(str(i)[0])
    end = int(str(i)[-1])
    start_end[start][end] += 1
ans = 0
for start in range(10):
    for end in range(start,10):
        if start == end:
            ans += start_end[start][end]**2
        else:
            ans += start_end[start][end] * start_end[end][start] * 2
print(ans)


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

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

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

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

int main(){
    int n, m; cin>>n>>m;
    bool is_prime=true;
    for(int i=2; i<=sqrt(m); i++){
        if(m%i == 0) is_prime=false;
    }

    if(is_prime) cout << 1 << endl;
    else{
        for(int i=n; i<=m; i++){
            if(m%i == 0){
                cout << m/i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int main() {
    int n;
    int* R;
    int i;
    int min;
    int diff;
    scanf("%d", &n);
    R = (int*)malloc(sizeof(int)*n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &R[i]);
    }
    min = R[0];
    diff = R[1] - R[0];
    for ( i = 1; i < n; i++ ) {
        if ( R[i] - min > diff ) diff = R[i] - min;
        if ( min > R[i] ) min = R[i];
    }
    
    printf("%d\n", diff);
    
    free(R);
    return 0;
}

Measured memory_bytes: 1152
import math
t1,t2 = map(int, input().split())
c1,c2 = map(int, input().split())
d1,d2 = map(int, input().split())

x = [(c1*t1, c2*t2),(d1*t1, d2*t2)]

x.sort(reverse=True)

if x[0][0]+x[0][1] == x[1][0]+x[1][1]:
    print("infinity")
elif x[0][0]+x[0][1] > x[1][0]+x[1][1]:
    print(0)
else:
    n = (x[0][0]-x[1][0]+0.0)/(x[1][0]+x[1][1]-x[0][0]-x[0][1])
    m = math.ceil(n)
    if math.floor(n) == m:
        print(2*m)
    else:
        print(2*m-1)

Measured memory_bytes: 38416
#include <stdio.h>

int pow10(int n){
  int ret=1,i;
  for(i=0;i<n;i++)
    ret*=10;
  return ret;
}

int solve(int s){
  int n,ret=0,i;
  n=s*s/100;
  for(i=0;i<4;i++){
    ret+=(n%10)*pow10(i);
    n/=10;
  }
  return ret;
}

int main(void){
  int d,i,j,s;
  scanf("%d",&d);
  i=1;
  while(d--){
    scanf("%d",&s);
    printf("Case %d:\n",i);
    for(j=0;j<10;j++){
      s=solve(s);
      printf("%d\n",s);
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
using namespace std;
int main() {
	int N = 0;
	scanf("%d", &N);
	vector<long>v (N+1,0);

	/*
	for (int x = 1; x < 100; x++) {
		for (int y = 1; y < 100; y++) {
			for (int z = 1; z < 100; z++) {
				if ((x * x + y * y + z * z + x * y + x * z + z * y) != 0 && ((x * x + y * y + z * z + x * y + x * z + z * y) < v.size())) {
					v[(x * x + y * y + z * z + x * y + x * z + z * y) - 1]++;
				}
				
			}
			
		}
		
	}*/

	for (int i = 1; i < 100; i++) {
		for (int w = 1; w < 100; w++) {
			for (int y = 1; y < 100; y++) {
				if (((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w)) <= v.size()) {
					v[((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w))]++;

				}

			}

		}
	}
	
	for (int i = 1; i <= N; i++) {
		string str = to_string(v[i]);
		const char* l = str.c_str();
		printf(l);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h;
        int m;
        int s;
        h = S/3600;
        m = S%3600/60;
        s = S%3600%60;
        System.out.println(h + (":") + m + (":") + s);
	}

}


Measured memory_bytes: 26124
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c;
int l[10];
int s[10];
int ans;
void dfs(int x) {
	if(x==n) {
		int x1=0,x2=0,x3=0,s1=0,s2=0,s3=0;
		for(int i=0; i<n; i++) {
			if(s[i] == 1) {
				x1++; s1+=l[i];
			} else if(s[i]==2) {
				x2++; s2+=l[i];
			} else if(s[i]==3) {
				x3++; s3+=l[i];
			}
		}
		if(x1*x2*x3==0) return;
		int cst = (x1+x2+x3-3)*10 + abs(s1-a) + abs(s2-b) + abs(s3-c);
		if(cst<ans) ans=cst;
	} else {
		for(int i=0; i<=3; i++) {
			s[x] = i;
			dfs(x+1);
		}
	}
}
int main() {
	cin >> n >> a >> b >> c;
	ans = 1e9;
	for(int i=0; i<n; i++) scanf("%d",&l[i]);
	dfs(0);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
def insertionSort(A, n, g, count):
    Acopy = A.copy()
    for i in range(g, n):
        v = Acopy[i]
        j = i - g
        while (j >= 0) and (Acopy[j] > v):
            Acopy[j + g] = Acopy[j]
            j = j - g
            count += 1
        Acopy[j + g] = v
    return Acopy, count

def shellSort(A, n):
    #Gを作成
    G = [1]
    h = 4
    while h < n:
        G.append(h)
        h = 3 * h + 1
    Gr = G.copy()
    Gr.reverse()
    count = 0
    #Gの各要素を使ってSort
    for g in Gr:
        A, count = insertionSort(A, n, g, count)
    return A, Gr, count

n = int(input())
q = 0
A = []
while q < n:
    A.append(int(input()))
    q += 1
A, G, count = shellSort(A, n)
ans = str(len(G)) + '\n' + ' '.join(map(str, G)) + '\n' + str(count) + '\n'
ans += '\n'.join(map(str, A))
print(ans)


Measured memory_bytes: 132220
<?php
$line          = fgets(STDIN);
$numbers       = explode(' ', $line);
$number_string = (string)$numbers[0] . (string)$numbers[1] . (string)$numbers[2];
$number        = (int)$number_string;

if ($number % 4 === 0) {
    print 'YES';
} else {
    print 'NO';
}


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

int main() {
  int D, N;
  cin >> D >> N;

  if (D == 0) {
    if (N == 100) cout << N + 1 << endl;
    else cout << N << endl;
  } else if (D == 1) {
    if (N == 100) cout << (N + 1) * 100 << endl;
    else cout << N * 100;
  } else {
    if (N == 100) cout << (N + 1) * 10000 << endl;
    else cout << N * 10000 << endl;
  }
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

if C % B == 0:
    Takahashi_attacks = C // B
else:
    Takahashi_attacks = C // B + 1

if A % D == 0:
    Aoki_attacks = A // D
else:
    Aoki_attacks = A // D + 1



if Takahashi_attacks <= Aoki_attacks:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int a[1003], d[1003];
vector<int> g[1003];

void dfs(int x) {
    int e[2][5003] = {1}, c = 0, b = 0;
    for (int i : g[x]) {
        b = !b;
        dfs(i);
        c += a[i] + d[i];
        for (int j = 0; j <= a[x]; j++) e[b][j] = 0;
        for (int j = a[x]; j >= 0; j--) {
            if (j >= a[i]) e[b][j] |= e[!b][j - a[i]];
            if (j >= d[i]) e[b][j] |= e[!b][j - d[i]];
        }
    }
    d[x] = -1;
    for (int i = a[x]; i >= 0; i--) if (e[b][i]) {
        d[x] = c - i;
        break;
    }
    if (d[x] == -1) {
        cout << "IMPOSSIBLE";
        exit(0);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, u;
    cin >> n;
    for (int i = 2; i <= n; i++) cin >> u, g[u].push_back(i);
    for (int i = 1; i <= n; i++) cin >> a[i];
    dfs(1);
    //for (int i = 1; i <= n; i++) cout << d[i] << ' ';
    cout << "POSSIBLE";
}


Measured memory_bytes: 17024
import java.util.Arrays;
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long k = sc.nextLong();

		int[] a = new int[n];
		int[] f = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}
		
		for(int i = 0;i < n;i++){
			f[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		Arrays.sort(f);
		for(int i = 0;i < n/2;i++){
			int tmp = f[i];
			f[i] = f[n-i-1];
			f[n-i-1] = tmp;
		}
		if(isvail(0, n, a, f, k)){
			System.out.println(0);
			return;
		}
		
		long left = 0;
		long right = Long.MAX_VALUE;

		while(right - left > 1){
			//System.out.println(left + " l");
			long mid = (left + right)/2;
			if(!isvail(mid, n, a, f, k)){
				left = mid;
			}else{
				right = mid;
			}
			
		}
		System.out.println(right);




	}
	
	static boolean isvail(long num,int n,int[] a,int[] food,long k){
		long sum = 0;
		for(int i = 0;i < n;i++){
			long dif = num/food[i];
			sum += Math.max(0, a[i]-dif);
		}
		return sum <= k;
	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 101204
#include<iostream>

using namespace std;
int H, W;
int x = 0, y = 0;
int rog[100][100];
bool check(){
	if (rog[x][y] == 0){
		cout << "LOOP" << endl;
		return true;
	}
	
		return false;
	
}

int main(){
	char ma[100][100];

	while (cin >> H >> W,W+H){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> ma[j][i];
				rog[j][i] = 1;
			}
		}

		x = 0, y = 0;
		while (1){
			if (ma[x][y] == '>'){
				x++;
				if (check())break; 
			}
			else if(ma[x][y]=='v'){
				y++;
				if (check()) break; 
			}
			else if (ma[x][y] == '<'){
				x--;
				if (check()) break; 
			}
			else if (ma[x][y] == '^'){
				y--;
				if (check())break; 
			}
			else {
				cout << x << " " << y << endl;
				break;
			}
			
			rog[x][y] = 0;

		}
	}
}

Measured memory_bytes: 1212
import Data.List
import Text.Printf
nextPyramid (x,y) = if y+1<101 then (x,y+1) else if x+1<101 then (x+1,0) else (-1,-1)
listToTuple [x,y,z] = (x,y,z)

check::(Integer,Integer)->[(Integer,Integer,Integer)]->Integer->Integer
check (x,y) (d:ds) h
    | h==0 = check (x,y) ds (abs (a-x) + abs (b-y) + c)
    | c==tmp = if ds==[] then h else check (x,y) ds h
    | otherwise = -1
    where
        (a,b,c) = d
        tmp = max (h - abs (a-x) - abs (b-y)) 0

solve (-1,-1) tbl = (-1,-1,-1)
solve (x,y) tbl
    | ans == (0-1) = solve (nextPyramid (x,y)) tbl
    | otherwise = (x,y,ans)
    where
        ans = check (x,y) tbl 0

main::IO()
main=do
    getLine
    tbl <- map (listToTuple.map read.words) . lines <$> getContents :: IO [(Integer,Integer,Integer)]
    let (x,y,h) = solve (0,0) (sortBy (\(a0,a1,a2) (b0,b1,b2) -> compare b2 a2) tbl)
    printf "%d %d %d\n" x y h

Measured memory_bytes: 1020
n = int(input())
s = input().split()
h = []
for i in range(n):
    h.append(int(s[i]))
dp = n*[0]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[n-1])


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()) {
    if (ans == 0 && s[i] == 'C') ans++;
    if (ans == 1 && s[i] == 'F') yes();
  }
  no();
}


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

int main(){
  string str;
  cin >> str;
  
  int n = str.size();
  
  if  ( n<1 ) {
    cout << "error" << endl;
  }
  
  if ( str.at(n-1) == 's' ) {
    cout << str << "es" << endl;
  }
  
  else {
    cout << str << 's' << endl;
  }
}


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, h;
vector<string> hint;
vector<bitset<10> > digit;
bitset<10> used;
string ret;

void solve(string& s, int i, int& num, vector<int> hit0, vector<int> blow0)
{
    if(i == n){
        ret = s;
        ++ num;
        return;
    }

    for(int j=0; j<10; ++j){
        if(used[j])
            continue;
        used[j] = true;
        s[i] = j + '0';

        vector<int> hit = hit0;
        vector<int> blow = blow0;
        bool ng = false;
        for(int k=0; k<h; ++k){
            if(s[i] == hint[k][i])
                -- hit[k];
            else if(digit[k][s[i]-'0'])
                -- blow[k];
            if(hit[k] < 0 || blow[k] < 0 || hit[k]+blow[k] >= n-i){
                ng = true;
                break;
            }
        }

        if(!ng)
            solve(s, i+1, num, hit, blow);

        used[j] = false;
        if(num == 2)
            break;
    }
}

int main()
{
    for(;;){
        cin >> n >> h;
        if(n == 0)
            return 0;

        hint.resize(h);
        digit.assign(h, 0);
        vector<int> hit(h), blow(h);
        for(int i=0; i<h; ++i){
            cin >> hint[i] >> hit[i] >> blow[i];
            for(int j=0; j<n; ++j)
                digit[i][hint[i][j] - '0'] = true;
        }

        string s(n, ' ');
        int num = 0;
        solve(s, 0, num, hit, blow);
        if(num == 1)
            cout << ret << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 932
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		long ans = 0;
		long now = a[0];
		for(int i = 1; i < n; i++) {
			if(now > a[i]) {
				ans+=(now-a[i]);
			}else {
				now = a[i];
			}
		}
		
		System.out.println(ans);
	}
	
}



Measured memory_bytes: 49708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int sum[3][2005][2005],lab[3][2005][2005];
int getsum(int x1,int y1,int x2,int y2,int lab)
{
	return sum[lab][x2][y2]-sum[lab][x1-1][y2]-sum[lab][x2][y1-1]+sum[lab][x1-1][y1-1];
}
char str[1000005];
int main()
{
	int n,m,q,i,j,a,b,c,d;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;i++)
	{
		scanf("%s",str);
		for(j=0;j<m;j++)
		{
			if(str[j]=='1')
				lab[0][i][j+1]=1;
			else
				lab[0][i][j+1]=0;
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			sum[0][i][j]=sum[0][i-1][j]+sum[0][i][j-1]+lab[0][i][j]-sum[0][i-1][j-1];
		}
	}
	for(i=1;i<=n;i++)
		for(j=1;j<m;j++)
		{
			if(lab[0][i][j]&&lab[0][i][j+1])
				lab[1][i][j]=1;
			else
				lab[1][i][j]=0;
		}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<m;j++)
		{
			sum[1][i][j]=sum[1][i-1][j]+sum[1][i][j-1]+lab[1][i][j]-sum[1][i-1][j-1];
		}
	}
	for(i=1;i<n;i++)
		for(j=1;j<=m;j++)
		{
			if(lab[0][i][j]&&lab[0][i+1][j])
				lab[2][i][j]=1;
			else
				lab[2][i][j]=0;
		}
	for(i=1;i<n;i++)
	{
		for(j=1;j<=m;j++)
		{
			sum[2][i][j]=sum[2][i-1][j]+sum[2][i][j-1]+lab[2][i][j]-sum[2][i-1][j-1];
		}
	}
	for(i=1;i<=q;i++)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		printf("%d\n",getsum(a,b,c,d,0)-getsum(a,b,c,d-1,1)-getsum(a,b,c-1,d,2));
	}
	return 0;
}


Measured memory_bytes: 96000
#include<stdio.h>

int main(void) 
{
  int n,m,a[1000];
  int i,j,sum,max;

	while(scanf("%d %d",&n,&m))
   {	
    if(n==0&&m==0)
	break;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	max =0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			sum=a[i]+a[j];
			if(sum>max&&sum<=m)
			max = sum;
		}
	}
	if(max==0)
	printf("NONE\n");
	else
	printf("%d\n",max);
   }
	return 0;
}


Measured memory_bytes: 2732
"""
    参加: N 人
    

    input:
        - S: S[i] == 'a' -> 国内, b -> 海外, c -> Neither
    output: 予選通過/No Yes/No
"""

N, A, B = map(int, input().split())
S = input()

passed_cnt = 0
overseas_cnt = 0
for c in S:
    if c == 'a': # 国内学生
        if passed_cnt < A + B:
            print('Yes')
            passed_cnt += 1
        else:
            print('No')
    elif c == 'b': # 海外学生
        if passed_cnt < A + B and overseas_cnt < B:
            print('Yes')
            passed_cnt += 1
        else:
            print('No')
        overseas_cnt += 1
    else: # 学生でない
        print('No')



Measured memory_bytes: 4016
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];

int main()
{
	int n; 
	while(1) {
		cin >> n;
		if (!n) break;
		int minx = inf, maxx = 0, sum = 0;
		rep(i,0,n) {
			int t;
			cin >> t;
			minx = min(minx, t);
			maxx = max(maxx, t);
			sum += t;
		}
		sum -= minx + maxx;
		int ans = floor((double)sum / (n-2));
		cout << ans << endl;
	}

 	return 0;
}

Measured memory_bytes: 3064
#abc129 c
import math
import itertools
n=int(input())
zahyo=[]
for i in range(n):
    line=list(map(int,input().split()))
    zahyo.append(line)
num=[i for i in range(n)]
patarn=list(itertools.permutations(num))
#print(patarn)

def siwu(x,keta):
    x=x*10**keta
    if (x*10)%10>=5:
        x+=1
    x=int(x)
    x/=10**keta
    return x


def kyori(xy1,xy2):
    x1,y1=xy1
    x2,y2=xy2
    s=math.sqrt((x1-x2)**2+(y1-y2)**2)
    return s
ans=0
for i in patarn:
    s=0
    for j in range(n-1):
        s+=kyori(zahyo[i[j]],zahyo[i[j+1]])
    ans+=s
ans/=len(patarn)
#ans=siwu(ans,6)
print(ans)

Measured memory_bytes: 8052
package main

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

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// a := make([]int, n)
	// A := strings.Split(nextLine(), " ")

	N, _ := strconv.Atoi(nextLine())
	L := strings.Split(nextLine(), " ")
	// n, _ := strconv.Atoi(input[0])

	// memo = make([]bool, n+1, n+2)

	amount := 0
	max := 0
	// arr := make([]int, N)
	for i := 0; i < N; i++ {
		val, _ := strconv.Atoi(L[i])

		if max < val {
			max = val
		}
		amount += val
	}
	amount -= max

	// ans := 0

	if max < amount {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}

	_ = wtr.Flush()
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

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

type dishh struct {
	first  int
	second int
}

// 構造体のスライス
type dish []dishh

// 以下インタフェースを満たす

func (p dish) Len() int {
	return len(p)
}

func (p dish) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p dish) Less(i, j int) bool {

	return p[i].first+p[i].second > p[j].first+p[j].second
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


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

    vector<ll> candies(n);
    rep(i, n)cin >> candies[i];
    ll ans = 0;
    if (candies.front() > x) {
        ans += (candies.front() - x);
        candies.front() = x;
    }
    for (int i = 1; i < n; i++) {
        ll c = candies[i] + candies[i - 1];
        if (c > x) {
            ll d = c - x;
            ans += d;
            candies[i] -= d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<long long>done(200005);
vector<long long>memo(200005);
vector<long long>data;
long long n;//ここら辺少しうーんって感じ
long long dp(long long p){
if (done.at(p)){
	return memo.at(p);
}
else{
	long long res;
  int f=p;
  if (p*2>n){
  res=data.at(p-1);
  }
  else{
    int e=0;
    p=2*f;
    while (p<=n){
      e+=dp(p);
      p+=f;
    }
   
  if (e%2==data.at(f-1)){
  res=0;  
  }
    else{
      
  res=1;
    }
  }
    memo.at(f)=res;
    done.at(f)=1;
  return res;
  }
}
  
  
  



int main(){
  cin>>n;
  data.resize(n);
  for (long long i=0;i<n;i++){
  cin >>data.at(i);
  }
  dp(1);
  
 
  long long r;
   for (long long i=1;i<n+1;i++){
     r+=memo.at(i);
   }
  cout <<r<<endl;
 for (long long i=1;i<n+1;i++){
   if (memo.at(i)){
   cout <<i<<" "; 
   }
    //前からp桁目の数の状況。
  }  
}

Measured memory_bytes: 5632
fun main(arg: Array<String>) {
    val INF = 1001001001
    var (N, X, Y) = listOfInt(0, -1, -1)
    val ans = IntArray(N)
    for (st in 0 until N) {
        val V = IntArray(N) { INF }
        val Q = Queue<Int>()
        fun push(v: Int, d: Int) {
            if (v !in 0 until N) return
            if (V[v] != INF) return
            V[v] = d
            Q.enqueue(v)
        }
        push(st, 0)
        while (!Q.isEmpty()) {
            val v = Q.dequeue()!!
            val d = V[v]
            push(v - 1, d + 1)
            push(v + 1, d + 1)
            if (v == X) push(Y, d + 1)
            if (v == Y) push(X, d + 1)
        }
        for (n in 0 until N) ans[V[n]] += 1
    }
    println(ans.drop(1).map { it / 2 }.joinToString("\n"))
}

class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(t: T) = elements.add(t)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }



Measured memory_bytes: 69308
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

void input(vec<pll> &v, ll n, ll idx) {
    for (ll i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        v.emplace_back(a, 3 - idx);
    }
}

int main() {
    ll x, y, a, b, c;
    std::cin >> x >> y >> a >> b >> c;
    vec<pll> apps;
    ll lis[] = { a, b, c, };
    for (ll i = 0; i < 3; i++) input(apps, lis[i], i);
    std::sort(ALLR(apps));
    ll rcnt = 0, gcnt = 0, sum = 0;
    ll ans = 0;
    for (auto &&e : apps) {
        ll s, t;
        std::tie(s, t) = e;
        if (t == 3) {
            if (rcnt == x) continue;
            rcnt++;
        }
        if (t == 2) {
            if (gcnt == y) continue;
            gcnt++;
        }
        sum++;
        ans += s;
        if (sum == x + y) break;
    }

    std::cout << ans << '\n';
    return 0;
}


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

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

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

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

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

void solve() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    bool ok = (A >= B) && (D >= B);

    ll g = __gcd(B, D);
    ll r = A % g;

    ll cr = C % g;
    ll low = cr < r ? C + r - cr : C + r - cr + g;

    cout << (ok && (low >= B) ? "Yes": "No") << "\n";
}

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

    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        solve();
    }

    return 0;
}



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

using namespace std;
int arr[3];
int main(){
	for(int i=0;i<3;i++){
		cin>>arr[i];
	}
	sort(arr, arr+3);
	for(int i=0;i<3;i++){
	cout<<arr[i];
	if (i<2){cout<<" ";
	}
}
	cout<<endl;
}


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

int main(){
    int h,a;
    cin>>h>>a;
    
    int cnt=0;
    while(h>0){
        h -=a;
        cnt++;
    }
    
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll b[200010];
	ll ans=0;
	for(ll i=n-1;i>=0;i--){
		ll cnt=0;
		for(ll j=2;;j++){
			if((i+1)*j>n){
				break;
			}
			else{
				cnt+=b[(i+1)*j-1];
			}
		}
		if(a[i]){
			if(cnt%2){
				b[i]=0;
			}
			else{
				b[i]=1;ans++;
			}
		}
		else{
			if(cnt%2){
				b[i]=1;ans++;
			}
			else{
				b[i]=0;
			}
		}
	}
	cout <<ans<<endl;
	for(ll i=0;i<n;i++){
		if(b[i]){
			cout << i+1<<" ";
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int MOD=1000000007;
const long long int INF=9999999;

long long int N,K,A[100005];


//階乗先に計算
class Kaizyou{
    public:
    long long int *kaizyou;
    Kaizyou(){};
    Kaizyou(long long int n,long long int mod){
        kaizyou=new long long int[n+1];
        kai(1,n,mod);
        return;
    }

    long long int kai(long long int a, long long int b, long long int mod) {
        long long int tmp = 1;
        for (long long int i = a; i <= b; i++) {
            tmp *= i;
            tmp %= mod;

            kaizyou[i] = tmp;
        }
        return tmp;
    }
};

//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
class Ruizyou{
    public:
    long long int rui(long long int a, long long int b, long long mod) {
        int memo[65] = {};
        long long int A[65] = {};
        long long int tmp = 1;
        for (int i = 0; i < 65; i++) {
            memo[i] = b % 2;
            b /= 2;
        }

        A[0] = a;
        A[0] %= mod;

        for (int i = 1; i < 65; i++) {
            A[i] = A[i - 1] * A[i - 1];
            A[i] %= mod;
        }
        for (int i = 0; i < 65; i++) {
            if (memo[i] == 1) {
                tmp *= A[i];
                tmp %= mod;
            }
        }
        tmp %= mod;
        return tmp;
    }
};
//コンビネーション計算
class Combination{
    public:
        Kaizyou * Kaizyou_Instance;
        Ruizyou Ruizyou_Instance;
    Combination(long long int n,long long int mod){
        Kaizyou_Instance=new Kaizyou(n,mod);
    }
    long long int comb(long long int n, long long int r, long long int mod) {
        long long int tmp;
		if(n==r){return 1;}
        tmp = (Kaizyou_Instance->kaizyou[n] * Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[r], mod - 2, mod)) % mod;
        tmp *= Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[n - r], mod - 2, mod);
        tmp %= mod;
        if (tmp < 0) { tmp = (mod - tmp) % mod; }
        return tmp;
    }
};	

long long int res=0;
int main() {
	cout<<setprecision(10);
	cin>>N>>K;
	Combination combination(100005,MOD);

	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N);
	for(int i=0;N-i-1>=K-1;i++){
		res+=combination.comb(N-i-1,K-1,MOD)*A[N-i-1];
		res-=combination.comb(N-i-1,K-1,MOD)*A[i];
		res%=MOD;
		//cout<<combination.comb(N-i-1,K-1,MOD)*A[N-i-1]<<" "<<combination.comb(N-i-1,K-1,MOD)*A[i]<<endl;
	}
	cout<<(MOD+res)%MOD;
} 


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

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

    int t[N], x[N], y[N];
    t[0] = 0; x[0] = 0; y[0] = 0;
    for (int i=1; i<=N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for (int i=0; i<N; i++){
        int temp1 = t[i+1] - t[i];
        int temp2 = abs(x[i+1] - x[i]);
        int temp3 = abs(y[i+1] - y[i]);

        if (temp1 < temp2 + temp3) {
            cout << "No" << endl;
            return 0;
        }

        if (temp1%2 != (temp2 + temp3)%2){
            cout << "No" << endl;
            return 0;
        }
    }

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

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n,0);

  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  cout << a.size() << endl;
}


Measured memory_bytes: 256