akhauriyash/Code-Regression huggingface dataset:
///Code by: Luis Alejandro
///Handle: Sekai
///Country: Cuba

#include <bits/stdc++.h>
#define endl '\n'
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN=1e5+5;
const int MOD=1e9+7;
const int INF=1e9;
const ld PI=acos(-1);
const ld EPS=1e-9;

#define lg2(x) 31-__builtin_clz(x)
#define logx(a,b) (log(a)/log(b))
#define pow2(a) a*a
#define pow3(a) a*a*a
#define lcm(a,b) (a*b)/__gcd(a,b)

pii mkp(int a, int b){
    if(a>b)swap(a,b);
    return make_pair(a,b);
}

int mod_pow(int a, int b){
    if(!b)return 1;
    if(b&1)return mod_pow(a,b-1)*a%MOD;
    int power=mod_pow(a,b>>1);
    return power*power%MOD;
}

int modular_inverse(int a){
    return mod_pow(a,MOD-2);
}

vector<int> movy={0,0,1,-1};
vector<int> movx={1,-1,0,0};

void solve(){
    ull sum=0;
    string s;
    cin>>s;
    for(int i=0;i<(int)s.length();i++){
        sum+=(s[i]-'0');
    }
    if(sum%3==0){
        cout<<"Yes"<<endl;
        return;
    }
    cout<<"No"<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("IN.txt","r",stdin);
        //freopen("OUT.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N;
	cin >> N;
	map<string, int> K;
	fx(N) {
		string s;
		cin >> s;
		K[s]++;
	}
	cout << "AC x " << K["AC"] << endl;
	cout << "WA x " << K["WA"] << endl;
	cout << "TLE x " << K["TLE"] << endl;
	cout << "RE x " << K["RE"] << endl;
    return 0;
}



Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	int n;
	int a[200000];
	int ch[200000]={};
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a[i];
		a[i]--;
		ch[a[i]]++;
	}
	for(int i=0;i<n;i++){
		cout<<ch[i]<<endl;
	}
	return 0;
}

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

typedef struct{
    long fy;
    long fx;
    long ty;
    long tx;
} move_t;


char a[500*500];

inline static long s(long y, long x, long w){
    if(y%2==0){
        return y*w+x;
    }else{
        return y*w+(w-1-x);
    }
}

inline static pair<long,long> xy(long n, long w){
    long q = n/w;
    long r = n%w;
    if(q%2==0){
        return {q,r};
    }else{
        return {q,w-1-r};
    }
}

int main(void){
    long h, w;
    cin >> h >> w;
    //vector<vector<char>> a(h);
    //vector<vector<bool>> used(h);
    //vector<move_t> m;
    for(long i=0; i<h; i++){
        for(long j=0; j<w; j++){
            cin >> a[s(i,j,w)];
        }
    }
    /*
       for(long i=0; i<h; i++){
       for(long j=0; j<w; j++){
       cout << a[s(i,j,w)] << " ";
       }
       cout << endl;
       }
       */
    bool haveCoin = false;
    long count = 0;
    stringstream ss;
    for(long i=0; i<h*w-1; i++){
        if(a[i]%2==1){
            haveCoin = !haveCoin;
        }
        if(haveCoin){
            const pair<long,long> p=xy(i, w);
            const pair<long,long> q=xy(i+1, w);
            ss << p.first+1 << " " << p.second+1 << " " << q.first+1 << " " << q.second+1 << "\n";
            count++;
        }
    }
    cout << count << "\n" << ss.str();
    return 0;
}


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

using namespace std;

const long long M = 1e9 + 7;
const int N = 1e5 + 1;

long long fac[N << 1], inv[N << 1];
long long h, w, a, b;

long long expo(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, a = (a * a) % M) {
    if (b & 1) {
      ans = (ans * a) % M;
    }
  }
  return ans;
}

long long C(int n, int k) {
  return fac[n] * (inv[k] * inv[n - k] % M) % M;
}

long long PathCount(int x1, int y1, int x2, int y2) {
  int d1 = x2 - x1, d2 = y2 - y1;
  if (d1 < 0 || d2 < 0) return 0;
  return C(d1 + d2, d1);
}

int main() {
  #ifdef GG
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
  #endif
  fac[0] = 1;
  for (int i = 1; i < N * 2; ++i) fac[i] = (fac[i - 1] * i) % M;
  inv[N * 2 - 1] = expo(fac[N * 2 - 1], M - 2);
  for (int i = N * 2 - 1; i >= 1; --i) {
    inv[i - 1] = (inv[i] * i) % M;
  }
  long long ans = 0;
  cin >> h >> w >> a >> b;
  a = h - a + 1;
  for (int i = b + 1; i <= w; ++i) {
    ans = (ans + PathCount(1, 1, a - 1, i) * PathCount(a, i, h, w) % M) % M;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3328
import math
N,K=map(int,input().split())
X=[(b,a*b)for a,b in zip(sorted(list(map(int,input().split()))),sorted(list(map(int,input().split())))[::-1])]
m,M,i=0,10**12,1
exec("i,M,m=((i+m)//2,i,m) if sum(math.ceil(max(0,c-i)/b)for b, c in X)<=K else((i+M)//2,M,i);"*50)
print(M)

Measured memory_bytes: 123340
package main

import (
	"fmt"
)


func main() {
	var n int
	a := []int{}
	b := []int{}
	fmt.Scan(&n)
	
	for i:=0;i<n+1;i++{
		var m int
		fmt.Scan(&m)
		a=append(a,m)
	}

	for i:=0;i<n;i++{
		var m int
		fmt.Scan(&m)
		b=append(b,m)
	}
	
	ans := 0
	for i:=0;i<n;i++{
		if a[i] >= b[i]{
			ans += b[i]
			a[i] -= b[i]
			b[i] -= b[i]
		} else if a[i] < b[i] {
			ans += a[i]
			b[i] -= a[i]
			a[i] -= a[i]
			if a[i+1]>=b[i]{
				ans += b[i]
				a[i+1] -= b[i]
				b[i] -= b[i]
			} else if a[i+1] < b[i]{
				ans += a[i+1]
				b[i] -= a[i+1]
				a[i+1] -= a[i+1]
			}
		}
	}
	
	fmt.Println(ans)
	
}

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

int main()
{
    int N, A;
    cin >> N >> A;
    if (N % 500 <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8");
// 
const [k, s] = input.split(" ").map(it => parseInt(it));
let count = 0;

for(let ix = 0; ix <= k; ix++){
  
  for(let iy = 0; iy <= k; iy++){
    const diff = s - (ix + iy);
    if(diff < 0)continue; // x+yの時点ですでに超過してるので
    if(diff > k)continue; // 更にzを足してもsに追いつかないので
    count++; // z はx,yが決まった時点で一意に決まる
  }
}


console.log(count);

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    ll n, a, b; cin >> n >> a >> b;
    ll x = n / (a + b);

    ll total = x * (a + b);
    ll rem = min(n - total, a);

    cout << x * a + rem;
}

Measured memory_bytes: 256
import java.util.HashSet;
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 c = sc.nextInt();

        HashSet<Integer> result = new HashSet<>();
        result.add(a);
        result.add(b);
        result.add(c);

        System.out.println(result.size());
    }
}


Measured memory_bytes: 23764
using System;

public class First_problem{
  public static void Main(){
    string[] str = Console.ReadLine().Split(' ');
    int h, a, cnt;
    h = int.Parse(str[0]);
    a = int.Parse(str[1]);
    
    for(cnt = 0 ; h > 0 ; cnt++){
      h -= a;
    }
    
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 13140
class uf:
	def __init__(self, n):
		self.size = n
		self.parents = [i for i in range(n)]
		self.ranks = [0 for i in range(n)]
	def find(self, x):
		if x == self.parents[x]:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.ranks[x] > self.ranks[y]:
			self.parents[y] = x
		else:
			self.parents[x] = y
		if self.ranks[x] == self.ranks[y]:
			self.ranks[y] += 1

ans = 0
n,m = map(int,input().split())
t = [uf(n) for i in range(m)]
g = [list(map(lambda x: int(x)-1,input().split())) for i in range(m)]
for i in range(m):
	for e in g:
		if e == g[i]:
			continue
		t[i].union(e[0],e[1])
	if len(set([t[i].find(j) for j in range(n)])) > 1:
		ans += 1
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long A, long long B) {
        long long n = gcd(A, B);

        vector<long long> P;
        auto x = n;
        for (int i = 2; i * 1LL * i <= x; ++i) {
            if (x % i == 0) {
                P.push_back(i);
                while (x % i == 0) {
                    x /= i;
                }
            }
        }
        if (x > 1) {
            P.push_back(x);
        }
        P.push_back(1);
        int res = P.size();
        return res;
    }

private:
    long long gcd(long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    }
};

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

    long long A, B;
    cin >> A >> B;
    Solution sol;
    cout << sol.solve(A, B) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll a,b,k,m;
    cin>>a>>b>>k;
   //  k = min( k , min( a, b ) );
   // cout<<a-k<<' '<<b-k<<endl;
    if( k <= a ){
	cout<<a-k<<' '<<b<<endl;
    }else{
	cout<<0<<' '<<max(b+a-k,0ll)<<endl;
    }
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    priority_queue<pair<ll, ll>, std::vector<pair<ll, ll> >, std::greater<pair<ll, ll> > > task;

    rep(i, 0, n){
        ll a, b; 
        cin >> a >> b;
        task.push({b,a});
    }

    ll now = 0;
    while(!task.empty()){
        auto p = task.top();
        //cerr << p.first << "," << p.second << endl;
        task.pop();
        now += p.second;
        if(now > p.first){
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
    return 0;
}

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

int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

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

    int sum_value = 0;
    for (int i = 1; i <= N; ++i) {
        string target = to_string(i);
        int num = 0;
        for (int index = 0; index < target.size(); ++index) {
            num += ctoi(target[index]);
        }
        if (num >= A && num <= B) {
            sum_value += i;
        }
    }

    cout << sum_value << endl;
}

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

#define mod 1000000007

int main() {

	int n,k,x; cin>>n>>k;
	vector<int>dp(n+1,0);
	set<int>sy;
    dp[0]=1;
	for(int i=0;i<k;i++) {
		cin>>x; sy.insert(x);
	}
    if(!sy.count(1)) dp[1]=1;
        for(int i=2;i<=n;i++) {
            if(!sy.count(i))  dp[i]=((dp[i-1]%mod)+(dp[i-2]%mod))%mod;
        }
    cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 5376
# 解説放送を見た

class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from collections import defaultdict

    mod = 10 ** 9 + 7

    _ = int(input())  # n
    *a, = map(int, input().split())

    sieve = Sieve(n=10 ** 6 + 5)

    mp = defaultdict(int)
    for x in a:
        f = sieve.factor(x=x)  # [[prime,cnt],...]
        for prime, cnt in f:
            mp[prime] = max(mp[prime], cnt)

    lcm = 1
    for prime, cnt in mp.items():
        for _ in range(cnt):
            lcm = (lcm * prime) % mod

    ans = 0
    for x in a:
        b = lcm * pow(x, mod - 2, mod) % mod
        ans = (ans + b) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15512
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

//個人的な好みだけど、メモ化再帰の時は、1-idxにする。

int N;
int dp[100001];//dp[i] := i(1-idx)本目の柱での最低コスト この実装では、1-idxをしてるので注意！
int h[100001];//柱の高さも1-idx固定にしておく

int memo(int n) {
	if (dp[n] != -1)
		return dp[n];
	if (n == 1) 
		return dp[n] = 0;
	else if (n == 2)
		return dp[n] = abs(h[n] - h[n - 1]);
	else 
		return dp[n] = min(memo(n - 1) + abs(h[n] - h[n - 1]), memo(n - 2) + abs(h[n] - h[n - 2]));
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		//1-idxにする
		cin >> h[i];
	}

	//dpの中身を全部-1で初期化しておく。そうすると、すでにメモされてるかどうかの判別が容易
	for (int i = 1; i <= N; i++)dp[i] = -1;

	memo(N);

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
    int x[10000];
    int i;
    while(1){
        scanf("%d",&x[i]);
        if(x[i]==0) break;
        i++;
    }
    for(i=0;i<10000;i++){
        if(x[i]==0) break;
        printf("Case %d: %d\n",i+1,x[i]);
    }
    return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;cin>>N>>D>>X;
  int a,ans=0;
  for(int i=0;i<N;i++){
    cin>>a;
    ans+=(D-1)/a+1;
  }
  ans+=X;
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
 	int count = 0;
  
  	string w;
  	cin >> w;
	for (int i = 0 ; i < w.size() ; i++ ){
		if (isupper(w[i])){
			w[i] = tolower(w[i]);
		}


	}

	string t;

	while(1){
		cin >> t;

		if (t == "END_OF_TEXT")break;

		for (int j = 0 ; j < t.size() ; j++ ){
			if ( isupper(t[j])){
				t[j] = tolower(t[j]);
			}
		}
		

		if (t == w )count++;

	}


    cout << count << endl;
	return 0;
}

Measured memory_bytes: 3140
#include<stdio.h>

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

    int b[n];
    int et = n/2+n%2;
    int ot = n/2;

    int tmp = 1;
    for(int i=0; i<et; i++){
        b[i] = a[n-tmp];
        tmp += 2;
    }

    tmp = 2;
    for(int i=0; i<ot; i++){
        b[n-i-1] = a[n-tmp];
        tmp += 2;
    }

    for(int i=0; i<n; i++){
        printf("%d ", b[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3712
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}

const int maxn = (int) 3e3 + 10;

int a[maxn];
vector<vector<int> > es;

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].pb(t), es[t].pb(s);
  }
  return 1;
}

bool dfs(int v, int p) {
  for (int u : es[v]) {
    if (u == p) {
      continue;
    }
    if (!dfs(u, v)) {
      if (a[v] > a[u]) {
        return 1;
      }
    }
  }
  return 0;
}

void solve() {
  vector<int> ans;
  for (int iter = 0; iter < n; ++iter) {
    if (dfs(iter, -1)) {
      ans.pb(iter + 1);
    }
  }
  for (int i = 0; i < sz(ans); ++i) {
    printf("%d%c", ans[i], " \n"[i == sz(ans) - 1]);
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    // 頂点数と辺数
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    for (int k = 0; k < M; k++) {
        // グラフ入力受取 (ここでは無向グラフを想定)
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            if (i == k) continue;
            int tmp_a, tmp_b;
            tmp_a = a[i];
            tmp_b = b[i];
            tmp_a--;
            tmp_b--;
            G[tmp_a].push_back(tmp_b);
            G[tmp_b].push_back(tmp_a);
        }
        // BFS のためのデータ構造
        vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
        queue<int> que;

        // 初期条件 (頂点 0 を初期ノードとする)
        dist[0] = 0;
        que.push(0); // 0 を橙色頂点にする

        // BFS 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int new_v : G[v]) {
                if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
                dist[new_v] = dist[v] + 1;
                que.push(new_v);
            }
        }
        for (int i = 0; i < N; i++) {
            if (dist[i] == -1) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

int main() { 
  int n;
  cin >> n;
  vl a(n),s(n+1,0);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  rep(i,n){
    s[i+1] = s[i]+a[i];
  }
  
  int ans = 1;
  drep(i,n){
    if(s[i]*2 >= a[i]) ans++;
    else break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

class Class3
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(" ");
        int N = int.Parse(s[0]);
        int D = int.Parse(s[1]);

        int cnt = 0;
        for (int i = 1; i<= N; i++)
        {
            string[] s2 = Console.ReadLine().Split(" ");
            long X = long.Parse(s2[0]);
            long Y = long.Parse(s2[1]);
            double dist = Math.Sqrt(Math.Pow(X,2) + Math.Pow(Y,2));
            if (dist <= D)
            {
                cnt++;
            }
        }


        Console.WriteLine(cnt);



    }
}

Measured memory_bytes: 40756
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

ll dp[10001][100][2];

int main()
{
	string k;
	int d;
	ll ans=0;
	cin>>k>>d;
	fill(dp[0][0],dp[10001][0],0);
	
	dp[0][0][1]=1;
	for(int i=1;i<k.size()+1;i++)
	{
		for(int j=0;j<d;j++)
		{
			if(dp[i-1][j][0]>0)
			{
				for(int m=0;m<10;m++)
				{
					int t=(j+m)%d;
					if(t<0)
						t+=d;
					dp[i][t][0]+=dp[i-1][j][0];
					dp[i][t][0]%=MOD;
				}
			}
			if(dp[i-1][j][1]>0)
			{
				int t;
				for(int m=0;m<(k[i-1]-'0');m++)
				{
					t=(j+m)%d;
					if(t<0)
						t+=d;
					dp[i][t][0]+=dp[i-1][j][1];
					dp[i][t][0]%=MOD;
				}
				t=(j+(int)(k[i-1]-'0'))%d;
				if(t<0)
					t+=d;
				dp[i][t][1]+=dp[i-1][j][1];
				dp[i][t][1]%=MOD;
			}
		}
	}

	ans=dp[k.size()][0][0]+dp[k.size()][0][1]-1;
	ans%=MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int[][] c = new int[3][];
        c[0] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        c[1] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        c[2] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        bool f = ((c[0].Sum() - c[1].Sum()) % 3 == 0) && ((c[1].Sum() - c[2].Sum()) % 3 == 0);
        if (!f)
            Console.WriteLine("No");
        else
        {
            int s1, s2, s3;
            s1 = c[0][0] + c[1][0] + c[2][0];
            s2 = c[0][1] + c[1][1] + c[2][1];
            s3 = c[0][2] + c[1][2] + c[2][2];
            bool f2 = ((s1 - s2) % 3 == 0) && ((s2 - s3) % 3 == 0);
            Console.WriteLine(f2 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(c==1){
    cout << "Open" <<endl;
  }else if(a==1&&b==1&&c==0){
    cout << "Open" <<endl;
  }else{
    cout << "Close" <<endl;
  }
  return(0);
}



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

int main() {
	int n, d, x[30][30];
	int ans = 0;
	float work = 0;
	int work2=0;


	scanf("%d %d", &n, &d);

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

	for (int i = 0; i < n-1; i++) {
		for (int m = i + 1; m < n; m++) {
			work = 0;
			for (int j = 0; j < d; j++) {
				work += (x[i][j] - x[m][j]) * (x[i][j] - x[m][j]);
			}
			work = sqrt(work);
			work2 = (int)work;
			
			if (work - work2 == 0) {
				ans++;
			}
		}
			
	}

	printf("%d", ans);

	return 0;
}

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

using namespace std;

#define ll long long 

int const N = 1e5 + 20;
int const INF = 1e9 + 7;

ll h[N], t, memo[N], k;
 


int main(){
	
	memset(memo, INF, sizeof(memo));
	
	cin>>t>>k;
	
	vector <ll> v(k);
	
	for(int i = 0; i < t; ++i)
		cin>>h[i];
	int a = 1;
	for(auto &x: v){
		x= a;
		a++;
	}
	memo[0] = 0;
	for(int i = 0; i < t; ++i)
		for(int j: v)
			if(i+j < t)
				memo[i+j] = min(memo[i+j], memo[i] + abs(h[i] - h[j+i]));
				
	cout<<memo[t-1];
	return 0;
}


Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  int a,b;
  cin >> a>> b;
  if(a%b==0){
    cout << 0 << endl;
  }else{
    cout << 1<<endl;
  }
  return 0;

}

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

int N,T,A;
int H[1050];
const int INF=10000000000;
int main(){
    cin>>N;
    cin>>T>>A;

    double res=INF;
    int temp_i;
    for(int i=1;i<=N;++i)cin>>H[i];

        for(int i=1;i<=N;++i){
            double H_med=abs(A-(T-H[i]*0.006));
                if(res>H_med){
                    res=H_med;
                    temp_i=i;
                }
        }
    cout<<temp_i;
}

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

int main(){
	int N;
	int X,Y;
	cin >> N >> X >> Y;
	int ans1=0,ans2=0;
	ans1 = min(X,Y);
	if(X+Y<=N) ans2=0;
	else{
		ans2 = X+Y-N;
	}
	cout << ans1 <<" " <<ans2<<endl;
	return 0;
}


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

int main(void){
    int n, m, p, x, sum = 0;
    cin >> n;
    vector<int> t(n);
    for (int i=0; i<n; i++) cin >> t[i];
    sum = accumulate(t.begin(), t.end(), 0);
    cin >> m;
    for (int i=0; i<m; i++){
        cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>

#define R register
typedef long long ll;
int main()
{
	R int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	--n;
	R ll l = -1ll * n * d, r = -1ll * n * c;
	for (R int i = 0; i <= n; ++i)
	{
//		printf("%d %d\n", l, r);
		if (l <= b - a && b - a <= r) return puts("YES"), 0;
		l += d + c;
		r += d + c;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int T;
  R T;
  while(T--) {
    int n,m;
    cin >> n >> m;
    string s[n];
    rep(i,n) R s[i];
    rep(kk,26) {
      rep(k,26) {
        char c='A'+k;
        int x1=MAX,y1=MAX,x2=-1,y2=-1;
        rep(i,n) {
          rep(j,m) {
            if(s[i][j]==c) {
              x1=min(x1,i);
              y1=min(y1,j);
              x2=max(x2,i);
              y2=max(y2,j);
            }
          }
        }
        if(x1==MAX) continue;
        bool f=1;
        REP(i,x1,x2+1) {
          REP(j,y1,y2+1) {
            if(s[i][j]!=c&&s[i][j]!='?') f=0;
          }
        }
        if(f) {
          REP(i,x1,x2+1) {
            REP(j,y1,y2+1) s[i][j]='?';
          }
        }
      }
    }
    bool ck=1;
    rep(i,n) {
      rep(j,m) {
        if(isalpha(s[i][j])) ck=0;
      }
    }
    if(ck) pr("SAFE");
    else pr("SUSPICIOUS");
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1208
#include <iostream>
#include <cstring>

using namespace std;

int n;
int cnt[4040];

void setcnt() {
	memset(cnt, 0, sizeof(cnt));
	for (int i=0; i<=1000; i++) for (int j=0; j<=1000; j++) cnt[i+j]++;
}

void solve() {
	int ans = 0;
	for (int ab = 0; ab<=n; ab++) {
		ans += cnt[ab] * cnt[n-ab];
	}
	cout << ans << endl;
}

int main() {
	setcnt();
	
	while (cin>>n) {
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1184
## main

loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0 && k == 0

  sums = gets.split.map(&:to_i)
  ok = true

  n.times do
    bs = gets.split.map(&:to_i)
    for i in (0...k)
      sums[i] -= bs[i]
      ok = false if sums[i] < 0
    end
  end

  puts (ok ? 'Yes' : 'No')
end

Measured memory_bytes: 6128
a, b, c, d, e = 5.times.map { gets.to_i }
time = 0

condition = if a.negative?
              'frozen'
            else
              'raw'
            end

if condition == 'frozen'
  time += -a * c
  time += d
  time += e * b
end

time += e * (b - a) if condition == 'raw'

p time



Measured memory_bytes: 6880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  vector<bool> dp(1000001, true);
  vector<int> b(1000001, 0);
  set<int> set;
  rep(i, n)
  {
    cin >> A[i];
    b[A[i]]++;
    set.insert(A[i]);
  }
  int sum = 0;
  sort(A.begin(), A.end());
  for (int i : set)
  {
    for (int j = 2; j < 1000001; j++)
    {
      if (i * j > 1000001)
      {
        break;
      }
      dp[i * j] = false;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (b[A[i]] == 1 && dp[A[i]]) //同じ数があるだけでそれはだめ。
    {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

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

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

  if ( A*N >B ) {
    cout << B << endl;
    }
  else if ( N*A == B ) {
    cout << B << endl;
    }
  else if ( A*N < B ) {
    cout << A*N << endl;
    }
}

Measured memory_bytes: 3636
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

K = I()
A,B = MI()
for i in range(A,B+1):
    if i%K==0:
        print('OK')
        break
else:
    print('NG')


Measured memory_bytes: 71068
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=4e5+5;
ll a[N];

ll run(ll x){
    if(x%2==1)  return 0ll;
    ll ans=0;
    while(x%2==0){
        ans++;
        x/=2;
    }
    return ans;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll x;
        cin >> x;
        ans+=run(x);
    }
    cout <<ans << endl;
    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int W,H,N;cin>>W>>H>>N;
  vi x(N),y(N),a(N);
  rep(i,N)cin>>x[i]>>y[i]>>a[i];
  int lef=0,rig=W,dow=0,up=H;
  rep(i,N){
    if(a[i]==1)lef=max(x[i],lef);
    else if(a[i]==2)rig=min(x[i],rig);
    else if(a[i]==3)dow=max(y[i],dow);
    else if(a[i]==4)up=min(y[i],up);
  }
  if(rig-lef<=0 ||up-dow<=0)cout<<0<<endl;
  else cout<<(rig-lef)*(up-dow)<<endl;
  
}





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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

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


int main()
{
ll A, B, K;
cin >> A >> B >> K;
if(A <= K) {
  K = K - A;
  A = 0;
}else{
  A = A - K;
  K = 0;
}

B = B - K;
if(B < 0) B = 0;

cout << A << ' ' << B << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, m, c, ans = 0;
    string t;
    cin >> n >> m >> c;
    vector<int> bs(m);
    vector<vector<int>> as(n, vector<int>(m));
    for (int i = 0; i < m; i++) {
        cin >> bs[i];
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            cin >> as[i][j];
            sum += bs[j] * as[i][j];
        }
        if (sum + c > 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e,f,k,cn=0;
  cin>>a>>b>>c;
  cin>>k;
  for(int i=0;cn==0 && i<k;i++)
  {
    if(b>a && c>b)
    {
      cout<<"Yes";
      cn++;
      break;
    }
    if(b<=a)
    {
        b=b*2;
    }
    else if(b>a && c<=b)
    {
        c=c*2;
    }
  }
    if(b>a && c>b && cn==0)
    {
      cout<<"Yes";
    }
    else if(cn==0){
        cout<<"No";
    }
  
}


Measured memory_bytes: 3624
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program {
	static void Main(string[] args) {
    	int kumi = int.Parse(ReadLine());
        Dictionary<int, List<int>> dic = new Dictionary<int, List<int>>();
        for (int i = 0; i < kumi; i++) {
           var p = ReadLine().Split(' ').Select(int.Parse);
           dic.Add(i, new List<int>(p));
        }
        int result = 0;
        for (int j = 0; j < dic.Keys.Count; j++) {
			result += dic[j].Max() - dic[j].Min() + 1;
        }
    	WriteLine(result);
    }
}

Measured memory_bytes: 13408
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>

using namespace std;
 
int main() {
	int size;
  	cin >> size;
  	unordered_set<string> item_set;
  	copy_n(istream_iterator<string>(cin), size, inserter(item_set, item_set.begin()));
  	cout << item_set.size();
  	return 0;
}

Measured memory_bytes: 17632
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if n <= k:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T,K;
	cin >> T>>K;
	vector<int> v;
	for(int i = 0; i<T;i++)
	{
		int temp;
		cin >>temp;
		v.push_back(temp);
	}
	sort(v.begin(),v.end());
	ll sum = 0;
	for(int i = 0; i<K;i++)
	{
		sum += v[i];
	}
	cout <<sum;
}


Measured memory_bytes: 3660
(let ((n (read))
      (a (make-array 1 :element-type 'integer
                       :initial-element 0
                       :fill-pointer 1
                       :adjustable t))
      (ans 0))
  (loop for i from 1 upto n
        do (setf ans (read))
           (vector-push-extend (+ (aref a (- i 1)) ans) a))
  (sort a #'<)
  (setf ans 0)
  (let ((flg 0))
    (loop for i from 1 upto n
          do (cond ((eq (aref a (- i 1)) (aref a i)) (incf flg) (incf ans flg))
                   (t (setf flg 0)))))
  (princ ans))


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

using namespace std;

int main(int argc,char* argv[]){
	int N,count=0;
	string S;
	cin >> N;
	cin >> S;
	for(int i=0;i<N-1;i++){
		if(S[i]=='X'&&S[i+1]=='O'){
			count++;
			i++;
		}else if(S[i]=='O'&&S[i+1]=='X'){
			count++;
			i++;
		} 
	}
	cout << count << endl;
	return 0;
}


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

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

    int i;
    for(i = 0; i < n; i++) {
        cin >> h.at(i);
    }

    vector<double> diff(n);
    for(i = 0; i < n; i++) {
        if (a < t - h.at(i) * 0.006) {
            diff.at(i) = (t - h.at(i) * 0.006) - a;
        }
        else {
            diff.at(i) = a - (t - h.at(i) * 0.006);
        }
    }

    int ans = 0;
    for(i = 0; i < n - 1; i++) {
        if (diff.at(ans) > diff.at(i + 1)) {
            ans = i + 1;
        }
    }

    cout << ans + 1 << endl;

}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
 
    String s = sc.nextLine();
 	for(int i = 0; i < 3;i++){ 
    	System.out.print(s.charAt(i));
    }
    
  }
}

Measured memory_bytes: 35784
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int last = 0;
  int x = 0, y = 0;
  rep(i, N) {
    int t, tx, ty;
    cin >> t >> tx >> ty;
    int time = t-last;
    int dist = abs(tx-x)+abs(ty-y);
    if (dist > time || dist%2 != time%2) {
      cout << "No\n";
      return 0;
    }
    x = tx;
    y = ty;
    last = t;
  }
  cout << "Yes\n";
  return 0;
}


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

using namespace std;

struct Edge
{
    int u,v;

    Edge(){}
    Edge(int u,int v):u(u),v(v){}
}e[100010];

int fa[100010],siz[100010];
long long anss[100010];

int find(int x)
{
    return fa[x]?fa[x]=find(fa[x]):x;
}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        e[i]=Edge(u,v);
    }
    for(int i=1;i<=n;i++)
    {
        siz[i]=1;
    }
    long long ans=0;
    for(int i=1;i<=m;i++)
    {
        int now=m-i+1;
        int fau=find(e[now].u),fav=find(e[now].v);
        if(fau!=fav)
        {
            ans+=1ll*siz[fau]*siz[fav];
            fa[fau]=fav;
            siz[fav]+=siz[fau];
        }
        anss[now]=ans;
    }
    for(int i=2;i<=m;i++)
    {
        cout<<ans-anss[i]<<'\n';
    }
    cout<<1ll*n*(n-1)/2<<'\n';
}

Measured memory_bytes: 3712
n=int(input())
ans=1;
i = []
for a in input().split():
    i.append( int(a) )
    if (int(a)==0):
        print(0)
        exit(0)
for l in i:
    ans*=l
    if (ans>1000*1000*1000*1000*1000*1000):
        print(-1)
        exit(0)
print(ans)


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

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int>a (n);
  for (auto &x : a) {
    cin >> x;
  }
  vector<int>dp (n, 1e9 + 2);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      int cur = i + j;
      if (cur < n) {
        dp[cur] = min (dp[cur], dp[i] + abs (a[i] - a[cur]) );
      }
    }
  }
  cout << dp[n - 1];
  return 0;
}


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

using namespace std;

int main(){

    int A, B, T, nb = 0, c = 0;

    cin >> A >> B >> T;

    c = A;
    while(c <= T){
        nb += B;
        c += A;
    }

    cout << nb << endl;

    return 0;

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
//#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string s;
    char a[10] = {'k','e','y','e','n','c','e'};
    cin >> s;
    int n = s.size();
    if(s[0] == 'k' && s[1] == 'e' && s[2] == 'y' && s[3] == 'e' && s[4] == 'n' && s[5] == 'c' && s[6] == 'e'){
        cout << "YES\n";
    }   
    else if(s[n-1] == 'e' && s[n-2] == 'c' && s[n-3] == 'n' && s[n-4] == 'e' && s[n-5] == 'y' && s[n-6] == 'e' && s[n-7] == 'k') cout << "YES\n";
    else{
        int cnt = 0;
        rep(i,7){
            if(s[i] == a[i]) cnt++;
            else break;
        }
        for(int i = n - (7 - cnt);i < n;i++){
            if(s[i] == a[cnt]) cnt++;
            else{
                cout << "NO\n";
                return 0;
            }
        }
        cout << "YES\n";
    }   
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string s;
cin>>s;
sort(all(s));
s.erase(unique(all(s)),s.end());
if(s.size()==2)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <complex>
#include <vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<list>
#include <iterator>
using namespace std;
int main() {
	int N;
	char S;
	vector<char> ss;
	vector<int> ans;
	cin >> N;
	ss.resize(N);
	ans.resize(N);
	int first = 0;
	for (int i = 0; i < N; i++) {
		cin >> ss[i];
	}
	ans[0] = 0;
	for (int i = 1; i < N; i++) {
		if (ss[i] == 'E')ans[0] += 1;
	}


	for (int i = 1; i < N; i++) {
		int temp = 0;
		if (ss[i-1] == 'W')temp += 1;
		if (ss[i] == 'E')temp += -1;
		ans[i] = ans[i - 1] + temp;
	}

	int min = 5000000;

	for (int i = 0; i < N; i++) {
		if (min > ans[i])min = ans[i];
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1664