akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define int         long long
#define ll          long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
} 

void solve(){
    int n,d,tot = 0;
    cin >> n >> d;
    FOR(i,1,n+1){
        int x,y;
        cin >> x >> y;
        if(x*x+y*y <= d*d)tot++;
    }
    cout << tot << "\n";
}
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

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

int main() {
	int N;
	cin >> N;
	int S = 0;
	int N_in = N;
	while (N > 0) {
		S += N % 10;
		N /= 10;
	}
	if (N_in % S == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
ll gcd(ll a,ll b)
{
	return b==0 ? a : gcd(b,a%b);
}
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
template<typename T> void debug(T x)
{
    cout<<"value="<<x<<endl;
    return;
}
vector<pair<ll,ll> > factorize(ll n)
{
    vector<pair<ll,ll> > res;
    for(ll i=2;i*i<=n;i++){
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i==0){
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    return res;
}
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	ll A,B;
	while(cin>>A>>B){
        if(gcd(A,B)==1) cout<<1<<endl;
        else{
            ll mxgcd=gcd(A,B);
            vector<pair<ll,ll> > ans=factorize(mxgcd);
            if(ans.size()==0) ans.emplace_back(1,0);
            cout<<ans.size()+1<<endl;
        }
	}
	return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int INF = 1e9+5;

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif
        
	int n, w;
	cin>>n>>w;

	vi64 dp(w+1,0);

	forn(i,n){
		i64 a;
		int b;
		cin>>b>>a;
		for(int j=w-b; j>=0; j--){
		 	uax(dp[j+b],dp[j]+a);
		}                  
	}
	cout<<(*max_element(all(dp)))<<endl;

        #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}	



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[] arr = input(n);
		long[][][]dp = new long[n][n][2];
		for(int slide = 0 ; slide < n; slide++) {
			for(int row = 0  ; row < n -slide ; row++) {
				int col = row+ slide; 
				if(row==col) {
					dp[row][col][0]=0;
					dp[row][col][1] = arr[row];
					continue;
				}
				long min = Long.MAX_VALUE;
				for(int k = row ; k < col ; k++) {
					min = Math.min(dp[row][k][0]+ dp[k+1][col][0]+dp[row][k][1]+ dp[k+1][col][1], min );
				}
				dp[row][col][0]=min;
				dp[row][col][1]=dp[row][col-1][1]+dp[col][col][1];
			}
		}
		
		System.out.println(dp[0][n-1][0]);
	}

	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

	public static int[][] input(int n, int m) throws Exception {

		int[][] arr = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				arr[i][j] = sc.nextInt();
			}
		}
		return arr;
	}

}


Measured memory_bytes: 42900
#include <stdio.h>
#include <iostream>
#include <ctype.h>
using namespace std;

int main(void)
{	
	char str[1200] = "\0";
	cin.getline(str, 1200);
	
	for (int i = 0; str[i] != '\0'; i++) {
		if (str[i] >= 'a' && str[i] <= 'z') {
			str[i] = toupper(str[i]);
		} else if (str[i] >= 'A' && str[i] <= 'Z') {
			str[i] = tolower(str[i]);
		}
	}
	
	cout << str << endl;
	
	return 0;
}

Measured memory_bytes: 3108
/**
 *  author: Behradm
 *  Created: 2020.07.05 17:09:12
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << '\n'; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  long long res = a[0];
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (cnt + 2 <= n - 2) {
      res += 2 * a[i];
      cnt += 2;
    } else if (cnt + 1 <= n - 2) {
      res += a[i];
      cnt += 1;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3920
s = input()[::-1]
t = input()[::-1]
for i,c in enumerate(s):
  if (c == t[0] or c == '?') and (i+len(t) < len(s)+1):
    for j in range(len(t)):
      if t[j] != s[i+j] and s[i+j] != '?':
        break
    else:
      str_list = list(s)
      for j in range(len(t)):
        str_list[i+j] =  t[j]
      s = ''.join(str_list)
      print(s.replace('?', 'a')[::-1])
      break
else:
  print('UNRESTORABLE')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
                
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;
        int t=1;
        // cin>>t;  
        while(t--){     
            int n,m;
            cin>>n>>m;
            int s=0;
            rep(i,0,m){
                int t;  
                cin>>t;
                s+=t;
            }
            if(s>n) cout<<-1;
            else cout<<n-s;
        } 
        return 0;  
    }       


    //keep it simple stupid 

Measured memory_bytes: 3668
import fractions

def main():
    n, x = [int(e) for e in input().split()]
    X = [int(e) for e in input().split()]

    ans = abs(x - X[0])
    for xi in X:
        ans = fractions.gcd(abs(x - xi), ans)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 88172
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<ll> a;

void solve(){
    cin >> n;
    a.resize(3*n,0);
    rep(i,3*n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for (int i=3*n-2;i>=n;i-=2){
        ans+=a[i];
    }
    cout << ans << endl;
}

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

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int ModPow(int a,int r,int m)
{
	int x=1;
	for(;r;r>>=1){
		if(r&1) x=(ll)x*a%m;
		a=(ll)a*a%m;
	}
	return x;
}

int ModInverse(int a,int m)
{
	int x=1;
	for(int b=m,u=0;b;){
		ll t=a/b;
		swap(a-=b*t,b);
		swap(x-=u*t,u);
	}
	return (x+m)%m;
}

struct Factorial{
	vi fact,ifact;
	int m;
	Factorial(int size,int m):fact(size),ifact(size),m(m){
		fact[0]=1;
		repi(i,1,size) fact[i]=(ll)fact[i-1]*i%m;
		rep(i,size) ifact[i]=ModInverse(fact[i],m);
	}
	int Choose(int n,int r){
		return (ll)fact[n]*ifact[n-r]%m*ifact[r]%m;
	}
};

int solve(int n,int m)
{
	Factorial f(n+1,m);

	vvl dp(n+1,vl(n+1));
	rep(i,n+1) dp[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			dp[i][j]=(dp[i-1][j-1]+ll(j+1)*dp[i-1][j])%m;
	
	int res=0;
	for(int i=0;i<=n;i++){
		ll add=0;
		for(int j=0;j<=i;j++)
			(add+=dp[i][j]*ModPow(2,(n-i)*j,m))%=m;
		(add*=ModPow(2,ModPow(2,n-i,m-1),m))%=m;
		(add*=f.Choose(n,i))%=m;
		if(i&1) add=m-add;
		(res+=add)%=m;
	}
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m;cin>>n>>m&&n|m;){
		cout<<solve(n,m)<<endl;
	}
}


Measured memory_bytes: 72832
#include<stdio.h>
#include<string.h>
int main(){
  char inStr1[50],inStr2[50];
  scanf("%s",inStr1);
  scanf("%s",inStr2);

  int num1=0,num2=0;
  for(int i = 1; i <= strlen(inStr1)+strlen(inStr2);i++){
    if(i%2==0){
      printf("%c",inStr2[num2]);
      num2++;
    }
    else{
      printf("%c",inStr1[num1]);
      num1++;
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
a, b, k = map(int, input().split())
takahashi = a
aoki = b
for i in range(k):
    if i%2 == 0:
        takahashi = takahashi//2
        aoki += takahashi
    else:
        aoki = aoki//2
        takahashi += aoki
print(takahashi, aoki)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll n, k;
    cin>>n>>k;
    map<ll, ll> mp;
    rep(i, n){
        ll a, b;
        cin>>a>>b;
        mp[a] += b;
    }    
    ll now = 0;
    ll ans;
    for(auto p : mp){
        now+=p.second;
        if(now>=k) {
            ans=p.first;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int D,G;
int p[11];
int c[11];
int main(void){
    cin>>D>>G;
    for(int i=0;i<D;i++) {
        cin>>p[i]>>c[i];
        c[i]+=p[i]*(i+1)*100;
    }
    int ans=1e9;
    for(int mask=0;mask<(1<<D);mask++){
        int num=0,total=0,rest=-1;
        for(int i=0;i<D;i++){
            if(mask>>i&1){
                total+=c[i];
                num+=p[i];
            }
            else rest=i;
        }
        if(total<G){
            int s1=100*(rest+1);
            int need=(G-total+s1-1)/s1;
            if(need>=p[rest]) continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int count = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++)
				if (500 * i + 100 * j + 50 * k == x)
					count++;

		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import collections
import fractions
from functools import reduce
import sys
input = sys.stdin.readline


def main():
    n, y = input_list()
    y_1000 = y//1000
    if y_1000 == n:
        print(0, 0, y_1000)
        exit(0)

    for x_1000 in range(n+1):
        for x_5000 in range(n+1):
            x_10000 = n - (x_1000+x_5000)
            if x_10000 < 0:
                continue
            yen_1000 = x_1000 * 1000
            yen_5000 = x_5000 * 5000
            yen_10000 = x_10000 * 10000
            if (yen_1000 + yen_5000 + yen_10000) == y:
                print(x_10000, x_5000, x_1000)
                exit(0)
    print(-1, -1, -1)


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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()


Measured memory_bytes: 66408
#include"bits/stdc++.h"
#include <ostream>
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int v;
    v = ceil(N / 1.08);
    cerr << "v: " << v << endl;
    cerr << floor(v*1.08) << endl;
    if (floor(v * 1.08) == N) cout << v << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
ans = 1
# 増加or減少
check = 0
before = a[0]
for i in a[1:]:
    if i == before:
        continue
    if before > i:
        if check == 0:
            check = 1
        elif check == -1:
            ans += 1
            check = 0
    else:
        if check == 0:
            check = -1
        elif check == 1:
            ans += 1
            check = 0
    before = i

print(ans)


Measured memory_bytes: 20120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

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

int N, Q;
string S;
char t[200020], d[200020];

bool checkL(int n) {
	int pos = n;
	REP(i, Q) {

		if (S[pos] == t[i]) {
			if (d[i] == 'L')pos--;
			else pos++;
		}
		if (pos < 0)return true;
		if (pos >= N)return false;
	}
	return false;
}

bool checkR(int n) {
	int pos = n;
	REP(i, Q) {

		if (S[pos] == t[i]) {
			if (d[i] == 'L')pos--;
			else pos++;
		}
		if (pos < 0)return false;
		if (pos >= N)return true;
	}
	return false;
}


signed main() {
	int N; cin >> N;
	string Sl, Sr;
	int l = 0, r = N - 1;
	cout << l << endl;
	cin >> Sl;
	if (Sl == "Vacant")return 0;
	cout << r << endl;
	cin >> Sr;
	if (Sr == "Vacant")return 0;
	REP(i, 19) {
		int mid = (l + r) / 2;
		string Sm;
		print(mid); cin >> Sm;
		if (Sm == "Vacant")return 0;
		if ((mid - l) % 2 == 0) {
			if (Sm != Sl) {
				r = mid; Sr = Sm;
			}
			else {
				l = mid;
				Sl = Sm;
			}
		}
		else {
			if (Sm == Sl) {
				r = mid; Sr = Sm;
			}
			else {
				l = mid; Sl = Sm;
			}
		}
	}
}


Measured memory_bytes: 852
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//いやーコンテスト中は絶対無理
int hist[300002], cnt[300001];
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	rep(i, N) hist[getint()]++;
	rep1(i, N) cnt[hist[i]]++;

	int ruiseki = N;
	int mae = 1;
	int kei = 1;
	int ijou = 0;
	for (int i = N; i >= 1; i--) {
		ijou += cnt[i];
		ruiseki -= cnt[i] * i;
		while ((kei - ijou) * i <= ruiseki) kei++;

		for (int j = mae; j < kei; j++) putint(i);
		mae = kei;
	}
	for (int j = mae; j <= N; j++) {
		*di++ = '0';
		*di++ = '\n';
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

inline ll power(ll a, ll n, ll m)
{
if(n==0) return 1;
ll p=power(a,n/2,m);
p=(p*p)%m;
if(n%2) return (p*a)%m;
else return p;
}


int main()
{
	boost;
	int n; cin>>n;
	vector<ll>v(n);
	for1(0,n,1) cin>>v[i];
	vector<ll>pro(n);
	pro[n-1]=v[n-1]%MOD;
	for(int j=n-2;j>=0;j--){
		pro[j]=(pro[j+1]+v[j])%MOD;		
	}
	
	ll ans=0;
	for(int i=0;i<n-1;i++){
		ll val=v[i]%MOD;
		ans=(ans+( val*pro[i+1])%MOD)%MOD;
	}
	ans%=MOD;
	cout<<ans<<endl;
	
return 0;
}


Measured memory_bytes: 6336
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
else:
    temp=[]
    #1
    h1=h//3
    w1=w
    temp.append([h1*w1,((h-h1)//2)*w,((h-h1+1)//2)*w])
    temp.append([h1*w1,(h-h1)*(w//2),(h-h1)*((w+1)//2)])
    #2
    h1=(h+2)//3
    w1=w
    temp.append([h1*w1,((h-h1)//2)*w,((h-h1+1)//2)*w])
    temp.append([h1*w1,(h-h1)*(w//2),(h-h1)*((w+1)//2)])
    #3
    h,w=w,h
    h1=h//3
    w1=w
    temp.append([h1*w1,((h-h1)//2)*w,((h-h1+1)//2)*w])
    temp.append([h1*w1,(h-h1)*(w//2),(h-h1)*((w+1)//2)])
    #4
    h1=(h+2)//3
    w1=w
    temp.append([h1*w1,((h-h1)//2)*w,((h-h1+1)//2)*w])
    temp.append([h1*w1,(h-h1)*(w//2),(h-h1)*((w+1)//2)])
    
    print(min([max(t)-min(t) for t in temp]))

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

signed main(void)
{
	int n, ans;
	string s, t;
	cin >> n >> s >> t;
	ans = 2 * n;
	rep(i, s.size())
	{
		if (s.substr(i, s.size() - i) == t.substr(0, s.size() - i))
		{
			ans = n + t.size() - (s.size() - i);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve()
{
    
    ll h1,s1,h2,s2;

    cin>>h1>>s1>>h2>>s2;

    int flag = 1;
    while(s1>0 and s2>0)
    {
        if(flag)
        {
            h2-=s1;
        }
        else
        {
            h1 -= s2;
        }
        flag = 1-flag;

        if(h2<=0)
        {
            cout<<"Yes"; return;
        }
        if(h1<=0)
        {
            cout<<"No"; return;
        }
    }


    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3648
import java.util.*;

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

        for (int i = 0; i < n; ++i) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);

        System.out.println(d[n / 2] - d[(n / 2) -1]);
    }
}


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

const int N = 1e5 + 10;
typedef long long ll;
int n, q[65];
ll a[N], sum, tot, p[65];

void insert(ll x) {
    rep(i, 1, tot) {
        if (!(x & (1ll << q[i]))) continue;
        if (!p[i]) {
            p[i] = x; break;
        }
        x ^= p[i];
    }
}

int main() {
    cin >> n;
    rep(i, 1, n) {
        scanf("%lld", &a[i]);
        sum ^= a[i];
    }
    for (int i = 60; i >= 0; i--) {
        if (!((1ll << i) & sum)) q[++tot] = i;
    }
    rep(i, 1, n) insert(a[i]);
    ll res = 0;
    rep(i, 1, tot) {
        if (!(res & (1ll << q[i]))) res ^= p[i];
    }
    printf("%lld\n", res + (sum ^ res));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  char pre;
  int ans=0;
  for(int i=0;i<(int)s.size();i++){
  	char c=s[i];
  	if(i!=0&&pre!=c)ans++;
    pre=c;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
    }
  }
  int ans=0;
  for(int bit1=0;bit1<(1<<h);bit1++){
    for(int bit2=0;bit2<(1<<w);bit2++){
      int cnt=0;
      for(int i=0;i<h;i++){
         for(int j=0;j<w;j++){
           if(bit1&(1<<i)) continue;
           if(bit2&(1<<j)) continue;
           if(s[i][j]=='#') cnt++;
         }
      }
      if(cnt==k) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3544
#include<iostream>

using namespace std;

int main()
{
	int count_2=0,count_4=0,count_x=0;
	int n;
	cin>>n;
	long int *a=new long int[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)
			{
				count_4++;
				continue;
			}
		if(a[i]%2==0&&a[i]%4!=0)
			{
				count_2++;
				continue;
			}
		count_x++;
	}
	if(count_2==0)
	{
		if(count_x>count_4+1)
		{
			cout<<"No";
		}
		else
		{
			cout<<"Yes";
		}
	}
	else
	{
		if(count_4>=count_x)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	return 0;
 } 

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

int main()
{
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n,t;
    cin >> n >> t;
    int ans = INF;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(b <= t) ans = min(ans, a);
    }
    if(ans < INF) cout << ans << endl;
    else cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <unordered_map>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 999999999;

int arr[100001];
char suite[100001];

int prev_arr[100001];
char prev_suite[100001];


void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int l, int r){
  // rearrange array and return pivot index
  // [3, 5, 2, 1, 4] -> [3, 2, 1, 5, 4] and return 4(index)
  int cur_ix=l;
  int piv = arr[r];
  
  rep(i, l, r){
    if(arr[i] <= piv){
      //swap(arr[i], arr[cur_ix])
      
      int tmp=arr[i]; char tmp2 = suite[i];
      arr[i] = arr[cur_ix]; suite[i] = suite[cur_ix];
      arr[cur_ix] = tmp; suite[cur_ix] = tmp2;
      cur_ix++;
      // swap(&arr[i], &arr[cur_ix]);
    }
  }
  int tmp=arr[cur_ix]; char tmp2 = suite[cur_ix];
  arr[cur_ix] = arr[r]; suite[cur_ix] = suite[r];
  arr[r] = tmp; suite[r] = tmp2;
  /*
  cout << "piv: " << piv << endl;
  cout << "l: " << l << ", r: " << r << endl;
  rep(i, l, r+1) cout << arr[i] << " ";
  cout << endl << endl;*/
  return cur_ix;
}

void quicksort(int l, int r){
  if(l>=r) return;
  int mid_ix = partition(l, r);
  quicksort(l, mid_ix-1);
  quicksort(mid_ix+1, r);
}

void check_stable(int n){
  
  unordered_map<int, int> num2id;
  int id = 0;
  int cur_val = -1;
  string order_suite[100000];
  
  rep(i, 0, n) order_suite[i] = "";
  rep(i, 0, n){
    if(cur_val != arr[i]){
      num2id[arr[i]] = id;
      cur_val = arr[i];
      id++;
    }
    order_suite[num2id[arr[i]]] += suite[i];
  }

  rep(i, 0, n){
    //cout << prev_suite[i] << endl;
    //cout << order_suite[num2id[prev_arr[i]]][0] << endl;
    //cout << endl;
    
    if(order_suite[num2id[prev_arr[i]]][0] != prev_suite[i]){
      cout << "Not stable" << endl;
      return;
    }
    else{
      order_suite[num2id[prev_arr[i]]].erase(0, 1);
    }
  }
  cout << "Stable" << endl;
}

int main(){
  int n;
  cin >> n;
  
  rep(i, 0, n){
    cin >> suite[i]; prev_suite[i] = suite[i];
    cin >> arr[i];   prev_arr[i] = arr[i];
  }
  quicksort(0, n-1);
  check_stable(n);
  rep(i, 0, n) cout << suite[i] << " "<< arr[i] << endl;
  return 0;
}



Measured memory_bytes: 6852
import sys
Input = sys.stdin.readline

n = int(Input())
v = list(map(int, Input().split()))
mi = float("inf")
count1 = 0
count2 = 0

v1 = v[0::2]
v1_count = {}
for i in v1:
    if i not in v1_count:
        v1_count[i] = 1
    else:
        v1_count[i] += 1

v1_count = sorted(v1_count.items(), key=lambda i: i[1], reverse=True)
count1 += len(v1) - v1_count[0][1]

v2 = v[1::2]
v2_count = {}
for i in v2:
    if i not in v2_count:
        v2_count[i] = 1
    else:
        v2_count[i] += 1

v2_count = sorted(v2_count.items(), key=lambda i: i[1], reverse=True)
count2 += len(v2) - v2_count[0][1]

if v1_count[0][0] != v2_count[0][0]:
    mi = count1 + count2
else:
    lv2 = len(v2)
    for k, i in v2_count[1:]:
        result = count1 + lv2 - i
        if mi > result:
            mi = result
    else:
        if mi > count1 + lv2:
            mi = count1 + lv2

    lv1 = len(v1)
    for k, i in v1_count[1:]:
        result = count2 + lv1 - i
        if mi > result:
            mi = result
    else:
        if mi > count2 + lv1:
            mi = count2 + lv1

print(mi)

Measured memory_bytes: 20636
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

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

	ll x, y;
	cin >> x >> y;

	if (abs(y) - abs(x) >= 0) {
		ans = abs(y) - abs(x);

		if (x < 0 && y < 0) {
			ans += 2;
		}
		else if (x >= 0 && y < 0) {
			ans += 1;
		}
		else if (x < 0 && y > 0) {
			ans += 1;
		}
	}
	else {
		ans = abs(x) - abs(y);

		if (x > 0 && y > 0) {
			ans += 2;
		}
		else if (x > 0 && y <= 0) {
			ans += 1;
		}
		else if (x < 0 && y > 0) {
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    // writeln(gcd(2, 3));
    // writeln((2 * 3) / gcd(2, 3));
    auto n = lread();
    auto t = new long[](n);
    foreach (i; 0 .. n)
    {
        long T;
        scan(T);
        t[i] = T;

    }
    // writeln(t);
    long gcd_ans = t[0];
    foreach (i; 1 .. n)
    {
        gcd_ans = gcd(gcd_ans, t[i]);
    }
    // writeln(gcd_ans);
    long lcm_ans = t[0];
    foreach (i; 1 .. n)
    {
        lcm_ans = lcm_ans * (t[i] / gcd(lcm_ans, t[i]));
    }
    writeln(lcm_ans);

    // writeln(ans);
}

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

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1LL << 50;
ll dp[110][100010];
ll w[100];
ll v[100];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif


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

	int vsum = 0;
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
		vsum += v[i];
	}

	fill((ll*)begin(dp), (ll*)end(dp), INF);
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= vsum; j++){
			if(dp[i][j] == INF) continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if(j + v[i] <= vsum){
				dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
			}
		}
	}

	ll ans = 0;
	for(int i = 0; i <= vsum; i++){
		if(dp[N][i] != INF && dp[N][i] <= W) ans = i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 86272
#include <stdio.h>
int main(void)
{
 int a[32],j,i,t;
 
 scanf("%d %d %d",&a[0],&a[1],&a[2]);
 
 for(j = 0;j < 2;j++){
   for (i = 0;i < 2 ;i++ ){
    if ( a[i] > a[i + 1] ){
       t = a[i];
       a[i] = a[i + 1];
       a[i + 1] = t;
     }
   }
 }

 printf("%d %d %d\n",a[0] ,a[1] ,a[2]);
 
}


Measured memory_bytes: 2080
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = c - (a - b);
		System.out.println((ans < 0) ? 0 : ans);
	}
	
}

Measured memory_bytes: 21844
from typing import List


def answer(n: int, s: List[str], m: int, t: List[str]) -> int:
    result = 0
    for i in s:
        result = max(result, s.count(i) - t.count(i))

    return result


def main():
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]
    print(answer(n, s, m, t))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10088
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
    string S;
    cin >> S;
    int cnt=0;
    for(int i=0;i<4;i++){
        while(S[i]==S[i+1]){
            cnt++;
            i++;
        }
        if(cnt>=2){
            cout << "Yes" << endl;
            return 0;
        }
        cnt=0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define P pair<ll, ll>
#define V vector<ll>
#define C vector<char>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)


int power(ll x, unsigned int y)  
{  
	ll p=mod;
    ll res = 1;      
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y)  
{  
    // Base Case  
    if (a == 0)  
    {  
        *x = 0;  
        *y = 1;  
        return b;  
    }  
  
    ll x1, y1; // Tor store results of recursive call  
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
  
    // Update x and y using results of  
    // recursive call  
    *x = y1 - (b/a) * x1;  
    *y = x1;  
  
    return gcd;  
}  

int main()
{
	ll n,m;
	cin>>n>>m;
	ll d[n],b[n];
	vector<pair<ll,ll>>v;
	for(int i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	ll ans=0,cnt=0;
	priority_queue<ll>q;
	sort(v.begin(),v.end());
	for(int i=1;i<=m;i++)
	{
		while(cnt<n&&v[cnt].fi<=i)
		{
			q.push(v[cnt].se);
			cnt++;
			//cout<<i<<" "<<v[cnt].se<<" "<<cnt<<endl;
		}
		if(!q.empty())
		{
			ans+=q.top();
			q.pop();
		}

	}
	cout<<ans<<endl;



}


Measured memory_bytes: 3568
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if (0 + r <= x && W - r >= x && 0 + r <= y && H - r >= y){
		printf("Yes\n");
	}
	
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 1012
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = []
    for _ in range(n):
        a.append(deque(list(map(int, input().split()))))
    
    siai = n*(n-1)
    d = [0]*n

    while siai:
        f = 0
        for i in range(n):
            while a[i] and a[a[i][0]-1][0] == i+1:
                f = 1
                day = max(d[i], d[a[i][0]-1])
                d[i] = day + 1
                d[a[i][0]-1] = day + 1
                siai -= 2
                a[a[i][0]-1].popleft()
                a[i].popleft()
        if not f:
            print(-1)
            break
    else:
        print(max(d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 71004
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> l(n), r(n);
    vector<int> id;
    int lmax = -1, rmin = IINF;
    int maxdex = -1, mindex = -1;
    int maxi = -1;
    rep(i, n){
        cin >> l[i] >> r[i];
        --l[i];
        id.emplace_back(i);
        if(chmax(lmax, l[i])){
            maxdex = i;
        }
        if(chmin(rmin, r[i])){
            mindex = i;
        }
        chmax(maxi, r[i] - l[i]);
    }

    int ans = max(rmin - lmax, 0) + maxi;

    auto comp = [&](int i, int j){
        return max(r[i] - lmax, 0) == max(r[j] - lmax, 0) ? max(rmin - l[i], 0) > max(rmin - l[j], 0) : max(r[i] - lmax, 0) < max(r[j] - lmax, 0);
    };

    sort(id.begin(), id.end(), comp);

    int mini = IINF;
    rep(I, n - 1){
        int i = id[I];
        int j = id[I + 1];
        chmin(mini, max(rmin - l[i], 0));
        chmax(ans, mini + max(r[j] - lmax, 0));
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 50;


int n,a,b;

int fun(int x)
{
  return (a*x)/b - a *(x/b);
}

int32_t main()
{



    IOS

    cin >> a >> b >> n;
    

    cout << fun(min(n,b-1));


    return 0;
}



Measured memory_bytes: 3620
def main():
    H,N=map(int,input().split())
    A=[0 for i in range(0,N)]
    B=[0 for i in range(0,N)]
    for i in range(0,N):
        A[i],B[i]=map(int,input().split())

    dp=[[0 for j in range(0,H+1)] for i in range(0,N+1)]
    for i in range(0,N):
        for j in range(1,H+1):
            if i==0:
                if A[0]>=j:
                    dp[1][j]=B[0]
                else:
                    dp[1][j]=dp[1][j-A[0]]+B[0]
            else:
                if A[i]>j:
                    dp[i+1][j]=min(dp[i][j],B[i])
                else:
                    dp[i+1][j]=min(dp[i][j],dp[i+1][j-A[i]]+B[i])
    print(dp[N][H])

if __name__ == '__main__':
    main()


Measured memory_bytes: 125916