akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
from heapq import heappop, heappush
n = int(input())
inf = 100 * 100000

M = [[] for i in range(n)]

for i in range(n):
    L = list(map(int, input().split()))
    u = L[0]
    k = L[1]
    v = L[2::2]
    c = L[3::2]
    for j in range(k):
        M[u].append((v[j], c[j]))
result = [0] * n
S = set()
V = set(range(n))
S.add(0)
d = []
for m in M[0]:
    heappush(d, (m[1], m[0]))
T = V - S

while len(T) != 0:
    c, v = heappop(d)
    while v in S:
        c, v = heappop(d)
    result[v] = c
    S.add(v)
    T.remove(v)
    for m in M[v]:
        if m[0] in T:
            heappush(d, (result[v] + m[1], m[0]))

for i, v in enumerate(result):
    print(i, v)

Measured memory_bytes: 8516
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
int dist[2][100005];
vector<int> connect[100005];

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

int Dfs(int root, int current, int num) {
	dist[num][current] = dist[num][root] + 1;
	for (int next: connect[current]) {
		if (next == root)continue;
		Dfs(current, next, num);
	}
}

int main() {

	int N;
	cin >> N;

	for (int i = 0; i < N-1; ++i) {
		int a, b;
		cin >> a >> b;
		connect[a-1].push_back(b-1);
		connect[b - 1].push_back(a - 1);
	}

	dist[0][0] = -1;
	Dfs(0, 0, 0);
	dist[1][N-1] = -1;
	Dfs(N-1, N-1, 1);

	int f;
	for (int i = 0; i < N-1;++i) {
		if (dist[0][i] <= dist[1][i])f++;
	}
	string ans = "Snuke";
	if ((N + 2) / 2 <= f)ans = "Fennec";
	cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    bool test = false;
    if (prev_permutation(a.begin(), a.end())) {
        test = true;
        for (int j = 0; j < n; ++j) {
            if (j == 0) cout << a[j];
            else cout << " " << a[j];
        }
    }
    if (test) cout << endl;
    next_permutation(a.begin(), a.end());
    for (int j = 0; j < n; ++j) {
        if (j == 0) cout << a[j];
        else cout << " " << a[j];
    }
    cout << endl;
    test = false;
    if (next_permutation(a.begin(), a.end())) {
        test = true;
        for (int j = 0; j < n; ++j) {
            if (j == 0) cout << a[j];
            else cout << " " << a[j];
        }
    }
    if (test) cout << endl;
}



Measured memory_bytes: 3116
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int[] input = new int[5];

		for (int i = 0; i < 5; i++) {
			input[i] = scan.nextInt();
		}

		for (int i = 0; i < 5; i++) {
			if (input[i] == 0) {
				System.out.println(i + 1);
			}
		}

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26976
/*
Problem

Category
BFS

URL:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=ja

考察:


Date: 2020/04/14
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int n, k;
vector<vector<int>> AL;
vector<int> D;


/* ======================== */

signed main(){
    getInput();
    solve();
    return 0;
}

void getInput() {
    cin>>n;
    D = vector<int>(n, 1e9);
    for(int i=0; i<n; ++i) {
        int g, k;
        cin>>g>>k;
        vector<int> al;
        for(int j=0; j<k; ++j) {
            int a;
            cin>>a;
            al.push_back(a-1);
        }
        AL.push_back(al);
    }
    
}


void bfs(int gid, int d) {
    if(d >= D[gid]) return;
    D[gid] = d;
    for(int child: AL[gid]) {
        bfs(child, d + 1);
    }
}

void solve() {
    // print(AL);
    bfs(0, 0);
    for(int i=0; i<n; ++i) {
        if (D[i] == 1e9) D[i] = -1;
        cout<<i+1<<" "<<D[i]<<endl;
    }
}






Measured memory_bytes: 3168
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define rnt register int
#define ll long long
using namespace std;
ll n,s,ans=1e11;
inline ll f(ll a,ll b){
	if(a>b)
		return b;
	else
		return f(a,b/a)+b%a;
}
int main(){
	scanf("%lld %lld",&n,&s);
	if(n==s)
		return printf("%lld",n+1),0;
	if(s>n)
		return printf("-1"),0;
	for(rnt i=2;i<=sqrt(n)+1;i=-~i)
		if(f(i,n)==s)
			return printf("%lld",i),0;
	for(rnt i=1;i<=sqrt(n-s);i=-~i)
		if((n-s)%i==0)
			if(f((n-s)/i+1,n)==s)
				if((n-s)/i+1<ans)
					ans=(n-s)/i+1;
	printf("%lld",ans==1e11?-1:ans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = int(n ** 0.5)
i = 0
while True:
    if n%(s + i) == 0:
        k = 1
        break
    if n%(s - i) == 0:
        k = -1
        break
    i += 1
s = s + i * k 
print((s + n // s) - 2)

Measured memory_bytes: 40784
N,Q=map(int,input().split())
S=input()
cnt=[0,0]
for i in range(1,N):
    cnt.append(cnt[-1]+S[i-1:i+1].count("AC"))
for _ in range(Q):
    l,r=map(int,input().split())
    print(cnt[r]-cnt[l])


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 057_abc_d / Link: https://abc057.contest.atcoder.jp/tasks/abc057_d?lang=en  ----- */
/* ------問題------

N 個の品物が与えられます。
i 番目の品物の価値は vi(1≦i≦N) です。
これらの品物から、A 個以上、B 個以下を選ばなければなりません。
この制約下において、選んだ品物の価値の平均の最大値を求めてください。
また、選んだ品物の平均が最大となるような品物の選び方が何通りあるかを求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

#define nCk_MAX 100
long long  comb[nCk_MAX + 1][nCk_MAX + 1];
/* nCk を求める */
void calcomb() {
	int  i, j;
	for (i = 0; i <= nCk_MAX; i++) {
		for (j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				comb[i][j] = 1;
			else
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}
#undef nCk_MAX
LL N,A,B;

LL ans = 0LL;

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

	cin >> N>>A>>B;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	calcomb();
	double ave;
	SORT(a);
	reverse(ALL(a));
	if (a[0] == a[A - 1]) {
		int cnt = 0;
		FOR(i, 0, N) {
			if (a[0] == a[i])cnt++;
		}
		FOR(i, A, min((LL)cnt,B)+ 1) {
			ans += comb[cnt][i];
		}
		ave = a[0];
	}
	else {
		// A個が良いが、最後の選択ができる
		int cnt = 0;
		FOR(i, 0, N) {
			if (a[A - 1] == a[i])cnt++;
		}
		int cnt2 = 0;
		LL sum = 0;
		FOR(i, 0, A) {
			sum += a[i];
			if (a[A - 1] == a[i])cnt2++;
		}
		ans = comb[cnt][cnt2];
		ave = (double)sum / A;

	}
	cout <<fixed<<setprecision(10)<< ave << endl;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
l=[]
r=[]
for i in range(len(a)):
  if i%2==0:
    r.append(a[i])
  else:
    l.append(a[i])
t=l[::-1]+r
if n%2==0:
  print(*t)
else:
  print(*t[::-1])

Measured memory_bytes: 26020
#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
using namespace std;

int main()
{
  double N, X;
  int T, c;
  cin >> N >> X >> T;
  c = ceil(N / X) * T;
  cout << c << endl;
}


Measured memory_bytes: 3256
#include<stdio.h>
#define N 10000

int main(){
    int i = 1;
    int flag = 1;
    int n;
    int l[N];

    scanf("%d", &n);

    while (flag){
        int x = i;
        if (x%3 == 0){
            printf(" %d", i);
        }

        else{
            int flag2 = 1;
            while (flag2){
                if (x%10 == 3){
                    printf(" %d", i);
                    flag2 = 0;
                }

                else
                {
                    x /= 10;
                    if (x < 1){
                        flag2 = 0;
                    }
                }
            }
        }
        i++;
        if (i > n){
            flag = 0;
        }

    }

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



Measured memory_bytes: 2116
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;

int n, k;
bool ans[100000][1000];

signed main() {
	cin >> n;
	
	for (k = 1; k * (k - 1) < 2 * n; k++);
	if (k * (k - 1) != 2 * n) { cout << "No" << endl; return 0; }
	
	cout << "Yes" << endl;
	int i, j;
	
	int cor = 0;
	for (i = 0; i < k; i++) {
		for (j = i + 1; j < k; j++) {
			ans[cor][i] = true;
			ans[cor][j] = true;
			cor++;
		}
	}
	
	cout << k << endl;
	for (j = 0; j < k; j++) {
		vector<int> s;
		for (i = 0; i < n; i++) {
			if (ans[i][j]) s.push_back(i);
		}
		cout << s.size();
		for (i = 0; i < s.size(); i++) {
			cout << " " << s[i] + 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 98688
#include <stdio.h>

int main(void){
    int i, a, b;
    scanf("%d %d", &a, &b);
    if (a<b){
        for (i=0;i<b;i++){
            printf("%d", a);
        }
    }
    else{
        for (i=0;i<a;i++){
            printf("%d", b);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

void leap_year(int year);
int leap_year_judge(int year_a, int year_b);

int main(void)
{
	int year_a, year_b, exist;
	int i = 0;
	while (1) {
		scanf("%d %d", &year_a, &year_b);
		exist = leap_year_judge(year_a, year_b);
		if (year_a == 0 && year_b == 0) {
			break;
		} else if (exist == 1) {
			if (i !=0) {
			printf("\n");
			}
			for (int i = year_a; i <= year_b; i++) {
				leap_year(i);
			}
		} else {
			if (i !=0) {
			printf("\n");
			}
			printf("NA\n");
		}
		i++;
		
	}
	return 0;
}

void leap_year(int year)
{
	if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
		printf("%d\n", year);
	} 
}

int leap_year_judge(int year_a, int year_b)
{
	int judge = 0;
	for (int i = year_a; i <= year_b; i++) {
		if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)) {
			judge = 1;
		}
	}
	return judge;
}

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


void solve(long long N){
  cout << ((N / 2) + (N % 2)) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b==c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
//1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31//
#include <iostream>
#include<string>
using namespace std;
int main(){
    string str[7]{"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int t[11]{31,60,91,121,152,182,213,244,274,305,335};
    //        0   1  2  3   4   5   6  7    8   9   10//
    int d,m;
    while(cin>>m>>d){
        if(m==0)break;
        if(m==1)cout<<str[d%7]<<endl;
        else{
            d=d+t[m-2];
            cout<<str[d%7]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

#define INF 10000000

int N, A, B, C;
int l[8];

int dfs(int d, int a, int b, int c) {
    if (d == N) {
        if (a > 0 && b > 0 && c > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else return INF;
    } else {
        int ret0 = dfs(d + 1, a, b, c);
        int ret1 = dfs(d + 1, a + l[d], b, c) + 10;
        int ret2 = dfs(d + 1, a, b + l[d], c) + 10;
        int ret3 = dfs(d + 1, a, b, c + l[d]) + 10;
        return min({ret0, ret1, ret2, ret3});
    }
}
int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(1000000)
# 頂点数と辺数を入力
N, M = map(int, input().split())
# グラフの入力
G = [[] for _ in range(N)]  # 頂点数Nだけ準備
color = [-1] * N  # 未訪問は-1とする
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
# 探索
flag = True
dist = [-1] * N
# dist[0] = 0
que = deque([])
for v in range(N):
    if dist[v] != -1:  # 探索済みの時はスルー
        continue
    dist[v] = 0
    que.append(v)
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] == -1:  # 未訪問の時
                dist[nv] = dist[v] + 1
                que.append(nv)
            else:  # すでに訪問済みの時は整合性を確認
                if dist[v] == dist[nv]:
                    flag = False
if flag:
    w = [i for i in dist if i % 2 == 0]
    b = [i for i in dist if i % 2 != 0]
    ans = len(w) * len(b) - M
else:
    ans = N * (N - 1) // 2 - M
print(ans)

Measured memory_bytes: 24116
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;


int n;
int a[102];

int main(){
    cin>>n;
    rep0(i,n) cin>>a[i];
    int k=0;
    int cnt=0;
    while(k<n){
        int j=k+1;
        while(a[j]==a[k]){
            j++;
        }
        cnt+=(j-k)/2;
        k=j;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll X,K,D;
    cin >> X >> K >> D;
    if(X<0){
        X=-X;
    }
    ll a=X/D;
    if(a>K){
        ll b=K*D;
        ll c=X-b;
        cout << c;
    }else{
        ll d=X%D;
        ll e=K-a;
        if(e%2==1){
            d=D-d;
        }
        cout << d;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0 ; i < n; i++){
        cin >> a[i];
    }
    int cnt = 1;
    int x = k;
    while(x < n){
        x += k - 1;
        cnt++;
    }
    cout << cnt;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int A,B; cin>>A>>B;
    int a,b,ans=0;
    a=max(A,B);
    b=min(A,B);
    ans=a;
    ans=ans+max(a-1,b);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
long long f[1000000]; 
int main() {
	long long l,k;
	for (int i=1;i<=1000;i++) {
		f[i]=0;
	}
	scanf("%lld%lld", &l, &k);
	f[1]=1;
	f[k]=1;
	long long ans=0;
	for (int i=1;i<=l;i++) {
		f[i+2]+=f[i];
		f[i+k+1]+=f[i];
		ans+=f[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2744
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> a(N); cin >> a;

  int cnt = 0;
  for (int i = 0; i < N; i += 2) {
    if (a[i] % 2 == 1) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	std::string s;

	std::cin >> s;

	std::cout << std::count(s.begin(), s.end(), '1') << std::endl;

	return 0;
}

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

using namespace std;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int n, x;
  int a[100];
  cin >> n >> x;
  for (int i=0; i<n; ++i) cin >> a[i];
  sort(a, a+n);

  int ans = 0;
  for (int i=0; i<n; ++i) {
    if (a[i] > x) break;
    x -= a[i];
    ++ans;
  }
  if ((n == ans) && (0 < x)) --ans;

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = a / (double)b;
        String str = String.format("%.6f", f);
        System.out.println(d +" " + r + " " + str);
    }
}


Measured memory_bytes: 26572
N = int(input())
A = [int(i) for i in input().split()]

y = 1000
k = 0

# 同額をSkip
B = []
for i in range(len(A)-1):
  if A[i] == A[i+1]: continue
  B.append(A[i])

# print("A=",A)
# print("B=",B)
B = A
for i in range(len(B)-1):
  b = B[i]

  if B[i] == B[i+1]: continue

  if B[i] < B[i+1]:
    # ⇒買う
    kabusu = y // b
    kakaku = kabusu * b
    y -= kakaku
    k += kabusu

    # print(i,b,y,k, "kabusu, kakaku", kabusu, kakaku)

  else:
    # ⇒売る
    urine = k * b
    y += urine
    k = 0

    # print(i,b,y,k, "urine", urine)


if k>0:
  b = B[-1]
  urine = k * b
  y += urine

print(y)


Measured memory_bytes: 9228
#include <algorithm>
#include <iostream>
#include <string>

int main() {
    int N, Y;
    std::cin >> N >> Y;

    const int max_10000 = std::min(N, Y / 10000);
    
    std::string ret = "-1 -1 -1";
    for (int i = 0; i <= max_10000; ++i) {
        const int max_5000 = N - i;
        for (int j = 0; j <= max_5000; ++j) {
            const int k = max_5000 - j;
            if (k < 0) {
                continue;
            }

            if (10000*i + 5000*j + 1000*k == Y) {
                ret = std::to_string(i) + " "
                    + std::to_string(j) + " "
                    + std::to_string(k);
                break;
            }
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
vector<pii> v;
signed main(){
  fast;
  int n , m , x , y;
  cin>>n>>m;
  for(int i=0;i<n;i++){
  	  cin >> x;
  	  v.pb({x , 1ll});
  }
  for(int i=0;i<m;i++){
  	  cin>>x>>y;
  	  v.pb({y , x});
  }
  sort(v.begin() , v.end());
  int cnt = 0 , ans = 0;
  for(int i = v.size()-1 ; i>=0 ; i--){
         if(cnt + v[i].ss >= n){
         	  ans += (n - cnt)*v[i].ff;
         	  break;
         }
         else{
         	ans += v[i].ss * v[i].ff;
         	cnt += v[i].ss;
         }
  }

  cout << ans << endl;

}
  


Measured memory_bytes: 6512
import java.util.*;
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int L = sc.nextInt(), R = sc.nextInt(),d = sc.nextInt();
    int count = 0;
    for (int num=L; num<=R; num++) {
      count += (num%d == 0)?1 : 0;
    }
    System.out.println(count);
  }
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  string s;
  cin >> s;
  int cnt0=0, cnt1=0;
  for(int i=0; i<s.length(); i++){
    if(i%2==0){
      if(s[i]=='0') cnt1++;
      else cnt0++;
    }else{
      if(s[i]=='0') cnt0++;
      else cnt1++;
    }
  }
  int ans = min(cnt0, cnt1);
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	for (int i=1; i<=b; i++){
		if(a*i%b == c){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}



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

using namespace std;

int N;
int order[1005][1005 - 1];
int convert[1005][1005 - 1];

vector<vector<int>> E;

const int MAXV = 1005 * (1005 - 1) / 2;

int dp[MAXV];
bool finished[MAXV];
bool reached[MAXV];

int dfs(int pos) {
	if (reached[pos]) {
		if (!finished[pos])return -1;
		return dp[pos];
	}
	dp[pos] = 0;
	reached[pos] = true;
	for (int i = 0; i < E[pos].size(); i++) {
		//cout <<"pos == " << pos <<  "to " << E[pos][i] << endl;
		int res = dfs(E[pos][i]);
		if (res == -1)return -1;
		dp[pos] = max(dp[pos], res + 1);
	}
	finished[pos] = true;
	return dp[pos];
}

int main() {
	cin >> N;
	E.resize(N * (N - 1));
	
	int cnt1 = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (j < i)convert[i][j] = convert[j][i];
			else if(i < j){
				convert[i][j] = cnt1;
				cnt1++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> order[i][j], order[i][j]--;
			order[i][j] = convert[i][order[i][j]];
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 2; j++) {
			E[order[i][j]].push_back(order[i][j + 1]);
			//cout << order[i][j] << " -> " << order[i][j + 1] << endl;
		}
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			int res = dfs(order[i][j]);
			if (res == -1) {
				cout << -1 << endl;
				return 0;
			}
			ans = max(ans, res);
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 50176
#include<stdio.h>
int main(){
  long long x,y,i,cnt=1,ans=0;
  scanf("%lld%lld",&x,&y);


  for(i=1; i<=y; i++){
    x*=2;
    cnt++;
    if(x>y){
      printf("%lld\n",cnt-1);
      break;
    }
  }


  return 0;


}


Measured memory_bytes: 128
#include <cstdio>

#define MOD 1000000007
#define N 2222222

typedef long long ll;

ll fct[N] = { 1, 1 }, inv[N] = { 1, 1 }, fiv[N] = { 1, 1 };

ll combination(ll n, ll r)
{
	return fct[n] * fiv[r] % MOD * fiv[n - r] % MOD;
}

int main(void)
{
	ll r1, c1, r2, c2, i;

	scanf("%lld %lld %lld %lld" ,&r1, &c1, &r2, &c2);
	++r2, ++c2;

    for (i = 2; i <= r2+c2; i++)
	{
		fct[i] = fct[i - 1] * i % MOD;
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fiv[i] = fiv[i - 1] * inv[i] % MOD;
	}

	printf("%lld" ,(combination(r2 + c2, r2) - combination(r1 + c2, r1) - combination(r2 + c1, r2) + combination(r1 + c1, r1) + MOD * 2) % MOD);
	return 0;
}

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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	long long int i,n,m,k,j,count,sum=0,cou;
	
	scanf("%lld", &n);
  for(i=1;i<=n;i++){
  cou=n/i;
    sum+=i*cou*(cou+1)/2;
  }
  
  
printf("%lld\n",sum);
return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    ll maxv = max(a,b);
    ll minv = min(a,b);

    if(maxv % minv == 0) return minv;
    else return gcd(maxv - minv, minv);
}

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

    ll ret = 0;
    for(int i = 1; i <= K; i++) {
        for(int j = 1; j <= K; j++) {
            for(int k = 1; k <= K; k++) {
                ret += gcd(gcd(i, j), k);
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3596
N,M=map(int,input().split())
P=[list(map(int,input().split())) for _ in range(M)]
for i in range(M):
  P[i].append(i)
P.sort()
j=1
k=0
for i in range(M):
  k+=1
  if P[i][0]!=j:
    j=P[i][0]
    k=1
  s=str(j)
  while len(s)!=6:
    s='0'+s
  t=str(k)
  while len(t)!=6:
    t='0'+t
  P[i].append(s+t)
P.sort(key=lambda x:x[2])
for i in range(M):
  print(P[i][3])

Measured memory_bytes: 38456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<ll>> dp(n, vector<ll>(n, 0));
  REP(i, n) {
    cin >> a[i];
  }

  REP(i, n) {
    if (n % 2) {
      dp[i][i] = a[i];
    } else {
      dp[i][i] = - a[i];
    }
  }

  FOR(l, 1, n - 1) {
    REP(i, n - l) {
      if ((n - l) % 2) {
        dp[i][i + l] = max(dp[i][i + l - 1] + a[i + l], dp[i + 1][i + l] + a[i]);
      } else {
        dp[i][i + l] = min(dp[i][i + l - 1] - a[i + l], dp[i + 1][i + l] - a[i]);
      }
    }
  }

  cout << dp[0][n - 1] << endl;

}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

int main(){
  int n;  cin >> n;
  int m = 0, f = 1, table[] = {1, 1};
  string rep;
  cout << "0\n";  cin >> rep;
  if(rep == "Female")  table[0] = f, table[1] = m;
  else if(rep == "Male") table[0] = m, table[1] = f;
  else  return 0;
  
  int s = 0, t = n;
  for(int i=0; i<50; i++){
    int mid = (s + t) / 2;
    cout << mid << endl;
    cin >> rep;
    if(rep == "Female")
      if(table[mid%2] == f)  s = mid + 1;
      else  t = mid;
    else if(rep == "Male")
      if(table[mid%2] == m)  s = mid + 1;
      else  t = mid;
    else
      return 0;
  }
  
  return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
      int a; cin >> a;
      if(i&1 && a&1)
        ans++;
    } 
    cout << ans << "\n";
  }
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    REP(i,3)if(s[i]=='1')ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    sc.close();

    long p = 1;
    long sum = 0;
    for (int i = 0; i < n; i++) {
      if (p%5 == 0 || p%3 == 0) {
        p++;
        continue;
      } else {
        sum += p;
        p++;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int K, S;
    cin >> K >> S;
    int cnt = 0;
    rep(x, K+1) {
        rep(y, K+1) {
            int z = S-(x+y);
            if(0<=z && z<=K) cnt++;
        }
    }  
    print(cnt);
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;	
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    ll int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
char O[510],E[500],a[1010],c;
int main()
{

  int i,j,t;
  scanf("%s%s",O,E);
   j=0;
   for(i=0;(c=O[i])!='\0';i++)
   {
     a[j]=O[i];
     j++;
     j++;
   }
   j=1;
   for(t=0;(c=E[t])!='\0';t++)
   {
     a[j]=E[t];
     j++;
     j++;
   }
   a[j]='\0';
   printf("%s",a);
}


Measured memory_bytes: 128
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int n, ans = 0;

void check(int x) {
    if (x <= n) {
        int three = 0, five = 0, seven = 0, other = 0;
        while (x >= 1) {
            if (x % 10 == 3)three++;
            else if (x % 10 == 5)five++;
            else if (x % 10 == 7)seven++;
            else other++;
            x /= 10;
        }
        if (three >= 1 && five >= 1 && seven >= 1 && other == 0)ans++;
    }
}

void dfs(int x) {
    check(x);
    if (x <= 100000000) {
        dfs(10 * x + 3);
        dfs(10 * x + 5);
        dfs(10 * x + 7);
    }
}

int main() {
    cin >> n;
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

ll mul(ll a, ll b) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) {
            r = (r + a) % mod;
        }
        a = (a + a) % mod;
        b /= 2;
    }
    return r;
}

ll power(ll x, ll n) {
    ll res = 1;
    x %= mod; 
    while (n > 0)  
    {  
        if (n & 1)  res = (res*x)%mod;  
        n = n>>1; 
        x = (x*x)%mod;  
    }  
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    string rev = s;
    reverse(rev.begin(), rev.end());
    int n = s.size();
    string a = s.substr(0, (n-1)/2);
    string b = s.substr((n+2)/2, (n-1)/2);
    string c  = a;
    reverse(c.begin(), c.end());
    string d = b;
    reverse(d.begin(), d.end());
    if(rev == s && c == a && d == b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int food, ans = 0;
    vector<int> wait(5);
    for(int i = 0; i < 5; i++){
        cin >> food;
        ans += food;
        if(food % 10 == 0) wait[i] += 0;
        else wait[i] += 10 - (food % 10); 
    }
    sort(wait.begin(), wait.end());
    for(int i = 0; i < 4; i++) ans += wait[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

string s;

int main() {
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ss
    integer(int32), allocatable:: s(:)

    read*, n
    allocate(s(n))
    do i = 1, n
        read*, s(i)
    end do

    call merge_sort(s,1,n)
    ss = sum(s)

    if (mod(ss,10) /= 0) then
        print*, ss
        stop
    end if

    do i=1,n
        if (mod(s(i),10) /= 0) then
            print*, ss-s(i)
            stop
        end if
    end do

    print*, 0
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
key = [0]*n
for i in range(n):
  key[a[i]-1] += 1
kake = [1]*n
ans = 0
for i in range(n):
  ans += key[i]*(key[i]-1)//2
for i in range(n):
  print(ans-(key[a[i]-1]-1))

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

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

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> L(M), R(M);
    rep (i, M) {
        cin >> L[i] >> R[i];
    }

    vector<Pii> p;
    for (int i = 0; i < L.size(); i++) {
        p.push_back(make_pair(L[i], R[i]));
    }

    sort(p.begin(), p.end());
    ll head = p[M-1].first;
    for (int i = 0; i < p.size(); i++) {
        int tmp = p[i].first;
        p[i].first  = p[i].second;
        p[i].second = tmp;
    }

    sort(p.begin(), p.end());
    ll tail = p[0].first;

    ll ans = tail - head + 1;
    if (ans > 0) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int D,T,S;
    cin>>D>>T>>S;
    if(D>=1&&D<=10000&&T>=1&&T<=10000&&S>=1&&S<=10000)
    {
        if(D%S==0)
        {
            if(D/S<=T)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
        {
            if(D/S+1<=T)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "No" << endl;
  exit(0);
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  vector<pair<int, int>> c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c[i] = {b[i], i};
  }
  sort(c.begin(), c.end());
  int now = 0;
  for (auto p : c) {
    int i = p.second;
    now += a[i];
    if (b[i] < now) err();
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vector<vi> txy(N+1, vi(3));
    txy[0]=vi{0,0,0};
    REP(i,N)cin>>txy[i+1][0]>>txy[i+1][1]>>txy[i+1][2];
    FOR(i,1,N+1){
        ll t1,x1,y1,t2,x2,y2;
        t1=txy[i-1][0];
        x1=txy[i-1][1];
        y1=txy[i-1][2];
        t2=txy[i][0];
        x2=txy[i][1];
        y2=txy[i][2];
        ll test=llabs(x1-x2)+llabs(y1-y2)-t2+t1;
        if (test>0||test%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 5760
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n = input()
  x = len(n)
  ans = 0
  for i in range(x):
    ans += int(n[i])
  if ans%9 == 0:
    print('Yes')
  else:
    print('No')
if __name__ == '__main__':
  main()

Measured memory_bytes: 9276
#include <stdio.h>
int main(){
	int x,a,b,c,d;
	scanf("%d %d %d",&x,&a,&b);
	c=(x-a);
	d=(x-b);
	if (c<0){
		c=c*-1;
	}
	if (d<0){
		d=d*-1;
	}
	if(c>d){
		printf("B");
	}else{
		printf("A");
	}

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	int N,M;
	int sugoroku[1000],saikoro[1000];
	while (cin>>N>>M,(N!=0&&M!=0)) {
		int pos=0,ans=0;
		for (int i=0; i<N; i++) cin>>sugoroku[i];
		for (int i=0; i<M; i++) cin>>saikoro[i];
		while (pos<N-1) {
			pos+=saikoro[ans];
			pos+=sugoroku[pos];
			ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	while (true)
	{
		if (a > b)
		{
			swap(a, b);
		}

		if (b % a == 0) break;

		b = b % a;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{  int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
    if(a > b){
    	printf("a > b\n");
    }else if(a < b){
    	printf("a < b\n");
    }else{printf("a == b\n");
	}return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int i;
    int64_t num=0;
    int64_t num2=0;
    int64_t div = pow(10,9) + 7;
    cin >> N;
    vector<int64_t> A(N);
    for(i=0;i<N;i++){
        cin >> A.at(i);
    }

    for(i=0;i<N;i++){
        num += A.at(i);
    }
    num = num % (2*div);
    num = num * num;
    for(i=0;i<N;i++){
        num2 = A.at(i) * A.at(i);
        num2 = num2 % (2*div);
        num = num - num2;
        if(num < 0){
            num += (2*div);
        }
    }
    num = num /2;
    num = num % div;


    cout << num << endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
const int Maxn=200005;
int p1[Maxn],p2[Maxn];
int sum[Maxn];
vector<int> col[Maxn];
int res[Maxn];
void _init(){
	for (int i=0;i<Maxn;i++){
		p1[i]=i;
		p2[i]=i;
	}
}
int f1(int x){
	return p1[x]=(p1[x]==x)?x:f1(p1[x]);
}
int f2(int x){
	return p2[x]=(p2[x]==x)?x:f2(p2[x]);
}
void U1(int x,int y){
	x=f1(x);
	y=f1(y);
	p1[x]=y;
}
void U2(int x,int y){
	x=f2(x);
	y=f2(y);
	p2[x]=y;
}
int main(){
	_init();
	int n;
	scanf("%d",&n);
	int K,L;
	scanf("%d %d",&K,&L);
	for (int i=0;i<K;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		U1(u,v);
	}
	for (int i=0;i<L;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		U2(u,v);
	}
	for (int i=1;i<=n;i++){
		col[f1(i)].push_back(i);
	}
	vector<int> use;
	for (int i=1;i<=n;i++){
		if (col[i].size()==0) continue;
		for (int j=0;j<col[i].size();j++){
			use.push_back(f2(col[i][j]));
			sum[f2(col[i][j])]++;
		}
		for (int j=0;j<col[i].size();j++){
			res[col[i][j]]=sum[f2(col[i][j])];
		}
		for (int j=0;j<use.size();j++){
			sum[use[j]]=0;
		}
		use.clear();
	}
	for (int i=1;i<=n;i++){
		printf("%d ",res[i]);
	} 
	printf("\n");
	return 0;
}

Measured memory_bytes: 14208