akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int 			long long int
#define pll 			pair<ll , ll>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

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

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
    
    int a , b;
    
    cin >> a >> b;
    
    cout << (a+b-1) / b;
}       

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    int odd[2][100001] = {}; // R, L
    int even[2][100001] = {}; // R, L
    int r_cont = 1;
    int l_cont = 1;
    for(int i=1;i<n;++i)
    {
        if(s[i] == 'R')
        {
            r_cont++;
        }
        else
        {
            even[0][i-1] = r_cont / 2 + r_cont % 2;
            odd[0][i-1] = r_cont / 2;
            r_cont = 0;
        }
        
        if(s[n-1-i] == 'L')
        {
            l_cont++;
        }
        else
        {
            even[1][n-i] = l_cont / 2 + l_cont % 2;
            odd[1][n-i] = l_cont / 2;
            l_cont = 0;
        }
    }

    for(int i=0;i<n;++i)
    {
        if(s[i] == 'R')
        {
            if(s[i+1] == 'L')
            {
                cout << even[0][i] + odd[1][i+1];
            }
            else
            {
                cout << 0;
            }
        }
        else
        {
            if(s[i-1] == 'R')
            {
                cout << even[1][i] + odd[0][i-1];
            }
            else
            {
                cout << 0;
            }
        }
        cout << " \n"[i == (n-1)];
    }
}

Measured memory_bytes: 2256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

long long getCtOfP(int n)
{
    long long a = 1;
    for(int i = 0; i <= n; i++){
        if(i != 0){
            a *= 2;
            a += 1;
        }
    }
    return a;
}


long long getCtOfAll(int n)
{
    long long a = 1;
    for(int i = 0; i <= n; i++){
        if(i != 0){
            a *= 2;
            a += 3;
        }
    }
    return a;
}

long long mkbg(int n, long long x)
{
    long long bgct = getCtOfAll(n);
    long long sum = 0;

    if(x == 0){
        return 0;
    }

    if(x == bgct){
        return getCtOfP(n);
    }

    if(bgct/2+1 == x){
        return getCtOfP(n-1)+1;
    }else if(bgct/2 < x){
        sum += getCtOfP(n-1) + 1 + mkbg(n-1, (x-bgct/2)-1);
    }else{
        sum += mkbg(n-1, x-1);
    }
    return sum;
}


int main(void)
{
    long long n,x;
    cin >>n >>x;

    long long ans = mkbg(n, x);

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

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(K == 0){
			Console.WriteLine(N * N);
			return;
		}
		
		long tot = N * N;
		
		long cnt = 0;
		for(long i=1;i<=K;i++) cnt += N;
		for(long i=K+1;i<=N;i++){
		
			var cnt0 = (N / i) * K - 1;
			if(N % i != 0){
				cnt0 += Math.Min(K, N % i + 1);
			} else {
				cnt0 += 1;
			}
//Console.WriteLine(cnt0);
			cnt += cnt0;
		}
		Console.WriteLine(tot - cnt);
		
	}
	long N,K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define reg register
char str[1000005];
int n,f[1000005][2];
int main ()
{
    scanf("%s", str + 1), n = strlen(str + 1);
    f[0][0] = 0, f[0][1] = 1;
    for (int i = 1; i <= n; i++)
    {
        int d = str[i] - '0';
        f[i][0] = min(f[i - 1][0] + d, f[i - 1][1] + 10 - d);
        f[i][1] = min(f[i - 1][0] + d + 1,f[i - 1][1] + 9 - d);
    }
    printf("%d\n", f[n][0]);
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <stack>
#include <string>
using namespace std;
void f(int);
int main() {
    string str;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(islower(str[i])){
            str[i]+='A'-'a';
        }
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 3040
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===
tMOD = 998244353


def main():
    x = ni()

    cnt = 0
    total=0
    while total < x:
        cnt += 1
        total += cnt

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
/// awoooooo

# include <bits/stdc++.h>

# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)3e5 + 5;
const int inf = (int)1e9 + 7;

int n;
int cnt[N];
string s;

int main(){
  cin >> n >> s;
  for(char i : s){
    cnt[i - 'a']++;
  }
  int ans = 1;
  for(int i = 0; i < 26; ++i){
    ans = (ans + ans * 1ll * cnt[i]) % inf;
  }
  printf("%d\n", (ans + inf - 1) % inf);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, t[100005];

void inc(int x, int v) {
    for (; x <= n; x += x & -x) t[x] += v;
}

int que(int x) {
    int z = 0;
    for (; x; x -= x & -x) z += t[x];
    return z;
}

int main() {
    ios::sync_with_stdio(false);
    int a[100005] = {}, c[100005] = {}, m = 0, p = 0;
    pii b[100005] = {};
    cin >> n; p = n + 1;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = {a[i], i};
    sort(b + 1, b + n + 1);
    reverse(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++) c[b[i].second] = i;
    for (int i = 1; i <= n; i++) inc(i, 1);
    for (int i = 1; i <= n; i++) {
        if (a[i] <= m) {
            cout << 0 << '\n';
            continue;
        }
        ll z = (ll)(a[i] - m) * que(c[i]);
        for (int j = c[i] + 1; j < p; j++) z += a[b[j].second] - m;
        cout << z << '\n';
        inc(c[i], -1);
        m = a[i];
        p = c[i];
    }
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') cnt++;
  }
  cout << (n < cnt * 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int ans = 0;

    vector<int> check(101, 0);
    for (int i = A; i <= B; i++) {
        check[i]++;
    }
    for (int i = C; i <= D; i++) {
        if (check[i] == 1) ans++;
    }

    cout << max(0, ans - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S=="abc" || S=="acb" || S=="bac" || S=="bca" || S=="cab" || S=="cba"){
    cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  if(!((L=A+B)-(R=C+D)))
    cout << "Balanced" << endl;
  else if(L>R)
    cout << "Left" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool check(string s1, string s2){
if(s1.length()!=s2.length()) return false;
string temp=s1+s1;
return(temp.find(s2)!=string::npos);
}
int main()
{
    string s,t;
    cin>>s>>t;
    if(check(s,t)){
        cout<<"Yes";
    }
    else {cout<<"No";}
    return 0;
}


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

const int maxn=2010;

char s[maxn];
int n,A[maxn],B[maxn],C[maxn];
int L[maxn],R[maxn],mx[maxn],Ans=0x7fffffff;

void solve()
{
	int i,p;
	for (i=0;i<n;i++)
	{
		for (R[i]=0,p=i;!B[p];p=(p+1)%n) R[i]++;
		for (L[i]=0,p=i;!B[p];p=(p+n-1)%n) L[i]++;
	}
	for (p=0;p<n;p++)
	{
		int Sum=p;
		for (i=0;i<n;i++)
			Sum+=C[i]=A[i]^B[(i+n-p)%n];
		memset(mx,0,sizeof(mx));
		for (i=0;i<n;i++)
			if (C[i]&&L[i]>p)
				mx[L[i]-p-1]=max(mx[L[i]-p-1],R[i]);
		for (i=n-1;i>=0;i--)
			mx[i]=max(mx[i],mx[i+1]);
		for (i=0;i<n;i++)
			Ans=min(Ans,Sum+2*(i+mx[i]));
	}
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,Acnt=0,Bcnt=0;
	scanf("%s",s);
	n=strlen(s);
	for (i=0;i<n;i++)
		Acnt+=A[i]=s[i]=='1';
	scanf("%s",s);
	for (i=0;i<n;i++)
		Bcnt+=B[i]=s[i]=='1';
	if (!Bcnt) {puts(Acnt?"-1":"0"); return 0;}
	solve();

	for (i=0;i<n;i++)
		if (i<n-1-i)
		{
			swap(A[i],A[n-1-i]);
			swap(B[i],B[n-1-i]);
		}
	solve();
	printf("%d\n",Ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[100];
int dp[110][1010];
int val[1010];
int sp[110];
int sq[110];
int np[110];
int nq[110];
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a){
		for(int i=0;i<b;i++){
			scanf("%s%d%d",in,sp+i,sq+i);
		}
		for(int i=0;i<c;i++)scanf("%s%d%d",in,np+i,nq+i);
		for(int i=0;i<110;i++)for(int j=0;j<1010;j++)dp[i][j]=-99999999;
		dp[0][0]=0;
		for(int i=0;i<c;i++){
			for(int j=i;j>=0;j--){
				for(int k=a-np[i];k>=0;k--){
					dp[j+1][k+np[i]]=max(dp[j+1][k+np[i]],dp[j][k]+nq[i]);
				}
			}
		}
		for(int i=0;i<1010;i++)val[i]=-99999999;
		for(int i=d;i<=c;i++)for(int j=0;j<=a;j++)val[j]=max(val[j],dp[i][j]);
		int ret=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<=a-sp[i];j++){
		//		if(sq[i]+val[j]==59)printf("%d %d\n",i,j);
				ret=max(ret,sq[i]+val[j]);
			}
			for(int j=i+1;j<b;j++){
				for(int k=0;k<=a-sp[i]-sp[j];k++){
			//		if(sq[i]+sq[j]+val[k]==59)printf("%d %d %d\n",i,j,k);
					ret=max(ret,sq[i]+sq[j]+val[k]);
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   int n,ans=0;
   cin>>n;
   vector<int>a(n);
   for(int i=0;i<n;i++) cin>>a[i];
   sort(a.begin(),a.end());
   for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int pos2=lower_bound(a.begin(),a.end(),a[i]+a[j])-a.begin();
            ans+=pos2-j-1;
        }
   }
   cout<<ans;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> s(M), c(M); REP(i, M) cin >> s[i] >> c[i];
  int ans = 1000;
  for(int i = 0; i <= 999; ++i) {
    string S = to_string(i); bool flag = false;
    REP(k, M) {
      if(char_to_int(S[s[k] - 1]) != c[k]) {
        flag = true;
        break;
      }
    }
    if(!flag) {
      if(S.size() == N) {
        ans = i;
        break;
      }
    }
  }

  if(ans == 1000) cout << -1 << endl;
  else cout << ans << endl;
}

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

const int MAX_N = 100100;
bool ans[MAX_N];
int h[MAX_N];

int N, M;


int main() {
    cin >> N >> M;
    for(int i = 0; i < N; ++i) {
        ans[i] = true;
        scanf("%d", h + i);
    }

    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        if(h[a - 1] == h[b-1]) {
            ans[a-1] = ans[b-1] = false;
        } else {
            int low = h[a - 1] <= h[b-1] ? a - 1 : b - 1;
            ans[low] = false;
        }
    }

    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        if(ans[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            out.println(6 - A - B);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std; 
int main () { 
string a;
cin>>a;
int sz=a.length();
int b=a.find("A");
int z=a.rfind("Z");
if (b >=0 && b < sz && z >=0 && z<sz) 
cout<< abs(b - z)  + 1 ;






  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N, M;
    cin >> N >> M;
    vector<pair<int64_t, int64_t>>vec(N);
    for (int64_t i=0; i<N; i++) {
        int64_t a, b;
        cin >> a >> b;
        vec[i] = make_pair(a, b);
    }
    sort(vec.begin(), vec.end());
    int64_t sum_count = 0;
    int64_t sum_en = 0;
    for (int64_t i=0; i<N; i++) {
        pair<int64_t, int64_t> p = vec[i];
        int64_t rem = M - sum_count;
        int64_t honsuu = min(rem, p.second);
        sum_en += honsuu * p.first;
        sum_count += honsuu;
        if (sum_count >= M) {
            break;
        }
    }

    cout << sum_en << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <stdio.h>

int gcd(int p,int q){
  int r=p%q;
  while(r>0){
    p=q;
    q=r;
    r=p%q;
  }
  return q;
}

int main(){
  int a,b,c,K,S=0;
  scanf("%d",&K);
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        S+=gcd(gcd(a,b),c);
      }
    }
  }
  printf("%d\n",S);
  return 0;
}

Measured memory_bytes: 1684
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            Console.WriteLine(Math.Truncate(r[0]*r[1]));
        }
    }
}

Measured memory_bytes: 28248
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,sum;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&k);
	FOR{
		scanf("%d",&a[i]);
		b[a[i]]++;
		sum+=a[i];
	}
	FOR{
		double at=a[i]/(double)(sum);
		if(at>=1.0/(4.0*k)){cev++;}
	}
	if(cev>=k){printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
}



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

#define jaldi ios_base::sync_with_stdio(false)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define all(x) x.begin(),x.end()
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}
ll root(ll a,vll &head)
{
    while(a!=head[a])
    {
        head[a]=head[head[a]];
        a=head[a];
    }
    return a;
}
void merge(ll a,ll b,vll &head, vll &size)
{
    ll p_a = root(a,head);
    ll p_b = root(b,head);
    if(p_a==p_b)
        return;
    
    if(size[p_a]>size[p_b])
    {
        size[p_a]+=size[p_b];
        head[p_b]=head[p_a];
    }
    else
    {
        size[p_b]+=size[p_a];
        head[p_a]=head[p_b];
    }
    
}

int main()
{
    jaldi;
    precision(2);
    ll i,j;
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
        long double a;
        long double b;
        cin>>a>>b;
        long double ans=a*b;

        // {
            // ll fans;
            string x=to_string(ans);
            for(i=0;i<x.size();i++)
            {
                if(x[i]=='.')
                    break;
                cout<<x[i];
            }
        // }
    }
    return 0;
}

Measured memory_bytes: 3856
//
//  main.cpp
//  ALDS1_3_A
//
//  Created by ptyuan on 2018/10/18.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;

struct Stack {
    int element[1000] = {0};
    int top = 0;
    
    void push(int value) {
        element[++top] = value;
    }
    
    int pop() {
        return element[top--];
    }
    
    bool empty() {
        return top == 0;
    }
};

int main(int argc, const char * argv[]) {
    Stack stack;
    char s[100];
    while (scanf("%s", s) != EOF) {
        char value = s[0];
        switch (value) {
            case '+':
            {
                int right = stack.pop();
                int left = stack.pop();
                int result = left + right;
                stack.push(result);
            }
                break;
            case '-':
            {
                int right = stack.pop();
                int left = stack.pop();
                int result = left - right;
                stack.push(result);
            }
                break;
            case '*':
            {
                int right = stack.pop();
                int left = stack.pop();
                int result = left * right;
                stack.push(result);
            }
                break;

            default:
                int v = atoi(s);
                stack.push(v);
                break;
        }
    }
    cout << stack.pop() << endl;
    
    
    return 0;
}



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

// 相手がパーを出せるときは自分もパーを出せるので全て相殺し、
// 余ったパーを相手のグーにぶつければよい。(最後から埋めていけば制約を満たせる。)
int main(){
  string hands;
  cin >> hands;

  int64_t ans= hands.size()/2;
  for(auto hand:hands){
    if(hand=='p'){ ans--; }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdlib.h> 
#include <stdio.h>
long long Max(long long x,long long y){
    return x>y?x:y;
}
long long Min(long long x,long long y){
    return x<y?x:y;
}
long long p=1000000000,n,a,b,c,l[10];
void dfs(long long i,long long A,long long B,long long C,long long T){
    if(i==n+1){return;}
    if(A>0&&B>0&&C>0){
        p=Min(p,abs(a-A)+abs(b-B)+abs(c-C) + 10*(Max(0,T-3)));
        
    }
        dfs(i+1,A+l[i],B,C,T+1);
        dfs(i+1,A,B+l[i],C,T+1);
        dfs(i+1,A,B,C+l[i],T+1);
        dfs(i+1,A,B,C,T);
}

int main()
{
    
    scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
    for(int i=0;i<n;i++){
        scanf("%lld",&l[i]);
    }
    dfs(0,0,0,0,0);
    printf("%lld",p);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << abs(c - a) + abs(d - b) - gcd(abs(c - a), abs(d - b)) << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}
template <typename T> void arrout(const T arr, int n) {
  for (int i = 0; i < n; ++i, cout << (i != n ? " " : "\n")) {
    cout << arr[i];
  }
}

template <typename T>
class UnionFind {
private:
  vector<T> parent,rank,size;
  T root(T k) {
    if(parent[k]==k) return k;
    else return parent[k]=root(parent[k]);
  }

public:
  UnionFind(T n) {
    parent.resize(n);
    rep(i,n) parent[i]=i;
    rank.resize(n,0);
    size.resize(n,1);
  }

  bool is_same(T i,T j) {
    return root(i)==root(j);
  }

  void unite(T i,T j) {
    i=root(i); j=root(j);
    if(i==j) return;
    if(rank[i]>rank[j]) {
      parent[j]=i;
      size[i]+=size[j];
    } else {
      parent[i]=j;
      size[j]+=size[i];
      if(rank[i]==rank[j]) rank[j]++;
    }
  }

  T get_size(T k) {
    return size[root(k)];
  }
};

void solve() {
  // main coding
  ll n,m; cin>>n>>m;
  vector<pll> ab;
  ll a,b;
  rep(i,m) {
    cin>>a>>b;
    a--; b--;
    ab.emplace_back(a,b);
  }
  // calculate
  UnionFind<ll> tree(n);
  vll ans;
  ll score=n*(n-1)/2;
  ans.pb(score);
  for(auto it=--ab.end();it!=ab.begin();--it){
    a=it->fi; b=it->se;
    if(not tree.is_same(a,b)){
      score-=tree.get_size(a)*tree.get_size(b);
      tree.unite(a,b);
    }
    ans.pb(score);
  }
  // output
  reverse(ans.begin(),ans.end());
  iter(it,ans) cout<<*it<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

int64_t caracalBattle(int64_t h) {
    if (h == 1) return 1;

    return caracalBattle(h / 2) * 2 + 1;
}

int main() {
    int64_t H; cin >> H;
    cout << caracalBattle(H) << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll INF = 1 << 29;
const ll MOD = 1e9 + 7;

int main()
{
    int X, Y, Z;
    std::cin >> X >> Y >> Z;

    X -= Z;
    std::cout << X / (Y + Z) << std::endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

typedef long long ll;
#define fi first
#define se second


using namespace std;

int main(){
  
  int N;
  
  cin>>N;
  
  char s[N+1];
  char t[N+1];
  
  scanf("%s", s);
  scanf("%s", t);
  
  int ans = N;
  
  
  
  int i;
  int j;
  int cnt;
  
  for( i = 0; i < N; i++ ){
    cnt = 0;
    for( j = 0; j < N; j++ ){
      
      if( i+j < N ){
        if( s[i+j] == t[j] ){
          cnt++;
        }
        else{ break;}
      }
      else{
        ans += ( N - cnt );
        break;
      }
    }
    if( cnt == N || ans != N ) break;
  }
  
  if( !(cnt) ) ans += N;
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a, b,i,j;
    int c = 0;
    int sum = 0;
    int L[100] = {};


    if(scanf("%d %d",&a,&b) == 0);

    for (i = 0; i < a;i++){
        if(scanf("%d", &L[i]) == 0);

    }
    for (j = 0; j < a;j++){
        sum = sum + L[j];
        c = j+1;
        if(sum>b){
            break;
        }else{
            c = c + 1;
        }
    }
    printf("%d\n",c);

    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ll N, W; cin >> N >> W;
    vector<ll> vec[4];
    ll w0;
    ll ans = 0;
    rep(i, N){
        ll w, v; cin >> w >> v;
        if(i == 0){
            w0 = w;
            vec[0].push_back(v);
        }
        else{
            vec[w-w0].push_back(v);
        }
    }
    rep(i, 4) sort(vec[i].begin(), vec[i].end(), greater<ll>());
    rep(i, 4){
        for(int j = 1; j < vec[i].size(); j++) vec[i][j] += vec[i][j-1];
    }

    for(int i = 0; i <= vec[0].size(); i++){
        for(int j = 0; j <= vec[1].size(); j++){
            for(int k = 0; k <= vec[2].size(); k++){
                ll acc_weight = i*w0 + j*(w0+1) + k*(w0+2);
                ll acc_val = 0;
                if(i > 0) acc_val += vec[0][i-1];
                if(j > 0) acc_val += vec[1][j-1];
                if(k > 0) acc_val += vec[2][k-1];
                for(int l = 0; l <= vec[3].size(); l++){
                    if(acc_weight + l*(w0+3) <= W){
                        if(l > 0) ans = max(ans, acc_val + vec[3][l-1]);
                        else ans = max(ans, acc_val);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

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

  vector<string> s;
  string a;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    s.push_back(a);
  }

  int count_a = 0;
  int count_b = 0;
  int only_a = 0;
  int only_b = 0;
  int both = 0;
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < s[i].length(); j++)
    {
      if (j == 0 && s[i][j] == 'B')
      {
        count_b++;
      }
      else if (j == s[i].length() - 1 && s[i][j] == 'A')
      {
        count_a++;
      }

      if (j < s[i].length() && s[i][j] == 'A' && s[i][j + 1] == 'B')
      {
        res++;
      }
    }

    if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')
    {
      both++;
    }
    else if (s[i][0] == 'B')
    {
      only_b++;
    }
    else if (s[i][s[i].length() - 1] == 'A')
    {
      only_a++;
    }
  }

  if (n > 1)
  {
    res += std::min(count_a, count_b);
  }
  if (only_a == 0 && only_b == 0 && both != 0)
  {
    res--;
  }

  cout << res << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef long long int int64;
typedef unsigned long long int uint64;
typedef float float32;
typedef double float64;
typedef long double float128;


int main(){
    int H,W;
    cin >> H >> W;
    char s[H+2][W+2];
    REP(i,H){
        s[i][0]='.';
        s[i][W+1]='.';
    }
    REP(j,W){
        s[0][j]='.';
        s[H+1][j]='.';
    }
    REP(i,H){
        REP(j,W){
            cin >> s[i+1][j+1];
        }
    }
    string ans="Yes";
    REP(i,H){
        REP(j,W){
            if(s[i+1][j+1]=='#'){
                if(s[i][j+1]=='#'||s[i+2][j+1]=='#'||s[i+1][j]=='#'||s[i+1][j+2]=='#'){
                    if(ans=="Yes"){
                        ans = "Yes";
                    }else{
                        ans = "No";
                    }
                }else{
                    ans = "No";
                }
            }
        }
    }
    cout << ans;

}

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

using namespace std;

int main()
{
   int n, m, num = 0;
   int k[30], a[30][30];
   int tmp[30] = {0};

   cin >> n >> m;

   for(int i=0;i<30;i++) tmp[i] = 0;

   for(int i=0;i<n;i++){
      cin >> k[i];
      for(int j=0;j<k[i];j++){
         cin >> a[i][j];
      }
   }

   for(int i=0;i<n;i++){
      for(int j=0;j<k[i];j++){
         tmp[a[i][j]-1]++;
      }
   }

   for(int i=0;i<m;i++){
      if(tmp[i] == n) num++;                                          
   }

   cout << num << endl;

   return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string par;
  cin >> par;
  stack<pair<int,bool>> s;
  list<char> l;
  for(int i=0;i<N;++i){
    l.push_back(par[i]);
    if(par[i]=='('){
      s.push(make_pair(i,true));
    }else{
      if(s.empty()||!s.top().second){
        s.push(make_pair(i,false));
      }else{
        s.pop();
      }
    }
  }
  while(!s.empty()){
    auto p = s.top();
    if(p.second){
      l.push_back(')');
    }else{
      l.push_front('(');
    }
    // cout << s.top().first << endl;
    s.pop();
  }
  for(auto c:l){
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

cand=list(range(1,n+1))

ans=[]
for i in range(1,(m+1)//2+1):
    ans.append((cand[1-i],i+1))

n_odd = m//2
start = ans[-1][1]+n_odd
for i in range(1,n_odd+1):
    ans.append((start-i+1,start+i+1))

for aa in ans:
    print(*aa)

Measured memory_bytes: 75256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <map>

using namespace std;
int main() {
	int N;
	cin >> N;
	std::map<std::string, int> Judge;
	Judge["AC"] = 0;
	Judge["WA"] = 0;
	Judge["TLE"] = 0;
	Judge["RE"] = 0;
	
	for(int i = 0;i<N;i++){
		std::string S;
		cin >> S;
		Judge[S]++;
	}
	
	std::cout << "AC x " << Judge["AC"] << endl; 
	std::cout << "WA x " << Judge["WA"] << endl; 
	std::cout << "TLE x " << Judge["TLE"] << endl; 
	std::cout << "RE x " << Judge["RE"] << endl; 
	
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}
#include<bits/stdc++.h>
using namespace std;
int H2D(long long x){
char a[]={(char)x};
int len = strlen(a);
int base =1,D=0;
for(int i=len-1;i>=0;i--){
    if(a[i]>='0' && a[i]<='9'){
        D+=(a[i]-48)*base;
        base*=16;
    }
    else if(a[i]>='A' && a[i]<='F'){
        D+=(a[i]-55)*base;
        base*=16;
    }
}
    return D;
}


int B2D(long long x){
long long rem,ans=0,s=0;
while(x!=0){
    rem=x%10;
    ans+=rem*pow(2,s);
    s++;
    x/=10;
}
    return ans;
}
int D2B(long long x){
long long rem,s=0,ans=0;
while(x!=0){
    rem=x%2;
    s=(s*10)+rem;
    x/=2;
}
while(s!=0){
    rem=s%10;
    ans=(ans*10)+rem;
    s/=10;
}
    return ans;
}





int main(){
    ll n,value,s,ans,sum = 0,ans1,ans2,p,x,y;
        cin>>n>>x;
         int dig = (int)(floor( log(n) /
                         log(x)) + 1);
                cout<< dig <<endl;

    return accepted;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{ 
    return (a.second < b.second);      // compare function for sorting modification
}

vector<ll> primes;
vector<bool> PRIME(1000005,true);       // prime no.s less than 10^6
void sieve(ll n)                        // PRIME[i]=true => i=prime no.
{  PRIME[0]=false;PRIME[1]=false;
    for (ll p=2; p*p<=n; p++) { 
        if (PRIME[p] == true) { 
            for (ll i=p*p; i<=n; i += p){PRIME[i]=false;} 
        } 
    } rep(i,2,n+1){if(PRIME[i]){primes.pb(i);}}
}  

ll nCr[1001][1001];
void combination(ll n)                  // nCr values
{
    rep(i,0,n+1){
        rep(j,0,i+1){
            if(j==0 or j==i)nCr[i][j]=1;
            else nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%NUM;
        }
    }
}

#define N  1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,p,r,u,v,w,x,y,z,mn,mx;
ll arr[N];
//ll dp[2005][2005];

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        mn=LONG_LONG_MAX;
        mx=LONG_LONG_MIN;
        cin>>n>>k;
        rep(i,0,n){cin>>arr[i];}
        
        ll dp[n];
        dp[0]=0;
        
        for(ll i=1;i<n;i++)
        {
            dp[i]=mn;
            for(ll j=max(i-k,0LL);j<i;j++)
            {
                dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
            }
        }
        
        cout<<dp[n-1];
        
        
        
        
        
        
        
        
        
        
        h:;
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 5296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    void solve() throws IOException {
        long x = getLong();
        long y = getLong();
        if(x == y){
            System.out.println(-1);
            return;
        }
        for(long i = 2; i < 1000000; ++i){
            long res = (long)(x * i);
            if(res % y != 0){
                System.out.println(res);
                return;
            }
        }
        System.out.println(-1);
    }

    BufferedReader bufferedReader;
    PrintWriter output;
    StringTokenizer tokenizer;

    public static void main(String[] args) throws IOException {
        Main contest = new Main();
        contest.run();
    }

    public String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(bufferedReader.readLine());
        }
        return tokenizer.nextToken();
    }

    public int getInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long getLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void run() throws IOException {
        bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        output = new PrintWriter(System.out);
        solve();
    }

}


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  cout << (n + x - 1) / x * t << endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3532
#E - Logs
import math
# 入力
N,K = map(int,input().split())
A   = list(map(int,input().split()))
Amax = int(max(A))
high = Amax
Cancut = Amax
low  = 0
while ( (high - low) > 0.01 ) :
    Cut = 0
    X = (high + low) / 2.0
    for i in range(N):
        Cut = Cut + math.ceil(A[i]/X) - 1
    if Cut <= K:
        high = X
        Cancut = X
    else:
        low  = X
# 出力
if (math.floor(high) != math.floor(low)):
    Cancut = math.floor( 100 * Cancut) /100.0
print(math.ceil(Cancut))

Measured memory_bytes: 31248
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int64_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int64_t a = 1; a <= 3500; a++)
		for (int64_t b = 1; b <= 3500; b++)
	{
			int64_t x = N*a*b;
			int64_t y = 4 * a*b - (a + b)*N;
			if (y > 0 && (x%y==0)) {
				out << a << ' ' << b << ' ' << (x / y) << endl;
				return 0;
			}
	}

	return 0;
}
#endif


Measured memory_bytes: 888
from collections import deque

N = int(input())

q = deque()

for i in range(N):
    A, B = map(int, input().split())
    q.append((B, A))

work = sorted(q)

A_sum = 0
for w in work:
    A_sum += w[1]

    if A_sum > w[0]:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 31444
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<algorithm>
#define int long long int
int32_t main()
{
	  int h,w;
	  cin>>h>>w;
      vector<int> row[h+1];
      int i,j;
      for(i=1;i<=h;i++)
      {
		  row[i].push_back(0);
		  row[i].push_back(w+1);
	  }
	  vector<int> col[w+1];
	  for(j=1;j<=w;j++)
	  {
		  col[j].push_back(0);
		  col[j].push_back(h+1);
	  }
	  char mat[h+1][w+1];
	  for(i=1;i<=h;i++)
	  {
		  for(j=1;j<=w;j++)
		  {
			  cin>>mat[i][j];
			  if(mat[i][j]=='#')
			  {
				  row[i].push_back(j);
				  col[j].push_back(i);
			  }
		  }
	  }
	  for(i=1;i<=h;i++)
	  {
		  sort(row[i].begin(),row[i].end());
	  }
	  for(j=1;j<=w;j++)
	  {
		  sort(col[j].begin(),col[j].end());
	  }
	  int answer=0;
	  for(i=1;i<=h;i++)
	  {
		  for(j=1;j<=w;j++)
		  {
			   if(mat[i][j]=='.')
			   {
				   auto it=lower_bound(row[i].begin(),row[i].end(),j);
				   int x=*it;
				   it--;
				   int y=*it;
				   auto it2=lower_bound(col[j].begin(),col[j].end(),i);
				   int p=*it2;
				   it2--;
				   int q=*it2;
				   int val=(x-y-1+p-q-1-1);
				   answer=max(answer,val);
			   }
		  }
	  }
	  cout<<answer<<endl;
}


Measured memory_bytes: 70912
tmp = input().split()
a = int(tmp[0])
b = int(tmp[1])

ans_a = a
ans_b = b
for i in range(b-1):
 ans_a =(ans_a*10) + a

for i in range(a-1):
 ans_b =(ans_b*10) + b

if ans_a == ans_b:
 print(ans_a)
else:
 list = [str(ans_a),str(ans_b)]
 list.sort()
 print(list[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  set<int> st;
  int x = a % b;
  rep(i, b*b)
  {
    st.insert(x);
    x = (x + a) % b;
  }
  if(st.find(c) != st.end()){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut aa = (0..n)
        .map(|_| {
            let mut v = util::gets::<usize>();
            v.reverse();
            for x in v.iter_mut() {
                *x -= 1;
            }
            v
        })
        .collect::<Vec<_>>();

    let mut ans = n;
    let mut used = vec![false; m];

    'outer: loop {
        let mut count = vec![0; m];
        for a in aa.iter_mut() {
            while !a.is_empty() && used[a.last().cloned().unwrap()] {
                a.pop();
            }
            if a.is_empty() {
                break 'outer;
            }
            let s = a.last().cloned().unwrap();
            count[s] += 1;
        }

        let s = (0..m).max_by_key(|&i| count[i]).unwrap();
        ans = min(ans, count[s]);
        used[s] = true;
    }

    println!("{}", ans);
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

int h, w;
string s[22];

const int inf = 1LL<<60;

signed main() {
  cin >> h >> w;
  rep(i, 0, h) cin >> s[i];

  vvi dist(h*w, vi(h*w, inf));
  rep(i, 0, h*w) dist[i][i] = 0;

  rep(i, 0, h) rep(j, 0, w){
    if(s[i][j] == '#') continue;

    if(i+1 < h and s[i+1][j] != '#'){
      dist[i*w+j][(i+1)*w+j] = 1;
      dist[(i+1)*w+j][i*w+j] = 1;
    }

    if(j+1 < w and s[i][j+1] != '#'){
      dist[i*w+j][i*w+(j+1)] = 1;
      dist[i*w+(j+1)][i*w+j] = 1;
    }
  }

  rep(k, 0, h*w) rep(i, 0, h*w) rep(j, 0, h*w){
    chmin(dist[i][j], dist[i][k] + dist[k][j]);
  }

  int ans = 0;
  rep(i, 0, h*w) rep(j, 0, h*w){
    if(dist[i][j] != inf) chmax(ans, dist[i][j]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1536