akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;

		if( a == b )
		{
		cout << "a == b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			cout << "a < b" << endl;
			}
		}

}



Measured memory_bytes: 3096
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,c,x,y=map(int,input().split())
if x<y:
    ans=min((a*x+b*y),2*x*c+b*(y-x),2*y*c)
    
else:
    ans=min((a*x+b*y),2*y*c+a*(x-y),2*x*c)
print(ans)

Measured memory_bytes: 77344
#include <stdio.h>

int main() {
    int p, q, r;
    scanf("%d%d%d", &p, &q, &r);
    if ( (p <= q && q <= r) || (q <= p && p <= r) ) {
        printf("%d\n", p + q);
    }
    else if ( (q <= r && r <= p) || (r <= q && q <= p) ) {
        printf("%d\n", q + r);
    }
    else if ( (r <= p && p <= q) || (p <= r && r <= q) ) {
        printf("%d\n", r + p);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }
    int root(int x) {
        if(par[x] == x) {
            return x;
        }
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) {
            return;
        }
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
    }
    UnionFind tree(N);
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
        if(tree.same(i, P[i]-1)) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a == b && b == c && a == c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int R,C;
int search(int i, vector< vector<int> > moti){
  if(i==R){
    int ret = 0;
    REP(j,C){
      int c=0;
      REP(k,R){
        if(moti[k][j]==1) c++;
      }
      ret+=max(c,R-c);
    }
    return ret;
  }else{
    vector< vector<int> > moti2;
    moti2=moti;
    REP(j,C){
      if(moti2[i][j]==1)moti2[i][j]=0;
      else moti2[i][j]=1;
    }
    return max(search(i+1,moti),search(i+1,moti2));
  }
}

int main(void){
  while(cin>>R>>C){
    if(R==0) break;
    vector< vector<int> > moti;    
    REP(i,R){
      vector<int> tmp;
      REP(j,C){
        int tmp2;
        cin>>tmp2;
        tmp.push_back(tmp2);
      }
      moti.push_back(tmp);
    }
    cout<<search(0,moti)<<endl;
  }
  return 0;
}

Measured memory_bytes: 12000
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
#define int long long
#define fi first
#define se second

int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
int modInverse(int n, int p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
int nCrModPFermat(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    int fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    ll res=0;
    for(ll i=1;i<=n;i++)
    {
        res=(res%mod+((m%mod*m%mod)%mod*(i%mod*(n-i)%mod)%mod)%mod)%mod;
    }
    for(ll i=1;i<=m;i++)
    {
        res=(res%mod+((n%mod*n%mod)%mod*(i%mod*(m-i)%mod)%mod)%mod)%mod;
    }
    res=(res%mod*nCrModPFermat(n*m-2,k-2,mod)%mod)%mod;
    cout<<res;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    bool cards[4][13]{false};

    int n;
    cin >> n;
    rep(qi, n) {
        char mark;
        int num;
        cin >> mark >> num;
        num--;

        if (mark == 'S') {
            cards[0][num] = true;
        } else if (mark == 'H') {
            cards[1][num] = true;
        } else if (mark == 'C') {
            cards[2][num] = true;
        } else {
            cards[3][num] = true;
        }
    }

    string marks = "SHCD";
    rep(i, 4) {
        rep(j, 13) {
            if (cards[i][j] == false)
                cout << marks[i] << " " << (j + 1) << endl;
        }
    }
}




Measured memory_bytes: 3176
#include<iostream>
using namespace std;
int N,A,B,s,ans=0;
int main(void){
	cin>>N>>A>>B;
	for(int i=1;i<=N;i++){
		s=i/10000+i/1000%10+i/100%10+i/10%10+i%10;
		if(s<=B&&s>=A)ans+=i;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import math
import sys
x = int(input())

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-1000, 1000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                sys.exit(0)
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                sys.exit(0)


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(m);
  rep(i,m) {
    cin >> a[i].first >> a[i].second;
  }
  
  rep(x,1000) {
    int keta = 1;
    vector<int> d(1,x%10);
    int xx = x/10;
    while(xx) {
      keta++;
      d.push_back(xx%10);
      xx /= 10;
    }
    reverse(d.begin(),d.end());
    
    if(keta == n) {
      bool ok = true;
      rep(i,m) if(d[a[i].first-1] != a[i].second) ok = false;   
      if(ok) {
        cout << x << endl;
        return 0;
      }    
    } else continue;
  }
  cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
long long int dp[99][21];
int main(void)
{
	int suu[100],n,i,j;
	scanf("%d",&n);
	for(i=0;i<=n;i++){
		for(j=0;j<=20;j++) dp[i][j]=0;
	}
	for(i=0;i<n;i++) scanf("%d",&suu[i]);
	dp[0][suu[0]]=1;
	for(i=0;i<n-2;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(j+suu[i+1]<=20) dp[i+1][j+suu[i+1]]+=dp[i][j];
				if(j-suu[i+1]>=0) dp[i+1][j-suu[i+1]]+=dp[i][j];
			}
		}
	}
/*	for(i=0;i<n-1;i++){
		for(j=0;j<=20;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	printf("%lld\n",dp[n-2][suu[n-1]]);
	return 0;
}

Measured memory_bytes: 616
import sys
import math


LIMIT = 1000000
p = 2
pList = [True] * (LIMIT + 1)


while p ** 2 <= LIMIT:
    if(pList[p]):
        for i in range(p * 2, LIMIT + 1 , p):
            pList[i] = False
    p += 1

# print(pList)


lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    count = 0
    for i in range(2, line + 1):
        if pList[i]:
            count += 1
    print(count)

Measured memory_bytes: 14964
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-27 00:19:34
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
int a[100];
int ans = 0;

int main()
{
  cin >> N >> K;
  for (auto i = 0; i < N; i++)
  {
    cin >> a[i];
  }
  for (auto l = 0; l <= K; l++)
  {
    for (auto r = 0; r <= K - l; r++)
    {
      if (l + r > N)
      {
        continue;
      }
      int now = 0;
      int d = K - l - r;
      vector<int> V;
      for (auto i = 0; i < l; i++)
      {
        now += a[i];
        V.push_back(a[i]);
      }
      for (auto i = N - r; i < N; i++)
      {
        now += a[i];
        V.push_back(a[i]);
      }
      sort(V.begin(), V.end());
      for (auto i = 0; i < d; i++)
      {
        if (i >= (int)V.size())
        {
          break;
        }
        if (V[i] >= 0)
        {
          break;
        }
        now -= V[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){
int N;
cin>>N;
string s;
cin>>s;
int w[N+1];
int e[N+1];
w[0]=0;
e[0]=0;

for(int i=1;i<=N;i++){
    if(s[i-1]=='W'){
        w[i]=w[i-1]+1;
    }
    else{
        w[i]=w[i-1];
    }
}
for(int i=N;i>=1;i--){
    if(s[i-1]=='E'){
        e[N-i+1]=e[N-i]+1;
    }
    else{
        e[N-i+1]=e[N-i];
    }
}
int ans=100'0000;
for(int i=1;i<=N;i++){
ans=min(ans,w[i-1]+e[N-i]);
}

cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp;
    string S;
    cin >> V[0] >>V[1] ;
    ans = V[0]+V[1];
    
    if(ans>=10)
    	puts("error");
    else
	cout << ans << endl;
    
    // cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
# S
# hiが1つ以上入っていればYes, No
# hii
S = gets
num = S.length / 2 
if num == 1 
  if S.match(/(hi){1}/) != nil && S.match(/[h+]hi/) == nil && S.match(/hi[i+]/) == nil
    puts "Yes"
  else
    puts "No"
  end
elsif num == 2
  if S.match(/(hi){2}/) != nil && S.match(/[h+]hi/) == nil && S.match(/hi[i+]/) == nil
    puts "Yes"
  else
    puts "No"
  end
elsif num == 3
  if S.match(/(hi){3}/) != nil && S.match(/[h+]hi/) == nil && S.match(/hi[i+]/) == nil
    puts "Yes"
  else
    puts "No"
  end
elsif num == 4
  if S.match(/(hi){4}/) != nil && S.match(/[h+]hi/) == nil && S.match(/hi[i+]/) == nil
    puts "Yes"
  else
    puts "No"
  end
elsif num == 5
  if S.match(/(hi){5}/) != nil && S.match(/[h+]hi/) == nil && S.match(/hi[i+]/) == nil
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll ans=0;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      if(i==j) continue;
      if(i<j&&a[i]>a[j]) (ans+=k*(k+1)/2)%=mod;
      if(i>j&&a[i]>a[j]) (ans+=k*(k-1)/2)%=mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
Ns = input()
N = int(Ns)
count = 0

for n in range(1, len(Ns)):
    if n % 2 == 0:
        continue
    count += 10 ** n - 10 ** (n - 1)

if len(Ns) % 2 == 1:
    count += N - 10 ** (len(Ns) - 1) + 1

print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long n;
void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    long long i,ans=0;
    for (i=0;i<n;i++)
    {
        char tmp[3];
        tmp[0]=a[i];
        tmp[1]=b[i];
        tmp[2]=c[i];
        sort(tmp,tmp+3);
        if (tmp[0]==tmp[1]&&tmp[1]==tmp[2]) ;
        else if (tmp[0]==tmp[1]&&tmp[1]!=tmp[2]) ans++;
        else if (tmp[0]!=tmp[1]&&tmp[1]==tmp[2]) ans++;
        else ans+=2;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).expect("Failed to read line");
    let n: i32 = n.trim().parse().unwrap();

    let mut vec = String::new(); 
    io::stdin().read_line(&mut vec).expect("Failed to read line");
    let mut vec: Vec<i32> = vec.trim().split(' ').map(|x| x.trim().parse().unwrap()).collect();
    vec.sort();
    println!("{:?}", vec[(n - 1) as usize] - vec[0])
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[K]);

    }
}

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

int main()
{

	int n;
	
	while(cin >> n, n){
		char a,b;
		char d[1000];
		for(int i = 0; i < 1000; i++)
			d[i] = -1;

		while(n > 0){
			n--;

			cin >> a >> b;

			d[a] = b;
		}

		cin >> n;

		char *s = new char[n+1];

		for(int i = 0; i < n; i++){
			cin >> a;
			if(d[a] != -1)
				s[i] = d[a];
			else
				s[i] = a;
			
		}
		s[n] = '\0';
		cout << s << endl;
	}






	return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(string, s);
	if (len(s) == 3) {
		reverse(all(s));
	}
	print(s);
	return 0;
}


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

int main() {
  ll n; cin >> n;
  vector<ll>v(n);
  for(ll i = 0; i<n; i++){
    cin >> v[i];
  }
  ll ans;
  for(ll i = 0; i<n; i++){
    if(v[i]%2==0){
      if(v[i]%3!=0 && v[i]%5!=0) ans++;
    }
  }
  if(ans>0) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
int n;
int a[100009];
int dp[100009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        dp[i+1] = min(dp[i+1], dp[i] + abs(a[i]-a[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(a[i]-a[i+2]));
    }
    cout << dp[n-1] << "\n";
}

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

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    for(int i = 0; i < s1.size(); ++i) {
        cout << s1[i];
        if(i < s2.size()) {
            cout << s2[i];
        }
    }
    cout << '\n';
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;
string s;
ll ans=0;

void dfs(int d,int cnt,ll sum){
    string t=s.substr(d-cnt,cnt+1);
    /*
    for(auto itr:t){
        cout<<itr;
    }
    cout<<'\n';
    cout<<d<<' '<<cnt<<' '<<sum<<'\n';
    */
    if(d==len(s)-1){
        sum+=stoll(t);
        ans+=sum;
        return;
    }
    dfs(d+1,cnt+1,sum);
    dfs(d+1,0,sum+stoll(t));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>s;
    dfs(0,0,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define SZ(v) ((int)(v).size())
typedef long long ll;
string s,t;
bool check(string s,string t){
	int N=SZ(s),M=SZ(t);
	for(int l=0;l+M<=N;l++){
		bool ok=true;
		for(int i=0;i<M;i++){
			if(s[l+i]=='?'||s[l+i]==t[i]);
			else ok=false;
		}
		if(ok)return true;
	}
	return false;
}
int main(){
    ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	if(!check(s,t)){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	int N=SZ(s);
	for(int i=0;i<N;i++){
		if(s[i]=='?'){
			for(char c='a';;c++){
				s[i]=c;
				if(check(s,t))break;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

char button[10][10] = {
    " ",        "',.!?",    "abcABC",   "defDEF",
    "ghiGHI",   "jklJKL",   "mnoMNO",
    "pqrsPQRS", "tuvTUV",   "wxyzWXYZ"
};

queue<int> splitString(string digit);
string translate(string digit, queue<int> splits);

int main(){
    queue<string> mails;
    queue<int> splits;
    string digits;
    string sentence;
    
    while (cin>>digits) {
        splits = splitString(digits);
        sentence = translate(digits, splits);
        mails.push(sentence);
    }
    
    while (!mails.empty()) {
        cout<<mails.front()<<endl;
        mails.pop();
    }
    
    return 0;
}

queue<int> splitString(string digit){
    queue<int> splits;
    int length = digit.length();
    
    for(int i = 0; i < length - 1; i++){
        if(digit[i] != digit[i + 1]){
            if(digit[i+1] == '0'){
                splits.push(i+2);
                i++;
            }
            else{
                splits.push(i+1);
            }
        }
    }
    
    splits.push(length);
    return splits;
}

string translate(string digit, queue<int> splits){
    int length = digit.length();
    int count;
    queue<char> chars;
    
    for(int i = 0; i < length; ){
        int k = splits.front();
        if(digit[i] == '0'){
            for(int j = i; j < k; j++){
                chars.push(' ');
            }
        }
        else if (digit[k-1] == '0'){
            count = k - 1 - i;
            chars.push(button[digit[i] - '0'][count - 1]);
        }
        else{
            count = k - i;
            chars.push(button[digit[i] - '0'][count - 1]);
        }
        
        i = k;
        splits.pop();
    }
    
    length = chars.size();
    char *sentence = new char[length + 1];
    sentence[length] = '\0';
    for(int i = 0; i < length; i++){
        sentence[i] = chars.front();
        chars.pop();
    }
    
    string str = sentence;
    return str;
}

Measured memory_bytes: 3136
#include<stdio.h>

int main(void){
 int a,b,c,d,e;
 scanf("%d %d %d",&a,&b,&c);

 if (b <= a){
  d = a; e = b;
  a = e;
  b = d; 
 }
 if (c <= b){
  d = b; e = c;
  b = e;
  c = d; 
 }

 if (b <= a){
  d = a; e = b;
  a = e;
  b = d; 
 }
 
      printf("%d %d %d\n",a,b,c);
 
 return 0;

}


Measured memory_bytes: 2044
#include<stdio.h>
#include<stdlib.h>

int max(int x,int y);
int min(int x,int y);


int main(void){
  int N;
  scanf("%d",&N);

  char *S=(char *)malloc(sizeof(char)*N);
  scanf("%s",S);
  
  int a=0,i,j,tmp;
  
  for(i=1;i<N;i++){
    tmp=1;
    for(j=0;i+j<N;j++){
      if(S[j]==S[j+i])
	a=max(a,min(i,tmp++));
      else
	tmp=1;
    }
  }
  printf("%d\n",a);
 
  free(S);
   
  return 0;
}

int max(int x,int y){
  if(x>y)
    return x;
  else
    return y;
}
int min(int x,int y){
  if(x<y)
    return x;
  else
    return y;
}


Measured memory_bytes: 1740
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 13) {
            System.out.println(b);
            return;
        }
        if  (a >= 6) {
            System.out.println(b / 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21716
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef array<int,4> A;

LL toLL(A a){
	A r=a;
	for(int i=0;i<3;i++){
		rotate(a.begin(),a.begin()+1,a.end());
		r=min(r,a);
	}
	LL v=0;
	for(int i=0;i<4;i++){
		v<<=10;
		v+=r[i];
	}
	return v;
}
LL ord(A a){
	if(a[0]==a[2]&&a[1]==a[3]){
		if(a[0]==a[1]){
			return 4;
		}
		return 2;
	}
	return 1;
}
LL vs[400];
A C[400];
int main() {
	int N;
	scanf("%d",&N);
	unordered_map<LL,int> cnt;
	for(int i=0;i<N;i++){
		for(int j=0;j<4;j++){
			int a;
			scanf("%d",&a);
			C[i][j]=a;
		}
		vs[i]=toLL(C[i]);
		cnt[vs[i]]++;
	}
	LL ret=0;
	for(int i=0;i<N;i++){
		cnt[vs[i]]--;
		for(int j=i+1;j<N;j++){
			cnt[vs[j]]--;
			for(int k=0;k<4;k++){
				LL r=1;
				LL u[4];
				for(int l=0;l<4;l++){
					A a={{C[i][(4-l+1)%4],C[i][(4-l)%4],C[j][(l+k+1)%4],C[j][(l+k)%4]}};
					LL v=toLL(a);
					r*=ord(a)*cnt[v];
#if 0
					if(i==0&&j==4){
						cerr << a[0] << ", " << a[1] << ", " << a[2] << ", " << a[3] << endl;
						cerr << cnt[v] << endl;
					}
#endif
					u[l]=v;
					cnt[v]--;
				}
				for(int l=0;l<4;l++){
					cnt[u[l]]++;
				}
				ret+=r;
			}
			cnt[vs[j]]++;
		}
	}
	printf("%lld\n",ret);

	return 0;
}



Measured memory_bytes: 58256
#include <iostream>
using namespace std;
bool c(int n){
    if(n>0&&n<=12) return true;
    return false;
}
int main(){
    int n;
    cin>>n;
    int s=n/100,e=n%100;
    if(!c(s)&&!c(e)){
        cout<<"NA\n";
    }
    else if(c(s)&&c(e)){
        cout<<"AMBIGUOUS\n";
    }
    else if(c(s)){
        cout<<"MMYY\n";
    }
    else{
        cout<<"YYMM\n";
    }
}

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

int main() {
 int N;
  cin >> N;
  vector<int> w;
  w.resize(N);
  int s=0;
  for(int i=0; i<N; i++){
    cin >> w.at(i);
    s+=w.at(i);
  }
  int wa=0;
  int sa;
  for(int i=0; i<N; i++){
   wa+=w.at(i);
    if(wa>=s-wa){
      sa=min(2*wa-s,s-2*(wa-w.at(i)));
      break;
    }
  }
  cout << sa << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b;ll c;}aaa;

int a,n,k,m,ans=0,res,minimo; 

int main(){
    scanf("%d%d",&n,&k);

    if(n>= k*2-1)printf("YES\n");
    else printf("NO\n");

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int  x = scan.nextInt();
        int a[] = new int[x];
        int nu;
        for(int i = 0; i < x; i++){
            nu = scan.nextInt();
            a[i] = nu;
        }
        int count = 0;
        Arrays.sort(a);
        for(int i = 0; i < x - 2; i++){
            for(int j = i + 1; j < x - 1; j++){
                for(int k = j + 1; k < x ; k++){
                    if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k]){

                        //System.out.println(a[i] + " " + a[j] + " " + a[k]);
                        int aa = a[i];
                        int bb = a[j];
                        int cc = a[k];
                        if(((aa + bb) > cc) && (bb + cc) > aa && (cc + aa) > bb){
                            count++;
                        }                        


                }
            }
        }
    }
    System.out.println(count);
}
}

Measured memory_bytes: 36716
n,k=map(int,input().split())
A=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(n):
    a=0
    b=0
    for j in range(min(i+1,n-1),n):
        if A[i]>A[j]:
            b+=1
    for j in range(i):
        if A[i]>A[j]:
            a+=1

    ans+=(b*k+(a+b)*k*(k-1)//2)
print(ans%mod)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int MOD = 1000000007;
main(){
    string s[8];
    int H,W,x = 0,y = 0;
    cin >> H >> W;
    for(int i = 0;i < H;i++)cin >> s[i];
    while(x != W-1 || y != H-1){
        s[y][x] = '-';
        if(y == H-1 || (x != W-1 && s[y][x+1] == '#'))x++;
        else y++;
    }
    s[H-1][W-1] = '-';
    for(int i = 0;i < H;i++){
        for(char c:s[i]){
            if(c=='#'){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
max_A, min_A = max(A), min(A)
max_idx, min_idx = A.index(max_A), A.index(min_A)
mode = None
if min_A >= 0: mode = 2
elif max_A <= 0: mode = 3
elif max_A >= abs(min_A): mode = 0
else: mode = 1
actions = []
if mode == 0:
    for i in range(N):
        if i != max_idx:
            A[i] += A[max_idx]; actions.append((max_idx+1, i+1))
    mode += 2
elif mode == 1:
    for i in range(N):
        if i != min_idx:
            A[i] += A[min_idx]; actions.append((min_idx+1, i+1))
    mode += 2
if mode == 2:
    for i in range(N-1):
        A[i+1] += A[i]; actions.append((i+1, i+2))
elif mode == 3:
    for i in range(N-1, 0, -1):
        A[i-1] += A[i]; actions.append((i+1, i))
print(len(actions))
for a in actions: print(*a)

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

int main() {
	// your code goes here
	string str1,str2;
	cin>>str1>>str2;
	int ans=0;
	for(int i=0;i<str1.size();i++){
		if(str1[i]!=str2[i]){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+100;
int main()
{
    FASTINOUT;
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string op;
    cin>>op;
    if (op==s)
        a--;
    else
        b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


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

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<vector<int>> ans(H, vector<int>(W));
  int h = 0, w = 0, check = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      ans.at(h).at(w) = i + 1;
      if (w == W - 1 && check == 0 || w == 0 && h != 0 && check == 0 || W == 1) {
        h++;
        check = 1;
      }
      else if (h%2 == 0) {
        w++;
        check = 0;
      }
      else {
        w--;
        check = 0;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << ans.at(i).at(j) << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

S = input()

x = defaultdict(int)

for s in S:
	x[s] = 1

if x["N"] == x["S"] and x["W"] ==x["E"]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  long long N;
  cin >> N;
  long long digit, digit2;
  digit = (long long)log10(N) + 1;
  for(long long i = 1; i * i <= N; i++){
    if(N % i == 0){
      digit2 = (long long)log10(N / i) + 1;
      digit = min(digit, digit2);
    }
  }
  cout << digit << endl;
}

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

using namespace std;

const int N = 100 + 77 , M = 100000 + 77;
int n , W;
long long dp[M];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> W;
   for(int w , c , i = 1;i <= n;++ i){
      cin >> w >> c;
      for(int j = W;j >= w;-- j)
         dp[j] = max(dp[j] , dp[j - w] + c);
   }
   cout << dp[W];
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d", min(n*a,b));
};


Measured memory_bytes: 256
while(1):
    x,h = [int(input()) for i in range(2)]
    if x == 0 and h == 0:
        break
    x,h = [float(i) for i in [x,h]]
    tot = x**2 + 4*0.5*x*(h**2 + (x/2)**2)**(0.5)
    print("{:.6f}".format(tot))


Measured memory_bytes: 5656
n = int(input())
a = list(map(int, input().split()))

dp = [0]*(n+1)
dp[0] = 1000

for i in range(1, n):
    dp[i] = dp[i-1]
    for j in range(i):
        stock = dp[j]//a[j]
        cost = dp[j]+(a[i]-a[j])*stock
        dp[i] = max(dp[i], cost)
print(dp[n-1])


Measured memory_bytes: 8984
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

mod = 10 ** 9 + 7
sum_a = sum(a_list)
total = 0
for i, a in enumerate(a_list):
    total += (a * (sum_a - a)) % mod
    sum_a -= a
total = total % mod
ans = total
print(ans)


Measured memory_bytes: 31548
n=int(input())
l=[0]+list(map(int,input().split()))
from itertools import accumulate
l=list(accumulate(l))
from bisect import bisect, bisect_left, bisect_right
ans=10**15
for i in range(2,n-1):
    x=bisect_left(l,l[i]//2)
    p1=l[x]
    p2=l[x-1]
    if abs(l[i]-p1*2)>=abs(l[i]-p2*2):
        p=p2
    else:
        p=p1
    q=l[i]-p
    x=bisect_left(l,(l[n]-l[i])//2+l[i])
    r1=l[x]-l[i]
    r2=l[x-1]-l[i]
    if abs(l[n]-l[i]-r1*2)>=abs(l[n]-l[i]-r2*2):
        r=r2
    else:
        r=r1
    s=l[n]-l[i]-r
    ans=min(ans,max(p,q,r,s)-min(p,q,r,s))
print(ans)

Measured memory_bytes: 25676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int x; cin >> x;
  cout << 1 - x << endl;
  return 0;
}


Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int count = 0;
		int total;

		for (int i = 1; i <= N; i++) {
			total = placeCount(i);

			if (total >= A && total <= B) {
				count += i;
			}
		}

		System.out.println(count);

	}

	static private int placeCount(int n) {
		int num = n;
		int sum = 0;

		while (num != 0) {
			sum += num%10;
			num /= 10;
		}

		return sum;
	}

	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }

	}

}


Measured memory_bytes: 23380
r, g, b, n = map(int, input().split())

ans = 0
C = sorted([r, g, b], reverse=True)
r, g, b = C[0], C[1], C[2]

for i in range(n//r+2):
    for j in range((n-r*i)//g+2):
        if n - r*i - g*j >= 0 and (n - r*i - g*j) % b == 0:
            ans += 1

print(ans)


Measured memory_bytes: 41436
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
    int p1,p2,p3;
    cout.precision(11);
    cin >> p1 >> p2 >> p3;
    vector<double> dummy;
    vector<vector<double>> mat1;
    vector<vector<double>> mat2;

    for (int row = 0; row < p1; row++)
    {
        dummy.clear();
        for (int col = 0; col < p2; col++)
        {
            double tmp;
            cin >> tmp;
            dummy.push_back(tmp);
        }
        mat1.push_back(dummy);
    }
    for (int row = 0; row < p2; row++)
    {
        dummy.clear();
        for (int col = 0; col < p3; col++)
        {
            double tmp;
            cin >> tmp;
            dummy.push_back(tmp);
        }
        mat2.push_back(dummy);
    }

    for (int row = 0; row < p1; row++)
    {
        for (int col = 0; col < p3; col++)
        {
            double tmp = 0;
            for (int i = 0; i < p2; i++)
            {
                tmp += mat1[row][i]*mat2[i][col];
            }
            cout << tmp;
            if(row==p1-1 && col==p3-1) continue;
            if(col!=p3-1) cout << " ";
        }
        cout << endl;
    }


    return 0;
}



Measured memory_bytes: 3344
import sys
import math

N = int(sys.stdin.readline().strip())
ABlist = []
for _ in range(N):
    a, b = map(int, sys.stdin.readline().strip().split())
    ABlist.append((a, b))

Asorted = sorted(ABlist)
Bsorted = sorted(ABlist, key=lambda x: x[1])
if N % 2 == 1:
    left = Asorted[N//2][0]
    right = Bsorted[N//2][1]
    # print(left, right)
    print(right - left + 1)
else:
    left = (Asorted[N//2 - 1][0] + Asorted[N//2][0]) / 2
    right = (Bsorted[N//2 - 1][1] + Bsorted[N//2][1]) / 2
    print(int((right - left) * 2 + 1))

Measured memory_bytes: 99868
n,m,v,p=map(int,input().split())
a=sorted(list(map(int, input().split())),reverse=True)[p-1:]
l,r=0,n-p
while l+1<r:
    k=(l+r)//2
    b=a[k]+m
    if b<a[0] or (v-(n-k))*m>(k*b-sum(a[:k])):
        r=k
    else:
        l=k
b=a[r]+m
print(p+l if(b<a[0] or (v-(n-r))*m>(r*b-sum(a[:r]))) else p+r)


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  string S, T;
  IN(N);
  IN(S, T);
  string ST;
  for(int i=0; i<2*N; ++i){
    if(i&1) ST += T[i/2];
    else    ST += S[i/2];
  }
  OUT(ST);

  return 0;
}

Measured memory_bytes: 256
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if b < 0:
    if (b-a)%2 == 1:
        print("Positive")
    else:
        print("Negative")
elif a<= 0 <= b:
    print("Zero")
else:
    print("Positive")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;


ll rec(ll n, ll x){
  if(x == 0) return 0;
  if(n == 0 && x == 1) return 1;

  ll n_layer = (1LL << (n+2)) - 3;
  ll buf = 0;
  ll xp = x;
  if(x == n_layer){
    return (1LL << (n+1)) - 1;
  }
  else if(x >= (n_layer - 3)/2 + 2){
    buf += (1LL << n);
    xp = x - ((n_layer - 3)/2 + 2);
  } else if(x == (n_layer - 3)/2 + 1){
    return (1LL << n) - 1;
  } else {
    xp = x - 1;
  }

  // cout << "n=" << n << endl;
  // cout << "nl=" << n_layer << endl;
  // cout << "xp=" << xp << endl;
  
  return buf + rec(n - 1, xp);
}
     
int main(){
  ll N, X;

  cin >> N >> X;

#ifdef DEBUG
  cout << "N=" << N << " X=" << X << endl;
#endif

  cout << rec(N, X) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]){
            ans++;
        }
        if(p[i+1] < p[i] && p[i] < p[i-1]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888