akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream
import java.math.BigDecimal
import java.math.BigInteger

fun main(args: Array<String>) = input.run {
    val n = nextInt();
    val a = nextInts(n)
    a.sort()
    var ans = 1
    var acc = 0L
    for (i in 0..n - 2) {
        acc += a[i]
        if (2 * acc >= a[i + 1]) {
            ans++;
        } else {
            ans = 1
        }
    }
    println(ans)
}

val input = FastScanner()

fun String.toBigInteger() = BigInteger(this)
fun String.toBigDecimal() = BigDecimal(this)

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun next(): String? {
        var c = skipWhitespace()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            do {
                append(c.toChar())
                c = read()
            } while (c > ' '.toInt())

            toString()
        }
    }

    fun nextLine(): String? {
        var c = read()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            while (c >= 0 && c != '\n'.toInt()) {
                append(c.toChar())
                c = read()
            }

            toString()
        }
    }

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()
    fun nextDouble() = next()?.toDouble() ?: 0.0
    fun nextBigInteger(): BigInteger = next()?.toBigInteger() ?: BigInteger.ZERO
    fun nextBigDecimal(): BigDecimal = next()?.toBigDecimal() ?: BigDecimal.ZERO

    fun nextInts(n: Int) = IntArray(n) { nextInt() }
    fun nextLongs(n: Int) = LongArray(n) { nextLong() }
    fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }
    fun nextBigIntegers(n: Int) = Array<BigInteger>(n) { nextBigInteger() }
    fun nextBigDecimals(n: Int) = Array<BigDecimal>(n) { nextBigDecimal() }

    fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }
    fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }
    fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }
    fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }
    fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}


Measured memory_bytes: 26348
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	int rec = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != i + 1) {
			rec++;
		}
	}
	if (rec == 2 || rec == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0039
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var Ds = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int result = 0;

            for (int i = 0; i < Ds.Count - 1; i++)
            {
                for (int j = i + 1; j < Ds.Count; j++)
                {
                    result += Ds[i] * Ds[j];
                }
            }

            Console.WriteLine(result);
        }
    }
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int x, y, z;
  int ans = 0;
  
  for (int i = 0; i < k+1; i++) {
    for (int j = 0; j < k+1; j++) {
      int tmp = s - i - j;
      if (tmp >= 0 && tmp < k+1) ans++;
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MAX=1e6+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
void solve(){
    string a;
    cin>>a;
    int ans=0;
    for(int i=0;i<a.length();i++){
        ans+=a[i]-'0';
        ans%=9;
    }
    if(ans%9) cout<<"No\n";
    else cout<<"Yes\n";
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3692
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var height = new int[10];
            for(int i=0;i < 10; ++i) {
                height[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(height);
            for(int i=0;i < 3; ++i) {
                Console.WriteLine(height[9 - i]);
            }
        }
    }
}

Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve_old(long long N, std::string S){
    ll len = S.length();
    // debg(len);
    for (ll i = 0; i < len; i++) {
        S[i] = S[i]+N;
        if(S[i]>'Z'){
            // S[i] = S[i]-N;
            ll r = (S[i]-'A')%26;
            S[i] = 'A'+r;
        }
    }
    cout << S << "\n";
}

void solve(long long N, std::string S){
    for (ll i = 0; i < S.length(); i++) {
        S[i] = 'A'+(S[i]+N-'A')%26;
    }
    cout << S << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,d,e;
   cin>>a;
   b=a/100;
   c=a%100;
   d=a%1000;
   e=d/10;
   if(b%11==0||c%11==0||e%11==0){
   cout<<"Bad"<<endl;
   }
   else{
   cout<<"Good"<<endl;
   }
   

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> ipair;
bool lP(const ipair& l, const ipair& r){return l.first < r.first;}

int main(){
  int N, M; cin>>N>>M;
  vector<pair<ll, ll>> vi;
  REP(i,N){
    ll a, b;
    cin>>a>>b;
    vi.push_back(pair<ll, ll>(a, b));
  }

  sort(vi.begin(), vi.end(), lP);

  ll ans=0;
  for(vector<ipair>::iterator it=vi.begin(); it!= vi.end(); ++it){
    if(it->second < M){
      ans += it->first * it->second;
      M -= it->second;
    }else{
      ans += it->first * M;
      break;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

		int D = in.nextInt();
		int[] c = new int[26];
		int[][] s = new int[D][26];
		for (int i=0;i<26;i++) {
			c[i] = in.nextInt();
		}
		for (int i=0;i<D;i++) {
			for (int j=0;j<26;j++) {
				s[i][j] = in.nextInt();
			}
		}
		long tmp = 0L;
		int[] before_ind = new int[26];
		ArrayList<TreeSet<Integer>> list = new ArrayList<TreeSet<Integer>>();
		for (int i=0;i<26;i++) {
			TreeSet<Integer> add = new TreeSet<Integer>();
			add.add(-1);
			add.add(D);
			list.add(add);
		}
		Arrays.fill(before_ind, -1);
		int[] t = new int[D];
		for (int i=0;i<D;i++) {
			t[i] = in.nextInt()-1;
			list.get(t[i]).add(i);
			for (int j=0;j<26;j++) {
				if (j != t[i]) tmp -= (long)c[j]*(i-before_ind[j]);
				else {
					tmp += s[i][j];
					before_ind[j] = i;
				}
			}
		}
		int M = in.nextInt();
		for (int i=0;i<M;i++) {
			int d = in.nextInt()-1;
			int q = in.nextInt()-1;
			list.get(t[d]).remove(d);
			list.get(q).add(d);

			int high_d_1 = list.get(t[d]).higher(d);
			int low_d_1 = list.get(t[d]).lower(d);
			int high_d_2 = list.get(q).higher(d);
			int low_d_2 = list.get(q).lower(d);

			tmp -= (long)c[t[d]]*(high_d_1-d)*(d-low_d_1);
			tmp += (long)c[q]*(high_d_2-d)*(d-low_d_2);

			tmp -= s[d][t[d]];
			tmp += s[d][q];

			long minus = (long)c[t[d]]*(high_d_1-d)*(d-low_d_1);
			long plus = (long)c[q]*(high_d_2-d)*(d-low_d_2);

			t[d] = q;
			out.println(tmp);
		}

		out.close();
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 55400
#!/usr/bin/python

import sys
from pprint import pprint

import math

def nCr(n, r):
    v = 10**9 + 7
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def cmb_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        numerator = 1
        for i in range(1, r + 1):
            numerator = (numerator * i) % mod
        return denominator * pow(numerator, mod - 2, mod) % mod 

x, y = map(int, sys.stdin.readline().strip().split(" "))

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

n = (2*y - x) // 3
m = (2*x - y) // 3

if n < 0 or m < 0:
    print(0)
    sys.exit()

# print(n, m)
# print(nCr(n+m, n) % (10**9+7))
print(cmb_mod(n + m, n, 10**9 + 7))

Measured memory_bytes: 38768
#include <stdio.h>
//#define DEBUG

int main (void){

	/*????????????????????????????????\?????§?????¢??°?????§??????????????§
	 main??¢??°?????§2?¬????????????¨?????????????????????*/


		char str[12] = {};
		int map[14][14] = {{}};
		int i = 0 ;
		int j = 0 ;

		char ch = 0 ;

		while (1){
		int flag[74] ={};
		int label = 1;
		int counter = 0 ;
		/*??°??????????????????*/
/*		if(scanf("%c",&ch) == EOF){
			return 0;
		}*/

		for( i = 0 ; i < 12 ; i++){
				if(scanf("%s",str) == EOF){
					return 0;
				}
				for ( j = 0 ; j < 12 ; j++){
					map[i+1][j+1] = str[j] - '0';
				}
		}



		for(i = 0 ; i < 14 ; i++){
			for( j = 0 ; j < 14 ; j++){
				if(map[i][j]){			//?????°?????£??????
					if(!map[i-1][j] && !map[i][j-1]){	//????????????????????£?????????
						label++;					//??????????????´??°????????????????????£??\??????
						map[i][j] = label ;
						flag[label] = 1 ;				//??????????????¨????????°????????????
					}
					else if(map[i-1][j] && !map[i][j-1]){ //???????????????
						map[i][j] = map[i-1][j];
					}
					else if(!map[i-1][j] && map[i][j-1]){	//???????????????
						map[i][j] = map[i][j-1];
					}else if(map[i-1][j] && map[i][j-1]){	//????????????????????£??????
						map[i][j] = map[i-1][j];			//?????¨?????????????????¨
						if(map[i-1][j] < map[i][j-1]){		//?????????????°?????????´???
							flag[(map[i][j-1])] = 0;				//???????????£?????????????????????????????°????¶????
						}
						if(map[i-1][j] > map[i][j-1]){		//?????????????°?????????´???
							flag[(map[i-1][j])] = 0;				//???????????£?????????????????????????????°????¶????
							}
						/*???????????????????????????????????????????????§nop*/
					}

				}
			}
		}


#ifdef DEBUG
		//??°????????¶????????¨????????????
		for(i = 0 ; i < 14 ; i++){
			for( j = 0 ; j < 14 ; j++){
				printf("%2d",map[i][j]);
			}
			printf("\n");
		}
#endif
		/*????????°?????°??????*/
		for( i = 0 ; i < 74 ; i++){
			if(flag[i]){
				counter++;
			}
		}
		printf("%d\n",counter);


		if(ch == -1 ){
			return 0;
		}

//		printf("%d\n",ch);		//\n?????????????????????10 ????§????????????????32
	};
	return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int i = 0;
        while (true) {
            i++;
            if ((360 * i) % X == 0) {
                System.out.println((360 * i) / X);
                return;
            }
        }
    }
}


Measured memory_bytes: 27040
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

const ll MAX = 1e6;

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<ll> line(n);
	foreach(i, line)cin>>i;

	ll insum = 0;
	foreach(i, line)insum += i;

	auto func = [&](ll num){
		vector<ll> nd;
		ll dsum = 0;
		foreach(i, line){
			ll d = i + (MAX*100) / num * num;
			d%=num;
			nd.push_back(d);
			dsum += num - d;
		}
		sort(all(nd));
		ll sum = 0;
		foreach(i, nd){
			sum += i;
			dsum -= num - i;
			if(dsum<=sum&&sum<=k)return true;
		}
		return false;
	};

	ll ans = 0;

	for(int i=1;i*i<=insum;++i){
		if(insum%i)continue;
		if(func(i))chmax(ans, i);
		if(func(insum/i))chmax(ans, insum/i);
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

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

    if (A + B >= C) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}


Measured memory_bytes: 256
# N = int(input())
N, M = map(int, input().split())
# L = list(map(int, input().split()))

L = [0] * (N + 1)

for m in range(M):
    l, r = map(int, input().split())
    L[l - 1] += 1
    L[r] -= 1

for i in range(len(L) - 1):
    L[i + 1] += L[i]

print(L.count(M))


Measured memory_bytes: 6900
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  ll ans=0;
  FOR(i,0,n){
    ci(A[i])
  }
  
  FOR(i,0,n){
    FOR(j,1,31){
      if(A[i]%2==0){
        ans++;
        A[i]/=2;
      }
      else{
        break;
      }
      }
  }
  co(ans)
}


Measured memory_bytes: 384
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;}
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

/* }}} */

const int MAX = 1e6;
bool prime[MAX + 1];

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

  fill(prime, prime + MAX, true);
  prime[0] = prime[1] = false;

  for (int i = 2; i <= MAX; i++){
    if (prime[i]){
      for (int j = i + i; j <= MAX; j += i){
        if (prime[j]) prime[j] = false;
      }
    }
  }

  int a, d, n;
  while (cin >> a >> d >> n, a || d || n){
    for (int i = a, j = 0; j < n; i += d){
      if (prime[i]){
        j++;
        if (j == n){
          print(i);
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 2172
#include<stdio.h>
#include<math.h>
int n;
void koch(double p1x, double p1y, double p2x, double p2y, int c){
  double sx, sy, tx, ty, ux, uy;
  if(c != 0){
    sx = (2 * p1x + p2x) / 3;
    sy = (2 * p1y + p2y) / 3;
    tx = (p1x + 2 * p2x) / 3;
    ty = (p1y + 2 * p2y) / 3;
    ux = sx + (tx - sx) * cos(M_PI/3) - (ty - sy) * sin(M_PI/3);
    uy = sy + (tx - sx) * sin(M_PI/3) + (ty - sy) * cos(M_PI/3);

    koch(p1x, p1y, sx, sy, c - 1);
    printf("%f %f\n", sx, sy);
    koch(sx, sy, ux, uy, c - 1);
    printf("%f %f\n", ux, uy);
    koch(ux, uy, tx, ty, c - 1);
    printf("%f %f\n", tx, ty);
    koch(tx, ty, p2x, p2y, c - 1);
  }
}

int main(){
  scanf("%d", &n);
  printf("%f %f\n", 0.0, 0.0);
  koch(0.0, 0.0, 100.0, 0.0, n);
  printf("%f %f\n", 100.0, 0.0);
  return 0;
}

Measured memory_bytes: 636
#!/usr/bin
# -*- coding="utf-8" -*-
 
K = int(input())
if K >= 50:
  N = 50
  a = K % N
  if a == 0:
    n = [K // N + 49] * N
  else:
    n = [K // N + (49 - a)] * N
    for i in range(a):
      n[i] = n[i] + N
elif K == 0:
  N = 2
  n = ["1", "1"]
else:
  N = K + 1
  n = [0] * N
  n[0] = K**2 + K*2
n = ' '.join(list(map(str, n)))
print(N)
print(n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  for (int X=0; X<=N; X++) {
    if (floor(1.08*X)==N) {
      ans=X;
    }
  }
  if (ans==0) {
    cout << ":(" << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3532
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		set<int> Set;
		vector<int> ID(N);
		map<int, unsigned long long int> Map;
		bool Flag = false;
		unsigned long long int b, c;
		for(int i = 0; i < N; ++i)
		{
			cin >> ID[i] >> b >> c;
			Map[ID[i]] += b * c;
		}
		for(int i = 0; i < N; ++i)
		{
			if(Map[ID[i]] >= 1000000)
			{
				if(!Set.count(ID[i]))
				{
					cout << ID[i] << endl;
					Set.insert(ID[i]);
					Flag = true;
				}
			}
		}
		if(!Flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
	string s;
	int jud = 0;
	cin >> s;
	for(int i = 0;i < sizeof(s) - 1;i++){
		if(s[i] == 'A'){
			if(s[i + 1] == 'C'){
				cout << "Yes" << endl;
				jud = 1;
				break;
			}
		}
	}
	if(jud != 1){
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)420;

int main(void) {
   ll N;
   cin>>N;
   vector<ll> T[N];
   vector<ll> F[N];
   rep(i,0,N) {
      ll a;
      cin>>a;
      rep(j,0,a) {
         ll x,y;
         cin>>x>>y;
         if (y==1) T[i].push_back(x-1);
         else F[i].push_back(x-1);
      }
   }
   ll ans = 0;
   rep(i, 0, 1<<N) {
      int stat[N];
      rep(j,0,N) stat[j] = (i>>j)%2;
      bool flag = true;
      rep(j,0,N) {
         if (!stat[j]) continue;
         for (auto el: T[j]) {
            if (!stat[el]) {
               flag = false;
               break;
            }
         }
         for (auto el: F[j]) {
            if (stat[el]) {
               flag = false;
               break;
            }
         }
         if (!flag) break;
      }
      if (flag) {
         ll nas_this = 0;
         // rep(j,0,N)cout<<stat[j]<<" ";
         // cout<<endl;
         rep(j,0,N) nas_this += stat[j];
         chmax(ans,nas_this);
      }
   }
   cout<<ans<<endl;




   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[4];
string s,h;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>f[1]>>f[2]>>f[3];
	sort(f+1,f+4);
	if(f[1]==f[2]){
		if(f[2]!=f[3]){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}else{
		if(f[1]==f[3]||f[2]==f[3]){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}
	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 REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    vector<string> vc;
    map<string, int> cnt;
    while( cin >> S ){
        vc.emplace_back( S );
        cnt[ S ]++;
    }
    int MAX{}, MAX2{};
    string res, res2;
    for( const auto &x: cnt )
    {
        if( MAX < x.second )
        {
            MAX = x.second;
            res = x.first;
        }
        if( MAX2 < (int)(x.first).size() )
        {
            MAX2 = (int)(x.first).size();
            res2 = x.first;
        }
    }
    cout << res << " " << res2 << endl;
    return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>

int main(){
	long long int N,M;
	scanf("%lld%lld",&N,&M);
	if(N==1 && M==1){
		printf("1\n");
	}else if(N==1 && M>1){
		printf("%lld\n",M-2);
	}else if(N>1 && M==1){
		printf("%lld",N-2);
	}else{
		printf("%lld\n",(M-2)*(N-2));
	}
	return 0;
}

Measured memory_bytes: 128
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
string s;
int q,f;
char c;
bool r;
signed main(){
	cin>>s,Rd(q);
	list<char>l(s.begin(),s.end());
	while(q--){
		if(read()==1)r^=1;
		else{
			f=read()-1,cin>>c;
			f^r?l.push_back(c):l.push_front(c);
		}
	}
	if(r)reverse(l.begin(),l.end());
	for(char i:l)Pc(i);
	exit(0);
}

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

int main() {
    int N, M; cin >> N >> M;
    int data[M] = {0};
    fill_n(data, M, 0);
    for (int i = 0; i < N; i++) {
        int K; cin >> K;
        for (int j = 0; j < K; j++) {
            int A; cin >> A;
            data[A - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (data[i] == N) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    for(int i=1;i<=5;i++)
    {
        int x;
        cin>>x;
        if(x!=i)
            cout<<i;
    }
}


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

using namespace std;

const int MAXN = (int)1e5;

int N, happiness[MAXN][3], dp[MAXN][3]; //dp[i][j] returns maximum happiness on day i with activity j done on day i

int main()
{
    cin >> N;
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin >> happiness[i][j];
        }
    }
    dp[0][0] = happiness[0][0];
    dp[0][1] = happiness[0][1];
    dp[0][2] = happiness[0][2];

    //dp[i][a] = max(dp[i-1][b], dp[i-1][c]) + happiness[i][a];
    for(int i=1; i<N; i++)
    {
        for(int j=0; j<3; j++)
        {
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])+happiness[i][j];
        }
    }
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
  int x;
  int i;
  int j;
  scanf("%d",&x);
  for(i=0;;i++){
    for(j=2;j<x+1;j++){if(x%j==0){break;}}if(j!=x){x=x+1;}else{
      break;};}
   printf("%d",x);
   return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
int sti(string s){
    stringstream rohit(s);
    int x=0; rohit>>x;
    return x;
}
int sti(char s){
    int x=(int)s-48;
    return x;
}
bool iseven(int t){
    if(t%2==0)
        return true;
    else
        return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    int i=sti(s);
    if(s.size()==1){
        int res=i/5;
        cout<<res*5;
    }
    else{
        int sz=s.size();
        int res=i/500;
        int ans=res*1000;
        int ext=i-(500*res);
        res=ext/5;
        ans+=res*5;
        cout<<ans;
    }
    return 0;
}


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

int main(){
	string S;
	cin >> S;
	int count0 = 0, count1 = 0;
	for(int i = 0; i < S.size(); i++){
		if(S.at(i) == '0')
			count0++;
		else
			count1++;
	}
	cout << 2*min(count0,count1) << endl;
	return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    int prev;
    cin >> prev;
    FOR(i,1,n){
        int next;
        cin >> next;
        ans += min((next - prev)*(ll)a, (ll)b);
        prev = next;
    }
    ANS(ans);
	return 0;
}


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

typedef long long ll;
#define MOD 1000000007
int main()
{
    ll h, w;
    char ch;
    cin>>h>>w;
    ll dp[h][w];
    char matrix[h][w];
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>matrix[i][j];
    bool flag = true;
    for(int i=0; i<w; i++)
    {
        if(matrix[0][i] == '.' && flag)
            dp[0][i] = 1;
        else
        {
            flag = false;
            dp[0][i] = 0;
        }
    }
    flag = true;
    for(int i=0; i<h; i++)
    {
        if(matrix[i][0] == '.' && flag)
            dp[i][0] = 1;
        else
        {
            flag = false;
            dp[i][0] = 0;
        }
    }
    for(ll i=1; i<h; i++)
    {
        for(ll j=1; j<w; j++)
        {
            ch = matrix[i][j];
            if(ch == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }
    cout<<dp[h-1][w-1];
}


Measured memory_bytes: 9088
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  while (true) {
  int h;
  cin >> h;
  if (h == 0) break;
  int array[h][5];
  int sco = 0;
  
  for (size_t i = 0; i < h; i++)
    for (size_t j = 0; j < 5; j++)
      cin >> array[i][j];

  int num;
  //for (size_t t = 0; t < 5; t++) {
  while (true) {
    for (size_t i = 0; i < h; i++) {
      int tmp =  array[i][0];
      int count = 0;
      int start;
      num = 0;
      for (size_t j = 0; j < 5; j++) {
	if (tmp == array[i][j]) {
	  if (!count) 
	    start = j;
	  count++;
	  num = tmp;
	} else if (count < 3) {
	  start = j;
	  tmp = array[i][j];
	  count = 1;
	  num = 0;
	} else
	  break;
      }
      if (count > 2 && num > 0) {
	for (int j = start; j < start + count; j++)
	  if(num == array[i][j])
	    array[i][j] = 0;
	//cout << "num::" << num << endl;
	//cout << "count::" << count << endl;
	  sco += num*count;
      }
    }
    bool flag = true;
    for (size_t i = 0; i < h; i++)
      for (size_t j = 0; j < 5; j++)
	if (array[i][j] == 0)
	  flag = false;

    if (flag) break;
    
    /*
    for (size_t i = 0; i < h; i++) {
      for (size_t j = 0; j < 5; j++)
	cout << array[i][j] << " ";
      cout << endl;
    } cout << endl;
    */

    /*
  for (int k = h-1; k > 0; k--) {
    for (size_t i = 0; i < 5; ) {
      if (array[k][i] == 0) {
	int nzc=0;
	for (int j = k; j >= 0; --j) {
	  if (array[j][i] != 0)
	    nzc++;
	}
	if (nzc != 0) {
	  for (int j = k; j > 0; j--) {
	    array[j][i] = array[j-1][i];	  
	  }
	  array[0][i] = 0;
	}
	else
	  i++;
      }
      else
	i++;
    }
  }
    */

    for (size_t i = 0; i < 10; i++)
    for (size_t k = 0; k < h-1; k++) {
      for (size_t j = 0; j < 5; j++) {
	if (array[k][j] > 0 && array[k+1][j] == 0) {
	  array[k+1][j] = array[k][j];
	  array[k][j] = 0;
	}
      }
    }

   for (size_t i = 0; i < h; i++) 
    for (size_t j = 0; j < 5; j++)
      if (array[i][j] == 0)
	array[i][j] = -1;
   
  
   /*
  for (size_t i = 0; i < h; i++) {
    for (size_t j = 0; j < 5; j++)
      if (array[i][j] == -1)
	cout << "  ";
      else 
	cout << array[i][j] << " ";
    cout << endl;
  } cout << endl;
   */
  
  }
  
  cout << sco << endl;
  }
  return 0;
  
}

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

int MOD;

struct modnum {
private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

using num = modnum;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n >> MOD;
	vector<vector<num> > dp(3*n+1, vector<num>(n+1, 0));
	dp[0][0] = 1;
	for(int i = 0; i <= 3*n; i++){
		if(i + 1 <= 3*n){
			for(int f = 0; f <= n; f++){
				dp[i+1][f] += dp[i][f];
			}
		}
		if(i + 2 <= 3*n){
			for(int f = 0; f < n; f++){
				dp[i+2][f+1] += dp[i][f] * (3*n - (i+1));
			}
		}
		if(i + 3 <= 3*n){
			for(int f = 0; f < n; f++){
				dp[i+3][f+1] += dp[i][f] * (3*n - (i+1)) * (3*n - (i+2));
			}
		}
	}
	num ans = 0;
	for(int f = 0; f <= n; f++) ans += dp[3*n][f];
	cout << ans << '\n';
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main() {
  int N,M; cin >> N >> M;
  vector<int> v(M);
  ll s = 0;

  rep(i,M){
     cin >> v[i];
     s+=v[i];
  }
  if(s <= N) cout << N-s << endl;
  else cout << -1 << endl;

}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

ll lcm(int a, int b){
    return (ll)a * b / __gcd(a, b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    --a;
    cout << (b - b/c - b/d + b/e) - (a - a/c - a/d + a/e) << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import string


S = input()
T = input()

td = defaultdict(set)
for i, s in enumerate(T):
    td[s].add(i)

for c in td.keys():
    index = td[c]
    s = set()
    for i in index:
        s.add(S[i])
    if len(s) != 1:
        print("No")
        exit()

sd = defaultdict(set)
for i, s in enumerate(S):
    sd[s].add(i)

for c in sd.keys():
    index = sd[c]
    s = set()
    for i in index:
        s.add(T[i])
    if len(s) != 1:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 37708
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    vector< pair<int,int> > vpii;
    for(int i = 0; i < n; ++i){
        int a, b; cin >> a >> b;
        pair<int,int> p = {b,a};
        vpii.push_back(p);
    }
    sort(vpii.begin(), vpii.end());
    bool ok = 1;
    int curtime = 0;
    for(int i = 0; i < n; ++i){
        curtime += vpii[i].second;
        if(curtime > vpii[i].first){
            ok &= 0;
        }
    }
    puts(ok?"Yes\n":"No\n");
    return 0;  
}

Measured memory_bytes: 5328
import java.util.Scanner;

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

        double x1 = Double.parseDouble(sc.next());
        double y1 = Double.parseDouble(sc.next());
        double x2 = Double.parseDouble(sc.next());
        double y2 = Double.parseDouble(sc.next());

        System.out.println(Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)));
    }
}

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

int H,W;
int dx[2][6] ={
	{-1,0,1,0,-1,-1},
	{0,1,1,1,0,-1}
};
int dy[] = {-1,-1,0,1,1,0} ;
int table[110][110] = {};

void search( int y , int x ){
	
	table[y][x] = -1 ;
	
	for( int k=0 ; k<6 ; k++ ){
		if( table[y+dy[k]][x+dx[y%2][k]] == -6 ){
			search( y+dy[k] , x+dx[y%2][k] ) ;
		}
	}
}

int main(){
	
	cin >> W >> H;
	for( int i=0 ; i<=H+1 ; i++ ){
		for( int j=0 ; j<=W+1 ; j++ ){
			if( !i || !j || i==H+1 || j==W+1 ){
				table[i][j] == -1 ;
			}else cin >> table[i][j] ;
			if( table[i][j] == 0 ) table[i][j] = -6;
			if( table[i][j] == 1 ) table[i][j] =  6;
		}
	}
	
	for( int j=1 ; j<=W ; j++ ){
		if( table[1][j] == -6 ) search( 1 , j ) ;
		if( table[H][j] == -6 ) search( H , j ) ;
	}
	for( int i=1 ; i<=H ; i++ ){
		if( table[i][1] == -6 ) search( i , 1 ) ;
		if( table[i][W] == -6 ) search( i , W ) ;
	}
	
	int ans = 0;
	for( int i=1 ; i<=H ; i++ ){
		for( int j=1 ; j<=W ; j++ ){
			if( table[i][j] == 6 ){
				for( int k=0 ; k<6 ;  k++ ){
					if( table[i+dy[k]][j+dx[i%2][k]] >= 0 ){
						table[i][j]-- ;
					}
					else if( table[i+dy[k]][j+dx[i%2][k]] == -6 ){
						table[i][j]-- ;
					}
				}
				ans += table[i][j] ;
			}
		}
	}
	/*
	for( int i=0 ; i<=H+1 ; i++ ){
		if( i%2 ) cout << " " ;
		for( int j=0 ; j<=W+1 ; j++ ){
			if(table[i][j]>=0)  cout << table[i][j] << " " ;
			else if(table[i][j] == -1) cout << "- " ;
			else cout << "# " ;
		}
		cout << endl ;
	}
	*/
	cout << ans << endl ;
	
	return 0;
}

Measured memory_bytes: 1508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p,q,r;
  cin>>p>>q>>r;
  if(p>q){
    swap(p,q);
  }
  if(q>r){
    swap(q,r);
  }
  if(p>q){
    swap(p,q);
  }
  cout<<p+q<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    int[int] D;
    foreach (a; A) D[a] += 1;

    auto B = D.values.array;
    B.sort!"a > b";
    auto M = B.length.to!int;
    auto sm = B.sum;
    auto mx = B.reduce!max;
    auto pq = new BinaryHeap!(Array!int, "a < b");
    foreach (b; B) pq.insert(b);

    auto C = new long[](N+1);
    foreach (i; 0..M) {
        C[0] += 1;
        C[B[i]] -= 1;
    }
    foreach (i; 0..N) C[i+1] += C[i];
    foreach (i; 0..N) C[i+1] += C[i];
    C = 0 ~ C;

    auto ans = new long[](N+1);
    foreach (i; 1..N+1) {
        auto x = (C[i] / i).to!int;
        ans[x] = max(ans[x], i);
    }

    foreach_reverse (i; 1..N+1) ans[i-1] = max(ans[i-1], ans[i]);
    ans[1..N+1].each!writeln;
}


Measured memory_bytes: 30384
X, Y = map(int,input().split())

a = 0
B = Y//4
flag = 0
for b in range(B,-1,-1):
    a = X-b
    ans = a * 2 + b * 4
    if ans == Y and (a+b) == X and a>=0:
        flag = 1
        print('Yes')
        break

if flag == 0:
    print('No')

Measured memory_bytes: 9188
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc123_d
import itertools
import math

# input
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# A = range(1000)
# B = range(1000)
# C = range(1000)
# getans
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
arr = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            arr.append(A[i]+B[j]+C[k])
#print(len(arr))
arr.sort(reverse=True)
# output
ans = '\n'.join(map(str, arr[:K]))
print(ans)


Measured memory_bytes: 8792
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    A=list(map(int,readline().split()))
    
    A.sort(reverse=True)
    S=sum(A)
    if 4*M*A[M-1]>=S:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

int dfs(int d,int g,vector<int> p,vector<int> sum){
    //問題d以下の中からg以下にする必要問題数
    if(d<=0){
        return pow(10,9);
    }
    int n=min(g/(100*d),p[d-1]);
    int s=100*d*n;
    if(n==p[d-1]){
        s=sum[d-1];
    }
    if(g>s){
        n+=dfs(d-1,g-s,p,sum);
    }
    return min(n,dfs(d-1,g,p,sum));
}

int main(){
    int d,g;
    cin>>d>>g;
    vector<int> p(d);
    vector<int> c(d);
    vector<int> sum(d);
    rep(i,d){
        cin>>p[i]>>c[i];
        sum[i]=c[i]+p[i]*(i+1)*100;
    }
    cout<<dfs(d,g,p,sum)<<endl;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

int A[3][3] = {0};
int b[101] = {0};

int main()
{
	int N = 0, i = 0, ans = 0;
	for (i = 0; i < 3; i++) {
		scanf("%d %d %d", &A[i][0], &A[i][1], &A[i][2]);
	}
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &b[i]);
	}

	for (i = 0; i < N; i++) {
		int j = 0, k = 0;
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 3; k++) {
				if (A[j][k] == b[i]) {
					A[j][k] = 0xff;
				}
			}
		}
	}


	for (i = 0; i < 3; i++) {
		if ((A[i][0] == 0xff) && (A[i][1] == 0xff) && (A[i][2] == 0xff)) {
			ans = 1;
		}
	}
	for (i = 0; i < 3; i++) {
		if ((A[0][i] == 0xff) && (A[1][i] == 0xff) && (A[2][i] == 0xff)) {
			ans = 1;
		}
	}
	if ((A[0][0] == 0xff) && (A[1][1] == 0xff) && (A[2][2] == 0xff)) {
		ans = 1;
	}
	if ((A[0][2] == 0xff) && (A[1][1] == 0xff) && (A[2][0] == 0xff)) {
		ans = 1;
	}
	if (ans == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
    return 0;
}


Measured memory_bytes: 128