akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	vector<pair<int, pair<int, int>>> work(n);
	for(int i = 0; i < n; i++){
		cin >> work[i].second.first >> work[i].second.second >> work[i].first;
		work[i].second.first -= work[i].first;
		work[i].second.second -= work[i].first;
	}
	sort(all(work));
	vi d(q), ans(q, -1);
	rep(i, q) cin >> d[i];
	set<pair<int, int>> st;
	for(int i = 0; i < q; i++){
		st.insert({d[i], i});
	}
	for(int i = 0; i < n; i++){
		auto [x, p] = work[i];
		int l = p.first, r = p.second;
		auto it = st.lower_bound(make_pair(l, -1));
		while(it != st.end()){
			if(it->first >= r) break;
			ans[it->second] = x;
			st.erase(it++);
		}
	}
	for(int i = 0; i < q; i++) cout << ans[i] << endl;

}

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

int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);  
#endif
  string s;
  cin>>s;
  int n = s.length();
  if(s[n-1]=='s')
    {
      cout<<s+"es";
    }
  else
    {
      cout<<s+"s";

    }

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  int max_water=0,max_sugar=0;
  float max_conc = 0;
  for(int a = 0;a <= 30;a++){
    for(int b = 0;b<=30;b++){
      for(int c = 0;c <= ceil((double)F/C);c++){
        for(int d = 0;d<= ceil((double)F/D);d++){
          int water = 100*A*a + 100*B*b;
          int sugar = C*c + D*d;
          if((water + sugar <= F) && (sugar*100 <= water * E) ){
            float conc = 100 * sugar / ((float)water + (float)sugar);
            if(max_conc < conc){
              max_water = water;
              max_sugar = sugar;
              max_conc = conc;
            }
          }
        }
      }
    }
  }
  if(max_conc == 0) max_water = 100 * A;
  cout << max_water + max_sugar << " " << max_sugar<< endl;
}
            


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

#define int long long

int N, K;
int a[1111];
vector<int> cand;

int countMask(int a) {
   int ret = 0;
   for (int x : cand) {
      if ((x & a) == a) {
         ret++;
      }
   }
   return ret;
}

signed main() {
   cin >> N >> K;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
   }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int mask = 0;
   for (int i = 40; i >= 0; i--) {
      if (countMask(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }

   cout << mask << endl;

   return 0;
}

Measured memory_bytes: 6384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n;
	while (cin >> n&& n) {
		vector<int> v;
		
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			v.emplace_back(a);
		}

		sort(v.begin(), v.end());

		int minl = INF;
		for (int i = 0; i < n-1; i++) {
			if (v[i + 1] - v[i] < minl){
				minl = v[i + 1] - v[i];
			}
		}
		cout << minl << endl;
	}
}

Measured memory_bytes: 3164
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
  char s[101];
  char *p;
  char *p2 = NULL;
  
  cin >> s;
  p = strchr(s, 'C');
  if ( p != NULL ) {
    p2 = strchr(p, 'F');
  }
  if ( p2 != NULL ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

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

    auto a = vector<uint32_t>();

    for (size_t i = 0; i < n; ++i) {
        uint32_t _a;
        cin >> _a;
        a.push_back(_a - 1);
    }

    cout << accumulate(a.begin(), a.end(), uint32_t()) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;



int main(int argc, const char * argv[]) {

  int r;
  cin >> r;
  cout << 3 * pow(r, 2) << endl;

  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n; 
	string s;
	cin>>s;
	int r=0;
	for (int i=0;i<s.size();i++)
		if (s[i]=='R') r++;
	if (r>n-r) puts("Yes");
	else puts("No");
}

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

int main() {
	int n;cin>>n;
	char s[n],s2[n];
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++)cin>>s2[i];
	long long ans=1;
	int logic=0;
	if(s[0]==s[1]){
		ans=6;
		logic=1;
	}else{
		ans=3;
		logic=0;
	}
	for(int i=1+logic;i<n;i++){
		if(i==n-1){
			if(logic){
			}else{
				ans*=2;
				ans%=MOD;
			}
		}else{
			if(s[i]==s[i+1]){
				i++;
				if(logic){
					ans*=3;
					ans%=MOD;
				}else{
					ans*=2;
					ans%=MOD;
				}
				logic=1;
			}else{
				if(logic){
				}else{
					ans*=2;
					ans%=MOD;
				}
				logic=0;
			}
		}
	}
	cout<<ans<<endl;


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

string b;

int main(){
  cin >> b;
  for(char c : b){
    if(c == 'A') cout << 'T';
    if(c == 'T') cout << 'A';
    if(c == 'G') cout << 'C';
    if(c == 'C') cout << 'G';
  }


}


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

import sys
import math
#from pprint import pprint
#import numpy as np
def myinput_int():
    return list(map(int, input().split()))
def myinput_str():
    return list(input().split())

N = myinput_int()[0]

print(3*N*N)



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int f(int n) {
  int x = 0;
  for (int d = 1; d <= n; d++) {
    if (n % d == 0) x++;
  }
  return x;
}

int main2() {
  int N = nextInt();

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1 && f(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define mkp make_pair
typedef pair<ll,ll> P;
ll mpp[100005][9];
int main()
{
	ll k;
	cin>>k;
	vector<ll> mp;
	for(ll i=1;i<=9;i++)
	{
		mp.push_back(i);
	}
	if(k<=10)
	{
		cout<<k<<endl;
		return 0;
	} 
	ll cnt = 9;
	while(1)
	{
		vector<ll> tmp;
		for(ll i=0;i<mp.size();i++)
		{
			ll now = mp[i]%10;
			if(now>0)
			{
				tmp.push_back(mp[i]*10+now-1);
				cnt++;
				if(cnt == k)
				{
					cout<<mp[i]*10+now-1<<"\n";
					return 0;
				}
			}
			tmp.push_back(mp[i]*10+now);
			cnt++;
			if(cnt == k)
			{
				cout<<mp[i]*10+now<<endl;
				return 0;
			}
			if(now<9)
			{
				tmp.push_back(mp[i]*10+now+1);
				cnt++;
				if(cnt == k)
				{
					cout<<mp[i]*10+now+1<<"\n";
					return 0;
				}
			}
		}
		mp = tmp;
	}
	return 0;
 } 

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>

#define MAX 1001

char X[MAX], Y[MAX];

int LCS(){
  int i, j;
  int m = strlen(X);
  int n = strlen(Y);
  int c[m + 1][n + 1];

  for (i = 1; i <= m; i++) c[i][0] = 0;
  for (j = 0; j <= n; j++) c[0][j] = 0;

  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (X[i - 1] == Y[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;
      else if (c[i - 1][j] >= c[i][j - 1]) c[i][j] = c[i - 1][j];
      else c[i][j] = c[i][j - 1];
    }
  }

  return c[m][n];
}

int main() {
  int n, i;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s%s", X, Y);
    printf("%d\n", LCS());
  }

  return 0;
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
  cin >> H.at(i);
  }
  int LL = 0;
  int SS = 0;
  int MM = 0;
  for(int j = 0; j < N-1; j++){
  if(H.at(j) >= H.at(j+1)){LL = LL + 1;}
    else{SS = LL; LL = 0;}
  if(MM < SS){MM = SS;}
  }
  if(MM < LL){MM = LL;}
  cout << MM << endl;
}
  

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> s;
    n = s.length();
    for(int i=0;i<n;i++){
        int u = 0;
        for(int j=0;j<n;j++){
            if(s[j] == s[i])u++;
        }
        if(u != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#abc 050 b
n=int(input())
t=list(map(int,input().split()))
sum_t=sum(t)
m=int(input())
px=[]
for i in range(m):
    p,x=map(int,input().split())
    px.append([p,x])

for i in px:
    henka=t[i[0]-1]-i[1]
    ans=sum_t-henka
    print(ans)

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

//int _; 

int a;
long long b,n;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b >> n;
	cout << a*min(n,b-1)/b << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int N;
	cin>>N;
	string s;
	cin>>s;
	if (N%2==1)
	{
		cout<<"No"<<endl;
		exit(0);
	}
	for (int i = 0 ; i < N / 2 ; i++)
	{
		if (s[i] != s[i + N / 2])
		{
			cout<<"No"<<endl;
			exit(0);
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef pair<double,string> pds;

/* global variables */

int n;
pds prds[MAX_N];

/* subroutines */

bool comp(const pds& p0, const pds& p1) {
  return
    (p0.first > p1.first) ||
    (p0.first == p1.first && p0.second < p1.second);
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      int pi, ai, bi, ci, di, ei, fi, si, mi;
      cin >> prds[i].second;
      cin >> pi >> ai >> bi >> ci >> di >> ei >> fi >> si >> mi;

      int rev = fi * mi * si - pi;
      int tm = (ai + bi + ci) + (di + ei) * mi;
      prds[i].first = (double)rev / tm;
    }

    sort(prds, prds + n, comp);

    for (int i = 0; i < n; i++) cout << prds[i].second << endl;
    cout << '#' << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
    int n,sum=0,sum2=0;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        sum2+=a[i];
    }
    int t,pro,time;
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>pro>>time;
        sum+=time;
        sum-=a[pro];
        cout<<sum<<"\n";
        sum=sum2;
    }

    return 0;
}


Measured memory_bytes: 3560
A, B, C = map(int, input().split())
cnt = 0

if A == B == C and A % 2 == 0:
    cnt = -1
else:
    while A%2 == 0 and B%2 == 0 and C%2 == 0:
        A, B, C = int((B+C)/2), int((A+C)/2), int((A+B)/2)
        cnt += 1

print(cnt)

Measured memory_bytes: 9104
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();
    int C = sc.nextInt();
    int D = sc.nextInt();
    System.out.println(Math.max(A*B,C*D));
  }
}

Measured memory_bytes: 20820
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e18;

int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll le=-INF,ri=INF;
    while(ri-le>1){
        ll mid=(le+ri)/2;
        ll sum=0;
        rep(i,n){
            if(a[i]<0){
                ll ng=-1,ok=n;
                while(ok-ng>1){
                    ll cen=(ok+ng)/2;
                    if(cen==-1 || cen==n) break;
                    if(a[i]*a[cen]<=mid){
                        ok=cen;
                    }
                    else{
                        ng=cen;
                    }
                }
                sum+=min(n-1-i,n-ok);
            }
            else{
                ll ok=-1,ng=n;
                while(ng-ok>1){
                    ll cen=(ok+ng)/2;
                    if(cen==-1 || cen==n) break;
                    if(a[i]*a[cen]<=mid){
                        ok=cen;
                    }
                    else{
                        ng=cen;
                    }
                }
                sum+=max(0LL,ok-i);
            }
        }
        if(sum>=k){
            ri=mid;
        }
        else{
            le=mid;
        }
        //cout << sum << " " << mid << endl;
    }
    
    cout << ri << endl;
    return 0;
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define inf 0x6fffffff
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    ll n=read();
    ll ans=0;
    for(ll i=1;i*i<=n;i++)
        if(n%i==0&&(n/i-1)>i)ans+=n/i-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    int ans = 0;
    rep(i, N){
        if(V[i]-C[i] > 0) ans += V[i]-C[i];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

 */
int n, k;
ll x[100000000];
#define INF 10000000000LL

int main()
{
  cin >> n>>k;
  for(size_t i = 0; i < n; i++)
  {
    cin >> x[i];
  }

  ll ans=INF;
  for(size_t i = 0; i <= n - k; i++)
  {
    ll left = abs(min(0LL, x[i]));
    ll right = abs(max(0LL, x[i + k - 1]));
    ans = min(ans, min(2*left + right, left + 2*right));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=998244353;
int fac[N],rev[N],n,m,ans,i;
int ksm(int x,int y)
{
    int ret=1;
    while (y)
    {
        if (y&1) ret=1ll*ret*x%mo;
        y>>=1;
        x=1ll*x*x%mo;
    }
    return ret;
}
int c(int n,int m)
{
    return 1ll*fac[m]*rev[n]%mo*rev[m-n]%mo;
}
int main()
{
    scanf("%d %d\n",&n,&m);
    if (n<m) swap(n,m);
    fac[0]=1;
    fo(i,1,n+m) fac[i]=1ll*fac[i-1]*i%mo;
    rev[n+m]=ksm(fac[n+m],mo-2);
    fd(i,n+m,1) rev[i-1]=1ll*rev[i]*i%mo;
    fo(i,1,m)
    {
        ans=(ans+1ll*c(i,i*2)*c(n-i,n+m-2*i))%mo;
    }
    ans=1ll*ans*ksm(2*c(n,n+m),mo-2)%mo;
    ans=(ans+n+mo)%mo;
    printf("%d",ans);
}

Measured memory_bytes: 7936
L, R = [int(i) for i in input().split()]
mini = 2019
for i in range(L,R):
    if L + 2019 < i:
        break
    for j in range(i+1, R+1):
        if i + 2020 < j:
            break
        tmp = (i * j) % 2019
        if tmp < mini:
            mini = tmp
print(mini)

Measured memory_bytes: 3060
n,m=map(int,input().split())
a=[[] for i in range(n)]
b=[[] for i in range(m)]
f=0
for i in range(n):
    
    a[i]=list(input())
for i in range(m):
    b[i]=list(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        ans=0
        for x in range(m):
            for y in range(m):
                if b[x][y]==a[x+i][y+j]:                 
                    ans+=1
        if ans==m*m:
            f=1
print("Yes" if f==1 else "No")
      
        


Measured memory_bytes: 9212
#include <iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main()
{
  cin>>a>>b>>c>>d;
  if(b<c ||d<a)
    cout << 0;
    else if(a<c)
      cout << min(b, d) - c;
      else if(a>c)
        cout << min(b, d) - a;
        else if(a==c)
        {
          if(b==d)
            cout << b - a;
            else if(b<d)
              cout << b - a;
              else if(b>d)
                cout << d - c;
        }
        else if(b==d)
        {
          if(a<c)
            cout << d - c;
            else
              cout << d - a;
        }
        
}

Measured memory_bytes: 256
import std.stdio;
import std.regex;

void main(){
	auto io = new IO();
	
	auto w = io.line!string()[0];
	
	foreach( a ; alphaB ){
		if( w.count(a) % 2 != 0 ){
			writeln( "No" );
			return;
		}
	}
	writeln("Yes");
	
	return;
}

import std.stdio,std.conv,std.string;
import std.algorithm,std.array,std.math;

immutable PRIME = 1_000_000_007;
immutable alphaB = "abcdefghijklmnopqrstuvwxyz";
immutable alphaU = "ABCDRFGHIJKLMNOPQRSTUVWXYZ";
class IO
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
	void swap( T )( ref T x , ref T y ){
		x = x^y;
		y = x^y;
		x = x^y;
	}
}
// Array compute
// T -> T[]
pure T[] step( T = size_t )( in T begin , in T end , in T step = 1 ){
	T[] ret = new T[]((end-begin)/step);
	size_t i;
	for( T n = begin ; n < end ; n += step ){
		ret[i] = n;
		i+=1;
	}
	return ret;
}
unittest{
	assert( step(0,10,2) == [0,2,4,6,8] );
}

// T[] -> T[]
pure T[] fill( T )( T[] args , in T filling ){
	foreach( ref arg ; args ){
		arg = filling;
	}
	return args;
}
T[] map( T )( T[] args , T function(T) f ){
	foreach( ref arg ; args ){
		arg = f(arg);
	}
	return args;
}
unittest{
	assert( [true,false,true,false].fill(true) == [true,true,true,true] );
	assert( [1,-2,3,-4].map!int(x=>x*2) == [2,-4,6,-8] );
}
// operation
// T[] -> T number
pure T sum( T )( in T[] args ){
	T ret = 0;
	foreach( i ; 0..args.length ){
		ret += args[i];
	}
	return ret;
}
pure real multi( in real[] args ){
	real ret = 1.0;
	foreach( i ; 0..args.length ){
		ret *= args[i];
	}
	return ret;
}
pure T ave(T)( in T[] args ){
	return args.sum()/args.length;
}
// Search
// T[] -> any
pure bool any( T )( in T[] args , in T target ){
	foreach( arg ; args ){
		if( arg == target ){return true;}
	}
	return false;
}
pure bool all( T )( in T[] args , in T cond ){
	foreach( arg ; args ){
		if( arg != cond ){return false;}
	}
	return true;
}
pure bool have( T )( in T[] args , in T[] target ... ){
	bool[] found = new bool[](target.length);
	foreach( arg ; args ){
		foreach( i,t ; target ){
			if( arg == t ){
				found[i] = true;
			}
		}
	}
	foreach( f ; found ){
		if( f == false ){return false;}
	}
	return true;
}
pure size_t count( T )( in T[] args , in T target ){
	size_t c = 0;
	foreach( arg ; args ){
		c += ( arg == target ) ? 1 : 0 ;
	}
	return c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    if((s1[s1.length()-1]==s2[0])&&(s2[s2.length()-1]==s3[0])){
        cout <<"YES" << endl;
    }else{
        cout<<"NO" << endl;        
    }
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1==0)
        cout << 1;
    else if(x2==0)
        cout << 2;
    else if(x3==0)
        cout << 3;
    else if(x4==0)
        cout << 4;
    else
        cout << 5;
}


Measured memory_bytes: 3556
#include<stdio.h>
int main() {
	long long N, M, ans = 0;
	scanf("%lld%lld", &N, &M);

	if (M >= N * 2)//N:M <= 1:2
	{
		ans += N;
		M -= 2 * N;
		ans += M / 4;
	}
	else if (M < N * 2)//N:M > 1:2
	{
		ans += M/2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define nn 3008
#define int long long 
#define mod 1000000007
int dp[2][nn][2],n,m;
void add(int&x,int y){
	x=(x+y)%mod;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	int now=1;for(int i=0;i<=n;i++) dp[now][i][i==0]=1;
	while(m--){
		now^=1;memset(dp[now],0,sizeof dp[now]);
		for(int i=0;i<=n;i++)for(int j=0;j<2;j++){
			int res=dp[now^1][i][j];
			//bb
			if(i) add(dp[now][i-1][j|(i==1)],res);
			//rr
			add(dp[now][i+1][j],res);
			//br
			if(i) add(dp[now][i][j|(i==1)],res);
			//rb
			if(i<n) add(dp[now][i][j],res);
			
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++) add(ans,dp[now][i][1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
  
int main(){
    int n; cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i, 2){
        rep(j, n){
            cin >> a[i][j];
        }
    }
    int sum;
    int sum_max = 0;
    rep(i, n){
        sum = 0;
        rep(j, n){
            if(j <= i) sum += a[0][j];
            if(i <= j and j <= n - 1) sum += a[1][j];
        }
        sum_max = max(sum_max, sum);
    }
    cout << sum_max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,m,q,e,f,g,h,i,j,k,l,o,p,s,a[50],b[50],c[50],d[50],t[11],u,r=0;
int main(){
    scanf("%d%d%d",&n,&m,&q);
    for(i=0;i<q;i++)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    for(e=1;e<=m;e++){t[1]=e;
        for(f=e;f<=m;f++){t[2]=f;
            for(g=f;g<=m;g++){t[3]=g;
                for(h=g;h<=m;h++){t[4]=h;
                    for(i=h;i<=m;i++){t[5]=i;
                        for(j=i;j<=m;j++){t[6]=j;
                            for(k=j;k<=m;k++){t[7]=k;
                                for(l=k;l<=m;l++){t[8]=l;
                                    for(o=l;o<=m;o++){t[9]=o;
                                        for(p=o;p<=m;p++){t[10]=p;
                                            u=0;
                                            for(s=0;s<q;s++){
                                                if(t[b[s]]-t[a[s]]==c[s])u+=d[s];
                                            }
                                            r=r<u?u:r;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int solve(int,int);

int arr[20],n;

int main(){

  int i,q,m;
  
  //in
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&m);
    
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m){
  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;
  
  res = solve(i+1,m) || solve(i+1,m-arr[i]);
  return res;
}

Measured memory_bytes: 580
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n = int(readline())
    a = readlist()
    neg_cnt = sum(ai < 0 for ai in a)
    if neg_cnt % 2 == 0:
        print(sum(map(abs, a)))
    else:
        print(sum(map(abs, a)) - 2 * min(abs(ai) for ai in a))


# region template

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


class ostream:
    def __lshift__(self, a):
        if a is endl:
            sys.stdout.write(b"\n")
            sys.stdout.flush()
        else:
            sys.stdout.write(str(a))
        return self


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
cout, endl = ostream(), object()

readline = sys.stdin.readline
readlist = lambda var=int: [var(n) for n in readline().split()]
input = lambda: readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 44652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000018
#define mod 1000000007
#define MAXN 100005
typedef pair<int, int> PA;
struct edge{
    int u;
    int v;
    int cost;
};
int n;
PA xx[MAXN], yy[MAXN];
edge G[2 * MAXN];

int par[2 * MAXN];
int ranks[2 * MAXN];

void init(int m)
{
    for(int i = 0; i < m; i++){
        par[i] = i;
        ranks[i] = 0;
    }
}

int finds(int x)
{
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = finds(par[x]);
    }
}

void unite(int x, int y)
{
    x = finds(x);
    y = finds(y);
    if(x == y) return;

    if(ranks[x] < ranks[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(ranks[x] == ranks[y]) ranks[x]++;
    }
}

bool same(int x, int y)
{
    return finds(x) == finds(y);
}

bool comp(const edge& e1, const edge& e2)
{
    return e1.cost < e2.cost;
}

signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> xx[i].first >> yy[i].first;
        xx[i].second = i;
        yy[i].second = i;
    }
    sort(xx, xx + n);
    sort(yy, yy + n);


    int k = 0;
    for(int i = 1; i < n; i++){
        G[k].u = xx[i - 1].second;
        G[k].v = xx[i].second;
        G[k].cost = xx[i].first - xx[i - 1].first;
        //printf("u:%lld - v:%lld : cost:%lld\n", G[k].u, G[k].v, xx[i].first - xx[i - 1].first);
        k++;
        G[k].u = yy[i - 1].second;
        G[k].v = yy[i].second;
        G[k].cost = yy[i].first - yy[i - 1].first;
        //printf("u:%lld - v:%lld : cost:%lld\n", G[k].u, G[k].v, yy[i].first - yy[i - 1].first);
        k++;
    }
    sort(G, G + 2 * (n - 1), comp);

    init(n);

    int res = 0;
    for(int i = 0; i < 2 * (n - 1); i++){
        edge e = G[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
            //printf("cost %lld\n", e.cost);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include <map>
#include<math.h>
#include<vector>           
#include<algorithm>
#include <string.h>


using namespace std;

int main(){
	int n,total,min_size=1;
	string str;
	map<string, int> products;
	map<string, int>::iterator it;

	cin >> n;

	for (int i = 0; i<n; i++){
		cin >> str >> total;
		if (products.find(str) != products.end()){
			products[str] =  products[str] + total;
		}
		else{
			products[str] = total;
		}
	}

	n = products.size();

	while (n != 0){
		it = products.begin();
			while (it != products.end()){
				if ((*it).first.size() == min_size){
					cout << (*it).first << " " << (*it).second << endl;
					n--;
				}
				it++;
			}
		min_size++;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    string s;
    cin >> n >> s;
    string ans = "";
    rep(i, len(s)) {
        ans += ((s[i] - 'A' + n) % 26) + 'A';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
lst = list(map(int, input().split()))

lst2 = []
for i in range(n):
  if i != n-1:
    lst2.append(lst[i+1]- lst[i])
  else:
    lst2.append(k- lst[i] + lst[0])
    
m = max(lst2)

print(sum(lst2) - m)

Measured memory_bytes: 26444
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n],b[n],suma=0,sumb=0;
    rep(i,n){
        cin >> a[i];
        suma += a[i];
    }
    rep(i,n){
        cin >> b[i];
        sumb += b[i];
    }
    if(suma < sumb){
        cout << -1 << endl;
        return 0;
    }
    ll need=0;
    vector<ll> ls;
    ls.clear();
    rep(i,n){
        if(a[i] < b[i]){
            need += b[i]-a[i];
            ans++;
        }
        if(a[i] > b[i]){
            ls.push_back(a[i]-b[i]);
        }
    }
    sort(ls.begin(),ls.end());
    rep(i,n){
        if(need <= 0) break;
        need -= ls.at(ls.size()-i-1);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2428
n = input()
n = int(n)
a = input().split()
a = [int(aa) for aa in a]
ans = 0
#a = map(int, input().split())
for i, a1 in enumerate(a, 0):
    for j, a2 in enumerate(a, 0):
        if i == j:
            continue
        ans = max(ans, abs(a1 - a2))
print(ans)

Measured memory_bytes: 39536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  if(x==1||x==2*n-1) cout<<"No"<<endl;
  else{
    int z=1;
    vector<int> ans;

    cout<<"Yes"<<endl;
    if(x==2){
      for(int i=1;i<n-1;i++){
        if(z<x-1||z>x+2) ans.push_back(z);
        else i--;
        z++;
      }
      ans.push_back(x+1);
      ans.push_back(x);
      ans.push_back(x-1);
      ans.push_back(x+2);
      for(;z<2*n;){
        if(z<x-1||z>x+2) ans.push_back(z);
        z++;
      }
    }else{
      for(int i=1;i<n-1;i++){
        if(z<x-2||z>x+1) ans.push_back(z);
        else i--;
        z++;
      }
      ans.push_back(x-1);
      ans.push_back(x);
      ans.push_back(x+1);
      ans.push_back(x-2);
      for(;z<2*n;){
        if(z<x-2||z>x+1) ans.push_back(z);
        z++;
      }
    }
    for(int i=0;i<2*n-1;i++){
      cout<<ans[i]<<endl;
    }
  }

  return 0;
}


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

int D, G, p[20], c[20], vis[20];

struct T {
    int p, c;
};

int sol() {
    int res = 0, rem = G;
    for(int i = 1 ; i <= D ; ++ i) {
        if(vis[i]) {
            res += p[i];
            rem -= 100 * i * p[i] + c[i];
        }
    }
    for(int i = D ; i >= 1 ; -- i) {
        if(vis[i] == 0) {
            if(rem > 0) {
                if(rem - 100 * i * p[i] >= 0) {
                    // return 1000000000;
                    rem -= 100 * i * p[i] + c[i];
                    res += p[i];                 
                } else {
                    // rem - 100 * i * x >= 0
                    // x <= rem / (100 * i)
                    int x = rem / (100 * i);
                    rem -= 100 * i * x;
                    res += x;
                }
            }
        }
    }
    return rem <= 0 ? res : 1000000000;
}

int main() {
    scanf("%d%d", &D, &G);
    for(int i = 1 ; i <= D ; ++ i) {
        scanf("%d%d", &p[i], &c[i]);
    }
    int ans = 1000000000;
    for(int s = 0 ; s < (1 << D) ; ++ s) {
        for(int i = 1 ; i <= D ; ++ i) vis[i] = ((s >> (i - 1)) & 1);
        ans = min(ans, sol());
        // cout << s << ' ' << sol() << endl;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a;
  cin >> a;
  set<ll> st;
  rep2(i, 2, 1e6 + 1) {
    st.insert(a);
    if(a % 2 == 0)
      a = a / 2;
    else
      a = 3 * a + 1;
    if(st.count(a)) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
# coding: utf-8
M,N = map(int, input().split())
A = 0
B = 0
C = M
D = 0
E = 0
F = N
while A < C:
    B += M -1
    M -= 1
    A += 1

while D < F:
    E += N -1
    N -= 1
    D += 1
print(B + E)

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	void solv(int[][] x) {

		Arrays.sort(x, new Comparator<int[]>() {
			@Override
			public int compare(int[] a, int[] b) {
				int x = a[1] - b[1];
				if (x == 0) {
					return a[2] - b[2];
				}
				return x;
			}
		});

		int prev = -1;
		int num = 0;
		for (int i = 0; i < x.length; i++) {
			if (x[i][1] != prev) {
				num = 1;
				prev = x[i][1];
			} else {
				num++;
			}
			x[i][3] = num;
		}

		Arrays.sort(x, (a, b) -> a[0] - b[0]);

		StringBuilder sb = new StringBuilder();
		for (int[] a : x) {
			sb.append(String.format("%06d%06d\n", a[1], a[3]));
		}
		out.print(sb);
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[][] x = new int[m][4]; // [idx, P, Y, num]

		for (int i = 0; i < m; i++) {
			x[i] = new int[] { i, sc.nextInt(), sc.nextInt(), -1 };
		}

		solv(x);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 171140
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int a, b;

	cin >> a >> b;
	cout << 2 * b - a << endl;

	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c==17)cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<pair<int, int>> X(N);
    REP(i, N) {
        int x;
        std::cin >> x;
        X[i] = make_pair(x, i);
    }

    SORT(X);

    vector<int> ans(N);
    REP(i, N) {
        ans[X[i].second] = (i < N / 2) ? X[N / 2].first : X[N / 2 - 1].first;
    }

    REP(i, N) {
        std::cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,k;
signed main(){
	cin>>n>>k;
	int ans=0;
	if(k==0)cout<<n*n<<endl;
	else{
		for(int i=k+1;i<=n;i++){
			ans+=n/i*i*(i-k)/i;
			ans+=max((ll)0,n%i-k+1);
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=300;

int main(){
	int n;
	cin>>n;
	int A[maxx];
	for(int i=1;i<=n;i++) cin>>A[i];
	for(int i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(i/2>0) printf("parent key = %d, ",A[i/2]);
		if(2*i<=n) printf("left key = %d, ",A[i*2]);
		if(i*2+1<=n) printf("right key = %d, ",A[i*2+1]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  ll X, K, D; cin >> X >> K >> D;
  if (abs(X)/D>=K) cout << min(abs(X-K*D),abs(X+K*D)) << endl;
  else {
    ll x = (X+(abs(X/D)+1)*D)%D;
    K -= abs(X-x)/D;
    if (K%2) cout << abs(x-D) << endl;
    else cout << x << endl;
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
public class Main{
   
     public static void main(String []args){
       Scanner s=new Scanner(System.in);
       int n=s.nextInt();
       long a[]=new long[n];
       for(int i=0;i<n;i++)
       a[i]=s.nextLong();
       boolean flag=true;
       for(int i=0;i<n;i++)
       {if((a[i]%2==0)&&(a[i]%3==0 || a[i]%5==0))
       flag=true;
       else if(a[i]%2==0)
       {flag=false;break;}}
       if(flag)
       System.out.println("APPROVED");
       else
       System.out.println("DENIED");}}

Measured memory_bytes: 23892