akhauriyash/Code-Regression huggingface dataset:
n,m,x,y = map(int,input().split())
lix = [int(xn) for xn in input().split()]
liy = [int(yn) for yn in input().split()]
cnt = 0
if y - x < 1:
    cnt = 0
else:
    for i in range(x + 1, y + 1):
        if min(liy) - i >= 0 and i - max(lix) >= 1:
            cnt = 1
        
if cnt == 1:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());

		String s = sc.next();

		sc.close();

		String ret = "";

		for(int i = 0;i < s.length();i++) {
			char c = (char)(s.charAt(i) + N);
			if(c > 'Z') {
				c -= 26;
			}
			ret += c;
		}

		System.out.println(ret);

//		FastScanner fs = new FastScanner();
//		int N = fs.nextInt();


	}
}

//import java.io.IOException;
//import java.io.InputStream;
//import java.util.NoSuchElementException;
//
//class FastScanner {
//  private final InputStream in = System.in;
//  private final byte[] buffer = new byte[1024];
//  private int ptr = 0;
//  private int buflen = 0;
//  private boolean hasNextByte() {
//      if (ptr < buflen) {
//          return true;
//      }else{
//          ptr = 0;
//          try {
//              buflen = in.read(buffer);
//          } catch (IOException e) {
//              e.printStackTrace();
//          }
//          if (buflen <= 0) {
//              return false;
//          }
//      }
//      return true;
//  }
//  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
//  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
//  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
//  public String next() {
//      if (!hasNext()) throw new NoSuchElementException();
//      StringBuilder sb = new StringBuilder();
//      int b = readByte();
//      while(isPrintableChar(b)) {
//          sb.appendCodePoint(b);
//          b = readByte();
//      }
//      return sb.toString();
//  }
//  public long nextLong() {
//      if (!hasNext()) throw new NoSuchElementException();
//      long n = 0;
//      boolean minus = false;
//      int b = readByte();
//      if (b == '-') {
//          minus = true;
//          b = readByte();
//      }
//      if (b < '0' || '9' < b) {
//          throw new NumberFormatException();
//      }
//      while(true){
//          if ('0' <= b && b <= '9') {
//              n *= 10;
//              n += b - '0';
//          }else if(b == -1 || !isPrintableChar(b)){
//              return minus ? -n : n;
//          }else{
//              throw new NumberFormatException();
//          }
//          b = readByte();
//      }
//  }
//  public int nextInt() {
//      long nl = nextLong();
//      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
//      return (int) nl;
//  }
//  public double nextDouble() { return Double.parseDouble(next());}
//}


Measured memory_bytes: 148152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> tonari[200010];
vector<int> cnt(200010,0),ans(200010,0);

void dfs(int n,int par){
    //cout<<n<<endl;
    if(par>=0) ans[n]+=ans[par];
    ans[n]+=cnt[n];
    for (auto i:tonari[n]){
        if(i==par) continue;
        dfs(i,n);
    }
}

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

    for (int i = 0; i < Q; ++i) {
        cin>>a>>b;
        --a;
        cnt[a]+=b;
    }

    dfs(0,-1);

    for (int i = 0; i < N; ++i) {
        cout<<ans[i]<<" ";
    }
    cout<<"\n";
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int A[200001],dp[200001];
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    rep(i,k+1){
        dp[i]=0;
        rep(j,n) if(i-A[j]>=0&&!dp[i-A[j]]) dp[i]=1;
    }
    if(dp[k]) cout<<"First"<<"\n";
    else cout<<"Second"<<"\n";
}

Measured memory_bytes: 640
//ABC054-D「Mixing Experiment」
#include<iostream>
using namespace std;

const int INF=1<<29;
int N,ma,mb;
int a[45],b[45],c[45];

//dpテーブル
//dp[i][j][k]:i種類目までの薬品を見たとき、Aがjグラム、Bがkグラム含むときの価格の最小値
int dp[45][410][410];

int main(){
    
    cin>>N>>ma>>mb;
    for(int i=0; i<N; i++)cin>>a[i]>>b[i]>>c[i];
    
    //dp初期条件:dp[i][0][0]=0
    for(int i=0; i<45; i++)
        for(int j=0; j<410; j++)
            for(int k=0; k<410; k++)dp[i][j][k]=INF;
    for(int i=0; i<N;i++)dp[i][0][0]=0;
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=400; j++){
            for(int k=0; k<=400; k++){
                if(j-a[i]>=0 && k-b[i]>=0){
                    dp[i+1][j][k]=min(dp[i][j-a[i]][k-b[i]]+c[i],dp[i][j][k]);
                }else dp[i+1][j][k]=dp[i][j][k];
            }
        }
    }
    int ans=INF;
    for(int l=1; l*max(ma,mb)<=400; l++){
        ans=min(ans,dp[N][l*ma][l*mb]);
    }
    
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 29824
def main():
    from collections import Counter

    N = int(input())

    p = [0] * (N + 1)
    for x in range(2, N + 1):
        d = 2
        cnt = 0
        while x % d == 0:
            x //= d
            cnt += 1
        p[d] += cnt

        d = 3
        while x > 1:
            cnt = 0
            while x % d == 0:
                x //= d
                cnt += 1
            p[d] += cnt
            d += 2

    ctr = Counter(p)

    def count(n):
        ret = 0
        for pw, cnt in ctr.items():
            if pw >= n - 1:
                ret += cnt
        return ret

    def choose(n, r):
        x, y = 1, 1
        for i in range(r):
            x *= n - i
            y *= i + 1
        return x // y

    ans = count(75)
    ans += count(25) * (count(3) - 1)
    ans += count(15) * (count(5) - 1)
    ans += choose(count(5), 2) * (count(3) - 2)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(ll i=0; i < n; i++)
#define reps(i, n) for(ll i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;


int main() {
  int array[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;cin >> k;
  cout << array[k-1];
}

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

int main() {
	long long N, X;
	cin >> N >> X;
	vector<long long>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		if ((A[i-1]+A[i])>X) {
			long long num =  (A[i-1]+A[i]-X);
			ans += num;
			A[i] = max((long long)0,A[i]-num);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

struct Info{
  string str, id1, id2;
};

bool CheckKey(const Info, vector<Info>&);
bool CheckString(const string&, const string&);

int main(){
  int i, n, m;
  Info a;
  vector<Info> data, ans;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(i=0; i<n; ++i){
      cin >> a.str >> a.id1 >> a.id2;
      data.push_back(a);
    }
    reverse(data.begin(), data.end());

    for(i=0; i<m; ++i){
      cin >> a.id1 >> a.id2 >> a.str;
      if(CheckKey(a, data)) ans.push_back(a);
    }

    cout << ans.size() << endl;
    for(i=0; i<ans.size(); ++i)
      cout << ans[i].id1 << " " << ans[i].id2 << " " << ans[i].str << endl;

    data.clear();
    ans.clear();
  }
  return 0;
}

bool CheckKey(const Info a, vector<Info>& data){
  for(int i=0; i<data.size(); ++i){
    if(CheckString(a.id1, data[i].id1) && CheckString(a.id2, data[i].id2)){
      if(data[i].str == "permit") return true;
      else return false;
    }
  }
  return false;
}

bool CheckString(const string& a, const string& b){
  if(a.size() != b.size()) return false;
  for(int i=0; i<a.size(); ++i){
    if(a[i] == '?' || b[i] == '?') continue;
    if(a[i] != b[i]) return false;
  }
  return true;
}

Measured memory_bytes: 1452
S = list(input())
for i in range(len(S)):
    if (i+1)%2 == 0:
        if S[i]=='R':
            print("No")
            exit(0)
    if (i+1)%2 != 0:
        if S[i]=="L":
            print("No")
            exit(0)
print("Yes")

Measured memory_bytes: 38384
old_str = input()
compare_str = input()

old_str = [e for e in old_str]
flag = False
for i in range(len(old_str)):
    old_str.append(old_str.pop(0))
    if ''.join(old_str) == compare_str:
        flag = True
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}

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


/////////////////////////////////////////////////////////////////////////////////////////

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

    vector<ll> a(n);
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    
    ll L = -1e18,R = 1e18;
    while(L + 1 != R){
        ll MID = (L + R) / 2; //仮の答え
        ll cnt = 0;
        for (int i = 0;i < n;i++){
            if (a[i] < 0){
                int l = i,r = n;

                while(l + 1 != r){
                    int mid = (l + r) / 2;

                    if (a[i] * a[mid] <= MID) r = mid;//a[mid]が小さくなればa[i]*a[mid]は大きくなる
                    else l = mid;
                }

                cnt += n - r;
            }
            else {
                int l = i,r = n;
                
                while(l + 1 != r){
                    int mid = (l + r) / 2;

                    if (a[i] * a[mid] <= MID) l = mid; //a[mid]が小さくなればa[i]*a[mid]は大きくなる
                    else r = mid;
                }

                cnt += l - i;
            }
        }
        if (cnt < k){
            L = MID;
        }
        else {
            R = MID;
        }
    }

    cout << R << endl;
    
    return 0;
}

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

int main();
double sq(double);


int main(){
	double x1,x2,x3,y1,y2,y3,a1,b1,c1,a2,b2,c2,x,y,r,dx,dy;
	int n,i;
	
	scanf("%d\n", &n);
	for(i = 0;i < n;i++){
		scanf("%lf %lf %lf %lf %lf %lf\n",
			&x1, &y1, &x2, &y2, &x3, &y3);

		
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = sq(x1) - sq(x2) + sq(y1) - sq(y2);
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = sq(x1) - sq(x3) + sq(y1) - sq(y3);
		
		x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		
		dx = fabs(x - x1);
		dy = fabs(y - y1);
		
		r = sqrt(sq(dx) + sq(dy));
		
		printf("%.3lf %.3lf %.3lf\n", x, y, r);
	}
	
	return 0;
}

double sq(double x){
	return pow(x, 2);
}

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

using namespace std;

int a, b;

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

	cin >> a >> b;

	for (int i = 1; i < 1100; i++)
    {
        if (floor(0.08 * i) == a && floor(0.1 * i) == b)
        {
            cout << i;
            return 0;
        }
    }

    cout << -1;
	return 0;
}


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

#define ll  long double
#define ld long double
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define nguyendz the_best
#define pii pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;

using namespace std;
const ll maxn=2e3+2;
const ll maxx=1e16;
const ll mod=1e9+7;
const ll mod1=998244353;

map<string,ll> mp;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
     cin>>n;
     for (int i=1;i<=n;i++)
     {
         string s;
          cin>>s;
          mp[s]=1;
     }
     cout <<mp.size();
}


Measured memory_bytes: 22472
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
class Solver(object):
    def __init__(self):
        self.n = int(input())
        self.primes = Solver.generate_primes(self.n)

    def solve(self):
        count = 0
        for i in range(2, self.n+1):
            if i % 2 != 0:
                factors = self.prime_factorize(i)
                if len(set(factors)) == len(factors):
                    if self.has_eight(factors):
                        # print(i, factors)
                        count += 1
                else:
                    c = Counter(factors)
                    s = list(c.keys())
                    if len(s) == 2:
                        if (c[s[0]] == 1) and (c[s[1]] == 3) or ((c[s[0]] == 3) and (c[s[1]] == 1)):
                            # print(i, factors)
                            count += 1

        print(count)
    
    def has_eight(self, factors):
        return len(set(factors)) == 3

    def prime_factorize(self, n):
        factor = []
        for i in self.primes:
            if i > n:
                break
            if n % i == 0:
                factor.append(i)
                n = int(n/i)
                while n % i == 0:
                    factor.append(i)
                    n = int(n/i)
        return factor

    @staticmethod
    def generate_primes(length):
        """Generate prime from 1 to length, inclusive"""
        primes = []
        if length < 2:
            return primes
        numbers = range(2, length+1)  # 2 .. length
        i = numbers[0]
        while True:
            primes.append(i)
            new_numbers = []
            for j in numbers:
                if j % i != 0:
                    new_numbers.append(j)
            numbers = new_numbers
            if len(numbers) == 0:
                break
            i = numbers[0]
        return primes


if __name__ == "__main__":
    s = Solver()
    s.solve()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
         
        using namespace std;
         
        #define ll long long
        #define endl '\n'
        #define pb push_back
        #define loop(i, a, b) for (int i = a; i < b; i++)
         
        const ll mod = 1e9+7;
        const ll m = 1e9+7;
         
        ll expo_mod(ll x, ll n) //Exponenciação rápida com módulo
        {
            if (n == 0)
                return 1;
         
            ll t = expo_mod(x, n/2); //O resultado já é em módulo
         
            ll result = (t * t)%mod;
         
            if (n%2 == 1) //Se n é ímpar
                return (result * (x%mod))%mod; //(a * b) mod m = (a mod m * b mod m) mod m
         
            return result;
        }
         
        ll fat(int x)
        {
            int r = 1%m;
            for (ll i = 1; i <= x; i++)
                r = (r * i%m)%m; //(a * b) mod m = (a mod m * b mod m) mod m
         
            return r;
        }
         
        int main ()
        {
         
            ll x, y; cin >> x >> y;
         
            if ((x+y)%3 != 0 || (2*x-y)<0 || (2*y-x)<0)
            { //Não há solução
                cout << 0 << endl;
                return 0;
            }
         
            ll n = (x+y)/3;
         
            ll a = (2 * y - x)/3;
            ll b = (2 * x - y)/3;
         
            //(n escolha a) mod m = ( n! / (a! * b!) ) mod m
         
            cout << ( ( ( ( fat(n) * expo_mod(fat(a), mod - 2) )%mod  ) * expo_mod(fat(b), mod - 2) )%m ) << endl;
         
            return 0;
        }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private int a, b;
    private int[] towerHeights;

    public Main() {
        Scanner sc = new Scanner(System.in);        
        this.a = Integer.parseInt(sc.next());
        this.b = Integer.parseInt(sc.next()); 
        this.towerHeights = new int[999];
        // set each tower's height
        for (int i = 1; i < 1000; ++i) {
            if (i == 1) {
                towerHeights[0] = 1;
            } else {
                towerHeights[i - 1] = towerHeights[i - 2] + i;
            }
        }
    }

    public void solve() {
        int x = 0;

        int diff = b - a;
        for (int i = 0; i < 999; ++i) {
            if (towerHeights[i + 1] - towerHeights[i] == diff) {
                x = towerHeights[i] - a;
                break;
            } 
        }

        System.out.println(x);
    }

    public static void main(String[] args) {
        Main m = new Main();
        m.solve();
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N;
    cin >> N;
    i64 S = 0;
    vector<i64> s(N);
    for(int i = 0; i < N; i++) {
        cin >> s[i];
        S += s[i];
        if(i) s[i] += s[i - 1];
    }
    i64 ans = 1e16;
    for(int i = 0; i < N - 1; i++) {
        ans = min(ans, abs(S - 2 * s[i]));
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define All(a) (a).begin(),(a).end()

ll M=pow(10,9)+7;
ll powMod(ll n, ll k, ll p) {
//n^k mod p
  ll ans=1;
  while(k>0){
    if(k&1) ans=(ans*n)%p;
    k>>=1;
    n=(n*n)%p;
  }
  return ans;
}
void solve(){
  ll n,a,b,c,ans;
  cin >> n;
  
  a=powMod(10,n,M);
  b=powMod(9,n,M);
  c=powMod(8,n,M);
  ans=(a-2*b+c)%M;
  while(ans<0)ans+=M;
  //cout << ans <<endl;
  //ans=powMod(2,30,M);
  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,z,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	z=a;
	if(z>b) z=b;
	if(z>c) z=c;
	x=d;
	if(x>e) x=e;
	printf("%d\n",(z+x)-50);
	return 0;
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

int dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
  	if(N == 1000000){
      	// hyperoptimisation via precomputation of worst case scenario
     	retainWays=370927276;
      	fact=641102369;
    }else{
        for(int i = 1; i <= N; i ++){
            fact = fact*i%MOD;
            retainWays += fact;
        }
        retainWays %= MOD;
    }

    //printf("retainWays=%lld fact=%lld\n", retainWays, fact);

    dp[0] = fact;
    int slidingWindowSum = dp[0];
    for(int i = 1; i < D; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i];

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }
  
  	for(int i = D; i < H; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i]-dp[i-D];

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}
        else if(slidingWindowSum < 0){slidingWindowSum += MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%d", slidingWindowSum);
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int mod=1000000007;
int n,top,num;
ll K,a[210],c[210],d[210];
pair<ll,ll> qj[12010];
struct node
{
	ll t[210],a1;
	int k;
}s[12010];
bool operator <(const node &a,const node &b)
{
	for(int i=1;i<n;i++)
		if(a.t[i]<b.t[i]) return 1;
		else if(a.t[i]>b.t[i]) return 0;
	return 0; 
}
bool check(node &a,node &b)
{
	for(int i=1;i<n;i++)
		if(a.t[i]!=b.t[i]) return 0;
	return 1;	
}

int maxpop(ll x,ll y)
{
	if(x==-1) return 0;
	int re=0;
	for(int i=60;i>=0;i--)
		if(((x>>i)&1)==((y>>i)&1)) re+=((x>>i)&1);
		else {re++;break;}
	return re;	
}
ll dp()
{
	//cout<<"***"<<endl;
	sort(qj+1,qj+num+1);
//	for(int i=1;i<=num;i++)
//		cout<<qj[i].first<<' '<<qj[i].second<<endl;
	ll re=0,l=0,r=-1;
	for(int i=1;i<=num;i++)
	{
		if(qj[i].first>r) {re+=(r-l+1);l=qj[i].first;}
		r=qj[i].second;
		//cout<<l<<' '<<r<<' '<<re<<endl;
	}
	re+=(r-l+1);
	return re;	
}
int main()
{
	scanf("%d%lld",&n,&K);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);	
	for(int i=0;i<=60;i++)
	{
		for(int j=1;j<=n;j++)
			c[j]=(a[j]&((1ll<<i)-1));	
		sort(c+1,c+n+1);
		c[0]=-1;
		int sz=unique(c+1,c+n+1)-c-1;
		for(int j=1;j<=sz;j++)
			if(a[1]>=c[j])
			{
				int P=maxpop(c[j-1],c[j]);
				for(int l=1;l<=n;l++)
					d[l]=((a[l]-c[j])>>i);	
				s[++top].a1=d[1];s[top].k=i+P;
				for(int l=1;l<n;l++)
					s[top].t[l]=d[l+1]-d[l];		
			}
	}
	sort(s+1,s+top+1);
//	for(int i=1;i<=top;i++)
//	{
//		cout<<"s:"<<s[i].k<<' '<<s[i].a1<<endl;
//		for(int j=1;j<n;j++)
//			cout<<s[i].t[j]<<' ';
//		cout<<endl;
//	}
	num=0;
	ll ans=0;
	for(int i=1;i<=top;i++)
	{
		if(i!=1&&!check(s[i],s[i-1])) ans=(ans+dp())%mod,num=0; 
		if(s[i].k<=K)qj[++num]=make_pair(max(s[i].a1-K+s[i].k,0ll),s[i].a1);
	}
	ans=(ans+dp())%mod;
	printf("%lld",ans);
	return 0;
}
/*2 3
5 7*/

Measured memory_bytes: 16640
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    if n < r:
        return 0
    a = b = 1
    r = min(n-r, r)
    for i in range(n-r+1,n+1):
        a*=i
    for i in range(1,r+1):
        b*=i
    
    return a//b
 
N, K = map(int, input().split())
MOD = int(1e9)+7
 
for i in range(1, K+1):
    temp = comb(N-K+1, i) * comb(K-1, i-1)
    print(int(temp % MOD))

Measured memory_bytes: 3316
Station = ('a'..'z').to_a + ('A'..'Z').to_a

while true do
  n = gets.to_i
  break if n == 0
  k = gets.split.map(&:to_i)
  s = gets.chomp
  answer = ""
  for i in 0...s.size do
    index = Station.index(s[i]) - k[i % k.size]
    answer += Station[index]
  end
  puts answer
end

Measured memory_bytes: 6120
#!/usr/bin/env python3
#ABC147 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
lst = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for j in range(a):
        x,y = LI()
        lst[i].append((x-1,y))
for i in range(2**n):
    b = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            b[j] = 1
    flg = True
    for j in range(n):
        if b[j] == 0:
            continue
        for k,l in lst[j]:
            if l == 0:
                if b[k] == 1:
                    flg = False
                    break
            else:
                if b[k] == 0:
                    flg = False
                    break
        if not flg:
            break
    else:
        ans = max(ans,sum(b))
print(ans)
        
    

Measured memory_bytes: 46700
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define f(i,l,h) for(ll i=l;i<h;i++)
#define fr(i,h,l) for(ll i=h;i>=l;i--)
#define PI 3.141592653589793
using namespace std;

typedef pair<ll,ll> pll;
const ll INF=(ll)(1e9+7);
typedef vector<ll> vll;

int main()
{
    //cout << "Hello world!" << endl;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    cout<<fixed<<setprecision(14);
    double angle= 30*h+ m/2-6*m;
    angle*=PI;
    angle/=180.0;

    double c=(a*a)+(b*b)- 2*a*b*cos(angle);
    c=sqrt(c);
    cout<<c<<endl;


}


Measured memory_bytes: 4212
#include <stdio.h>
int main(void){
    int a,b;
    int c;
    
    scanf("%d %d",&a,&b);
    
    c=(10*a+10*b)/2;
    
    if(c%10!=0){
       c=c/10+1; 
    }else{
        c=c/10;
    }
    
    printf("%d\n",c);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int a[110];
int dp[110000];

int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    dp[0] = false;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i - a[j] >= 0)
                dp[i] |= !dp[i-a[j]];
        }
    }
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

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

typedef long long ll;
typedef long double ld;

const int N=3e5+10;

int a[2][101];

int main(){
    //freopen("a.txt", "r", stdin);
    //freopen("answers.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    }
    int ans=0,res=0;
    for(int i=0;i<n;i++){
        res+=a[0][i];
        int foo=0;
        for(int j=i;j<n;j++){
            foo+=a[1][j];
        }
        ans=max(ans,res+foo);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>vec(n);
  ll x=0;
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    x-=b;
    vec[i]=a+b;
  }
  sort(vec.begin(),vec.end(),greater<ll>());
  ll sum=0;
  rep(i,(n+1)/2){
    sum+=vec[2*i];
  }
  cout << sum+x<< endl;
}


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

map<int,int> mp;
bool V[100001];
int dfs(int i,int count){
    if(V[i]==true) return -1;
    V[i]=true;
    if(i==2) return count;
    else{
        dfs(mp[i],++count);
    }
}

int main (){
    int N;
    cin >> N;
    fill(V,V+N+1,false);
    for(int i=1;i<=N;i++){
        int a;
        cin >> a;
        mp[i]=a;
    }
    int ans = dfs(1,0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
Uses math;
var
	ans,L,R,Lmax,Rmax,c:int64;
	n,i:Longint;
	x,v:array[1..100000]of int64;
begin
	read(n,c);
	for i:=1 to n do begin
		read(x[i],v[i]);
		inc(L,v[i]);
	end;
	ans:=L-x[n];
	for i:=n downto 1 do begin
		dec(L,v[i]);
		inc(R,v[i]);
		Rmax:=Max(Rmax,R-(c-x[i]));
		if i>1 then ans:=Max(ans,L-x[i-1]*2+Rmax)else ans:=Max(ans,Rmax);
	end;
	for i:=1 to n do begin
		inc(L,v[i]);
		dec(R,v[i]);
		Lmax:=Max(Lmax,L-x[i]);
		if i<n then ans:=Max(ans,R-(c-x[i+1])*2+Lmax)else ans:=Max(ans,Lmax);
	end;
	writeln(ans);
end.


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#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 maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

int main() {
  int a;
  std::string S;
  cin >> a >> S;
  if (a >= 3200) {
    cout << S << '\n';
  } else {
    cout << "red\n";
  }
}


Measured memory_bytes: 504
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toInt() }
    var cv0 = IntArray(100001)
    var cv1 = IntArray(100001)
    for(i in v.indices){
        if(i%2==0){
            cv0[v[i]]++
        }else{
            cv1[v[i]]++
        }
    }
    val m0=cv0.max()!!
    val m1=cv1.max()!!
    if(cv0.indexOf(m0) == cv1.indexOf(m1)
            && cv0.count{it==m0}==1
            && cv1.count{it==m1}==1){
        val scv0=cv0.sortedDescending()
        val scv1=cv1.sortedDescending()
        val ans = n- Math.max(scv0[0]+scv1[1],scv0[1]+scv1[0])
        println(ans)
    }else{
        val ans = n-m0-m1
        println(ans)
    }

}

Measured memory_bytes: 52688
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
struct qq{
	int id, d, fr, to;
	int stt;
};
const int N = 500000;
qq que[N];
int t, m, q, a, b, dd, k = 0;
 map<int, int> invals;
void addRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l != r) {
            left = min(left, l->first);
            right = max(right, (--r)->second);
            invals.erase(l,++r);
        }
        invals[left] = right;
    }
    
    bool queryRange(int left, int right) {
        auto it = invals.upper_bound(left);
        if (it == invals.begin() || (--it)->second < right) return false;
        return true;
    }
    
    void removeRange(int left, int right) {
        auto l = invals.upper_bound(left), r = invals.upper_bound(right); 
        if (l != invals.begin()) {
            l--;
            if (l->second < left) l++;
        }
        if (l == r) return;
        int l1 = min(left, l->first), r1 = max(right, (--r)->second);
        invals.erase(l, ++r);
        if (l1 < left) invals[l1] = left;
        if (r1 > right) invals[right] = r1;
    }
bool cmp(qq a, qq b){
	if(a.d != b.d) return a.d < b.d;
	return a.id < b.id;
}
void solve(){
	invals.clear();
	k = 0;
		scanf("%d%d%d", &t, &m, &q);
	for(int i = 0; i < m ; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 1; que[k].d = dd + 1; que[k].fr = a; que[k].to = b;
		k++;
	}
	for(int i = 0; i < q; i++){
		scanf("%d%d%d", &dd, &a, &b);
		que[k].id = 2; que[k].d = dd; que[k].fr = a; que[k].to = b;
		que[k].stt = i;
		k++;
	}
	sort(que, que + k, cmp);
	bool ans[q]; memset(ans, 0, sizeof ans);
	for(int i = 0; i < k; i++){
		if(que[i].id == 1){
			addRange(que[i].fr, que[i].to);
		}else{
			if(queryRange(que[i].fr, que[i].to) || que[i].fr >= que[i].to){
				ans[que[i].stt] = true;
			}else ans[que[i].stt] = false;
		}
	}
	for(int i = 0; i < q; i++){
		if(ans[i]) printf("Yes\n");
		else printf("No\n");
	}
}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 8592
import sys

def solve():
    A, B = map(int, input().split())
    ans = (A + B) % 24
    print(ans)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
	ll x,y,i,j,cn=1;
	cin >> x >> y;
     
       if(y%2!=0)No(); 
	else
	{
		for(i=0; i<=x; i++)
		{
			for(j=0; j<=x; j++)
			{
				if(i*2+j*4==y and i+j==x)
				{
					cn=0;
					Yes();
					break;
				}
			}
		}
		if(cn)No();
	}

    

    biday;
}
 
//...............BYE BYE................

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans=0;
	for(int t=0; t<1000; ++t){
		int num=t, now=0;
		for(int i=N-1; i>=0; --i){
			if(S[i]-'0'==num%10){
				++now;
				num /= 10;
			}
			if(now==3){
				++ans;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
require 'bigdecimal/util'

n = gets.to_i
x = y = 1

n.times do |i|
  t, a = gets.split.map(&:to_i)

  r = [(x / t.to_d).ceil, (y / a.to_d).ceil].max
  x, y = r * t, r * a
end

puts x + y

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

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

  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++) {
      if(i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int cmp(int a,int b)
{
	return a>b;
}
int aa[200090];
int bb[200090];
main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&aa[i]);
		bb[i]=aa[i];
	}
	sort(bb+1,bb+n+1,cmp);
	int m=1;
	for(i=1;i<=n;i++)
	{
		if(aa[i]!=bb[1])
		{
			printf("%d\n",bb[1]);
		}
		else
		{
			printf("%d\n",bb[2]);
		}
	}
	
}

Measured memory_bytes: 3072
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (N, M, P) = get!(usize, usize, i64);
    let ABC = get!(usize, usize, i64; M);

    let INF = 1000000000000;
    let mut dp = vec!(INF; N + 1);
    let mut used = vec!(false; N + 1);
    dp[1] = 0;
    used[1] = true;
    for k in 0..3*N {
        for i in 0..M {
            let (a, b, c) = ABC[i];
            let w = P - c;
            if used[a] && dp[b] > dp[a] + w {
                dp[b] = dp[a] + w;
                used[b] = true;
                if k >= N - 1 {
                    dp[b] = -INF;
                }
            }
        }
    }
    let mut ans = cmp::max(0, -dp[N]);
    if ans == INF {
        ans = -1;
    }
    println!("{}", ans);
}



Measured memory_bytes: 4476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);
        System.out.println( solve() );
    }

    static int solve() {
        if( N == 1 ) return 0;

        int ans = 0;
        for (int i = 1; i < N; i++) {
            if( (A[i-1] == A[i])) {
                ans++;
                i++;
            }
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            UInt64 mod = 1000000007;
            UInt64 N = UInt64.Parse(Console.ReadLine());
            Dictionary<UInt64, UInt64> dic = new Dictionary<UInt64, UInt64>();
            for (UInt64 i = 2; i <= N; i++) 
            {
                func(i, ref dic);
            }

            //結果を出力
            UInt64 count = 1;
            foreach (var key in dic.Keys) {
                count *= (dic[key] + 1);
                count %= mod;
            }
            Console.WriteLine(count.ToString());
            Console.ReadLine();
        }

        static void func(UInt64 n, ref Dictionary<UInt64,UInt64> dic)
        {
            UInt64 i = 2;
            while (i * i <= n)
            {
                if (n % i == 0)
                {
                    n /= i;
                    if (dic.ContainsKey(i)) dic[i]++;
                    else dic.Add(i, 1);
                }
                else
                {
                    i++;
                }
            }
            if (n != 1) 
            {
                if (dic.ContainsKey(n)) dic[n]++;
                else dic.Add(n, 1);
            }
        }
    }
}


Measured memory_bytes: 3032
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string a,b="CODEFESTIVAL2016";
	int ans=0;
	cin>>a;
	for(int i=0;i<16;i++){
		if(a[i]!=b[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  rep(i,n){
    cin >> a.at(i).second >> a.at(i).first;
  }
  sort(ALL(a));
  ll sum = 0;
  rep(i,n){
    sum+=a.at(i).second;
    if(sum>a.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1792
def resolve():
    nnn = int(input())
    for h in range(1, 3501):
        for w in range(1, 3501):
            div = 4 * h * w - nnn * h - nnn * w
            if div == 0:
                continue
            n = nnn * h * w / div
            if int(n) == n and 0 < n:
                print(h, w, int(n))
                return

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 66724
#include<stdio.h>
int main()
{
long long int a,b,c;
  scanf("%lld %lld %lld",&a,&b,&c);
  if(a+b<=c) printf("0 0");
  else if(a>c) printf("%lld %lld",a-c,b);
  else printf("0 %lld",a+b-c);



return 0;
}

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


int main(void){
 
    int N;
    long long C,K;
    cin >> N >> C >> K;
    long long T[N];
    for(long long i = 0; i < N;i++){
        cin >> T[i];
    }
    
    sort(T,T+N);
    
    long long ans = 0;

    for(long long i = 0; i < N;){
        ans++;
        long long start = i;
        while(i < N&& i - start < C&&T[i] - T[start] <= K)i++;
        
    }

    
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
n=int(input())
l=[]
s=0
for i in range(n):
  a=int(input())
  s+=a
  if a%10!=0:
    l.append(a)
if len(l)==0:
  print(0)
else:
  if s%10==0:
    print(s-min(l))
  else:
    print(s)
  

           


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(x %2 == 1 && i %2 == 0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
int main(){
  string k;
  int d;
  cin>>k>>d;
  reverse(k.begin(),k.end());
  int p=1000000007;
  vector<vector<int64_t>> dp(k.size()+1,vector<int64_t>(d,0));
  vector<vector<int64_t>> dp9(k.size()+1,vector<int64_t>(d,0));
  dp[0][0]=1;
  dp9[0][0]=1;
  for(int i=1;i<=k.size();i++){
    for(int j=0;j<d;j++){
      for(int x=0;x<10;x++){
        if(x<k.at(i-1)-'0')
          dp[i][j]=(dp[i][j]+dp9[i-1][(j-x+d*10)%d])%p;
        else if(x==k.at(i-1)-'0')
          dp[i][j]=(dp[i][j]+dp[i-1][(j-x+d*10)%d])%p;
        dp9[i][j]=(dp9[i][j]+dp9[i-1][(j-x+d*10)%d])%p;
      }
    }
  }
  cout<<(dp[k.size()][0]-1+p)%p<<endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second

int32_t main() {
	string s,t;
	cin>>s>>t;
	bool okk  = true;
	if(t.size()<s.size())
		okk = false;
	for(int i=0;i<s.size() && okk;i++){
		if(s[i] != t[i])
			okk = false;
	}
	if(okk)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}	

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

int main()
{
	long long N, A, B;
	scanf("%lld %lld %lld", &N, &A, &B);
	
	long long min = (N - 1) * A + B, max = (N - 1) * B + A;
	if (min > max) printf("0\n");
	else printf("%lld\n", max - min + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128