akhauriyash/Code-Regression huggingface dataset:
// ABC 055 D
#include<bits/stdc++.h>
 
using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int a,b,c;

  cin >> a >> b >> c;
  //VI l(N);
  cout << min(c,b/a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};

int main() {
    int a,b,c;
    cin >> a >> b >> c;
  cout << (c-(a-b)>0 ? c-(a-b) : 0) << endl;
}

Measured memory_bytes: 1024
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
//const int MOD = 1000000007;
const int MOD = 998244353;
//int MOD = 1000000007;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res(0);
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}



void solve(){
  int a, b;
  cin >> a >> b;
  for(int i = 0; i < 100000; i++){
    int addA = i * 8 / 100;
    int addB = i * 10 / 100;
    if(addA == a && addB == b){
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int n;
	string w[105];
	char e;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w[i];
		if(i!=0 && w[i][0]!=e){
			cout<<"No"<<endl;
			return(0);
		}
		e=w[i][w[i].size()-1];
	}
	sort(w,w+n);
	for(int i=0;i<n-1;i++){
		if(w[i]==w[i+1]){
			cout<<"No"<<endl;
			return(0);
		}
	}
	cout<<"Yes"<<endl;
	return(0);
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  sort(ALLr(h));
  int ans = INF;
  for(int i = 0; i+k-1 < n; i++) chmin(ans, h[i] - h[i+k-1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  string S;
  cin>>S;
  int K;
  cin>>K;
  set<string> X;
  rep(i,S.size()){
    string Y;
    rep(j,K){
      if(i+j>=S.size()) continue;
      Y+=S[i+j];
      X.insert(Y);
    }
  }
  auto itr=X.begin();
  rep(i,K-1) itr++;
  cout<<*itr<<endl;
}

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

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

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		Value[] vs = new Value[2 * N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			vs[i * 2] = new Value(A[i], i, 0);
			vs[i * 2 + 1] = new Value(B[i], i, 1);
		}
		Arrays.sort(vs);
		boolean[][] use = new boolean[2][N];
		long sum = 0;
		for (int i = 0; i < N; i++) {
			use[vs[i].d][vs[i].i] = true;
			sum += vs[i].v;
		}
		int c0 = 0;
		for (int i = 0; i < N; i++) {
			if (use[0][i] && use[1][i]) {
				System.out.println(sum);
				return;
			}
			if (use[0][i]) ++c0;
		}
		if (c0 == N || c0 == 0) {
			System.out.println(sum);
			return;
		}
		int[] maxF = new int[N + 1];
		int[] maxB = new int[N + 1];
		for (int i = 0; i < N; i++) {
			maxF[i + 1] = Math.max(maxF[i], use[0][i] ? A[i] : B[i]);
			maxB[N - i - 1] = Math.max(maxB[N - i], use[0][N - i - 1] ? A[N - i - 1] : B[N - i - 1]);
		}
		long ans = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			long cur = sum + (use[0][i] ? B[i] : A[i]);
			cur -= Math.max(maxF[i], maxB[i + 1]);
			ans = Math.min(ans, cur);
		}

		System.out.println(ans);
	}

	static class Value implements Comparable<Value> {
		int v, i, d;

		public Value(int v, int i, int d) {
			this.v = v;
			this.i = i;
			this.d = d;
		}

		@Override
		public int compareTo(Value o) {
			return Integer.compare(this.v, o.v);
		}
	}

}

Measured memory_bytes: 99212
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll n;
vector<ll> v;

void solve();

int main() {
   solve();
   return 0;
}

void solve() {
	ll buf = 0,tar=0;
	v.resize(1e5 + 2);
	cin >> n;
	REP(i, n) {
		cin >> buf;
		if(buf != 0) v[buf - 1]++;
		v[buf]++;
		v[buf + 1]++;
	}
	buf = 0;
	REP(i, v.size()) {
		if (buf < v[i]) {
			buf = v[i];
			tar = i;
		}
	}
	cout << buf << endl;
}

Measured memory_bytes: 1024
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    one = A.count(1)
    two = A.count(2)
    three = A.count(3)

    dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
    for sushi in range(1, N + 1):
        for k in range(sushi + 1):
            for j in range(0, sushi - k + 1):
                i = sushi - k - j
                if i != 0:
                    dp[i][j][k] += dp[i - 1][j][k] * i / sushi
                if j != 0:
                    dp[i][j][k] += dp[i + 1][j - 1][k] * j / sushi
                if k != 0:
                    dp[i][j][k] += dp[i][j + 1][k - 1] * k / sushi
                dp[i][j][k] += N / sushi
    print(dp[one][two][three])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 295492
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,ok,L,cnt;
vector<int> u[100000],v;
int main(void){
    cin>>n;
    for(int i=2;i<=1000;i++){
        if((i*(i-1))/2==n){
            cout<<"Yes"<<endl;
            cout<<i<<endl;
            L=i;
            ok=1;
            break;
        }
    }
    for(int i=0;i<n;i++){
        v.push_back(i+1);
        v.push_back(i+1);
    }
    cnt=0;
    if(ok==0){cout<<"No"<<endl;return 0;}
    for(int i=0;i<L;i++){
        for(int j=0;j<(L-1)-i;j++)u[i].push_back(j+cnt+1);
        for(int j=0;j<L-i-1;j++)u[i+j+1].push_back(j+cnt+1);
        cnt+=L-1-i;
    }
    for(int i=0;i<L;i++){
        cout<<L-1<<" ";
        for(auto x:u[i])cout<<x<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 5364
from collections import defaultdict

def solve(n, A):
    count = defaultdict(int)
    for a in A:
        count[a - 1] += 1
        count[a] += 1
        count[a + 1] += 1
    return max(count.values())

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))


Measured memory_bytes: 20004
#include<cstdio>
#include<algorithm>
char s[2000][2001];
//len[0]:横、len[1]:縦
int len[2][2000][2000];
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",s[i]);
    for(int i=0;i<h;i++){
        int l=0;
        while(l<w){
            if(s[i][l]=='#'){
                len[0][i][l]=0;
                l++;
            }else{
                int r=l+1;
                while(r<w&&s[i][r]=='.')r++;
                for(int j=l;j<r;j++)len[0][i][j]=r-l;
                l=r+1;
            }
        }
    }
    for(int j=0;j<w;j++){
        int u=0;
        while(u<h){
            if(s[u][j]=='#'){
                len[1][u][j]=0;
                u++;
            }else{
                int d=u+1;
                while(d<h&&s[d][j]=='.')d++;
                for(int i=u;i<d;i++)len[1][i][j]=d-u;
                u=d+1;
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                ans=std::max(ans,len[0][i][j]+len[1][i][j]-1);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E9 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[100005][3], dp[100005][3] ;
int n ;

ll check(ll len, ll pos)
{
    if (dp[len][pos] != -1) {
        return dp[len][pos] ;
    }
    if (len == n - 1) {
        return dp[len][pos] = arr[len][pos] ;
    }
    for (int i = 0; i < 3; i++) {
        if (i != pos) {
            dp[len][pos] = max(dp[len][pos], arr[len][pos] + check(len + 1, i)) ;
        }
    }
    return dp[len][pos] ;
}

int main()
{
    ll ans = 0 ;
    cin >> n ;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%lld", &arr[i][j]) ;
            dp[i][j] = -1 ;
        }
    }
    for (int i = 0; i < 3; i++) {
        ans = max(ans, check(0, i)) ;
    }

    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  string S;
  cin >> S;

  string temp;
  int ans = 0;

  int l = 0, r = 0;
  while (true) {
    r = l + 1;
    while (temp == S.substr(l, r - l) && r < S.size()) {
      r++;
    }
    if (r == S.size()) {
      if (temp != S.substr(l, r - l))
        ans++;
      break;
    }
    temp = S.substr(l, r - l);
    ans++;
    l = r;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
sx, sy, tx, ty = [
  int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

p1 = dy * 'U' + dx * 'R'
p2 = dy * 'D' + dx * 'L'
p3 = 'D' + (dx + 1) * 'R' + \
	(dy + 1) * 'U' + 'L'
p4 = 'U' + (dx + 1) * 'L' + \
	(dy + 1) * 'D' + 'R'
  
print(p1 + p2 + p3 + p4)

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

using namespace std;

#define ll long long
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, e) for(int x = 0; x <=e; x++)
#define in_arr(n) loop(i,0,n-1){cin>>a[i];}
#define out_arr(n) loop(i,0,n-1){cout<<a[i];}

const int N = 1e5 + 5;
const int INF = 1 << 30;
const int MOD = 2019;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}


int main() {
    boost();
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        if (b[n - 1] != a[i]) cout << b[n - 1] << "\n";
        else {
            auto it = (upper_bound(b.begin(), b.end() - 1, a[i]));
            if (it == b.begin()) cout << *it << "\n";
            else {
                cout << *(it - 1) << "\n";
            }
        }
    }
    return 0;
}

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

int main(){
    int a, b; cin >> a >> b;
    int res = 0;
    for(int i = a; i <= b; i++){
        int s, t, u ,v;
        s = i % 10;
        t = i / 10000 % 10;
        u = i /10 % 10; 
        v = i / 1000 % 10;
        if(s == t && u == v) res++;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

void greatFirst(ll& a, ll& b)
{
  if(a < b)
  {
    ll tmp = a;
    a = b;
    b = tmp;
  }
}

ll gcd(ll a, ll b)
{
  greatFirst(a, b);
  
  while(a % b != 0)
  {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  
  return b;
}

int main()
{
  ll n;
  cin >> n;
  ll sum = 0;
  
  for(ll i = 1; i <= n; i++)
  {
    for(ll j = 1; j <= n; j++)
    {
      ll gcd1 = gcd(i, j);
      for(ll k = 1; k <= n; k++)
      {
        sum += gcd(gcd1, k);
      }
    }
  }
  
  cout << fixed << sum << endl; 
  
  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
using namespace std;
int f(int n)
{
    int temp=0;
    while(n)
    {
        temp+=n%10;
        n=n/10;
    }
    return temp;
}
int main()
{
	int i,m,a,b,s=0;
	scanf("%d %d %d",&m,&a,&b);
	for(i=1;i<=m;i++)
	{
		if(f(i)>=a)
		{
			if(f(i)<=b)
			{
				s+=i;
			}
		}
	}
	printf("%d",s);
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> a(n),b(n);
    for(auto&i:a) in>>i;
    for(auto&i:b) in>>i;
    vector<pair<int,int>> ab(n);
    fr(i,n) ab[i]=make_pair(a[i],b[i]);
    sort(ab.begin(),ab.end());
    sort(b.begin(),b.end());
    sort(a.begin(),a.end());
    fr(i,n) if(a[i]>b[i]) return cout<<"No"<<endl,0;
    unordered_map<int,int> v;
    fr(i,n){
        if(v.count(ab[i].second)) return cout<<"Yes"<<endl,0;
        v[ab[i].second]=i;
    }
    fr(i,n) if(ab[i].second==b[i]) return cout<<"Yes"<<endl,0;
    int j=0;
    fr(i,n-1){
        j=v[b[j]];
        if(j==0) return cout<<"Yes"<<endl,0;
    }
    fr(i,n-1) if(b[i]>=a[i+1]) return cout<<"Yes"<<endl,0;
    cout<<"No"<<endl;
}

Measured memory_bytes: 5924
N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])


Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
  int i;
  int h[10];
  int pri,swapC=1;

  for(i=0;i<10;i++)
    scanf("%d",&h[i]);
  while(swapC!=0){
    swapC=0;
    for(i=0;i<9;i++)
      if(h[i]<h[i+1]){
        swapC++;
        pri=h[i];
        h[i]=h[i+1];
        h[i+1]=pri;
      }
  }
  for(i=0;i<3;i++)
    printf("%d\n",h[i]);
  return 0;
}

Measured memory_bytes: 0
import sys

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    H = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    ans = 0

    for i in range(N):
        for j in range(i):
            if H[i] < H[j]:
                break
        else:
            ans += 1
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
  int a, b, tasu, hiku, kakeru;

  scanf("%d",&a);
  scanf("%d",&b);

  tasu = a + b;
  hiku = a - b;
  kakeru = a * b;

  if(tasu >= hiku){
    if(tasu >= kakeru){
      printf("%d",tasu);
    }
    else{
      printf("%d",kakeru);
    }
  }
  else{
    if(hiku >= kakeru){
      printf("%d",hiku);
    }
    else{
      printf("%d",kakeru);
    }
  }

  return 0;
  
}


Measured memory_bytes: 128
H = int(input())

TwoExp = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776]
for i in range(41):
  if H < TwoExp[i]:
    print(TwoExp[i]-1)
    break

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	result = input[0].split("")[0]+input[1].split("")[1]+input[2].split("")[2];
	console.log(result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import fractions

a,b,c,d = map(int,input().split())

ans = 0

if c % d == 0:
    print((b - a + 1) - ((b)//d - (a-1)//d))
elif d % c == 0:
    print((b - a + 1) - ((b)//c - (a-1)//c))
else:
    tot = c * d // fractions.gcd(c, d)
    tmp = ((b) // d - (a-1) // d) + ((b)//c - (a-1)//c) - ((b) // tot - (a-1) // tot)
    print(int((b - a + 1) - tmp))

Measured memory_bytes: 5052
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    ans = 0
    prev = N + 100

    for i in range(N):
        x = A[i] - 1
        ans += B[x]
        if prev + 1 == x:
            ans += C[prev]
        prev = x

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61964
#include<bits/stdc++.h>
    using namespace std;
    long long m=1000000007;

    #define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define MAX(a,b) ((a)>(b)?(a):(b))
    #define MIN(a,b) ((a)<(b)?(a):(b))
    #define pb  push_back
    typedef long long ll;
    typedef long double ld; 
    long long M=1e9+7;			
    #define deb_(x)       cerr<< #x <<" : "<< x << endl;
    #define deb(A,N)    cerr <<" :[";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
    #define deb2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}																				
    #define rep(n) for(int i=0;i<n;i++)																		
    #define range(a,b) for(int i=a;i<=b;i++)																	
    #define loop(i,n) for(int i=0;i<n;i++)
	void code();
	   
    int main()
    {   
    	boost;
       ll t=1;
       // cin>>t;
       while(t--){
       	code();
       }
     
       return 0;
    }

   
    void code(){
    	ld a,b;
    	cin>>a>>b;
    	int y=b;
    	ll x=a*y;
    	ld fra=b-y;
    	if(fra>0.5){
    		fra=1-fra;
    		ll k=x+(a-(a*fra));
    		
    	    	// deb_(fra);
    	    	// deb_(b*fra);
    	    	// deb_(x);
    		cout<<k<<endl;

    	}
    	else{
    	    	ll k=fra*a;
    	    	// deb_(y);
    	    	// deb_(fra);
    	    	// deb_(k);
    	    	// deb_(x);
    	    	cout<<x+k;
    	}
    		}
    



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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a;
  string s;
  cin >> a;
  cin >> s;
  cout << ((a >= 3200)?s:"red") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b;
	std::cin >> a >> b;
	std::cout << ((a + b < 24) ? (a + b) : (a + b - 24)) << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}




int main() {

	string s;
	cin >> s;

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	string r,t; cin >> r >> t;
	if(r.size()<t.size()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	vector<string> v;
	for(int i=0;i<r.size()-t.size()+1;i++){
		string s=r;
		bool ok=true;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!=t[j]&&s[i+j]!='?')ok=false;
		}
		if(ok){
			for(int j=0;j<t.size();j++){
				s[i+j]=t[j];
			}
			for(int j=0;j<s.size();j++){
				if(s[j]=='?')s[j]='a';
			}
			v.push_back(s);
		}
	}
	sort(v.begin(),v.end());
	if(v.size()==0){
		cout << "UNRESTORABLE" << endl;
	}
	else{
		cout << v[0] << endl;
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            int N= int.Parse(Console.ReadLine());
            string[] Input_ID = Console.ReadLine().Split(' ');
            int[] x = Input_ID.Select(int.Parse).ToArray();
            int[] y = new int[N];

            for (int i = 1; i <= x.Length; i++)
            {
                y[x[i - 1] - 1]+=1; 
            }
            for(int i = 0; i < y.Length; i++)
            {
                Console.WriteLine(y[i]);
            }
        }
    }
}

Measured memory_bytes: 43572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B,result;
  cin >> N;
  
 
  for(int i=0; i<N;i++){
    cin >> A >> B;
    result += B-A+1;
  }
  
  cout << result << endl;
}


Measured memory_bytes: 256
import math

x = int(input())

def is_prime(n):
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True
    
while(True):
  if is_prime(x):
    print(x)
    break
  else:
    x += 1
  

Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""


input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1

"""

import sys


class UnionFind(object):
    __slots__ = ('size', 'tree_height_rank_list', 'ancestor_list')

    def __init__(self, size):
        self.size = int(size)
        self.tree_height_rank_list = [0] * self.size
        self.ancestor_list = [i for i in range(self.size)]

    def _find(self, x):
        if x != self.ancestor_list[x]:
            self.ancestor_list[x] = self._find(self.ancestor_list[x])
        return self.ancestor_list[x]

    def same(self, x, y):
        return self._find(x) == self._find(y)

    def _link(self, x, y):
        if self.tree_height_rank_list[x] > self.tree_height_rank_list[y]:
            self.ancestor_list[y] = x
        else:
            self.ancestor_list[x] = y
            if self.tree_height_rank_list[x] == self.tree_height_rank_list[y]:
                self.tree_height_rank_list[y] += 1

    def union(self, x, y):
        self._link(self._find(x), self._find(y))


def action(_cmd_list):
    for _, each in enumerate(_cmd_list):
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            if case.same(ele_1, ele_2):
                print('1')
            else:
                print('0')
    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    ele_num, cmd_num = map(int, _input[0].split())
    cmd_list = map(lambda x: x.split(), _input[1:])

    case = UnionFind(size=ele_num)

    ans = action(cmd_list)

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

int main() {
  int a;
  cin >> a;
  if (a % 2 == 1) {
  double A = a;
  double b = (a + 1) / 2;
  cout << b / a << endl;
  }
  else {
  cout << 1.0 / 2.0 << endl;
  }
  }

Measured memory_bytes: 256
#入力部分を取得
#A, B, C = map(int,input().split())

#sumを取得
#sum([A,B,C])

A, B= map(int,input().split())
if A>=13:
    print(B)
elif 6<=A:
     print(int(B/2))   
else:
    print(0)


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var c string
	fmt.Fscan(read, &c)
	ans := string(int(c[0]) + 1)
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
c = [list(map(int,input().split())) for _ in [0]*3]
def main():
    for i in range(3):
        tmp1 = set()
        tmp2 = set()
        for j in range(3):
            tmp1.add(c[i][j]-c[(i+1)%3][j])
            tmp2.add(c[j][i]-c[j][(i+1)%3])
        if len(tmp1) != 1 or len(tmp2) != 1:
            return "No"
    return "Yes"
print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	queue<pair<ll,int>>q;
	q.emplace(3LL,1);
	q.emplace(5LL,2);
	q.emplace(7LL,4);
	cin >>n;
	pair<ll,int> at=mp(0LL,0);
	while(n >=at.F){
		at=q.front();
		q.pop();
		if(at.S==7 and at.F <=n){
			ans++;
		}
		q.emplace(at.F*10+3,at.S|1);
		q.emplace(at.F * 10 + 5, at.S | 2);
		q.emplace(at.F * 10 + 7, at.S | 4);
	}
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int N, M;
    ll S;
    cin >> N >> M >> S;
    ll C = 3000;
    vector<vector<ll> > dp(N, vector<ll>(C + 1, LLONG_MAX >> 4));

    vector<vector<tuple<int, int, ll>>> E(N);
    vector<pair<ll, ll>> B(N);

    for(int i = 0; i < M; i++) {
        int u, v, a;
        ll b;
        cin >> u >> v >> a >> b;
        E[u-1].push_back(make_tuple(v-1,a,b));
        E[v-1].push_back(make_tuple(u-1,a,b));
    }

    for(auto & [c, d]: B) cin >> c >> d;

    for(int i = 0; i <= min(C, S); i++) dp[0][i] = 0;
    for(int i = 0; i < 2000; i++) {
        for(int j = 0; j < N; j++) {
            for(ll s = 0; s <= C; s++) {
                for(auto [from, cost, t]: E[j]) {
                    if(s + cost > C) continue;
                    dp[j][s] = min(dp[j][s], dp[from][s + cost] + t);
                }
                ll b = dp[j][max(0LL, s - B[j].first)] + B[j].second;
                dp[j][s] = min(dp[j][s], b);
            }
        }
    }

    for(int i = 1; i < N; i++) cout << dp[i][0] << endl;
}

Measured memory_bytes: 4544
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
const int MOD = 1e9+7;
int main() {
  int n;
  cin >> n;
  ll base = 1;
  for(int i = 1; i<=n ;i++) {
    base = base%MOD * i;
  }
  cout << base%MOD << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/
int main() {
    int A,B;
    s(A) s(B)
    if(A == 1){
        A = 14;
    }
    if(B == 1){
        B = 14;
    }
    if(A > B){
        puts("Alice");
    }else if(A < B){
        puts("Bob");
    }else{
        puts("Draw");
    }

    return 0;
}


Measured memory_bytes: 256
#最大公約数
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

#最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

#最大公約数（複数）
def gcds(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return gcd(l[0], l[1])
    else:
        n = len(l) // 2
        L = l[:n]
        R = l[n:]
        return gcd(gcds(L), gcds(R))

#最小公倍数(複数)
def lcms(l):
	if len(l) == 1:
		return l[0]
	elif len(l) == 2:
		return lcm(l[0], l[1])
	else:
		n = len(l) // 2
		L = l[:n]
		R = l[n:]
		return lcm(lcms(L), lcms(R))

n = input()
a = [int(i) for i in input().split()] 
print(gcds(a))

Measured memory_bytes: 14480
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<map>
using namespace std;

int gcd(long long a,long long b){
  if (a%b==0) return b;
  else return gcd(b,a%b);
}

int main(){
  int n,k;
  cin >> n >> k;
  long long d1=0;
  long long d2=0;
  d1 = n/k;
  if (k%2==0) d2 = (n+k/2)/k;
  cout << d1*d1*d1+d2*d2*d2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)

// const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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 N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int main() {
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    chmax(ans,a*d);
    chmax(ans,b*c);
    chmax(ans,b*d);
    cout<<ans<<endl;

    return 0;
} 
 

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

int main(){
  int K;
  string S;
  cin>>K>>S;
  if(K>=S.size())
    cout<<S<<endl;
  else{
    for(int i=0;i<K;i++)
      cout<<S.at(i);
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 int dp[2][100000]; 
 int a[1000];
 ll n,K;
 int solve(int i,int k){
     int rev;if(i==0){rev=1;}else{rev=0;}
      int &ret = dp[i][k];
    if(ret != -1) return ret;
     if(k<a[0]){ 
         return i^1;
     }
     for(int j=0;j<n;j++){
         if(a[j]>k){continue;}
         if(solve(i^1,k-a[j])==i){return ret=i;}
     }return ret=i^1;
 }
int main()
{
    
  cin>>n>>K;
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   memset(dp,-1,sizeof dp);
   
  ll ans= solve(0,K);
  if(ans==0){cout<<"First";}else{cout<<"Second";}
}

Measured memory_bytes: 9020
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

x1, y1, x2, y2 = map(int, input().split())
del_x = del_y = x3 = y3 = x4 = y4 = 0
del_x = abs(x1 - x2)
del_y = abs(y1 - y2)

if x1 > x2:
    if y1 > y2:
        x3 = x2 + del_y
        y3 = y2 - del_x
        x4 = x3 + del_x
        y4 = y3 + del_y
    else:
        x3 = x2 - del_y
        y3 = y2 - del_x
        x4 = x3 + del_x
        y4 = y3 - del_y
else:
    if y1 > y2:
        x3 = x2 + del_y
        y3 = y2 + del_x
        x4 = x3 - del_x
        y4 = y3 + del_y
    else:
        x3 = x2 - del_y
        y3 = y2 + del_x
        x4 = x3 - del_x
        y4 = y3 - del_y


print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int N; cin >> N;
	vector<int> A_plus_B(N);
	ll res = 0;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		A_plus_B[i] = a + b;
		res -= b;
	}
	sort(A_plus_B.begin(), A_plus_B.end());
	for (int i = 0; i < N; ++i) {
		if (i & 1) continue;
		else res += A_plus_B[N - 1 - i];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int c = a / b;
	int d = a % b;
	double e = (a + 0.0) / b;
	cout << c << " " << d << " " << fixed << setprecision(5) << e << endl;
	return 0;
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,l; cin >> n >> l;
    VI apple(n);
    rep(i,n) apple[i] = l + i;
    int low = 0;
    rep(i,n-1) if(abs(apple[low]) > abs(apple[i+1])) low = i + 1;
    int sum = 0;
    rep(i,n) sum += l + i;
    SORT(apple);
    cout << sum - apple[low] << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] P = new int[N];

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

		int a = 0;
		int b = 0;
		int c = 0;
		for (int Pi : P) {
			if (Pi <= A) {
				a++;
			}
			if (A+1 <= Pi && Pi <= B) {
				b++;
			}
			if (B+1 <= Pi) {
				c++;
			}
		}

		int result = Math.min(a, b);
		result = Math.min(result, c);

		System.out.println(result);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

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


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/18  Problem: ABC 079 B / Link: http://abc079.contest.atcoder.jp/tasks/abc079_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N + 1, 0);
	a[0] = 2;
	a[1] = 1;
	FOR(i, 2, N + 1) {
		a[i] = a[i - 1] + a[i - 2];
	}
	ans = a[N];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    string s,t;
    cin>>s>>t;
    rep(i,0,s.length()-1){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }    
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main()
{
	int N, M;
	cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String lines[]=line.split(" ",0);
        
        int W=Integer.parseInt(lines[0]);
        int H=Integer.parseInt(lines[1]);
        int x=Integer.parseInt(lines[2]);
        int y=Integer.parseInt(lines[3]);
        int r=Integer.parseInt(lines[4]);
        String ans="Yes";
        
        if(x-r<0||y-r<0||x+r>W||y+r>H){
           ans="No"; 
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24424
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
    char a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
            if(i==j)cout<<a[i][j];
        }
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		if ("s".equals(String.valueOf(s.charAt(s.length() - 1)))) {
			System.out.println(s + "es");
		} else {
			System.out.println(s + "s");
		}

		sc.close();

	}
}


Measured memory_bytes: 38496
N = int(input())
AS = list(map(int, input().split()))
BS = list(map(int, input().split()))
CS = list(map(int, input().split()))

total = 0
last = None
for x in AS:
    total += BS[x - 1]
    if x - 1 == last:
        total += CS[x - 2]
    last = x
print(total)


Measured memory_bytes: 38256
/*
 * 
 * */

#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << ":\t" << x << endl
#define _ << " " <<

#define s_time clock_t time_start = clock()
#define t_time cout << double(clock() - time_start) / 1000 << endl

using namespace std;
using namespace __gnu_pbds;

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

const int N = 1e4 + 3;
const int D = 101;
const ll M = 1e9 + 7;

string s;
int d, digit;
ll dp[N][D], res;

int main(int argc, char** argv) {
//	mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> s >> d;
	digit = s.size();
	
	dp[0][0] = 1;
	for (int i = 0; i <= digit; ++i) {
		for (int j = 0; j < d; ++j) {
			dp[i][j] %= M;
			for (int k = 0; k <= 9; ++k) {
				dp[i+1][(j + k) % d] += dp[i][j];
			}
		}
	}
	
	ll sum = 0;
	for (int i = 1; i <= digit; ++i) {
		int num = s[i-1] - '0';
		for (int k = 0; k < num; ++k) {
			(res += dp[digit - i][(d + d - (sum + k % d)) % d]) %= M;
		}
		sum = (sum + num) % d;
	}
	
	(res += M - 1) %= M;
	if (sum == 0) ++res;
	cout << res;
	
	return 0;
}

/*
 * 
 * */


Measured memory_bytes: 8192
n=int(input())
B=list(map(int,input().split()))
A=[]
for i in range(n):
    for j in reversed(range(len(B))):
        if B[j]==j+1:
            A.append(B.pop(j))
            break
    else:
        print(-1)
        exit()

print(*reversed(A),sep="\n")

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int n, i, j, a[25], p, flag;

  while(1) {
    p = 0;
    n = 32;
    flag = 1;

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

    while(n > 0) {
      if(flag == 1) {
	n -= (n-1) % 5;
      } else {
	n -= a[p];
	p++;
	if(p >= i) p = 0;
      }
      if(n < 0) n = 0;
      printf("%d\n", n);
      flag *= -1;
    }
  }
  return 0;
}

Measured memory_bytes: 0