akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1e9 + 7;
const int nax = 2e6 + 20;
ll sil[nax];
ll odw[nax];
ll pots[nax];
ll pots25[nax];


ll choose(int n, int k) {
	ll res = (sil[n] * odw[k]) % mod;
	return (res * odw[n - k]) % mod;
}

ll pot(ll a, int b) {
	ll res = 1;
	while (b) {
		if (b&1) {
			res = (res * a) % mod;
		}
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}

ll odwr(int x) {
	return pot(x, mod - 2);
}

int main() {
	ios_base::sync_with_stdio(false);
	int k;
	string c;
	cin >> k;
	cin >> c;
	int m = k + sz(c);
	int n = sz(c);
	sil[0] = 1;
	odw[0] = 1;
	pots[0] = pots25[0] = 1;
	rep(i,1,nax) {
		sil[i] = (sil[i-1] * i) % mod;
		odw[i] = odwr(sil[i]);
		pots[i] = (pots[i-1] * 26) % mod;
		pots25[i] = (pots25[i-1] * 25) % mod;
	}
	ll res = 0;
	rep(i,n-1, m) {
		ll pom = (choose(i, n-1) * pots25[i - (n-1)]) % mod;
		pom = (pom * pots[m - (i + 1)]) % mod;
		// printf("adding: (%d po %d) * 25^(%d)*26^(%d)\n", i, n-1, (i - (n-1)), m - (i + 1));
		res = (res + pom) % mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 66884
N = int(input())
*A, = map(int, input().split())


min = float("inf")
for y in range(-100, 101, 1):
    sum = 0
    for a in range(len(A)):
        sum = sum + (A[a]-y)**2
    if min > sum:
        min = sum
        ans = y

print(min)

Measured memory_bytes: 3060
#include <cstdio>

const char temp[] = "CODEFESTIVAL2016";
char str[17];

int main()
{
	scanf("%s", str);
	int ans = 0;
	for (int i = 0; i < 16; ++i)
	{
		if (str[i] != temp[i])
		{
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int g[2002][2002];
int u[2002][2002], d[2002][2002], l[2002][2002], r[2002][2002], res = 0;

int main()
{
    int h, w;
    cin >> h >> w;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            char tmp;
            cin >> tmp;
            if (tmp == '.')
            {
                g[i][j] = 1;
            }
            u[i][j] = 0;
            d[i][j] = 0;
            l[i][j] = 0;
            r[i][j] = 0;
        }
    }

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (g[i][j] == 1)
            {
                u[i][j] = u[i - 1][j] + 1;
                l[i][j] = l[i][j - 1] + 1;
            }

            int p = h - i + 1;
            int q = w - j + 1;
            if (g[p][q] == 1)
            {
                d[p][q] = d[p + 1][q] + 1;
                r[p][q] = r[p][q + 1] + 1;
            }
        }
    }

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            res = max(res, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
        }
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  vi ABC(3);
  cin >> ABC;
  sort(rng(ABC));
  i64 ans = 0;

  if(ABC.at(0)%2==ABC.at(1)%2 and ABC.at(0)%2!=ABC.at(2)%2){
    ABC.at(0)++;
    ABC.at(1)++;
    ans++;
  }
  if(ABC.at(0)%2==ABC.at(2)%2 and ABC.at(0)%2!=ABC.at(1)%2){
    ABC.at(0)++;
    ABC.at(2)++;
    ans++;
  }
  if(ABC.at(1)%2==ABC.at(2)%2 and ABC.at(0)%2!=ABC.at(1)%2){
    ABC.at(1)++;
    ABC.at(2)++;
    ans++;
  }

  sort(rng(ABC));
  ans += (ABC.at(2)-ABC.at(0))/2;
  ans += (ABC.at(2)-ABC.at(1))/2;

  cout << ans << "\n";



}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

using namespace std;

int main(void)
{
    int N;
    int i;
    int Color_Num = 3;
    string Color;

    cin >> N;

    for (i = 0; i < N; i++){
        cin >> Color;
        if (Color == "Y")
            Color_Num = 4;
    }

    if (Color_Num == 3)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<ll> L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    int ans=0;

    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
                    if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
a, b, k = map(int, input().split())
if 2*k >= b-a+1:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for j in range(b-k+1, b+1):
        print(j)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll n,m,sum = 0;
	cin >> n >> m;
	ll x[m];
	
	rep(i,0,m) cin >> x[i];
	
	if(m == 1 || n >= m){
		cout << 0 << endl;
		return 0;
	}
	
	sort(x,x+m,greater<ll>());
	
	ll d[m-1]= {};
	
	rep(i,1,m){
		d[i-1] = x[i-1] - x[i];
		sum += d[i-1];
		//cout << d[i-1] << " " << sum << endl;
	}
	
	sort(d,d+m-1,greater<ll>());
	
	
	rep(i,0,n-1){
		sum -= d[i];
	}
	
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int diff(string a,string b)
{
	int sum=0;
	for(int i=0;i<a.size();i++)
	sum+=a[i]!=b[i];
	return sum;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	string s,t;
	int ans=10000;
	cin>>s>>t;
	for(int i=0;i<=s.size()-t.size();i++)
	ans=min(ans,diff(t,s.substr(i,t.size())));
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        long n=nl(),k=nl(),rem=n%k;
        pn(Math.min(rem, Math.abs(rem-k)));
    }


    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

Measured memory_bytes: 21332
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)
import           Data.Sequence         as S

main :: IO ()
main = do
  n <- readLn
  xs <- getInts
  putStr . unlines . map show $ solve n xs

solve :: Int -> [Int] -> [Int]
solve n xs = map f xs
  where f x = if x <= a then b else a
        a = S.index v (n `div` 2 - 1)
        b = S.index v (n `div` 2)
        v = S.unstableSort $ S.fromList xs

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 59900
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    map<ll,ll> M;
    vl B=A;
    sort(B.begin(), B.end());
    for(ll i=0;i<N;++i){
        M[B[i]]=i;
    }
    ll ans=0;
    for(ll i=0;i<N;++i){
        if(i%2!=M[A[i]]%2)ans++;
    }
    prt(ans/2)

    return 0;
}


Measured memory_bytes: 8064
use std::collections::HashSet;

fn solve(mut ds: Vec<u8>) -> usize {
    ds.sort();
    ds.into_iter().collect::<HashSet<u8>>().len()
}

fn main() {
    let n = read_1();
    let ds = read_1_n(n);

    println!("{}", solve(ds));
}

fn read_1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_1_n<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let mut ss = String::new();
    for _ in 0..n {
        std::io::stdin().read_line(&mut ss).ok();
    }
    let mut v = ss.split("\n").collect::<Vec<&str>>();
    v.pop();
    v.iter()
        .map(|s| s.trim().parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}
ll solve (ll n){
    long *div=new long [n+1];
    // ll div[n + 1];
    for(int i=0;i<=n;i++)
        div[i]=0;
   // memset(div, 0, sizeof div);

    // For every number from 1 to n
    for (ll i = 1; i <= n; i++) {

        // Increase divisors count for
        // every number divisible by i
        for (ll j = 1; j * i <= n; j++)
            div[i * j]++;
    }
    ll s=0;
    for(ll i=1;i<=n;i++){
        s+=i*div[i];
    }
    return s;
}
int main(){
   fio

           ll n;
           cin>>n;
           ll ans=solve(n);
           cout<<ans;

  return 0;
}


Measured memory_bytes: 81804
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  string A, B, C;
  int a =0, b=0, c=0;
  int point = 0;
  cin >> A >> B >> C;

  while(1){
    if(a==A.size() && point==0) {
      print("A");
      return 0;
    } else if (b==B.size() && point == 1) {
      print("B");
      return 0;
    } else if (c==C.size() && point == 2){
      print("C");
      return 0;
    }
    if (point == 0){
      if(A[a] == 'b') point = 1;
      if(A[a] == 'c') point = 2; 
      a++;
    } else if (point == 1){
      if(B[b] == 'a') point = 0;
      if(B[b] == 'c') point = 2; 
      b++;
    } else {
      if(C[c] == 'a') point = 0;
      if(C[c] == 'b') point = 1;
      c++;
    }
  }

}


Measured memory_bytes: 888
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
ll n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	cout<<n*n*n;
	return 0;
}

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

int main() {
   int x, y;
   cin >> x >> y;

   int a[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

   if (a[x-1] == a[y-1]) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define INF 1000000000
int main(){

  while(true){
    int n,k;
    cin >> n >> k;
    if(n==0)break;
    int cost[100][100];
    for(int i =0;i<n;i++){
      for(int j =0;j<n;j++){
        if(i!=j)cost[i][j]=INF;
        else cost[i][j] = 0;
      }
    }
    int flg = false;
    for(int i =0;i<k;i++){
      int a,b,c,d,e,f;
      cin >>f;
      if(!f){
        if(flg){
          for(int i1 =0;i1<n;i1++){
            for(int j =0;j<n;j++){
              for(int k = 0;k<n;k++){
                cost[j][k]=min(cost[j][k],cost[j][i1]+cost[i1][k]);
              }
            }
          }
        }
        flg = false;
        cin >>a>>b;
        if(cost[a-1][b-1]==INF){
          cout <<-1<<endl;
        }
        else{
          cout << cost[a-1][b-1]<<endl;
        }
      }
      else{
        cin >>c>>d>>e;
        if(cost[d-1][c-1]>e){
          flg = true;
          cost[d-1][c-1]=cost[c-1][d-1]=e;
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3088
# -*- coding: utf-8 -*-

s = input()
K = int(input())

sub = []
for i in range(1,6):
    for j in range(0,int(len(s))):
        if s[j:j+i] in sub:
            pass
        else:
            sub.append(s[j:j+i])

sub=sorted(sub)
print(sub[K-1])


Measured memory_bytes: 4072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int N, L;
	string s[102];
	cin >> N >> L;
	for (int i = 0;i < N;i++) {
		cin >> s[i];
	}

	sort(s, s + N);

	for (int i = 0;i < N;i++) {
		cout << s[i];
	}

	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n,a,b;
    cin>>n>>a>>b;
    int c=a+b;
    ll ans=(n/c)*a;
    ll d=n%c;
    ll e=min(d,a);
    //cerr<<ans<<endl;
    cout<<ans+e<<endl;
    
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();    
    let i: usize = iter.next().unwrap().parse().unwrap();    
    println!("{}", n - i + 1);
}



Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;
const int maxn=1e5+5;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(c<=a+b) cout<<"Yes";
	else cout<<"No";
 } 

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=r[0].split(" "),n=Number(t[0]),o=Number(t[1]),f=[],u=[],a=0;a<n;a++){var i=r[a+1].split(" "),l=Number(i[0]),p=Number(i[1]);f.push(l),u.push(p)}for(var s=9999999,c=[],d=0;d<n;d++)c.push(0);for(var v=[{depth:0,flags:c}];v.length>0;){var b=v.shift();if(b.depth<n){var g=b.flags.concat();g[b.depth]=1;var h={depth:b.depth+1,flags:g};v.push(h);var y=b.flags.concat(),m={depth:b.depth+1,flags:y};v.push(m)}if(b.depth==n){for(var x=0,j=0,O=0;O<n;O++)1==b.flags[O]&&(j+=100*(O+1)*f[O]*b.flags[O],j+=u[O],x+=f[O]);if(j<o)for(var S=n-1;S>=0;S--)if(1!=b.flags[S]){for(var _=0;_<f[S]&&(x+=1,!((j+=100*(S+1))>=o));_++);if(j>=o)break}x<s&&(s=x)}}console.log(s)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		long[] a=sc.La;
		long b=0,c=0;
		int q=0;
		string[] ans=new string[n*2];
		for(int i = 0;i<n;i++) {
			if(a[b]<a[i]){b=i;}
			if(a[c]>a[i]){c=i;}
		}
		if(Math.Abs(a[b])>Math.Abs(a[c])){
			for(int i = 1;i<n;i++) {
				while(a[i]<a[i-1]){
					a[i]+=a[b];
					ans[q]=(b+1)+" "+(i+1);
					q++;
					if(a[b]<a[i]){b=i;}
				}
			}
		}
		else{
			for(int i = n-2;i>=0;i--) {
				while(a[i]>a[i+1]){
					a[i]+=a[c];
					ans[q]=(c+1)+" "+(i+1);
					q++;
					if(a[c]>a[i]){c=i;}
				}
			}
		}
		Array.Resize(ref ans,q);
		Console.WriteLine("{0}",q);
		if(q>0){Console.WriteLine(String.Join("\n",ans));}
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
const int Shurui=26;//今回は26種類
int Date;//今回は1年間なので365日
long long Seigenjikan=1800000;//実行時間
long long s[400][Shurui];
long long c[Shurui];
long long last[Shurui];

long long range(long long l,long long r){
  long long len=r-l-1;
  return -len*(len+1)/2;
}
struct ContestJouhou{
  set<long long>kaisai[Shurui];
  vector<long long>t;
  int Date;
  long long tensuu=0;
  ContestJouhou(int Date):Date(Date){
    t.resize(Date,-1);
    for(int i=0;i<Shurui;i++){
      kaisai[i].insert(-1);
      kaisai[i].insert(Date);
      tensuu+=c[i]*range(-1,Date);
    }
  }
  void tasu(int d,int q){
    if(t[d]!=-1){
      cout<<"tasemasendesita"<<endl;
      exit(1);
    }
    t[d]=q;
    tensuu+=s[d][q];
    kaisai[q].insert(d);
    auto it=kaisai[q].find(d);
    auto rit=next(it);
    auto lit =prev(it);
    tensuu-=c[q]*range(*lit,*rit);
    tensuu+=c[q]*range(*it,*rit);
    tensuu+=c[q]*range(*lit,*it);
  }
  void hiku(int d){
    if(t[d]==-1){
      cout<<"hikemasendesita"<<endl;
      exit(1);
    }
    int q=t[d];
    t[d]=-1;
    tensuu-=s[d][q];
    auto it=kaisai[q].find(d);
    auto rit=next(it);
    auto lit=prev(it);
    tensuu+=c[q]*range(*lit,*rit);
    tensuu-=c[q]*range(*it,*rit);
    tensuu-=c[q]*range(*lit,*it);
    kaisai[q].erase(it);
  }
  void kaeru(int d,int q){
    hiku(d);
    tasu(d,q);
  }
};
      

int main() {
  clock_t start = clock();//スタート時間
  cin >>Date;
  long long wa=0;
  for(int i=0;i<Shurui;i++){
    cin>>c[i];
    wa+=c[i];
  }
  for(int i=0;i<Date;i++){
    for(int j=0;j<Shurui;j++){
      cin>>s[i][j];
    }
  }
  ContestJouhou cj(Date);
  for(int i=0;i<Date;i++){
    long long t=i%Shurui;//1から順番に並べるを繰り返す
    cj.tasu(i,t);
  }  
  long long tensuu=cj.tensuu;//最初の満足度
  
  clock_t end = clock();//初期値を出した時間
  long long time = end - start;//改善に使える残りの時間
  while(time<Seigenjikan){

    /*int d=rand()%Date;
    int q=rand()%Shurui;
    int old=cj.t[d];
    cj.kaeru(d,q);*/

    //2点swapに変更
    int d=rand()%Date;
    int d2;
    if(d+2<Date)d2=d+2;
    else if(d-2>=0)d2=d-2;
    else d2=rand()%Date;
    int q=cj.t[d2];
    int q2=cj.t[d];
    int old=cj.t[d];
    int old2=cj.t[d2];
    cj.kaeru(d,q);
    cj.kaeru(d2,q2);
    
    long long new_tensuu=cj.tensuu;
    if(new_tensuu<tensuu){
      cj.kaeru(d,old);
      cj.kaeru(d2,old2);
    }else{
      tensuu=new_tensuu;
    }
    end = clock();
    time = end - start;
  }
  for(int i=0;i<Date;i++){
    cout<<cj.t[i]+1<<endl;
  }
  return 0;
}

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

using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

#define lson o<<1
#define rson o<<1|1
#define gmid l[o] + r[o] >> 1

int n, Q;

LL S[N<<2], lazy[N<<2];
int l[N<<2], r[N<<2];

void build(int o, int ll, int rr){
    l[o] = ll;
    r[o] = rr;
    S[o] = lazy[o] = 0;
    if(ll < rr){
        int mid = gmid;
        build(lson, ll, mid);
        build(rson, mid+1, rr);
    }
}

void update(int o, int ll, int rr, LL v);

int pushdown(int o){
    int mid = gmid;
    if(lazy[o]){
        update(lson, l[o], mid, lazy[o]);
        update(rson, mid+1, r[o], lazy[o]);
        lazy[o] = 0;
    }
    return mid;
}

void update(int o, int ll, int rr, LL v){
    if(l[o]==ll && r[o]==rr){
        S[o] = v * (rr - ll + 1);
        lazy[o] = v;
        return;
    }
    int mid = pushdown(o);
    if(rr <= mid)   update(lson, ll, rr, v);
    else if(ll > mid)   update(rson, ll, rr, v);
    else{
        update(lson, ll, mid, v);
        update(rson, mid+1, rr, v);
    }
    S[o] = S[lson] + S[rson];
}

LL query(int o, int ll, int rr){
    if(l[o]==ll && r[o]==rr){
        return S[o];
    }
    int mid = pushdown(o);
    if(rr <= mid)   return query(lson, ll, rr);
    if(ll > mid)    return query(rson, ll, rr);
    return query(lson, ll, mid) + query(rson, mid+1, rr);
}

void solve(int a, LL b){
    int low = 1, top = a, mid, key = top;
    LL tmp, v;
    while(low <= top){
        mid = low + top >> 1;
        tmp = query(1, mid, a);
        v = query(1, mid, mid);
        if(v * (a - mid + 1) - tmp <= b){
            key = min(key, mid);
            top = mid - 1;
        } else {
            low = mid + 1;
        }
    }
    tmp = query(1, key, a);
    v = query(1, key, key);
    int len = a - key + 1;
    LL d = v * len - tmp;
    b = b - d;
    LL g = b / len + v;
    LL h = b % len;
    if(h > 0){
        int p = key + (int)h - 1;
        update(1, key, p, g + 1);
        update(1, p+1, a, g);
    } else {
        update(1, key, a, g);
    }
}

int main(){
    while(~scanf("%d %d", &n, &Q)){
        build(1, 1, n);
        int a;
        LL b;
        for(int i=1; i<=Q; i++){
            scanf("%d %lld", &a, &b);
            solve(a, b);
        }
        for(int i=1; i<=n; i++){
            printf("%lld\n", query(1, i, i));
        }
    }
    return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  while( cin >> n ,n)
    {
      long long int a[5101] = {0};
      for(int i = 0 ; i < n ; i++ )
	{
	  cin >> a[i];
	}

      long long int dp[5101] = {0},mx = a[0];

      dp[0] = a[0];
      for(int i = 1 ; i < n ; i++ ){
	dp[i] = max(dp[i-1] + a[i],a[i]); 
	mx = max(dp[i],mx);
      }
      cout << mx << endl;
    }
  return 0;
}

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

 long long g(long long a,long long b);

long long l(long long a,long long b);

int main(){
long long w,h,c,z,a;
cin>>w>>h>>c;
    z=g(w,h)*g(w,h);
    a=w*h;
    a=a/z;
    cout<<a*c<<"\n";
    return(0);
    }
long long g(long long a,long long b){
    while(b!=0){
    long long r=a%b;
    a=b;
    b=r;
    }
    return(a);
}


Measured memory_bytes: 3100
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, N = il()
    magic = [il() for _ in range(N)]
    dp = [0] * (H + 1)

    dp[0] = 0
    for h in range(1, H + 1):
        for n in range(N):
            if n == 0:
                if magic[n][0] <= h:
                    dp[h] = dp[h - magic[n][0]] + magic[n][1]
                else:
                    dp[h] = magic[n][1]
            else:
                if magic[n][0] <= h:
                    dp[h] = min(dp[h], dp[h - magic[n][0]] + magic[n][1])
                else:
                    dp[h] = min(dp[h], magic[n][1])
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 79100
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll a[305][305];
ll b[305][305];
vector<pair<int,pair<int,int>>> e;

int main(){
    int n;
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >>a[i][j];
            b[i][j]=a[i][j];
            e.push_back(mp(a[i][j],mp(i,j)));
        }
    }
    //sort(a.begin(),a.end());
    rep(k,n){
        rep(i,n){
            rep(j,n){
                b[i][j]=min(b[i][j],b[i][k]+b[k][j]);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(b[i][j]<a[i][j]){
                cout<<-1<<endl;
                return 0;
            }else if(b[i][j]>a[i][j]){
                a[i][j]=0;
            }else{
                rep(w,n){
                    if(i!=w&&j!=w&&b[i][j]==b[i][w]+b[j][w]){
                        a[i][j]=0;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,n){
        rep(j,n){
            ans+=a[i][j];
        }
    }
    ans/=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2936
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	for (int i = N; i <= 999; i++) {
		string S = to_string(i);
		if (S[0] == S[1] && S[1] == S[2]) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

int N, A;
vector<int> x(51);
vector<vector<vector<ll>>> dp(51, vector<vector<ll>>(51, vector<ll>(50*50+1, -1)));

ll calc(int count, int index, int sum) {
    if ( sum < 0 ) return 0;
    if ( count < 0 ) return 0;
    if ( dp[count][index][sum] > -1 ) return dp[count][index][sum];
    if (sum == 0) {
        if (count == 0) return 1;
        else return 0;
    }

    if ( index == 1 ) {
        if ( count == 1 && sum == x[1] ) return 1;
        else return 0;
    }
    // cout << count << " " << index << " " << sum << "\n";
    dp[count][index][sum] = calc(count, index - 1, sum) + calc(count - 1, index - 1, sum - x[index]);
    // cout << count << " " << index << " " << sum << ":" << dp[count][index][sum] << "\n";

    return dp[count][index][sum];
}

int main() {

    cin >> N >> A;
    for (int i = 1; i <= N; i++) {
        cin >>x[i];
    }

    ll count = 0;

    for (int i = N; i > 0; i--) {
        count += calc(i, N, i * A);
    }


    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 52224
#include <stdio.h>

int main(void)
{
    int n[3], i;
    for (i = 0; i < 3; i++)
    {
        scanf("%d", &n[i]);
        if (n[0] == 1)
        {
            printf ("Hello World\n");
            return (0);
        }
    }
    printf ("%d\n", n[1] + n[2]);
    return (0);
}


Measured memory_bytes: 128
S = input()

if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)
  

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  scanf("%d", &n);
  int t = n, c=0;
  while(t>0) {
    c += t%10;
    t/=10;
  }
  printf("%s\n", (n%c==0? "Yes":"No"));
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, P):
    revp = [-1] * (N + 1)
    for i, p in enumerate(P):
        revp[p] = i

    segt = [[(v, 0) for v in P]]
    while len(segt[-1]) > 1:
        base = segt[-1]
        if len(base) % 2 == 1:
            base.append((0, 0))
        new = []
        for i in range(len(base) // 2):
            a, b = base[2 * i]
            c, d = base[2 * i + 1]

            arr = [a, b, c, d]
            arr.sort()
            new.append((arr[-1], arr[-2]))
        segt.append(new)

    dprint('segt', segt)

    def get12(i, j):
        if j - i <= 0:
            return (0, 0)

        segi = 0
        top = []

        while True:
            if j - i <= 0:
                break

            seg = segt[segi]

            if j - i == 1:
                top.extend(seg[i])
                break

            if i % 2 == 1:
                top.extend(seg[i])
                i += 1
            if j % 2 == 1:
                top.extend(seg[j - 1])
                j -= 1

            i //= 2
            j //= 2
            segi += 1

        top.sort()
        return top[-1], top[-2]

    cache = dict()

    stk = [(0, N)]
    while stk:
        item = stk.pop()
        if len(item) == 2:
            i, j = item
            if (i, j) in cache:
                continue

            a, b = get12(i, j)
            ai = revp[a]
            bi = revp[b]
            li, ri = (ai, bi) if ai < bi else (bi, ai)
            ri += 1

            sc = b * (li - i + 1) * (j - ri + 1)

            want = [(i, ri - 1), (li + 1, j), (li + 1, ri - 1)]
            req = []
            for c, d in want:
                if not (d - c < 2 or (c, d) in cache):
                    req.append((c, d))
            if not req:
                left, right, mid = [0 if d - c < 2 else cache[(c, d)]
                                    for c, d in want]
                cache[(i, j)] = left + right - mid + sc
                continue

            stk.append((i, j, want, sc))
            for r in req:
                stk.append(r)
            continue

        i, j, want, sc = item
        left, right, mid = [0 if d - c < 2 else cache[(c, d)]
                            for c, d in want]
        cache[(i, j)] = left + right - mid + sc

    return cache[(0, N)]


def main():
    N = int(inp())
    P = [int(e) for e in inp().split()]
    print(solve(N, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 109728
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef pair<int,int> P;
int N;
vector<P> ps;
signed main(){
	cin>>N;
	rep(i,N){
		int a,b;
		cin>>b>>a;
		ps.pb(P(b+a,a));
	}
	sort(all(ps));
	priority_queue<int> qa;
	int T = 0;
	int ans = 0;
	rep(i,N){
		int a = ps[i].sc;
		int b = ps[i].fs;
		T+=a;
		ans++;
		qa.push(a);
		if(T>b){
			int rm = qa.top();
			qa.pop();
			T -= rm;
			ans--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
S = input()

ans = 'AC'
if S[0] != 'A':
    ans = 'WA'

c = 0
cc = None
for i in range(2, len(S) - 1):
    if S[i] == 'C':
        c += 1
        cc = i

if c != 1:
    ans = 'WA'

for i in range(1, len(S)):
    if i == cc:
        continue

    if S[i].isupper():
        ans = 'WA'

print(ans)


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int a, b; cin >> a >> b;
	cout << max(a+b, max(a-b, a*b)) << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int n;
  string t_str;
  string h_str;
  string taro[1009];
  string hanako[1009];
  int t_score=0;
  int h_score=0;

  int i;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t_str >> h_str;
    transform(t_str.begin(),t_str.end(),t_str.begin(),::tolower);
    transform(h_str.begin(),h_str.end(),h_str.begin(),::tolower);
    taro[i]=t_str;
    hanako[i]=h_str;
  }

  for(i=0;i<n;i++){
    if(taro[i]>hanako[i])
      t_score+=3;
    else if(taro[i]<hanako[i])
      h_score+=3;
    else{
      t_score+=1;
      h_score+=1;
    }
  }
  cout << t_score << " " << h_score << endl;
}

Measured memory_bytes: 3304
N, M, K = gets.split.map(&:to_i)
ABs = M.times.map{gets.split.map(&:to_i)}
CDs = K.times.map{gets.split.map(&:to_i)}

@p = Array.new(N + 1, -1)

def root(x)
  @p[x] < 0 ? x : @p[x] = root(@p[x])
end

def unite(x, y)
  x, y = root(x), root(y)
  if x != y
    x, y = y, x if @p[y] < @p[x]
    @p[x] += @p[y]
    @p[y] = x
  end
end

def num(x)
  @p[x] == -1 ? 1 : -@p[root(x)]
end

def union?(x, y)
  root(x) == root(y)
end

f = Array.new(N + 1){[]}
ABs.each{|a, b| unite(a, b); f[a] << b; f[b] << a}
b = Array.new(N + 1){[]}
CDs.each{|c, d| b[c] << d; b[d] << c}
puts (1 .. N).map{|n| num(n) - f[n].count{|m| union?(n, m)} - b[n].count{|m| union?(n, m)} - 1}.join(' ')

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

typedef long long ll;
ll MOD = 1000000007;


ll mygcd(ll a, ll b) {
  return b != 0 ? mygcd(b, a % b) : a;
}
ll mylcm(ll a, ll b) {
  return a * b / mygcd(a, b);
}
int main()
{
    ll A, B, C, D;
    ll tmp, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
    cin >> A >> B >> C >> D;

    tmp = mylcm(C, D);
    tmp1 = (A - 1) / C + 1;
    tmp2 = B / C;
    tmp3 = (A - 1) / D + 1;
    tmp4 = B / D;
    tmp5 = (A - 1) / tmp + 1;
    tmp6 = B / tmp;
    //cout << tmp1 << " " << tmp2 << " " << tmp3 << " " << tmp4 << endl;
    cout << (B - A + 1) - (tmp2 - tmp1 + 1) - (tmp4 - tmp3 + 1) + (tmp6 - tmp5 + 1)<< endl;
    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 INF = 1e18 + 7;


signed main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<vector<int>> edges(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }

    vector<double> mem(n, -1);
    vector<int> par(n);
    vector<vector<int>> childs(n);
    function<void(int)> f = [&](int from){
        mem[from] = 0;
        int cnt = 0;
        for(auto& to : edges[from]){
            if(mem[to] != -1)
                continue;
            childs[from].emplace_back(to);
            par[to] = from;
            f(to);
            ++cnt;
            mem[from] += mem[to] + 1;
        }
        if(cnt)
            mem[from] /= cnt;
    };
    f(0);

    vector<double> ans(n, -1);
    function<void(int, double, int)> g = [&](int from, double sum, int cnt){
        for(auto& to : childs[from]){
            sum += mem[to] + 1;
            ++cnt;
        }
        ans[from] = sum / cnt;
        for(auto& to : childs[from]){
            double val = sum;
            val -= mem[to] + 1;
            // cout << "val : " << val << " - >  cnt : " << cnt << endl;
            if(cnt - 1)
                val /= cnt - 1;
            else
                val = 0;
            val += 1;

            g(to, val, 1);
        }
    };
    g(0, 0, 0);

    for(auto& x : ans)
        printf("%.20lf\n", x);
}


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

long long int n,ans;
int main()
{
	cin>>n;
	ans=(n*(n+1))/2;
	for(long long int i=2;i<=n;i++)
	{
		for(long long int j=1;j*i<=n;j++)
			ans+=j*i;
	}
	cout<<ans;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(1e2 + 5);
const int MAX_W = (int)(1e2 + 5);

int a, b;

int h = 100;
int w = 100;
char white = '.';
char black = '#';
char field[MAX_H][MAX_W];

void coloring(char color, int begin_h, int num) {
  if (num == 0) return;
  
  int cnt = 0;
  for (int i = begin_h; i < h; i += 2) {
    for (int j = 0; j < w; j += 2) {
      field[i][j] = color;
      cnt += 1;
      if (cnt == num) return;
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      field[i][j] = (i < h / 2) ? black : white;
    }
  }

  coloring(white, 0, a - 1);

  coloring(black, h / 2 + 1, b - 1);

  printf("%d %d\n", h, w);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      printf("%c", field[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x[n];

  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=1;i<n+1;i++){
    cout << x[n-i];

    if(i==n){
      cout <<endl;
    }else{
      cout << " ";
    }
  }

}



Measured memory_bytes: 3092
#include<iostream>
#include<cmath>
#include<vector>
#include<iostream>

#define ll long long
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a*b % 2) {
      cout << "Odd";
    } else {
      cout << "Even";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]
n = int(input())
men = [tuple(map(int, input().split())) for _ in range(n)]
men.sort(key=lambda x: (x[0]+x[1], -x[0]))
allowed = [-1 for _ in range(n)]
allowed[n-1] = men[-1][0]
for i in range(n-2, -1, -1):
	allowed[i] = max(allowed[i+1], men[i][0])

INF = 10**10
dp = [INF for _ in range(n+1)]
dp[0] = 0
for i in range(n):
	for j in range(i+1, 0, -1):
		if dp[j-1] <= men[i][0]:
			dp[j] = min(dp[j], dp[j-1] + men[i][1])

#print(dp)
for i in range(n+1):
	if dp[i] < INF:
		ans = i
print(ans)

Measured memory_bytes: 43500
#include <stdio.h>
int main()
{
    int K,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i;
    scanf("%d",&K);
    for(i=1;i<=32;i++)
    {
        if(K==i)
            printf("%d",a[i-1]);
    }
}



Measured memory_bytes: 128