akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		long a = Integer.parseInt(sa[1]);
		int b = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long ans = 0;
		for (int i = 1; i < n; i++) {
			ans += Math.min(b, a * (x[i] - x[i - 1]));
		}
		System.out.println(ans);
	}
}


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

int main()
{
        long long N, K;
        cin >> N >> K;
        map<long, long> m;
        for (int i = 0; i < N; ++i) {
                int a, b;
                cin >> a >> b;
                m[a] += b;
        }
        long long sum = 0;
        for (auto i : m) {

                sum += i.second;
                if (sum >= K) {
                        cout << i.first << endl;
                        break;
                }

        }



}


Measured memory_bytes: 4224
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

a, b = na()

print(a * b)

Measured memory_bytes: 9240
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort, group)

main :: IO ()
main = do
  abc <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    l = length . group . sort $ abc
  putStrLn $ if l == 2 then "Yes" else "No"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
  for j in range((n-i*r)//g+1):
    if (n-i*r-j*g)>=0 and (n-i*r-j*g)%b==0:
      ans=ans+1
print(ans)

Measured memory_bytes: 40428
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPsecond 1e-9
#define MOD 1000000007
 
// // for using in pairs
// #define first first
// #define second second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

// Utility functions.
void swap(int a, int b)
{
	int t = a;
	a = b;
	b = t;
}

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

int diff(string &s, string &t, int i)
{
	int ans = 0;
	int j = i + t.size();
	int x = i;
	for (i; i < j; i++)
		if (s[i] != t[i - x]) ans++;

	return ans;
}

void solve(int tc)
{
	string s, t;
	cin >> s >> t;
	int ans = INF;
	for (int i = 0; i <= s.size() - t.size(); i++)
	{
		ans = min(ans, diff(s, t, i));
	}

	cout << ans;
}	

int32_t main()
{	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
// gcd lcm
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
  ll a,b;
  cin>>a>>b;
  ll n=gcd(a,b);
  ll cu=1;
  ll num=n;
  if(n==1) COUT(1);
  else{
  if(num%2==0){
    cu++;
    while(num%2==0){
      num/=2;
    }
  }
  for (int i = 3; i <= sqrt(num); i+=2) {
    int j=0;
    if(num%i==0){
    while (num%i==0) { // 素数で割り切れなくなるまで割っていく
      num /= i;
      j=1; 
    }
    }
    if(j==1) cu++;
  }
    if(num>1) COUT(cu+1);
    else COUT(cu);
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

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

int main() {

    //freopen("input07.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);
    int n;cin>>n;
    ll even = 0, odd = 0;
    ll A[n];
    rep(i, n) {cin>>A[i];if(A[i]%2==0) even++;else odd++;}
    if(n == 1) {
        cout<<"Second"<<endl;
        return 0;
    }

    if(even%2 != 0) {
        cout<<"First"<<endl;
        return 0;
    }

    if(odd >= 2) {
        cout<<"Second"<<endl;
        return 0;
    }

    int f = 1;
    while(true) {
        bool found = false;
        rep(i, n) {if(A[i]%2 != 0 and A[i] > 1) {found = true;A[i]-=1;break;}}
        if(not found) {
            ll sum = 0;
            rep(i, n) sum += A[i];
            sum -= n;
            if(sum%2 == 0) {
                if(f) cout<<"Second"<<endl;
                else cout<<"First"<<endl;
                return 0;
            } else {
                if(!f) cout<<"Second"<<endl;
                else cout<<"First"<<endl;
                return 0;
            }
        }
        ll cgcd = 0;
        rep(i, n) cgcd = gcd(cgcd, A[i]);
        even = odd = 0;
        rep(i, n) {A[i]/=cgcd;if(A[i]%2==0) even++;else odd++;}
        f = 1^f;

        if(even%2 != 0) {
            if(f)
                cout<<"First"<<endl;
            else
                cout<<"Second"<<endl;
            return 0;
        }

        if(odd >= 2) {
            if(f)
                cout<<"Second"<<endl;
            else
                cout<<"First"<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








int main(){
    long n;
    cin >> n;
    vector<long> a(n);
    long Sum = 0;
    for(int i = 0;i < n;i++){
          cin >> a[i];
          Sum += a[i];
    }
    
    long ans = Sum;
    long t = 0;
    for(int i = 0;i < n;i++){
          t += a[i];
          ans = min(ans,abs(Sum - 2 * t));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   int x,y;
   cin >> x >> y;
    if(x%y==0)cout << -1 << endl;
    else cout << x << endl;
}



    
   


Measured memory_bytes: 3600
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    int n,x,t;
    cin >> n >> x >> t;
    int a = ((n+(x-1))/x);
    int ans = a*t;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3188
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
b = []
for _ in range(int(input())):
    b.append(int(input()))
if (a[0][0] in b and a[0][1] in b and a[0][2] in b) or\
   (a[1][0] in b and a[1][1] in b and a[1][2] in b) or\
   (a[2][0] in b and a[2][1] in b and a[2][2] in b) or\
   (a[0][0] in b and a[1][0] in b and a[2][0] in b) or\
   (a[0][1] in b and a[1][1] in b and a[2][1] in b) or\
   (a[0][2] in b and a[1][2] in b and a[2][2] in b) or\
   (a[0][0] in b and a[1][1] in b and a[2][2] in b) or\
   (a[0][2] in b and a[1][1] in b and a[2][0] in b):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
import sys
input = sys.stdin.readline

N, M  = (int(i) for i in input().split())
SM = [[int(i) for i in input().split()] for i in range(M)]

ans = [-1]*N

if M == 0 and N == 1:
    print(0)
    exit()

for i in range(M):
    if ans[SM[i][0]-1] == -1 or ans[SM[i][0]-1] == SM[i][1]:
        ans[SM[i][0]-1] = SM[i][1]
    else:
        print(-1)
        exit()

for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0

#if ans[0] == 0:
 #   print(-1)
 #   exit()

fans = str(int("".join(map(str, ans))))
#print(len(str(fans)))
#print(int(fans))

if len(fans) != N:
    print(-1)
    exit()
else:
    print(fans)


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

int main()
{
  string str;
  cin >> str;
  bool flag = true;
  for( int i = 0; i < str.size(); i++ ) 
  {
    if( i % 2 == 0 ) 
    {
      // 奇数文字目の時
      if( !( str.at(i) == 'R' || str.at(i) == 'U' || str.at(i) == 'D' ) )
      {
        flag = false;
      }
    }
    else
    {
      // 奇数文字目の時
      if( !( str.at(i) == 'L' || str.at(i) == 'U' || str.at(i) == 'D' ) )
      {
        flag = false;
      }
    }
  }
  cout << ( flag ? "Yes" : "No" ) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
ll n, m;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(m);
    ll ans=min(n, m/2);
    m-=ans*2;
    ans+=m/4;
    writeln(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0; i <= n ; i++) {
			sum += i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35808
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

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

    int lower = max(A, C);
    int upper = min(B, D);
    cout << max(0, upper - lower) << endl;
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long n, m;
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  
  long long d = gcd(n, m);
  long long i1 = n / d;
  long long i2 = m / d;

  long long len = n * m / d;
  long long index1 = 0;
  long long index2 = 0;
  while (index1 < n && index2 < m) {
    if (s1[index1] != s2[index2]) {
      cout << -1;
      return 0;
    }
    index1 += i1;
    index2 += i2;
  }
  cout << len;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c,d; cin >> a >> b >> c >>d ;
    if(((abs(b-a) <= d)&&(abs(c-b)<=d))|| abs(c-a) <= d)cout << "Yes" << endl;
    else cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long rec(long long n,int x,long long m){
    if(n<=(1<<x)*m) return x;
    rec(n,x+1,m);
}
long long waru2(long long k){
    if(k%2==0)return k/2;
    else return k/2+1;
}
int main(){
    long long N;cin>>N;
    long long K;cin>>K;
    long long K0=K;
    int k=rec(K,0,1);
    long long sum=N*(1<<k);
    long long ans=0;
    int count=0;
    //cout<<" hi"<<endl;
    while(N<K){
        K=waru2(K);
        count++;
    }
    ans+=(N-K+1)*(1<<(k-count));
    N=K-1;
    //cout<<"hihi"<<endl;
    while(K>1){
        K=waru2(K);
        count++;
        ans+=(N-K+1)*(1<<(k-count));
        N=K-1;

    }
    //cout<<" hiihih"<<endl;
    cout<<fixed<<setprecision(9)<<(double)ans/sum<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;

  ll p;
  string S;
  vl prob(N, 0);
  vl wa_cnt(N, 0);
  rep(i, M){
    cin >> p >> S;

    if(prob[p - 1] == 0){
      if(S == "WA"){
	wa_cnt[p - 1]++;
      } else{
	prob[p - 1] = 1;
      }
    }
  }

  ll ac = accumulate(prob.begin(), prob.end(), 0);
  ll wa = 0;
  rep(i, N) wa += prob[i] == 1 ? wa_cnt[i] : 0;

  cout << ac << ' ' << wa << "\n";
  
  return 0;
}


Measured memory_bytes: 4824
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define MAX_W 10000 
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

int
solve()
{
	int i, j;

	for (j = 0; j <= W; ++j)
		dp[0][j] = 0;

	for (i = 0; i < n; ++i)
	{
		for (j = 0; j <= W; ++j)
		{
			if (j < w[i])
				dp[i + 1][j] = dp[i][j];
			else
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}

	return dp[n][W];
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d %d", &n, &W);
	for (i = 0; i < n; ++i)
		scanf("%d %d", &v[i], &w[i]);

	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 4536
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
  ll a, b, c;
  cin >> a >> b >> c;

  if (c - a - b < 0){
    cout << "No" << endl;
  } else if (4 * a * b < c * c + a * a + b * b - 2 * c * a + 2 * a * b - 2 * c * b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
a=[int(input())]
def f(x):
    if x%2==0:
        return x//2
    else:
        return 3*x+1

for i in range(1,1000001):
    a.append(f(a[i-1]))
    if a.count(f(a[i-1]))==2:
        print(i+1)
        break

    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int k;string s;
	cin>>k>>s;
	vi p(1,0);
	for(auto c:s) p.pb(c=='I'?1:-1);
	partial_sum(all(p),p.begin());
	cout<<*max_element(all(p))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 998244353
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	int N;
	ll res = 0;
	cin >> N;
	vector<ll> a(N);

	rep(i, N)
	{
		cin >> a[i];

		ll tmp = a[i];
		while (1)
		{
			if (tmp % 2 == 0)
			{
				res++;
				tmp /= 2;
			}
			else {
				break;
			}
		}
	}
	
	cout << res << endl;
	return 0;
}

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


int main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    int sum[n+1];
    for(int i=0; i<n; i++)cin >> p[i];
    sum[0] = 0;
    for(int i=0; i<n; i++)sum[i+1] = sum[i]+p[i];
    int max = 0;
    for(int i=0; i<=n-k; i++){
        int val = sum[k+i] - sum[i];
        if (max < val) max = val;
    }
    double ans = (((double)max + (double)k) / 2.0);
    printf("%.16f", ans);
}


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

int main() {
	string S; cin >> S;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == S[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    while(K > 0){
        if(K >= 60){
            H2--;
            K -=60;
        }else if(M2 < K){
            H2--;
            M2 += (60 - K);
            K = 0;
        }else{
            M2 -= K;
            K = 0;
        }
    }
    ll a, b;
    if(M2 - M1 >= 0){
        a = H2 - H1;
        b = M2 - M1;
    }else{
        a = H2 - H1 - 1;
        b = M2 + (60 - M1);
    }
    ll ans = 60*a + b;
    if(ans <= 0){prt(0);}
    else{prt(ans);}
}

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

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c, d;
    int n;
    cin >> a >> b >> c >> d >> n;

    ll m1 = min(4 * a, (min(2 * b, c)));
    ll m2 = min(2 * m1, d);

    ll ans = n / 2 * m2 + n % 2 * m1;
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = [0]
    b = [0]
    c = [0]
    for _ in range(N):
        ai, bi, ci = map(int, input().split())
        a.append(ai)
        b.append(bi)
        c.append(ci)
    dp = [[0] * 3 for _ in range(N + 1)]

    for i in range(1, N + 1):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]

    print(max(dp[N]))


main()


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

using namespace std;

int main(){

  int N,W;
  cin >> N >> W;

  vector<int> v(N+1),w(N+1);
  for(int i = 1; i <= N; i++)
    cin >> v[i] >> w[i];

  auto dp = vector< int >(W+1,0);
  //  int dp[2][10001] = {0};
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= W; j++){
      if(j >= w[i]) dp[j] = max( dp[j], dp[j-w[i]] + v[i] ); 
    }
  }

  cout << dp[W] << endl;

}



Measured memory_bytes: 3124
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  vector<uint64_t> a(N);
  cin >> a;

  uint64_t S = 0;
  N_TIMES(n, N) { S ^= a[n]; }
  
  N_TIMES(n, N) {
    cout << (S ^ a[n]);
    if (n + 1 < N) { cout << ' '; }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 4740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        scanner.close();

        StringBuilder sb = new StringBuilder();
        for (char c : S.toCharArray()) {
            switch (c) {
                case '0':
                case '1':
                    sb.append(c);
                    break;
                case 'B':
                    if (sb.length() > 0) {
                        sb.deleteCharAt(sb.length() - 1);
                    }
                    break;
                default:
                    throw new IllegalStateException();
            }
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
#define MAX 50100

int main(void){
  bool prime[MAX] = {false};

  prime[0] = prime[1] = true;
  for(int i = 2 ; i*i <= MAX-1 ; i++){
    if(!prime[i]){
      for(int j = i*2 ; j <= MAX - 1 ; j += i){
        prime[j] = true;
      }
    }
  }

  int n;
  while(cin >> n){
    for(int i = n-1 ; ; i--){
      if(!prime[i]){
        cout << i << ' ';
        break;
      }
    }
    for(int i = n+1 ; ; i++){
      if(!prime[i]){
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1216
N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for i in range(Q)]
# print(N, M, Q)
# print(abcd)

def calculate(A):
    total = 0
    for abcdi in abcd:
        a = abcdi[0] - 1
        b = abcdi[1] - 1
        c = abcdi[2]
        d = abcdi[3]
        if A[b] - A[a] == c:
            total += d
    # print(A, total)

    return total

maximum = 0
for i in range(1, M + 1):
    if N == 1:
        maximum = max(calculate([i]), maximum)
    for j in range(i, M + 1):
        if N == 2:
            maximum = max(calculate([i, j]), maximum)
        for k in range(j, M + 1):
            if N == 3:
                maximum = max(calculate([i, j, k]), maximum)
            for l in range(k, M + 1):
                if N == 4:
                    maximum = max(calculate([i, j, k, l]), maximum)
                for m in range(l, M + 1):
                    if N == 5:
                        maximum = max(calculate([i, j, k, l, m]), maximum)
                    for n in range(m, M + 1):
                        if N == 6:
                            maximum = max(calculate([i, j, k, l, m, n]), maximum)
                        for o in range(n, M + 1):
                            if N == 7:
                                maximum = max(calculate([i, j, k, l, m, n, o]), maximum)
                            for p in range(o, M + 1):
                                if N == 8:
                                    maximum = max(calculate([i, j, k, l, m, n, o, p]), maximum)
                                for q in range(p, M + 1):
                                    if N == 9:
                                        maximum = max(calculate([i, j, k, l, m, n, o, p, q]), maximum)
                                    for r in range(q, M + 1):
                                        if N == 10:
                                            maximum = max(calculate([i, j, k, l, m, n, o, p, q, r]), maximum)

print(maximum)


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x) {
  return x * x;
}

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B)
    cout << C << endl;
  else if (A == C)
    cout << B << endl;
  else if (B == C)
    cout << A << endl;

  return 0;
}


Measured memory_bytes: 3572
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int a,z;
vec<vec<int>> l;
vec<int> add, o;

void dfs(int v, int p, int s){
    s+=add[v];
    o[v] = s;
    for(int h : l[v]){
        if(h==p) continue;
        dfs(h,v,s);
    }
}

int main(){
    fast;
    cin>>a>>z;
    o = vec<int>(a);
    add = vec<int>(a);
    l = vec<vec<int>>(a, vec<int>());
    for(int q=0; q<a-1; q++){
        int x,y; cin>>x>>y; x--; y--;
        l[x].pb(y);
        l[y].pb(x);
    }
    for(; z;z--){
        int v,x; cin>>v>>x; v--;
        add[v]+=x;
    }
    dfs(0, -1, 0);
    for(int i : o) cout<<i<<" ";
}

Measured memory_bytes: 20864
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
in All points

Complexity: 101 * 101 * N -> Max: 101 * 101 * 100 = 1020100
"""
import sys
from itertools import product

input = sys.stdin.readline

N = int(input())
xyh_list = [tuple(map(int, input().split())) for _ in range(N)]

# There is one point where hi == 1:
non0_hhh = []
for x, y, h in xyh_list:
    if h != 0:
        non0_hhh.append([x, y, h])
if len(non0_hhh) == 1:
    print(*non0_hhh[0])
    exit()

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    for i, (xi, yi, hi) in enumerate(xyh_list):
        if hi == 0:
            continue
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        if last_H is None:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break

    if valid_flag:
        print(Cx, Cy, last_H)
        exit()


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  for(int i=0; i < (int)str.size() - 1; i++) {
    if (str[i] == 'A' && str[i + 1] == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    
   
   int h,w,sx=0,sy=0,gx,gy,nw=0;
   
   cin>>h>>w;
 

   
    gx=w-1;gy=h-1;
    
    vvll d(h,vll(w,0));
    vvll d2(h,vll(w,0));
    d.at(0).at(0)=1;
    vvll maze(h,vll(w));
    rep(i,h){
        rep(j,w){
            char c;
            cin>>c;
            if(c=='#')maze.at(i).at(j)=1;
            else{
                maze.at(i).at(j)=0;
                nw++;
            } 
        }
    }

   
    queue<pll> q;
    q.push({sy,sx});
    
    vll dy={0,-1,0,1};

    vll dx={-1,0,1,0};

    while(!q.empty()){
        ll ny=q.front().first;
        ll nx=q.front().second;
        q.pop();
        //cout<<ny<<" "<<nx<<endl;;
        rep(i,4){
            ll x=nx+dx.at(i);
            ll y=ny+dy.at(i);
           
            if(0<=x&&x<w&&0<=y&&y<h){
                 
                if(maze.at(y).at(x)==0){
                     if(d.at(y).at(x)==0){
                         //cout<<y<<x<<endl;
                        d.at(y).at(x)=d.at(ny).at(nx)+1;
                        d2.at(y).at(x)=1;
                        q.push({y,x});
                     }
                }
            }
        }// cout<<endl;
    }

    
    if(d.at(gy).at(gx)==0)cout<<-1<<endl;
    else cout<<nw-d.at(gy).at(gx)<<endl;
    
    
    
}



Measured memory_bytes: 3648
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ;
typedef unsigned long long int ull;
using namespace std;
int main(){
    
    ll n;
    cin>>n;
    ll ans=LLONG_MAX;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ll val= i-1;
            ll val1= n/i;
            val1--;
           ans= min(ans, val+val1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    
    int a = 0;
    for(int i = 1; i <= sqrt(m); ++i)
    {
        if(i <= m/n && m % i == 0)
        {
            a = max(a, i);
            if(i >= n)
                a = max(a, m/i);
        }
    }
    
    cout << a << '\n';
    
    return 0;
}


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

struct SkewHeap {
    struct Node {
        Node *left, *right;
        int dat;
        Node(int x) : left(nullptr), right(nullptr), dat(x) {}
    };
    Node *root;
    int sz;
    SkewHeap() : root(nullptr) {}

    Node *meld(Node *a, Node *b) {
        if (a == nullptr) return b;
        if (b == nullptr) return a;
        if (a->dat < b->dat) swap(a, b);
        a->right = meld(a->right, b);
        swap(a->left, a->right);
        return a;
    }

    /// 
    const int &top() const {
        return root->dat;
    }
    int size() const {
        return sz;
    }
    void push(int x) {
        Node *p = new Node(x);
        root = meld(root, p);
        ++sz;
    }
    void pop() {
        Node *p = root;
        root = meld(root->right, root->left);
        delete p;
        --sz;
    }
    void meld(SkewHeap &other) {
        root = meld(root, other.root);
    }
};


vector<int> children[100010];
SkewHeap query[100010];
int markedAt[100010];
using ll = long long;

ll pull(int v) {
    ll res = 0;
    for (int c : children[v]) {
        res += pull(c);
        if (query[v].size() < query[c].size()) {
            swap(query[v], query[c]);
        }
        while (query[c].size()) {
            query[v].push(query[c].top());
            query[c].pop();
        }
    }
    while (query[v].size() && query[v].top() > markedAt[v]) {
        res += v + 1;
        query[v].pop();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    while (cin >> n >> q && n) {
        fill(children, children + n, vector<int>());
        fill(markedAt, markedAt + n, 1e9);
        for (int i = 1; i < n; ++i) {
            int p;
            cin >> p;
            --p;
            children[p].push_back(i);
        }
        markedAt[0] = -1;
        for (int i = 0; i < q; i++) {
            char c;
            int v;
            cin >> c >> v;
            --v;
            if (c == 'Q') {
                query[v].push(i);
            } else {
                if (markedAt[v] == 1e9) {
                    markedAt[v] = i;
                }
            }
        }
        cout << pull(0) << endl;
    }
}

Measured memory_bytes: 25108
// AOJ 2249: Road Construction
// 2017.11.15 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define MAX 16010
typedef struct { int t, node, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].c < que[i].c)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].c < que[min].c)) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, int t, int c)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t, que[i].c = c;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].c > que[i].c)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x55555555
typedef struct { int to, d, c; } EG;
typedef struct { int len; EG e[50]; } TBL;
TBL tbl[10001];
char visited[10001]; int size;

int dijkstra(int start)
{
	int i, s, d, c, ans = 0;
	EG *e;

	qsize = 0;
	memset(visited, 0, sizeof(visited));
	enq(start, 0, 0);
	while(qsize) {
		s = que[0].node, d = que[0].t, c = que[0].c; deq();
		if (visited[s]) continue;
		visited[s] = 1;
		ans += c;
		for (e = tbl[s].e, i = tbl[s].len; i--; e++) {
			if (visited[e->to]) continue;
			enq(e->to, d + e->d, e->c);
		}
	}
	return ans;
}

char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, u, v, d, c;
	EG  *e;
#if TM
	clock_t start, finish;
	start = clock();
#endif

	while (fgets(p=buf, 40, stdin) && *p != '0') {
		size = n = getint(), p++, m = getint();

		memset(tbl, 0, sizeof(TBL)*size);
		for (i = 0; i < m; i++) {
			fgets(p=buf, 40, stdin);
			u = getint()-1, p++, v = getint()-1, p++, d = getint(), p++, c = getint();

			e = tbl[u].e + tbl[u].len;
			e->to = v, e->d = d, e->c = c, tbl[u].len++;

			e = tbl[v].e + tbl[v].len;
			e->to = u, e->d = d, e->c = c, tbl[v].len++;
		}
		printf("%d\n", dijkstra(0));
	}
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 7292
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  struct Work {
    ll spend;
    ll limit;
  };
  vector<Work> works(N);
  for (ll i = 0; i < N; i++) {
    cin >> works[i].spend >> works[i].limit;
  }

  sort(begin(works), end(works), [](auto x, auto y) {
    if (x.limit != y.limit) {
      return x.limit < y.limit;
    }
    return x.spend > y.spend;
  });

  ll spend_sum = 0;
  for (ll i = 0; i < N; i++) {
    spend_sum += works[i].spend;
    if (spend_sum > works[i].limit) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	static int[] num;
	static int set;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			set=scan.nextInt();
			if(set==0) break;
			String gomi = scan.nextLine();
			String[] data = new String[set];
			num=new int[set];
			for(int i=0;i<set;++i){
				data[i]=scan.nextLine();
				num[i]=data[i].length();
			}
			for(int i=0;i<set;++i){
				int flag=0,sum=0,j=i;
				while(true){
					if(i<set){
						sum+=num[j];
						if(flag==0||flag==2){
							if(sum==5){
								sum=0;
								flag+=1;
							} else if(sum<5){
							} else {
								break;
							}
						} else {
							if(sum==7){
								sum=0;
								flag+=1;
							} else if(sum<7){
							} else {
								break;
							}
						}
						j++;
					} else {
						break;
					}
					if(flag==5){
						System.out.println(i+1);
						i=set;
						break;
					}
				}
			}
		}
	}
}



Measured memory_bytes: 33856
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int a[N];
  int i;
  for(i=0;i<N;i++)
  {
    cin>>a[i];
  }
  int Alice=0;
  int Bob=0;
  sort(a,a+N);
  for(int k=N-1;k>=0;k=k-2)
  {
    Alice=Alice+a[k];
  }
  for(int j=N-2;j>=0;j=j-2)
  {
    Bob=Bob+a[j];
  }
  cout<<Alice-Bob<<endl;
  return 0;

}


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

using namespace std;

vector<int> G[200000];
long add[200000];
bool used[200000];

void dfs(int v){
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            add[G[v][i]] += add[v];
            dfs(G[v][i]);
        }
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < Q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        add[p] += x;
    }
    dfs(0);
    for(int i = 0; i < N-1; i++){
        cout << add[i] << ' ';
    }
    cout << add[N-1] << endl;
}

Measured memory_bytes: 24448
#include <stdio.h>

int main(){
  long long int N,Y;
  long long int S=0LL;
  scanf("%lld",&N);
  for(long long int i=1LL;i<=N;i++){
    Y=N/i;
    S+=Y*(Y+1)*i/2LL;
  }
  printf("%lld\n",S);
  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int M=scan.nextInt();
        int start=scan.nextInt();
        int[] A=new int[M];
        int i;
        int count1=0;
        int count2=0;
        for(i=0;i<M;i++){
            A[i]=scan.nextInt();
            if(A[i]<start){
                count1++;
            }
            else{
                count2++;
            }
        }
        if(count1<count2){
            System.out.println(count1);
        }
        else{
            System.out.println(count2);
        }
        
    }
}

Measured memory_bytes: 23892
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X = int(input())

A = 100
cnt = 0

while A < X:
    A = int(A * 1.01)
    cnt += 1

print(cnt)

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

int main() {
  int x, y;
  cin >> x >> y;
  int z = x + y;
  if (z == 2) {
    cout << 1000000 <<endl;
  }
  else {
    int c = 0;
    if (x == 1) {
      c += 300000;
    }
    else if (x == 2) {
      c += 200000;
    }
    else if (x == 3) {
      c += 100000;
    }
    if (y == 1) {
      c += 300000;
    }
    else if (y == 2) {
      c += 200000;
    }
    else if (y == 3) {
      c += 100000;
    }
    cout << c <<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int k=0;
  while(n>0)
  {
    int z=n%10;
    if(z==7)
    {
      k=1;
      break;
    }
    n/=10;
  }
  if(k==1) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int H, W, w=0;
	for (;;){
		cin >> H >> W;
		if (W == 0 && H == 0){
			break;
		}
		for (int i = 1; i <= H; i++){
			if (i == 1 || i == H){
				for (; w < W; w++){
					cout << "#";
				}
				cout << endl;
				w = 0;
			}
			else if (i < H){
				cout << "#";
				for (int j = 2; j < W; j++){
					cout << ".";
				}
				cout << "#" << endl;
			}
		}
		cout << endl;
		}
	return 0;
	}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> cnt(n, 1);
    vector<bool> red(n, false);
    red[0] = true;
    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        if (!red[x]) {
            cnt[x]--;
            cnt[y]++;
        }
        else {
            if (cnt[x] == 1) {
                red[x] = false;
            }
            cnt[x]--;
            cnt[y]++;
            red[y] = true;
        }
    }
    ll ans = 0;
    rep(i, n) ans += (red[i] ? 1 : 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024