akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int h = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    int maxA = 0;
    int cnt = 0;
    for(int i = 0;i < n;i++){
      a[i]=sc.nextInt();
      b[i]=sc.nextInt();
      maxA = Math.max(maxA,a[i]);
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0;i < n;i++){
      if(b[i]>maxA)list.add(b[i]);
    }
    Collections.sort(list,Collections.reverseOrder());
    while(h>0&&list.size()!=0){
      h-=list.get(0);
      cnt++;
      list.remove(0);
    }
    if(h<=0){
      System.out.println(cnt);
      return;
    }
    while(h>0){
      h-=maxA;
      cnt++;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 85768
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

int A[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    cin>>n;
    int mx = 0;
    fr(i,n){
        cin>>A[i];
        mx+=A[i]-1;
    }

    cout<<mx<<"\n";


    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n;string s;
    cin >> n >> s;

    vector<int> itiran(26);
    for(int i = 0;i < n;i ++){
        itiran.at(s.at(i)-'a') ++;
    }

    int ans = 1;
    for(int i = 0;i < 26;i ++){
        ans *= (itiran.at(i) + 1);
        ans %= 1000000007;
    }
    cout << ans -1 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int i;

	scanf("%d", &i);

	if (i / 100 == 7)
	{
		printf("Yes\n");
		return (0);
	} else if (i%100/10 == 7)
	{
		printf("Yes\n");
		return (0);
	} else if (i%10 == 7)
	{
		printf("Yes\n");
		return (0);
	}
	printf("No\n");
	return (0);
}	

Measured memory_bytes: 1640
index = 0
answer = []


def postorder_treewalk(left, right):
    if left >= right:
        return

    global index, answer

    node_mid = preorder[index]
    index += 1
    mid = inorder.index(node_mid)

    postorder_treewalk(left, mid)
    postorder_treewalk(mid + 1, right)
    answer += [node_mid]



n = int(input())
preorder = list(map(int, input().split()))
inorder = list(map(int, input().split()))


postorder_treewalk(0, n)
print(*answer)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1, str2;
  cin >> str1;
  cin >> str2;
  int a, b;
  a=str1.size();
  b=0;
  for(int i=0;i<a;i++){
      if(str1.at(i)!=str2.at(i))b=1;
  }
 if(b==0){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

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

int	DF(vector<vector<int>> &A, int P, int D, vector<bool> &Done) {
	D++;
	if (A.size()==D+1)
		return 1;
	int S=0;
	Done.at(P)=true;
	for (int i=0; i<A.at(P).size(); i++) {
		int PP=A.at(P).at(i);
		if (Done.at(PP))
			continue;
		S += DF(A, PP, D, Done);
	}
	Done.at(P)=false;
	return S;
}

int	main() {
	int M, N;
	cin >>N >>M;
	vector<vector<int>> A(N+1);
	for (int i=0; i<M; i++) {
		int a, b;
		cin >>a >>b;
		A.at(a).push_back(b);
		A.at(b).push_back(a);
	}
	int S=0;
	vector<bool> Done(N+1, false);
	S=DF(A, 1, 0, Done);
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,m,i;
	cin>>n>>m;
	pair<int,int> x[n]; 
	for(i=0;i<n;i++){
		cin>>x[i].yy>>x[i].xx;
	}
	
	sort(x,x+n,greater<pair<int,int> >());
	set<int> s;
	for(i=0;i<m;i++)s.insert(i);

	ll res=0;
	for(i=0;i<n;i++){
		if(s.empty()) break;
		int temp=m-x[i].yy;
		if(temp<0) continue;
		
		auto id=s.lower_bound(temp);
		
		if( id!=s.end() && *id==temp ){
			s.erase(id);
			res+=x[i].xx;
		}else{
			
			if(id!=s.begin()){
				--id;
				s.erase(id);
				res+=x[i].xx;
			}
		}
	}
	cout<<res;
}
// check for any potential overflow before submitting



Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

bool kaibun(string S){
  int t=S.size();
  bool K=true;
  rep(i,t){
    if(S.at(i)!=S.at(t-1-i)) K=false;
  }
  return K;
}

void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}

int main() {
  string S,s1,s2; cin>>S;
  int N=S.size();
  rep(i,(N-1)/2){
    s1.push_back(S.at(i));
    s2.push_back(S.at(i+(N+1)/2));
  }
  bool a=kaibun(s1),b=kaibun(s2);
  YN(a&&b&&s1==s2);
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[ohara];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    rep(i,ohara)dp[i]=LINF;
    dp[0]=0;
    rrep(i,1,a+1){
        if(i-b>=0)dp[i]=min({dp[i],dp[i-1]+1,dp[i-b]+1});
        else dp[i]=min(dp[i],dp[i-1]+1);
    }
    Cout(dp[a]);
    return 0;
}


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

const int MOD = 1e9 + 7;

int qpow(int a, int x, int mod) {
    int res = 1;
    for(; x; x >>= 1) {
        if(x & 1) res = 1ll * res * a % mod;
        a = 1ll * a * a % mod; 
    }
    return res;
}

void exgcd(int a, int b, int &x, int &y) {
    if(b == 0) {
        x = 1, y = 0;
        return;
    }
    exgcd(b, a%b, y, x), y -= a/b * x;
}

int cacu(int n, int m, int mod) {
    int a = 1, b = 1;
    for(int i = 0; i < m; ++i) {
        a = 1ll * a * (n - i) % mod;
        b = 1ll * b * (i + 1) % mod;
    }
    int x, y;
    exgcd(b, mod, x, y);
    x = (x % mod + mod) % mod;
    return (1ll * a * x) % mod;
}


int main() {
    int n, a, b;
    while(~scanf("%d%d%d", &n, &a, &b)) {
        int ans = (qpow(2, n, MOD) - 1) % MOD;
        ans = ((ans - cacu(n, a, MOD) - cacu(n, b, MOD)) % MOD + MOD) % MOD;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
class Solve:
    def __init__(self,n):
        self.counter5 = 0
        self._n = n

    def perform(self):

        if self.is_odd(self._n):
            return 0

        #５割り切れる値まで戻る
        while(True):

            if self._n%5 == 0:
                break
            else:
                self._n -= 2

        # 5の何乗かを考える- > 5^1で割り切れる 5^2でわれる・・・
        t = 10
        while(self._n>=t):
            self.counter5 += self._n // t
            t *= 5

        return self.counter5

    def is_odd(self,n):

        if not n %2 == 0:
            return True
        else:
            return False

        return None

if __name__ == '__main__':

    N = int(input())

    Count = Solve(N)

    ans = Count.perform()

    print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D=0;
  str N;
  cin>>N;
  for(int i=0;i<3;i++){
    if(N[i]=='1'){
      D+=1;
    }
  }
  cout<<D<<endl;
}


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

using namespace std;

//#define cin fi
//#define cout fo

//ifstream fi ("");
//ofstream fo (".INP");

int main(){
//	freopen("test.txt" , "r" , stdin);
//	ios_base:: sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	long long d, t ,s;
	cin >> d >> t >>s;
	if (t*s >= d) cout << "Yes" ;
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	if (a < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        sc.close();

        //硬貨の枚数
        int count500 = 0;
        int count5 = 0;
        //残高
        int remain = 0;
        //嬉しさ合計
        int happy500 = 0;
        int happy5 = 0;

        count500 = X / 500;
        happy500 = 1000 * count500;
        remain = X - (500 * count500);

        count5 = remain / 5;
        happy5 = 5 * count5;

        System.out.println(happy500 + happy5);

    }

}


Measured memory_bytes: 21716
//123 B
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

//B
int main(){
    int n,k; cin>>n>>k;
    if(n%k==0) cout<<0<<endl;
    else cout<<1<<endl;
    return 0; 
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0])
         << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,W;
	cin>>n>>W;
	vector<ll> dp(W+1,0);
	// dp[i] max vlaue of items with total weight exacty i
	int weight, value;
	for(int i=0;i<n;i++){
		cin>>weight>>value;
		for(ll weight_already=W-weight;weight_already>=0;weight_already--){
			dp[weight_already+weight]=max(dp[weight_already+weight], dp[weight_already]+value);
		}
	}
ll ans=0;
	for(int i=0;i<=W;i++)
	ans=max(ans, dp[i]);
	cout<<ans;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	int n ;string s;
	cin >> n >> s ;
	string t="";
	rep(i,n/2){
		t+=s[i];
	}
	t+=t;
	if(s==t){
		coY();
	}
	else coN();


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl '\n'
using namespace std;


int main(){
	int n;
	cin>>n;
	string s;
	map<string,int> m;
	while(n--){
		cin>>s;
		m[s]++;
	}

	cout<<"AC x "<<m["AC"]<<nl;
	cout<<"WA x "<<m["WA"]<<nl;
	cout<<"TLE x "<<m["TLE"]<<nl;
	cout<<"RE x "<<m["RE"]<<nl;
	
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int h,w;
	cin>>h>>w;
	string s;
	rep(i,h){
	    cin>>s;
	    cout<<s<<endl;
	    cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

    int st[]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
	int a,b;
	string result;
	cin >> a;
    cin >> b;
    if(st[a]==st[b]) result="Draw";
    else if(st[a]<st[b]) result="Bob";
    else result="Alice";
	cout << result << "\n";
}

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

const int max_n = (int)1e5 + 5;
const int inf = (int)1e9 + 5;


int n;
int a[max_n];
int now = -1;
int now_counter;
int counter;

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

    if (n == 0) {printf("%d\n", 0); return 0;}

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

    sort(a, a + n);
    a[n] = inf;

    for (int i = 0; i <= n; ++i) {
      if (now == a[i]) {
        now_counter++;
        if (now_counter > now) counter++;
      }
      else {
        if (now_counter < now) counter += now_counter;
        now = a[i];
        now_counter = 1;
      }
    }

    printf("%d\n", counter);
}


Measured memory_bytes: 640
-- prev 0.6sec total

import Data.Array

mymin x y = if x>y then y else x
mymax x y = if x>y then x else y

cases2 n
    | 2000<n    = 0
    | n<=1000   = n+1
    | otherwise = (mymax 1000 (n-1000))-(mymin 1000 (n-1000))+1

acases2 :: Array Int Int
acases2 = array (0,2000) $ map (\i->(i,cases2 i)) [0..2000]

cases3 n
    | 3000<n    = 0
    | otherwise = sum $ map (\x->acases2!(n-x)) [(mymax 0 (n-2000))..(mymin n 1000)]

cases4 n = sum $ map (\x->cases3 (n-x)) [(mymax 0 (n-3000))..(mymin n 1000)]

solve n = do
    print $ cases4 n

main = do
    ss<-getContents
    mapM_ solve $ map (\x->read x::Int) $ lines ss

Measured memory_bytes: 5480
using System;
using System.IO;

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

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

              string[] str = Console.ReadLine().Split(' ');

            int N = int.Parse(str[0]);
            int R = int.Parse(str[1]);


            if (N < 10)
            {
                Console.WriteLine(R + (100* (10 - N)));
            }
            else
            {
                Console.WriteLine(R);
            }


            //  int N = int.Parse(Console.ReadLine());
            //  string[] str = Console.ReadLine().Split(' ');
            //  int i;
            //  int[] num = new int[N];
            //
            //  for (i = 0; i < N; i++)
            //  {
            //      num[i] = int.Parse(str[i]);
            //  }


            Console.Out.Flush();
        }





    }
}


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

using namespace std;

int main() {
	int sum, price;
	
	while (cin >> sum, sum) {
		for (int i = 0; i < 9; ++i) {
			cin >> price;
			sum -= price;
		}
		cout << sum << endl;
	}

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    rep(i, n + 1) cin >> a[i];

    ll sum = accumulate(a.begin(), a.end(), 0ll);
    sum -= a[0];
    ll branch = 1;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        if (branch < a[i] || sum < 0) {
            puts("-1");
            return 0;
        }

        ans += branch;
        sum -= a[i];
        branch -= a[i];
        branch = min(branch * 2, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>

int main(){
  int A, B, C, X, tmpX=0, count=0, res;

  std::cin >> A;
  std::cin >> B;
  std::cin >> C;
  std::cin >> X;

  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      tmpX = i * 500 + j * 100;
      res = (X - tmpX)/50;
      if ((res <= C)&&(res >= 0)) count++;
    }
  }

  std::cout << count << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a, b) memset(a, b, sizeof(a))
const ll MOD = 1000000007;
using namespace std;
int df(int n){
	int x=0;
	while(n>0){
		x = n%10;
		n/=10;
	}
	return x;
}
int reversDigits(int num) 
{ 
    int rev_num = 0; 
    while (num > 0) 
    { 
        rev_num = rev_num*10 + num%10; 
        num = num/10; 
    } 
    return rev_num; 
} 
int32_t main()
{
	vaibhavv06;
	int n; cin>>n;
	// if(n==1){
	// 	cout<<1<<endl;
	// 	return 0;
	// }
	int arr[200]={0};
	for(int i=0;i<=n;i++){
		int f = df(i);
		int l = i%10;
		arr[10*f+l]++;
	}
	int ans=0;
	for(int i=10;i<=99;i++){
		// cout<<arr[i]<<" ";
		int l = i;
		int r = reversDigits(i);
		ans+=arr[l]*arr[r];
	}
	// cout<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad.ST            (ST)
import           Data.Bits                   (shiftR)
import qualified Data.ByteString.Char8       as BC
import           Data.Maybe                  (fromJust)
import           Data.Vector.Unboxed         ((!))
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

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

solve :: Int -> [Int] -> [Int]
solve n xs = map solve' xs
  where solve' x
          | x <= a    = b
          | otherwise = a
        a = v ! (n `div` 2 - 1)
        b = v ! (n `div` 2)
        v = sort' $ V.fromList xs

sort' :: V.Vector Int -> V.Vector Int
sort' = V.modify (\v -> quicksort v 0 (VM.length v))

-- https://github.com/as-capabl/haskell-qsort-pfm/blob/master/src/UV.hs
quicksort :: VM.STVector s Int -> Int -> Int -> ST s ()
quicksort work iStart iEnd
    | iEnd - iStart <= 1 = return ()
    | otherwise = do
        pivot <- VM.unsafeRead work (((iEnd - iStart) `shiftR` 1) + iStart)
        med <- divide pivot iStart (iEnd - 1)
        quicksort work iStart med
        quicksort work med iEnd
  where
    divide pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            lower <- shrinkLower pivot iS' iE'
            higher <- shrinkHigher pivot lower iE'
            if lower >= higher
              then do
                return lower
              else do
                swapWork lower higher
                divide pivot (lower + 1) (higher - 1)

    shrinkLower pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            x <- VM.unsafeRead work iS'
            if x >= pivot
              then
                return iS'
              else
                shrinkLower pivot (iS' + 1) iE'

    shrinkHigher pivot iS' iE'
        | iS' > iE' = return iE'
        | otherwise = do
            x <- VM.unsafeRead work iE'
            if x <= pivot
              then
                return iE'
              else
                shrinkHigher pivot iS' (iE' - 1)

    swapWork i j = VM.unsafeSwap work i j

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

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


Measured memory_bytes: 35196
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;

queue<int> getNoin( vector<P> g, set<int> node ){
  queue<int> res;
  for(set<int>::iterator it=node.begin(); it!=node.end(); ++it){
    bool isNoin=true;
    for(vector<P>::iterator it2=g.begin(); it2!=g.end(); ++it2){
      if( (*it) == (*it2).second ){
	isNoin = false;
	break;
      }
    }
    if(isNoin)
      res.push(*it);
  }
  return res;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int m,n;
  cin >> m >> n;

  vector<P> graph;
  set<int> node;

  REP(_t,n){
    int x,y;
    cin >> x >> y;
    graph.PB( MP(x,y) );
    node.insert(x);
    node.insert(y);
  }

  vector<int> res;
  queue<int> noin = getNoin(graph, node);

  while( !noin.empty() ){
    int ni = noin.front(); noin.pop();
    res.PB(ni);

    for(vector<P>::iterator it=graph.begin(); it!=graph.end(); ){
      if( (*it).first == ni )
	it = graph.erase( it );
      else
	++it;
    }
    for(set<int>::iterator it=node.begin(); it!=node.end(); ++it){
      if( (*it) == ni ){
	node.erase( it );
	break;
      }
    }

    if( noin.empty() )
      noin = getNoin(graph,node);
  }
  
  IREP(it,res){
    cout << *it << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
import numpy as np
import scipy.misc as scm
hoge = input()
hoge = list(map(int,hoge.split(" ")))
N = hoge[0]
P = hoge[1]
A = input()
A = list(map(int,A.split(" ")))
A = np.array(A)

odd = len(A[A %2 == 1])
even = N -odd
perm = 0
if P == 0:
    for i in range(0,odd+1,2):
        perm +=scm.comb(odd,i,1)
else:
    for i in range(1,odd+1,2):
            perm +=scm.comb(odd,i,1)
ans = 2**even * perm
print(ans)

Measured memory_bytes: 22520
def main():
    R, C, K = map(int, input().split())
    l = {}
    for _ in range(K):
        r, c, v = map(int, input().split())
        l[(r, c)] = v
    dp0 = [[0] * (C+1) for _ in range(R+1)]
    dp1 = [[0] * (C+1) for _ in range(R+1)]
    dp2 = [[0] * (C+1) for _ in range(R+1)]
    dp3 = [[0] * (C+1) for _ in range(R+1)]
    for i in range(1, R+1):
        for j in range(1, C+1):
            dp0[i][j] = max(dp0[i][j-1], dp0[i-1][j], dp1[i-1][j], dp2[i-1][j], dp3[i-1][j])
            if (i, j) in l:
                dp1[i][j] = max(dp1[i][j-1], l[(i, j)] + max(dp0[i-1][j], dp1[i-1][j], dp2[i-1][j], dp3[i-1][j], dp0[i][j-1]))
                dp2[i][j] = max(dp2[i][j-1], l[(i, j)] + dp1[i][j-1])
                dp3[i][j] = max(dp3[i][j-1], l[(i, j)] + dp2[i][j-1])
            else:
                dp1[i][j] = dp1[i][j-1]
                dp2[i][j] = dp2[i][j-1]
                dp3[i][j] = dp3[i][j-1]
    return max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1], dp3[-1][-1])

print(main())


Measured memory_bytes: 372756
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
int main(void){
int n;	
int ans = 0;
 	cin >> n;
  	if(n%10==0) 	ans=10;
    else{
    	while(n!=0){
			ans+=n%10;
			n/=10;
		}
    }
     cout << ans << endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())

if a==b:
    print(a)
elif a%2==0 and b%2==1:
    if ((b+1-a)//2)%2==0:
        print(0)
    else:
        print(1)
elif a%2==1 and b%2==1:
    if ((b-a)//2)%2==0:
        print(0^a)
    else:
        print(1^a)
elif a%2==0 and b%2==0:
    if ((b-a)//2)%2==0:
        print(0^b)
    else:
        print(1^b)
elif a%2==1 and b%2==0:
    if ((b-a-1)//2)%2==0:
        print(a^0^b)
    else:
        print(a^1^b)



Measured memory_bytes: 9220
// #pragma warning(disable:4996)
#include <memory.h>
#include <stdio.h>
#include <assert.h>

#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

const ll maxn = (ll)310;
const ll maxm = (ll)1e6 + 10;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int fast_read(){ int input; char c=0; while(c<33)c= getchar(); input=0; while(c>33){ input=input*10+c-'0'; c=getchar(); } return input; }

char a[maxn][maxn];
int dp[maxn][maxn];
int cnt[maxn][maxn];

int Cal(char s[maxn], char t[maxn], int len) {
	RE(i, maxn) RE(j, maxn) dp[i][j] = INF, cnt[i][j] = 0;

	for (int i = len; i >= 1; --i) {
		for (int j = len; j >= 1; --j) {
			cnt[i][j] = (s[i] == t[j]);
			cnt[i][j] += cnt[i + 1][j + 1];
		}
	}

	dp[0][0] = 0;
	FOREACH(i, 0, len) {
		FOREACH(j, 0, len) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt[len + 1 - i - 1][len + 1 - j]);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt[len + 1 - i][len + 1 - j - 1]);
		}
	}
	return dp[len][len];
}

int main() {


	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	int h, w;
	while (cin >> h >> w) {
		RESET(a);
		RE(i, h) {
			string line;
			cin >> line;
			RE(j, w) {
				a[j][h - i] = line[j];
			}
		}
		int ans = 0;
		RE(i, w - 1) {
			ans += Cal(a[i], a[i + 1], h);
		}
		cout << ans << endl;
	}

	// cout << (float)(clock() - start_time)/CLOCKS_PER_SEC << "s" << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector <int>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)

int count_bits(int n)
{
    n=(n&0x55555555)+(n>>1&0x55555555);
    n=(n&0x33333333)+(n>>2&0x33333333);
    n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f);
    n=(n&0x00ff00ff)+(n>>8&0x00ff00ff);
    n=(n&0x0000ffff)+(n>>16&0x0000ffff);
    return n;
}

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

    int n, m; cin >> n >> m;
    int k[m];
    int s[m];
    REP(i, m) {
        cin >> k[i];
        s[i] = 0;
        REP(j, k[i]) {
            int tmp; cin >> tmp;
            s[i] |= (1 << (tmp-1));
        }
    }
    int p[m];
    REP(i, m) {
        cin >> p[i];
    }

    int cnt = 0;
    REP(bit, (1 << n)) {
        bool flag = true;
        REP(i, m) {
            if (count_bits(bit & s[i])%2 != p[i]) {
                flag = false;
                break;
            }
        }
        if (flag) cnt++;
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  set<string> ss;
  int n;
  cin >> n;

  bool ok = true;
  char last = '1';
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (i != 0) {
      if (s.at(0) != last || ss.find(s) != ss.end()) {
        ok = false;
      }
    }
    ss.insert(s);
    last = s.at(s.size()-1);
  }

  if (ok) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]

ok = False
if K <= (N - 1)*(N - 2)//2:
    ok = True
    e = N*(N - 1)//2 - K
    edge = []
    cnt = 0
    done = False
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            edge.append([i, j])
            cnt += 1
            if cnt == e:
                done = True
                break
        if done == True:
            break

if ok == True:
    print(e)
    for x in edge:
        print(x[0], end=' ')
        print(x[1])
else:
    print(-1)

Measured memory_bytes: 75048
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  if (N < 10) {
    cout << N << endl;
  } else if (N < 100) {
    cout << 9 << endl;
  } else if (N < 1000) {
    cout << (N - 99) + 9 << endl;
  } else if (N < 10000) {
    cout << (999 - 99) + 9 << endl;
  } else if (N < 100000) {
    cout << 9 + (999 - 99) + (N - 9999) << endl;
  } else {
    cout << 90909 << endl;
  }
}

Measured memory_bytes: 3532
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int num[100001];
int n;

int search (int key)
{
    int left;
    int right;
    int mid;
    
    left = 0;
    right = n;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (key == num[mid])
        {
            return 1;
        }
        else if (key < num[mid])
        {
            right = mid;
        }
        else if (key > num[mid])
        {
            left = mid + 1;
        }
    }
    
    return 0;
}

int main(int argc, const char * argv[]) {
    int sum = 0;
    int m;
    int tmp;
    
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }
    
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp;
        if (search(tmp))
        {
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 3388
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int N;
	vector<int> a;
	cin >> N;
	for (int i = 0; i < N; i++) { int b; cin >> b; a.push_back(b); }

	sort(a.begin(), a.end());
	print(a.back() - a[0]);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
void solve()
    { 
			ll int n;
			cin>>n;
			vl ar(n);
			fo(i,n) cin>>ar[i];
			ll int ans=0;
			for(int i=1;i<n;i++)
			{
				if(ar[i-1]>ar[i])
				{
					ans+=ar[i-1]-ar[i];
					ar[i]=ar[i-1];
				}
			}
			cout<<ans<<endl;
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 11952
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 

int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else if(s=="Rainy") cout<<"Sunny"; 
}

Measured memory_bytes: 256
// review

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

ll l;

void solve() {
  int n = 0;
  while (l >= pow(2, n)) {
    n++;
  }

  vector<vector<ll> > v;
  for (int i=1;i<n;i++) {
    v.push_back({i, i+1, (ll)pow(2, i-1)});
    v.push_back({i, i+1, 0});
  }

  for (int i=n-1;i>0;i--) {
    if (l - pow(2, i-1) >= pow(2, n-1)) {
      v.push_back({i, n, (ll)(l - pow(2, i-1))});
      l -= pow(2, i-1);
    }
  }
  cout << n << " " <<  v.size() << endl;
  for (int i=0;i<v.size();i++) {
    cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << endl;
  }
}

int main() {
  cin >> l;
  solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000100

int main(void){
	int prime[MAX];
	int i,j,n,count;
	for(i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	
	for(i=2;i<MAX;i++){
		for(j=2;i*j<MAX;j++){
			prime[i*j]=0;
		}
	}

	while((scanf("%d",&n))!=EOF){
		count=0; 
		for(i=0;i<n+1;i++){
			if(prime[i]==1){
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 4500
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	sort(ALL(a));
	if (a[N - 1] - a[0] >= 2) {
		cout << "No" << endl;
		return 0;
	}
	if (a[1] == 1 && a[N - 1] >= 2) {
		cout << "No" << endl;
		return 0;
	}
	if (a[0] != a[N - 1]) {
		//色の種類はa[N-1]通りである。
		//少ない色を言っている猫は、その色が自分しかいない。
		int kind = a[N - 1];
		int single = 0, non = 0;
		rep(i, N) {
			if (a[i] == a[0])single++;
			else non++;
		}
		if (single >= a[N - 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (non / 2 >= a[N - 1] - single) {//single + non / 2 >= a[N-1]) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}

	}
	else {
		//全員が同じ数字を言っている場合、
		//すべての色に対して猫が2匹以上いるか、
		//全員違う色かである。
		if (N / 2 >= a[N - 1]) {
			cout << "Yes" << endl;
			return 0;
		}
		if (a[N - 1] == N - 1) {
			cout << "Yes" << endl;
			return 0;
		}
		cout << "No" << endl;
		return 0;
	}

	return 0;
}





Measured memory_bytes: 1024
X,K,D = map(int, input().split())


if D * K < abs(X):
    #届かない場合
    print(abs(X) - D * K)
else:
    #届く場合、何回移動すると一番近くなるかを算出
    cnt = int(abs(X) / D) 
    distance = abs(X) % D
    if distance > (D/2):
        cnt = cnt + 1
        distance = abs(distance - D)
    #残り移動回数が奇数の場合は一個動く、偶数の場合は確定
    if (K - cnt) % 2 == 0:
        print(distance)
    else:
        print(abs(distance - D))

Measured memory_bytes: 9144
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    intmax_t N, X, L[100], D = 0;
    intmax_t ans = 1;

    scanf("%jd%jd", &N, &X);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &L[i]);
    }

    for (size_t i = 0; i < N; i++) {
        D += L[i];
        if (D <= X) ans++;
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 35824
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    int D;
    scanf("%d", &D);
    if (D == 22) {
        printf("Christmas Eve Eve Eve");
    } else if (D == 23) {
        printf("Christmas Eve Eve");
    } else if (D == 24) {
        printf("Christmas Eve");
    } else if (D == 25) {
        printf("Christmas");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

int main() {
	string a, b, c;
	int na = 0, nb = 0, nc = 0;
	cin >> a >> b >> c;
	char m = a[0];
	while (1)
	{
		if (m == 'a') {
			m = a[na];
			if (na == a.length()) {
				cout << "A" << endl;
				return 0;
			}
			na++;
		}
		if (m == 'b') {
			m = b[nb];
			if (nb == b.length()) {
				cout << "B" << endl;
				return 0;
			}
			nb++;
		}
		if (m == 'c') {
			m = c[nc];
			if (nc == c.length()) {
				cout << "C" << endl;
				return 0;
			}
			nc++;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
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 int INF = 1001001001;

int n;
int p[110];
int dp[110][110];

int main(){
  cin >> n;
  REP(i, 1, n) cin >> p[i-1] >> p[i];

  memset(dp, INF, sizeof(dp));
  rep(i, n+1) dp[i][i] = 0;

  REP(l, 2, n){
    REP(i, 1, n-l+1){
      int j = i+l-1;
      REP(k, i, j-1){
        chmin(dp[i][j], dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  cout << dp[1][n] << endl;

  return 0;
}





Measured memory_bytes: 3140
#include<stdio.h>

int main(){
    long long N, A[110000], B[110000];
    long long sum, ans=0;
    int i, j, k;

    scanf("%lld", &N);
    for(i=0; i<N+1; i++){
        scanf("%lld", &A[i]);
    }
    for(i=0; i<N; i++){
        scanf("%lld", &B[i]);
    }

    for(i=N-1; i>=0; i--){
        if(A[i+1]>0){
            if(A[i+1]>B[i]){
                ans+= B[i];
                A[i+1]= A[i+1]-B[i];
                B[i]=0;
            }else{
                ans+= A[i+1];
                B[i] = B[i]-A[i+1];
                A[i+1] = 0;
            }
            //printf("%d %d\n", A[i+1], B[i]);
        }

        if(A[i]>B[i]){
            ans+=B[i];
            A[i] = A[i]-B[i];
            B[i] = 0;
        }else{
            ans+=A[i];
            B[i]=B[i]-A[i];
            A[i]=0;
        }
        //printf("%d %d\n", A[i], B[i]);
    }

    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1792
//This template belongs to Juan Carlo Vieri

/*   ____   __
    /  _/  |  |    __         __
 __|  |__  |  |   /_/        |  |
|__    __| |  |   __    ____ |  | __   ___   _  ___
   |  |    |  |  |  |  /  _/ |  |/ /  / _ \ | |/ _/
   |  |    |  |  |  | |  |_  |     \ |  __/ |   /
   |__|    |__|  |__|  \___\ |__|\__\ \___\ |__|
*/

#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void solve() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  intt minute = 6 * m;
  double hour = (double)30 * h + (double)0.5 * m;
  double ans = fabs((double)minute - hour);
  if (ans > (double)180) {
    ans = (double)360 - ans;
  }
  // deb(cos(ans * pi / 180));
  // deb(ans);
  ans = sqrt((double)((double)a * a) + ((double)b * b) -  2 * a * b * cos(ans * pi / 180));
  printf("%.9lf\n", ans);
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

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


Measured memory_bytes: 4108
def main():
  n=int(input())
  p=[float(i) for i in input().split()]
  
  dp=[[0]*(n+1) for i in range(n+1)]
  dp[0][0]=1
  for i in range(n):
    dp[i+1][0]=dp[i][0]*(1-p[i])
    for j in range(i+1):
      dp[i+1][j+1]=dp[i][j]*p[i]+dp[i][j+1]*(1-p[i])
  print(sum(dp[n][(n+1)//2:]))
      
if __name__=='__main__':
  main()

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

typedef long long ll;

#define fio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout);
#define cio() ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

const int mod = 1e9+7;
template<typename T>
void amax(T& a, T b) { a=a>b?a:b; }
template<typename T>
void amin(T& a, T b) { a=a<b?a:b; }

using namespace std;

int a;

int main() {
    cio();
    for(int i=1; i<=5; ++i) {
        cin >> a;
        if(a==0) {cout << i << endl; return 0;}
    }
        
    return 0;
}


Measured memory_bytes: 3648
#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 s, w;
  string ans;
  cin >> s >> w;
  if (w >= s) ans = "unsafe";
  else ans = "safe";
  cout << ans << endl;

  return 0;
}


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

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

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

  if(n == 1) {
    cout << abs(a[0] - y) << '\n';
    return 0;
  }

  int ans = max(abs(a.back() - y), abs(a[n - 1] - a[n - 2]));
  cout << ans << '\n';

  return 0;
}

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

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

    int b_div, a_div;
    b_div = b / k;
    a_div = (a - 1) / k;
    
    if (b_div - a_div) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3608