akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

// N, E, S, W
const int dx[] = { 1, 0, -1, 0};
const int dy[] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

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

	int n, m;
	cin >> n >> m;

	vi dp(n + 1, INF);
	dp[0] = 0;

	int c;
	REP(i, m) {
		cin >> c;
		for (int j = 0; j + c <= n; j++) {
			dp[j + c] = min(dp[j + c], dp[j] + 1);
		}
	}

	cout << dp[n] << "\n";
	return 0;
}

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

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

    int l,r;
    int l_max = 0;
    int r_min = n-1;
    rep(i,m) {
        cin >> l >> r;
        l--;
        r--;
        l_max = max(l, l_max);
        r_min = min(r, r_min);
    }

    cout << max(r_min-l_max+1, 0) << endl;
    return 0;
}

Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, K = Scanner.map_int()
    S = Scanner.string()
    cnt = 0
    for i in range(N):
        if S[i] == "R":
            if i + 1 < N and S[i+1] == "R":
                cnt += 1
        else:
            if i - 1 >= 0 and S[i-1] == "L":
                cnt += 1
    print(min(N-1, cnt + 2 * K))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 40812
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std ;

#define MAXN 207

int n ;
struct tuhla {
    long long x , y ;
    double ang ;
};
tuhla a[ MAXN ] ;

bool cmp ( tuhla p1 , tuhla p2 ) {
    return ( p1.ang < p2.ang ) ;
}

long long calc ( int st , int en ) {
    long long x , y ;
    x = y = 0 ;
    for ( int i = st ; i <= en ; ++ i ) {
        x += a[ i ].x ;
        y += a[ i ].y ;
    }
    return ( x * x + y * y ) ;
}

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%lld%lld" , &a[ i ].x , &a[ i ].y ) ;
        a[ i ].ang = atan2 ( a[ i ].y , a[ i ].x ) ;
    }
    sort ( a + 1 , a + n + 1 , cmp ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        a[ n + i ] = a[ i ] ;
    }
}

void solve ( ) {
    long long ans = 0 ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        for ( int j = 0 ; j < n ; ++ j ) {
            long long aux = calc ( i , i + j ) ;
            if ( ans < aux ) { ans = aux ; }
        }
    }
    printf ( "%.15lf\n" , sqrt ( ans ) ) ;
}

int main ( ) {
    ///freopen ( "in.txt" , "r" , stdin ) ;
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 512
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000], y[100000];
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> a >> b >> n >> m;
	for (i = 0;a > 0; i++) {
		n -= b;
		if (n <= 0)break;
		a -= m;
	}
		if(a > 0)cout << "Yes" << endl;
			else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << ((a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int n = sc.nextInt();
            int r = sc.nextInt();
            if(n==0)break;
            
            int[] huda = new int[n+1];
            huda[0] = 0;
            
            for(int i=0; i<n+1; i++){
                huda[i] = n-i+1;
            }
            
            for(int i=0;i<r;i++){
                int p = sc.nextInt();
                int c = sc.nextInt();
                
                int[] temp = new int[c];
                
                for(int j=0; j<c; j++){
                    temp[j] = huda[p+j];
                }
                for(int j=p-1; j>0; j--){
                    huda[j+c] = huda[j];
                }    
                for(int j=0; j<c; j++){
                    huda[j+1] = temp[j];                
                }
                
            }   
            System.out.println(huda[1]);
        }
    }
}

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

using namespace std;

int main() {
	double x1, y1, x2, y2;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%lf\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans = 0;
    ll oe[2] = {};
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        ans += temp;
    }
    if(ans % 2) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import math


def main():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int, input().split())
        T.append(t)
        A.append(a)

    for i in range(N - 1):
        if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
            KT = T[i]//T[i + 1] if T[i]%T[i + 1]==0 else (T[i]//T[i + 1])+1
            KA = A[i]//A[i + 1] if A[i]%A[i + 1]==0 else (A[i]//A[i + 1])+1
            mul = max([KT,KA])
            A[i + 1] *= mul
            T[i + 1] *= mul
    print(T[N - 1] + A[N - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 5092
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split(" ").map(Number);
var a=arr[0];
var b=arr[1];
var d=Math.floor(a/b);
var r=a%b;
var f=(a/b).toFixed(5);
console.log(d+" "+r+" "+f);

Measured memory_bytes: 7648
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;

#undef int
int main() {
#define int long long
	int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	int passed = 0;
	int rankB = 0;
	REP(i, n) {
		if (s[i] == 'a') {
			if (passed < a + b) {
				passed++;
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else if (s[i] == 'b') {
			rankB++;
			if (passed < a + b && rankB <= b) {
				passed++;
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else {
			cout << "No\n";
		}
	}
}



Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    LL N;
    cin>> N;
    set<pair<LL,LL> > s;
    while(N--)
    {
        LL x,y;
        cin >> x >> y;
        s.insert({x,y});
    }
    LL maxS=INT_MIN;
    LL minS=INT_MAX;
    LL maxD=INT_MIN;
    LL minD=INT_MAX;
    for(auto it:s)
    {
        maxS=max(maxS,it.first+it.second);
        minS=min(minS,it.first+it.second);
        maxD=max(maxD,(it.first-it.second));
        minD=min(minD,(it.first-it.second));
    }
    cout<<max(maxS-minS,(maxD-minD))<<endl;
}


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

int main() {
    int N;
    cin >> N;
    double M=0;

    for(int i=0; i<N; i++){
        double O;
        cin >> O;
        M += 1/O;
    }

    printf("%.12lf\n",1/M);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

using ll = long long int;


const int MAXN=1e4+2;
const ll MOD=1e9+7;
int N;
ll A[MAXN];
map<int,int> factor;

ll fast_power(ll base,int exp){
    if (exp==0) return 1ll;
    auto temp=fast_power(base,exp/2);
    if (exp%2) return ((temp*temp)%MOD)*base%MOD;
    else return (temp*temp)%MOD;
}

ll inverse(ll a){ return fast_power(a,MOD-2);};



int main(){

    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%lld",A+i);

    for(int i=0;i<N;i++){
        auto copy=A[i];

        for(ll f=2ll;f*f<=copy;f++){
            if (copy%f) continue;
            int count=0;
            while (copy%f==0){
                copy/=f;
                count++;
            }
            factor[f]=max(factor[f],count);
        }

        if (copy!=1) factor[copy]=max(factor[copy],1);
    }
    // puts("OK");

    auto prod=1ll;
    for(auto vk:factor) 
        prod=prod*fast_power(vk.first,vk.second)%MOD;
    
    // puts("OK");
    auto ans=0ll;
    for(int i=0;i<N;i++) ans=(ans+prod*inverse(A[i])%MOD)%MOD;

    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

const int maxn=2e5+5;
int a[maxn];
int cnt1[maxn],cnt2[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	rept(i,1,n) cin>>a[i];
	
	while(k--)
	{
		bool flag=1;
		int cnt=0;
		mes(cnt1,0);mes(cnt2,0);
		rept(i,1,n)
		{
			cnt1[max(1,i-a[i])]++;
			cnt2[min(n+1,i+a[i]+1)]++;
		}
		rept(i,1,n)
		{
			cnt+=cnt1[i]-cnt2[i];
			if(cnt!=n) flag=0;
			a[i]=cnt;
		}
		if(flag) break;
	}
	rept(i,1,n) cout<<a[i]<<" ";
	cout<<"\n";
	return 0;
}

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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  ll N;
  ll A, ans=0;
  cin >> N;
  vector<ll> sumlist(N), alist(N);
  for(ll i=0; i<N; i++) {
    if(i==0) {
      cin >> A;
      sumlist.at(i)=A;
      alist.at(i)=A;
    }
    else {
      cin >> A;
      sumlist.at(i) = (sumlist.at(i-1)+A)%(1000000000+7);
      alist.at(i)=A;
    }
  }
  for(ll i=0; i<N-1; i++) {
    if(sumlist.at(N-1)-sumlist.at(i)>=0) {
      ans += (alist.at(i)*(sumlist.at(N-1)-sumlist.at(i)))%(1000000000+7);
    }
    else {
      ans += (alist.at(i)*(sumlist.at(N-1)-sumlist.at(i)+1000000000+7))%(1000000000+7);
    }
  }
  cout << ans%(1000000000+7);
}

Measured memory_bytes: 6384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  unordered_map<long, long> mp;
  rep (i, N) {
    long a;
    cin >> a;
    mp[a]++;
  }
  vector<long> foo;
  for (auto it: mp) foo.push_back(it.second);
  sort(foo.begin(), foo.end());
  long ans = 0;
  for (long i = 0; i + K < foo.size(); i++) {
    ans += foo[i];
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 11592
#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

  string s;
  cin >> s;
  int ans = 0;

  stack<int> s1;
  stack<pair<int, int>> s2;  // (pos, area)
  for (int i = 0; i < s.size(); i++) {
    const char c = s[i];
    if (c == 0x5c) {  // '/'
      s1.push(i);
    } else if (c == 0x2f && !s1.empty()) {  // '\''
      const int left = s1.top();
      const int a = i - left;
      ans += a;
      s1.pop();
      int a2 = a;
      while (!s2.empty() && left < s2.top().first) {
        a2 += s2.top().second;
        s2.pop();
      }
      s2.push({left, a2});
    }
  }
  vector<int> areas(s2.size());
  for (int i = 0; i < areas.size(); i++) {
    areas[areas.size() - 1 - i] = s2.top().second;
    s2.pop();
  }

  cout << ans << endl;
  cout << areas.size();
  for (int e : areas) {
    cout << " " << e;
  }
  cout << endl;

  return 0;
}



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

vector<P>E[3000];
int d[3000];
int main() {
	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	rep(i,m){
		int a,b,l;scanf("%d%d%d",&a,&b,&l);a--;b--;
		E[a].push_back(P(l,b));E[b].push_back(P(l,a));
	}
	memset(d,0x3f,sizeof(d));
	priority_queue<P,vector<P>,greater<P>>que;
	rep(i,k){
		int s;scanf("%d",&s);s--;
		que.push(P(0,s));
		d[s]=0;
	}
	while(!que.empty()){
		P p=que.top();que.pop();
		if(p.first!=d[p.second])continue;
		for(P u:E[p.second]){
			if(d[u.second]>p.first+u.first){
				d[u.second]=p.first+u.first;
				que.push(P(d[u.second],u.second));
			}
		}
	}
	int Max=0;
	rep(i,n){
		for(P p:E[i]){
			for(double k=0;k<=(double)p.first;k+=0.5){
				Max=max(Max,(int)ceil(min((double)d[i]+k,(double)d[p.second]+(double)p.first-k)));
			}
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 5984
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n;cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    bool s = true;
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]) s = false;
    }
    if(s){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

Measured memory_bytes: 1024
inpl = lambda: list(map(int,input().split()))
def min_len(A):
    N = len(A)
    p = [-1]
    m = [0]
    L = []
    for i in range(N):
        a = A[i]
        while a < m[-1]:
            m.pop()
            p.pop()
        m.append(A[i])
        p.append(i)
        L.append(i-p[-2])
    return L

N = int(input())
A = inpl()
L = min_len(A)
R = min_len(A[::-1])
ans = sum(L[i]*R[N-1-i]*A[i] for i in range(N))
print(ans)

Measured memory_bytes: 116396
s=gets.chomp.chars
s1=s[0...s.size/2]
s2=s[(s.size-s.size/2)...s.size]
a = (0...s.size).all?{|i|s[i] == s[i - s.size]} 
b = (0...s1.size).all?{|i|s1[i] == s1[i - s1.size]} 
c = (0...s2.size).all?{|i|s1[i] == s2[i - s2.size]} 

if a && b && c
    print 'Yes'
else
    print 'No'
end


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String winner = "Alice";
		if(A == B) {
			winner = "Draw";
		}
		else if(A != 1 && (B == 1 || A < B)) {
			winner = "Bob";
		}
		System.out.println(winner);
	}
}


Measured memory_bytes: 35540
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e2+10;
using namespace std;

ll dp[maxn][maxn][2];
int main()
{
    string s;
    int K;
    cin>>s;
    cin>>K;
    int len=s.length();
    dp[0][0][0]=1;
    for(int i=0;i<len;i++)
    {
        for(int j=0;j<4;j++)
        {
            for(int k=0;k<2;k++)
            {
                int numd=s[i]-'0';
                for(int l=0;l<10;l++)
                {
                    int numi=i+1,numj=j,numk=k;
                    if(l!=0) numj++;
                    if(numj>K) continue;
                    if(k==0)
                    {
                        if(l>numd) continue;
                        if(l<numd) numk=1;
                    }
                    dp[numi][numj][numk]+=dp[i][j][k];

                }
            }
        }
    }
    ll ans=dp[len][K][0]+dp[len][K][1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  int iti = 0;
  int zero = 0;
  if(s.size()==1){cout << 0 << endl;return 0;}
  for(auto &i:s){
    if(i=='1') iti++;
    else zero++;
  }
  cout << min(iti,zero)*2 << endl;
  return 0;
}


Measured memory_bytes: 512
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

K = int(input())


if K == 0:
	N = 2
	aa = [1,1]
elif K == 1:
	N = 2
	aa = [0,2]
elif K < 50:
	N = K
	aa = [K]*N
else:
	N = 50
	aa = [49-K]*N
	kk = K % 50
	KK = K //50
	for i in range(N):
		aa[i] += 51*KK
	for i in range(kk):
		aa[i] += 51

print(N)
print (' '.join(map(str,aa)))


Measured memory_bytes: 4204
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}
struct UnionFind{
    vector<int> par; // 親
    vector<int> rank; // 木の深さ
    int size;
    UnionFind(int n){
        REP(i,n) par.push_back(i);
        rank = vector<int>(n);
        size=n;
    }
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);y = root(y);
        if(x==y)return;
        if(rank[x] < rank[y])par[x] = y;
        else par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
        size--;
    }
};

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	while(true){
		int H,W;cin >> H >> W;
		if(H==0 && W==0)return 0;
		vector<vector<int> > map(H,vector<int>(W));
		REP(y,H){
			string str;cin >> str;
			REP(x,W) map[y][x]=str[x];
		}
		UnionFind uf(H*W);
		REP(y,H)REP(x,W){
			REP(di,4){
				int px=x+dx[di],py=y+dy[di];
				if(IN(0,px,W) && IN(0,py,H)){
					if(map[y][x]==map[py][px]){
						uf.unite(y*W+x, py*W+px);
					}
				}
			}
		}
		cout << uf.size<<endl;
	}
	return 0;
}

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

monney = 1000
stock = 0


def max_day(index):
    if index == N-1 or (A_list[index] > A_list[index+1]):
        return index
    return max_day(index+1)


def min_day(index):
    if index == N-1:
        return -1
    if A_list[index] < A_list[index+1]:
        return index
    return min_day(index+1)


def main(day=0, flag="buy"):
    global monney, stock
    if flag == "buy":
        buy_day = min_day(day)
        if buy_day == -1:
            return monney
        stock, monney = divmod(monney, A_list[buy_day])
        return main(buy_day+1, "sell")
    elif flag == "sell":
        sell_day = max_day(day)
        monney += stock * A_list[sell_day]
        stock = 0
        if sell_day == N-1:
            return monney
        return main(sell_day+1, "buy")


print(main())


Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    if (n == 0)
    {
        cout << 1 << endl;
    }
    else if (n == 1)
    {
        cout << 2 << endl;
    }
    else if (n == 2)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int mi = a[0];
    int ans = 0;
    rep(i, n) {
        if(mi >= a[i]) ++ans;
        chmin(mi, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int n, a, cnt[333333] = {}, sum[333333] = {};
    cin>>n;
    rep(i, n){
        cin>>a;
        a--;
        sum[cnt[a]]++;
        cnt[a]++;
    }
    int i = n, tmp = n;
    rep(j, 1, n + 1){
        while(tmp < i * j){
            i--;
            tmp -= sum[i];
        }
        cout<<i<<endl;
    }
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>

using namespace std;
string S;
// vector<int> S;

int main(){
  cin >> S;
  int a,b;
  bool A,B;
  a = stoi(S.substr(0,2));
  b = stoi(S.substr(2,2));
  A = a > 0 && a <= 12;
  B = b > 0 && b <= 12;
  if(A && B){
    cout << "AMBIGUOUS" << endl;
  }else if(A && !B){
    cout << "MMYY" << endl;
  }else if(!A && B){
    cout << "YYMM" << endl;
  }else if(!A && !B){
    cout << "NA" << endl;
  }
  return 0;
}


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

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

    for(int j=0; j<4; ++j) {
        int x=j/2, y=j%2;
        int a[n]={};
        a[0]=x;
        a[1]=y;
        for(int k=1; k+1<n; ++k) a[k+1]=(s[k]%2^a[k]^a[k-1]);
        if (a[0]==(s[n-1]%2^a[n-2]^a[n-1]) and a[1]==(s[0]%2^a[0]^a[n-1])) {
            for(int e: a) cout<<(e?'S':'W');
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pans cout<<ans<<endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
  	string s;cin>>s;
    bool flag=false;
  	for(int i=0;i<3;i++){
      if(s[i]==s[i+1]){
        flag=true;
      }
    }
  int a=0;
  	for(int i=0;i<1000000;i++){
      a+=1;
    }
  	if(flag){
      cout<<"Bad"<<endl;
    }else{
      cout<<"Good"<<endl;
    }
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,k,i;
int main(){
    scanf("%d%d%d",&k,&a,&b);
    for(i=a;i<=b;i++){
        if(i%k==0){
           printf("OK");
           break;
        }
    }
    if(i==b+1){
        printf("NG");
    }
    return 0;
}

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

int main() {
    int ans;
    string s;
    
    cin >> s;
    ans = 0;
    
    for ( int i = 0; i < 3; i++ ) {
        if ( s[i] == 'o' ) {
            ans+=100;
        }
    }
    
    cout << 700 + ans << endl;
    
    return (0);
}

Measured memory_bytes: 3592
//F - LCS

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;

    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<t.size(); j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    string ans="";
    int y=s.size();
    int x=t.size();
    while(dp[y][x]!=0){
        if(dp[y][x]==dp[y-1][x]){
            y--;
        }else if(dp[y][x]==dp[y][x-1]){
            x--;
        }else{
            ans.push_back(s[y-1]);
            x--;
            y--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

vector<vector<ll>> g(100010);
bool seen[2][100010];
ll taka[2][100010];// 0がtakahasi,1がaoki

void ki(ll i,ll type){
    if(seen[type][i]){
        return;
    }
    seen[type][i]=true;
    rep(j,0,g[i].size()-1){
        if(seen[type][g[i][j]]){
            
        }else{
            taka[type][g[i][j]]=taka[type][i]+1;
            //cout<<taka[type][g[i][j]]<<endl;
            ki(g[i][j],type);
        }
    }
    
}


int main(){
    ll n,u,v;cin>>n>>u>>v;
    ll a[n],b[n];
    rep(i,0,n-2){
        cin>>a[i]>>b[i];
        g[a[i]].pb(b[i]);
        g[b[i]].pb(a[i]);
    }
    taka[0][u]=0;
    taka[1][v]=0;
    seen[0][u]=0;
    seen[1][v]=0;
    ki(u,0);
    ki(v,1);
    /*
    rep(i,1,n){
        cout<<taka[0][i]<<endl;
    }
    rep(i,1,n){
        cout<<taka[1][i]<<endl;
    }
    cout<<endl;
     */
    ll ans=-1;
    ll mie=inf;
    rep(i,1,n){
        if(taka[0][i]<taka[1][i]){
            ans=max(ans,taka[1][i]-1);
        }else if(taka[0][i]==taka[1][i]){
            mie=min(mie,taka[1][i]);
        }else{
            
        }
    }
    if(mie==inf){
        cout<<ans<<endl;
    }else{
        cout<<max(mie,ans)<<endl;
    }
    
    return 0;
}




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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

int n;
const int maxn = 1e5 + 5;
int a[maxn];
typedef long long ll;

ll num[maxn];
ll suf[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll cur = 1;
    cin >> n;
    ll ans = 0;
    suf[n + 1] = 0;
    for(int i = 0;i <= n;i++){
        cin >> a[i];
    }
    for(int i = n;i >= 0;i--){
        suf[i] = suf[i + 1] + a[i];
    }
    for(int i = 0;i <= n;i++){
        ans += cur;
        if(cur < a[i]){
            cout << -1 << endl;
            return 0;
        }
        cur -= a[i];
        if(cur > suf[i + 1]){
            cout << -1 << endl;    
        }
        cur = min(cur * 2, suf[i + 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N, M; 
	cin >> N >> M; 
	int A[100010] = {}; 
	for(int i = 0; i < M * 2; i++){
		int a; 
		cin >> a; 
		A[a] ++; 
	}
	string ans = "YES"; 
	for(int i = 1; i <= N; i++){
		if(A[i] % 2 == 1) ans = "NO";
	}
	cout << ans << endl; 
}

Measured memory_bytes: 640
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  checker = 0
  query = [int(i+1) for i in range(n)]
  for i in range(n):
    if p[i] != query[i]:
      checker += 1
  if checker >2 :
    print("NO")
  elif checker ==1:
    print("NO")
  else:
    print("YES")
solve()

Measured memory_bytes: 3060
n, k, c = map(int, input().split())
s = input()

l = [-c-1]
for i in range(n):
    if s[i] == 'o' and i - l[-1] > c:
        l.append(i)
r = [n + c]
for i in reversed(range(n)):
    if s[i] == 'o' and r[-1] - i > c:
        r.append(i)
r.reverse()


if len(l)-1 == k:
    for li, ri in zip(l[1:], r):
        if li == ri:
            print(li + 1)

Measured memory_bytes: 22204
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
int main() {
	int N, Q; cin >> N >> Q;
	UnionFind uf(N);
	for (int i = 0; i < Q; ++i) {
		int a, b, c; cin >> a >> b >> c;
		if (!a) {
			uf.unionSet(b, c);
		}
		else {
			cout <<int( uf.root(b) == uf.root(c)) << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

vector <pair <int, int>> graf[1000005];
ll dist[1000005];

void dfs(int v, int parent){
    for(auto c : graf[v]){
        if(c.first == parent) continue;
        dist[c.first] = dist[v] + c.second;
        dfs(c.first, v);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    for(int i=1; i<n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        graf[a].push_back({b, c});
        graf[b].push_back({a, c});
    }
    int q, k;
    cin >> q >> k;
    dfs(k, 0);
    while(q--){
        int a, b;
        cin >> a >> b;
        cout << dist[a] + dist[b] << "\n";
    }
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>

using namespace std;
int n;
int dat[100][100];
int cost[100];
int done[100];

void prim(){
	for(int i=0;i<n;i++){
		cost[i]=1<<21;
		done[i]=0;
	}
	int s=0;	
	int next, ncost=1<<21;
	done[s]=1;
	cost[s]=0;
	while(1){
		ncost=1<<21;
		for(int j=0;j<n;j++){
			if(done[j]){
				for(int i=0;i<n;i++){
					if(dat[j][i]!=-1){
						if(cost[i]>=dat[j][i]&&!done[i]){
							cost[i]=dat[j][i];
						}
						if(ncost>cost[i]&&!done[i]){
							next=i;
							ncost=cost[i];
						}
					}
				}
			}
		}
//		cout<<"next:"<<next<<" cost:"<<cost[next]<<endl;
		done[next]=1;
		int flag=true;
		for(int i=0;i<n;i++){
			if(!done[i]) flag = false;
		}
		if(flag)
			return;
	}
}


void dijk(){
	for(int i=0;i<n;i++){
		cost[i]=1<<21;
		done[i]=0;
	}
	int s=0;	
	int next, ncost=1<<21;
	done[s]=1;
	cost[s]=0;
	while(1){
		ncost=1<<21;
		for(int j=0;j<n;j++){
			if(done[j]){
				for(int i=0;i<n;i++){
					if(dat[j][i]!=0){
						if(cost[i]>=dat[j][i]+cost[j]){
							cost[i]=dat[j][i]+cost[j];
						}
						if(ncost>cost[i]&&!done[i]){
							next=i;
							ncost=cost[i];
						}
					}
				}
			}
		}
//		cout<<"next:"<<next<<" cost:"<<cost[next]<<endl;
		done[next]=1;
		int flag=true;
		for(int i=0;i<n;i++){
			if(!done[i]) flag = false;
		}
		if(flag)
			return;
	}
}


int main(){
	int num, from, dist, c;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>from>>num;
		for(int j=0;j<num;j++){
			cin>>dist>>c;
			dat[from][dist]=c;
		}
	}
	dijk();
	for(int i=0;i<n;i++){
		cout<<i<<" "<<cost[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<pair<intmax_t, intmax_t>> task(N);
    for (auto &ti: task) {
        cin >> ti.second >> ti.first;
    }

    sort(task.begin(), task.end());

    intmax_t now = 0;
    for (auto &ti: task) {
        now += ti.second;
        if (now <= ti.first) {
            continue;
        } else {
            return cout << "No" << "\n", 0;
        }
    }

    cout << "Yes" << "\n";

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,H,W,n;
  cin >> H >> W;
  vector<int> a;
  for (cin >> N; N; N--) {
    cin >> n;
    a.push_back(n);
  }
  int b[H][W];
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H && !(j%2); i++, a[a.size()-1]--) {
      if (a.back()) {
      	b[i][j] = a.size();
      } else {
        a.pop_back();
        b[i][j] = a.size();
      }
    }
    for (int i = H-1; i+1 && j%2; i--, a[a.size()-1]--) {
      if (a.back()) {
        b[i][j] = a.size();
      } else {
        a.pop_back();
        b[i][j] = a.size();
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << b[i][j] << ' ';
    }
    cout << '\n';
  }
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    cout << (a - b) * (a - b - 1) / 2.0 - b << endl;
}


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

int main(void) {
    int N, sum = 0;
    cin >> N;
    vector<int> p(N);
    
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    
    for (int i = 0; i < N - 1; i++) sum += p[i];
    sum += p[N - 1] / 2;
    
    cout << sum << endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int[] arr = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++){
			arr[i] = scan.nextInt();
			if(isPrime(arr[i])){
				count++;
			}
		}
		System.out.printf("%d\n", count);
	}

	public static boolean isPrime(int x){
		if(x == 2)
			return true;
		if(x < 2 || x % 2 == 0)
			return false;
		int i = 3;
		while(i <= Math.sqrt(x)){
			if(x % i == 0)
				return false;
			i += 2;
		}
		return true;
	}
}

Measured memory_bytes: 41652
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

ll A,B,C,D;

ll cnt(ll x) {
	ll l=(A+x-1)/x;
	ll r=B/x;
	return r-l+1;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>A>>B>>C>>D;
	ll res=B-A+1 - cnt(C) - cnt(D) + cnt(C*D/__gcd(C,D));
	cout<<res<<"\n";
}


Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: l,r,d,ans=0,cnt,temp
      
      read*,l,r,d
      cnt = 1
      do while(.true.)
        temp = d*cnt
        if( l<=temp.and.temp<=r )then
          ans = ans + 1
        end if
        
        if( temp>r ) exit
        
        cnt = cnt + 1
      end do
      
      print*,ans
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2792
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,a,b=MI()
if a>b:
    print(0)
    sys.exit()
if a!=b and n<2:
    print(0)
    sys.exit()
mx=b*(n-1)+a
mn=a*(n-1)+b
print(mx-mn+1)

Measured memory_bytes: 65540
#include <bits/stdc++.h>
#define TUBO 3.305785
#define EPS 1e-10
using namespace std;

double calc(int a, int b) {
    return(a * b / (double)TUBO);
}

int main(void) {
    int a, b;
    cin >> a >> b;
    printf("%.6f\n", calc(a, b));
    
    return(0);
}

Measured memory_bytes: 1192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int a = sc.nextInt();
			int L = sc.nextInt();
			if (L == 0) break;
			int[] as = new int[21];
			as[0] = a;
			OUT: for (int i = 1;; ++i) {
				as[i] = next(as[i - 1], L);
				for (int j = 0; j < i; ++j) {
					if (as[j] == as[i]) {
						System.out.println(j + " " + as[i] + " " + (i - j));
						break OUT;
					}
				}
			}
		}
	}

	static int next(int a, int L) {
		int[] d = new int[L];
		for (int i = 0; i < L; ++i) {
			d[i] = a % 10;
			a /= 10;
		}
		Arrays.sort(d);
		int hi = 0;
		int lo = 0;
		for (int i = 0; i < L; ++i) {
			hi *= 10;
			hi += d[L - 1 - i];
			lo *= 10;
			lo += d[i];
		}
		return hi - lo;
	}

}

Measured memory_bytes: 20200
n=int(input())
t1, a1=map(int, input().split())
t_now=t1
a_now=a1
for _ in range(n-1):
    t, a=map(int, input().split())
    if t==a:
        t_now=max(t_now, a_now)
        a_now=t_now
    else:
        t_tmp=((t_now-1)//t+1)*t
        a_tmp=((a_now-1)//a+1)*a
        t_now=max(t_tmp//t, a_tmp//a)*t
        a_now=max(t_tmp//t, a_tmp//a)*a
print(t_now+a_now)





Measured memory_bytes: 9008
#include <cstdio>
#include <cstring>
#include <vector>
#define maxn 2010
#define INF (ll)1e17
using namespace std;
typedef long long ll;
int n,m;
int a[maxn],b[maxn];
ll c[maxn];
vector<int> map[maxn];
vector<int> map1[maxn];
ll dist[maxn];
bool f[maxn],g[maxn];
void dfs(int x) {
	if (f[x])
		return;
	f[x]=1;
	for (int i=0;i<map[x].size();i++)
		dfs(map[x][i]);
}
void dfs1(int x) {
	if (g[x])
		return;
	g[x]=1;
	for (int i=0;i<map1[x].size();i++)
		dfs1(map1[x][i]);
}
int main() {
    scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++) {
		scanf("%d %d %lld",&a[i],&b[i],&c[i]);
		c[i]*=-1LL;
		map[a[i]].push_back(b[i]);
		map1[b[i]].push_back(a[i]);
    }
	memset(f,0,sizeof(f));
	dfs(1);
	memset(g,0,sizeof(g));
	dfs1(n);
    for (int i=1;i<=n;i++)
		dist[i]=INF;
    dist[1]=0;
    bool t=true;
    for (int i=1;i<=n+1;i++) {
		for (int j=1;j<=m;j++)
		if (dist[b[j]]>dist[a[j]]+c[j]) {
			dist[b[j]]=dist[a[j]]+c[j];
			if (i==n+1&&f[b[j]]&&g[b[j]]) {
				t=false;
				break;
			}
		}
	}
    if (!t)
		printf("inf\n");
    else printf("%lld\n",dist[n]*-1LL);
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
#define ll long long
using namespace std;
ll p=998244353;
ll fac[300010],de[300010],inv[300010];
ll C(ll n,ll m)
{
	if(m==0) return 1;
	return fac[n]*de[m]%p*de[n-m]%p;
}
int main()
{
	ll n,a,b,k,ans=0;
	cin>>n>>a>>b>>k;
	if(k==0)
	{
		cout<<1;
		return 0;
	}
	if(1ll*(a+b)*n<k)
	{
		cout<<0<<endl;
		return 0;
	}
	fac[0]=1,inv[1]=1,de[0]=1;
	for(int i=1;i<=300000;i++) fac[i]=fac[i-1]*i%p;
	for(int i=2;i<=300000;i++) inv[i]=(long long)(p-p/i)*inv[p%i]%p;
	for(int i=1;i<=300000;i++) de[i]=de[i-1]*inv[i]%p;
	for(ll x=0;x<=n;x++)
	{
		ll y=(k-a*x)/b;
		if(y*b+a*x!=k) continue;
		if(y<0||y>n) continue;
		ans+=C(n,x)*C(n,y)%p;
		ans%=p;
	}
	cout<<ans%p;
	return 0;
}

Measured memory_bytes: 7296