akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
  string s;
  while(1){
    getline(cin, s);
    if(s[0] == '#'){
      break;
    }else{
      int state = -1, ans = 0;
      string left = "qwertasdfgzxcvb";
      string right = "yuiophjklnm";
      REP(i, s.size()){
        if(left.find(s[i], 0) != string::npos){
          if(state == 1)
            ans++;
          state = 0;
        }else{
          if(state == 0)
            ans++;
          state = 1;
        }
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1184
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

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

    if ((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
all = [*1..n]
not_good = []
m.times do
  a, b = gets.split.map(&:to_i)
  if h[a-1] > h[b-1]
    not_good << b
  elsif h[a-1] < h[b-1]
    not_good << a
  else
    not_good += [a, b]
  end
end
not_good.uniq!
puts (all - not_good).size


Measured memory_bytes: 47268
import numpy as np

n = int(input())
x_list = list(map(int, input().split()))
x_list = np.array(x_list)

min_x = min(x_list)
max_x = max(x_list)

sum_min = 1e+9
for p in range(min_x, max_x+1, 1):
    sum = np.sum((x_list-p)**2)
    sum_min = min(sum_min, sum)
print(sum_min)

Measured memory_bytes: 12508
#include <stdio.h>
 
int main(void)
{
    int c,i,j,s,k;
    int out[26];

    for(i=0;i<26;i++)
    {
        out[i]=0;
    }

    while((c=getchar())!=EOF)
    {     
        for(j='a',k='A',s=0;j<='z';j++,k++,s++){
            if(j==c || k==c){
                out[s]+=1;
            }
        }
    }
    for(i='a',j=0;j<26;i++,j++){
        printf("%c : %d\n",i,out[j]);
    }

    return 0;
}

Measured memory_bytes: 524
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

pair<ll,int> solve(char s[], ll prev=0){
    if(s[0] == '\0') return mp(prev,1);
    //
    pair<ll,int> reta = mp(0,0), retb = mp(0,0);
    reta = solve(s+1, (ll)(s[0]-'0'));
    reta.fi += reta.se * prev;
    if(prev != 0){
        retb = solve(s+1, (ll)10*prev + (ll)(s[0]-'0'));
    }
    return mp(reta.fi + retb.fi, reta.se + retb.se);
}

int main(){
    char s[15]; scanf("%s", s);
    printf("%lld\n", solve(s).fi);
    return 0;
}


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

int main()
{
    ll n,d,ans=0;
    cin>>n>>d;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        if(sqrt((a*a)+(b*b))<=d)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3676
S=gets.chomp.split("")
nsflg = S.include?("N") && S.include?("S")
nnsflg = ! S.include?("N") && ! S.include?("S")
ewflg = S.include?("E") && S.include?("W")
nswflg = ! S.include?("E") && ! S.include?("W")
if(
	nsflg && ewflg ||
	nsflg && nswflg ||
	nnsflg && ewflg
)
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,x;
	cin>>n>>x;
	int pv;
	cin>>pv;
	ll res=0LL;
	for(int i=1;i<n;++i){
		int t; cin>>t;
		if(pv+t>x){
			ll dec=pv+t-x;
			res+=dec;
			pv=(dec>=t?0:t-dec);
		}
		else pv=t;
	}
	cout<<res;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
int main(int argc, char *argv[]) {
	string a,b;
	cin >> a >> b;
	if(a.length() > b.length()){
		cout << "GREATER" << endl;
	} else if(a.length() < b.length()){
		cout << "LESS" << endl;
	}else{
		int i = 0;
		while(true){
			if(a[i] > b[i]){
				cout << "GREATER" << endl;
				break;
			} else if(a[i] < b[i]){
				cout << "LESS" << endl;
				break;
			}else{
				i++;
				if(i > a.length()){
					cout << "EQUAL" << endl;
					break;
				}
			}
		}
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

const ll MAX = 400005;

vector<long long> fac(MAX, 0), finv(MAX, 0), inv(MAX, 0);

void initCombTable() {
    fac.at(0) = 1; fac.at(1) = 1;
    finv.at(0) = 1; finv.at(1) = 1;
    inv.at(1) = 1;
    for (ll i = 2; i < MAX; i++) {
        fac.at(i) = fac.at(i-1) * i % MOD;
        inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
        finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
    }
}

long long nCk(long long n, long long k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fac.at(n) * (finv.at(k) * finv.at(n-k) % MOD) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    initCombTable();
    if (k >= n - 1) {
        ll ans = nCk(2 * n - 1, n - 1);
        cout << ans << '\n';
    } else {
        ll ans = 0;
        for (ll i = 0; i <= k; i++) {
            (ans += nCk(n, i) * nCk(n - 1, i) % MOD) %= MOD;
        }
        cout << ans << '\n';
    }
    return 0;
}


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

using namespace std;

int main(){
    long long int K;
    queue<string> Q;
    Q.push("1");
    Q.push("2");
    Q.push("3");
    Q.push("4");
    Q.push("5");
    Q.push("6");
    Q.push("7");
    Q.push("8");
    Q.push("9");

    cin >> K;
    K--;
    
    while(0!=K){
        string now = Q.front();
        Q.pop();
        for(int i=0;i<10;i++){
            char add = i+'0';
            if(abs(now.back()-'0'-i)<=1){
                Q.push(now+add);
            }
        }
        K--;
    }

    cout << Q.front() << endl;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int N; cin >> N;
  vi x(N), y(N), h(N); REP(i,N) cin >> x[i] >> y[i] >> h[i];

  int H, Cx, Cy;
  int is;
  REP(i,N) {
    if (h[i] != 0) {
      is = i;
      break;
    }
  }

  REP(Cx,101) {
    REP(Cy,101) {
      bool flag = true;
      H = h[is]+abs(x[is]-Cx)+abs(y[is]-Cy);
      REP(i,N) {
        if (h[i]==0) {
          if (H-abs(x[i]-Cx)-abs(y[i]-Cy)>0) {
            flag = false;
            break;
          }
        }
        else {
          if (h[i]!=H-abs(x[i]-Cx)-abs(y[i]-Cy)) {
            flag = false;
            break;
          }
        }
      }
      if (flag == true) {
        printf("%d %d %d\n",Cx,Cy,H);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

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;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

#define MAX_N 200000


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	
	int t = 0;
	int sum = 0;
	ll res = 0;
	REP(s, n) {
		while (t < n && (sum ^ a[t]) == (sum + a[t])) {
			sum += a[t];
			++t;
		}
		res += t - s;
		if (s == t) ++t;
		else sum -= a[s];
	}
	
	cout << res << endl;
	
	return 0;
}

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

int main() {
  int h, a;
  cin >> h >> a;
  int ans = (h + (a - 1)) / a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	int n,x,e=0,a,i;
	long long int num=0;
	scanf("%d%d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(x<e+a){
			num += e + a - x;
			a = x - e;
		}
		e = a;
	}
	printf("%lld\n", num);
	return 0;
}

Measured memory_bytes: 128
from math import*
a, b, h, m = map(int, input().split())
h = 30 * h + m / 2
m *= 6
d = (a * sin(radians(h))) - (b * sin(radians(m)))
e = (a * cos(radians(h))) - (b * cos(radians(m)))
print((d * d + e * e)**0.5)


Measured memory_bytes: 9456
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

void solve(int tc) {
	int k;
	cin>>k;
	int a, b;
	cin>>a>>b;
	if(a/k != b/k || a%k==0 || b%k==0)
		cout<<"OK\n";
	else
	{
		cout<<"NG\n";
	}
	
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    for(int tc=1; tc<=t; ++tc) {
        solve(tc);
    }    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 5e5 + 5;
int n,m,k,rt;
struct node{
    ll l, r;
}s[N];

bool cmp(node p, node q){
    if(p.r!=q.r) return p.r<q.r;
    return p.l<q.l;
}

int main(){
    scanf("%d",&n);
    rep(i,1,n){
        ll x, l;
        scanf("%lld%lld",&x,&l);
        s[i].l=x-l;
        s[i].r=x+l;
    }
    sort(s+1,s+1+n,cmp);
    int ans=0,r=-2e9;
    rep(i,1,n){
        if(s[i].l>=r){
            ++ans;
            r=s[i].r;
        }
    }
    printf("%d\n", ans);
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1){
        puts("No");
        return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i] != s[i+n/2]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

int main()
{
    ll L;
    cin >> L;
    // for (ll i = 0; i < 1001; ++i)
    // {
    //     L = i;
    //     long double k = 27;
    //     long double a = (L * L * L) / k;

    //     cout << std::fixed;
    //     cout << std::setprecision(8) << i << ":" << a << endl;
    // }

    long double k = 27;
    long double a = (L * L * L) / k;

    cout << std::fixed;
    cout << std::setprecision(10) << a << endl;

    // cout << std::setprecision(50) << a << endl;
}

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

int main() {
  int N;
  cin >> N;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  
  int i = 0;
  while (i < N){
    i++;
    string S;
    cin >> S;
    if (S == "P"){
      p = 1;
    }
    if (S == "W"){
      w = 1;
    }
    if (S == "G"){
      g = 1;
    }
    if (S == "Y"){
      y = 1;
    }
    
  }
  
  if(p + w + g + y == 4){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<map>
#include<iostream>
using namespace std;
int main(){
int a[10]={0},b[1001]={0},c[11]={0},n,f,place[100001]={0};
int panda=0;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>f;
	if(f%2==1){
		a[0]++; 
	}
	else if(f%4==2){
		b[0]++;
	}
	else {
		c[0]++;
	}
}
for(int i=1;i<=n;i++){
if(place[i-1]==1){
	if(c[0]==0){
		panda=1;break;
	}
	else {
		c[0]--;
		place[i]=4;
	}
}
else if(place[i-1]==4){
	if(a[0]!=0){
		a[0]--;
		place[i]=1;
	}
	else if(b[0]!=0){
	 b[0]--;
	 place[i]=2;
}
else break;
}
else {
	if(i==1){
		if(a[0]!=0){
			place[1]=1;a[0]--;
		}
		else if(b[0]!=0){
			place[1]=2;b[0]--;
		}
		else break;
	}
	else {
		if(b[0]!=0){
			place[i]=2;
			b[0]--;
		}
		else if(c[0]==0){
			panda=1;break;
		}
		else {
			place[i]=4;c[0]--;
		}
	}
}
}
if(place[n]==2&&place[n-1]==1)panda=1;
if(n==1&&c[0]==0)panda=1;
if(panda==1)cout<<"No";
else cout<<"Yes";
return 0;
}


Measured memory_bytes: 640
def main():
    N = int(input())

    tmp = 0
    lst1 = [] #合計としては伸びるけど途中にマイナスがあるもの
    lst1_append = lst1.append

    lst2 = [] #合計してもマイナス　途中もマイナス
    lst2_append = lst2.append

    minas = 0

    for _ in range(N):
        S = list(input())
        min_ = 0
        total = 0
        for s in S:
            if s == '(':
                total += 1
            else:
                total -= 1
                min_ = min(min_, total)
        if min_ == 0:
            tmp += total
        else:
            if total > 0:
                lst1_append([min_, total])
            elif total == min_:
                minas += total
            else:
                lst2_append([min_, total])

    lst1.sort(key = lambda x: x[0], reverse = True) #途中での小さくなり方が小さいものから入れる どんどん条件は緩くなるから小さくなる値が0に近いものから
    for a, b in lst1:
        if tmp + a < 0:
            print ('No')
            exit()
        else:
            tmp += b

    lst2.sort(key = lambda x: x[1], reverse = True)
    lst2.sort(key = lambda x: x[0], reverse = False) #どんどん条件が厳しくなるから、より小さいもの　= 0から遠いもの　から使っていく

    # print (lst2)
    for a, b in lst2:
        if tmp + a < 0:
            print ('No')
            exit()
        else:
            tmp += b
    
    tmp += minas

    if tmp == 0:
        print ('Yes')
    else:
        print ('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 116544
#include<cstdio>
#include<vector>

using namespace std;

typedef struct {
	int a;
	int b;
}side;

int main(void)
{
	int i, j;
	int N;
	vector<side> ans;
	side tmp;
	int pair_num;

	scanf("%d", &N);

	// Nが偶数
	if (N % 2 == 0) {
		pair_num = 1 + N;
	}
	// Nが奇数
	else {
		pair_num = 1 + N - 1;

	}

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (pair_num - i != j) {
				tmp.a = i;
				tmp.b = j;
				ans.push_back(tmp);
			}
		}
	}

	printf("%d\n", ans.size());
	for (int i = 0; i < ans.size(); i++) {
		printf("%d %d\n", ans[i].a, ans[i].b);
	}

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void) {
	int h, w, i;
	char top_bottom[301], mid_row[301];

	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)
			break;

		for (i = 0; i < w; i++) {
			top_bottom[i] = '#';
			mid_row[i] = '.';
		}
		top_bottom[i] = mid_row[i] = '\0';
		mid_row[0] = mid_row[i-1] = '#';

		h -= 2;
		puts(top_bottom);
		while (h--) {
			puts(mid_row);
		}
		printf("%s\n\n", top_bottom);
	}
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    ll x,y;cin>>x>>y;
    
    if(x%y==0){
        cout<<-1<<endl;
    }
    else {
        cout<<x<<endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}
map<int,int>mp;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  rep(i,N){
    int x;cin >> x;
    rep(i,8){
      if(x>=i*400 && x<(i+1)*400){
        ++mp[i];
      }
    }
    if(x>=3200) ++mp[8];
  }

  int ans1 = 0;
  rep(i,8) if(mp.count(i)) ++ans1;
  int ans2 = ans1;
  if(mp.count(8)) ans2+=mp[8];
  if(ans1==0&&mp.count(8)) ans1=1;
  cout << ans1 SP ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: String,
    }
    let s = s.chars().collect::<Vec<_>>();
    let mut ones = vec![];
    let mut zeros = vec![];
    if s[0] == '0' {
        ones.push(0i32);
    }
    let mut i = 0;
    while i < n {
        let c0 = s[i];
        let j = i;
        while i < n && c0 == s[i] {
            i += 1;
        }
        if c0 == '0' {
            zeros.push((i - j) as i32);
        } else {
            ones.push((i - j) as i32);
        }
    }
    if s[n - 1] == '0' {
        ones.push(0);
    }
    zeros.push(0);
    let k = std::cmp::min(k, ones.len());
    let mut sum = 0i32;
    for i in 0..k {
        sum += ones[i];
        sum += zeros[i];
    }
    if k < ones.len() {
        sum += ones[k];
    }
    let mut max = sum;
    for i in 1..ones.len() - k {
        sum -= ones[i - 1];
        sum -= zeros[i - 1];
        sum += ones[i + k];
        sum += zeros[i + k - 1];
        if sum > max {
            max = sum;
        }
    }
    println!("{}", max);
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 最小公倍数を計算
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int result = 0;
  rep(i, n) {
    result = gcd(result, a[i]);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	
	int huro;
	int puru;
	int huroken;
	int puruken;
	int niti;
	int ryo;
	int gokei;
	int wgokei;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		niti = sc.nextInt();
		for(int i=0;i<niti;i++){
			huro = sc.nextInt();
			puru = sc.nextInt();
			huroken = sc.nextInt();
			puruken = sc.nextInt();
			gokei = huro*huroken+puru*puruken;
			if(huroken<5){
				huroken = 5;
			}
			if(puruken<2){
				puruken = 2;
			}
			wgokei = (huro*huroken+puru*puruken)/10*8;
			if(gokei > wgokei){
				System.out.println(wgokei);
			}else{
				System.out.println(gokei);
			}
		}
	}
	public static void main(String[]args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 23280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    int c[510], s[510], f[510];
    for(int i = 1; i <= n - 1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 1; i <= n; i++){
        int time = 0;
        for(int k = i; k <= n - 1; k++){
            if(time % f[k] == 0){
                time = (time / f[k]) * f[k];
            } else {
                time = ((time / f[k]) + 1) * f[k];
            }
            time = max(time, s[k]);
            time += c[k];
        }
        cout << time << endl;
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

vector<vi> e;
bool vis[200000];
int rec(int u, int v, int sz){
	if(sz == 0) return 1;
	vis[u] = vis[v] = 1;
	for(int i : e[u]) if(!vis[i])
	for(int j : e[v]) if(!vis[j] && i != j){
		if(rec(i, j, sz - 2)) return 1;
	}
	vis[u] = vis[v] = 0;
	return 0;
}
bool check(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, u, v;
	cin >> n >> u >> v; u--; v--;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	if(n % 2) return 0;
	int cnt = 0;
	rep(i, n){
		if(e[i].size() > 3 ) return 0;
		if(e[i].size() == 3) cnt++;
	}
	if(cnt > 2) return 0;
	return rec(u, v, n - 2);
}
int run(){
	cout << (check() ? "Yes" : "No") << endl;
	return 0;
}
long long esp_org, esp_new;
int main(){
	const int size = 128*1024*1024;
	void *p = malloc(size);
	esp_new = (long long)p + size - 1;
	
	
	__asm__("mov %%rsp, %0" : "=r"(esp_org) : : );
	__asm__("mov %0, %%rsp" : : "r"(esp_new) : );
	
	run();
	
	__asm__("mov %0, %%rsp" : : "r"(esp_org) : );
	free(p);
	return 0;
}

Measured memory_bytes: 13096
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = []
P = []
stock = []
N.times do |i|
  S[i], P[i] = gets.chomp.split
  P[i] = P[i].to_i
  stock[i] = {
    name: S[i],
    point: P[i],
    index: i + 1,
  }
end

ans = stock.sort do |a, b|
  name_x = a[:name] <=> b[:name]
  if name_x != 0
    name_x
  else
    b[:point] <=> a[:point]
  end
end

ans.each do |x|
  puts x[:index]
end


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

int main() {
	string words;
	getline(cin, words);
	int change = 'A' - 'a';

	for (int i = 0;i < words.length();i++) {
		if (words.at(i) >= 'a' && words.at(i) <= 'z') {
			words.at(i) += change;
		}
	}

	cout << words << endl;

	return 0;
}

Measured memory_bytes: 1172
s = input()

if len(s) == 2:
    if len(set(list(s))) == 1:
        print("1 2")
        exit()

for i in range(len(s)-2):
    if len(set(list(s[i:i+3]))) != 3:
        print(str(i+1)+ " "+ str(i+3))
        exit()

print("-1 -1")




Measured memory_bytes: 3188
#include <stdio.h>
#define N 500000
#define inf 1000000000
 
int S[N];
int L[N/2+2],R[N/2+2];
int count=0;
 
int merge(int S[],int n, int left, int mid, int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
 
  j=0;
  k=0;
 
  for(i=0; i<n1; i++) L[i] = S[left+i];
  for(i=0; i<n2; i++) R[i] = S[mid+i];
 
  L[n1] = R[n2] = inf;
 
  for(i=left; i<right; i++){
    count++;
    if(L[j]<=R[k]) S[i] = L[j++];
    else {
      S[i] = R[k++];
    }
 
  }
}
 
int mergeSort(int S[],int n, int left, int right){
  if(left+1 < right){
    int mid = (left + right) /2;
    mergeSort(S,n,left,mid);
    mergeSort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}
 
int main(){
  int S[N],i,n;
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
 
  mergeSort(S,n,0,n);
 
  for(i=0; i<n; i++){
    if(i) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
 
  printf("%d\n",count);
 
  return 0;
 
}



Measured memory_bytes: 5636
N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x, y))

def circumcenter(p, q, r):
    a, b = p
    c, d = q
    e, f = r
    a, b, c, d = a-e, b-f, c-e, d-f
    g = a * d-b * c
    if p == q: return ((p[0]+r[0]) / 2, (p[1]+r[1]) / 2)
    if g == 0: return (0, 0)
    ab = a * a + b * b
    cd = c * c + d * d
    return ((d * ab - b * cd) / (2 * g) + e, (a * cd - c * ab) / (2 * g) + f)

mi = 2000000
for i, p in enumerate(X):
    for j, q in enumerate(X[i:]):
        for r in X[j+1:]:
            a, b = circumcenter(p, q, r)
            mi = min(mi, max([(x-a)**2+(y-b)**2 for x, y in X]))

print(mi ** 0.5)

Measured memory_bytes: 48216
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    int count=0;
    cin>>n>>m;
    int a[n+5]={0};
    vector<pair<int,int>>v;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        a[l]++;
        a[r+1]--;
        v.push_back({l,r});
    }
    for(int i=2;i<n+2;i++){
        a[i]+=a[i-1];
    }
    for(int i=1;i<=n;i++){
        //cout<<a[i]<<endl;
        if(a[i]==m){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
    
}



Measured memory_bytes: 3188
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[10000];
    int max=-1000001,min=1000001,i=0,n=0;
    long long int count=0;
    scanf("%d",&n);
    if(n==1){
        scanf("%d",&a[0]);
        max = a[0];
        min = a[0];
        count = a[0];
    }else{
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
            if(a[i]>max){
                max = a[i];
            }
            if(a[i]<min){
                min = a[i];
            }
            count += a[i];
        }
    }
    printf("%d %d %lld\n",min,max,count);
    return 0;
}

Measured memory_bytes: 640
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	std::ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	cout << T << S << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	k, t := scanInt(), scanInt()
	mx := math.MinInt64
	for i := 0; i < t; i++ {
		a := scanInt()
		mx = max(mx, a)
	}
	fmt.Println(max(mx-1-(k-mx), 0))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--,b--,c--,d--;
  string s;
  cin>>s;
  int f=0;
  for(int i=a;i<c;i++){
    if(s[i]=='#'&&s[i+1]=='#')f=1;
  }
  for(int i=b;i<d;i++){
    if(s[i]=='#'&&s[i+1]=='#')f=1;
  }
  if(c>d){
    int k=0;
    for(int i=b;i<=d;i++){
	 int sum=0;
	 if(0<=i-1&&s[i-1]!='#')sum++;
	 if(s[i]!='#')sum++;
	 if(i+1<n&&s[i+1]!='#')sum++;
	 if(sum==3)k=1;
    }
    if(k==0)f=1;
  }
  if(f==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

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;}

using Graph = vector<vector<P>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,a;
    cin>>n>>a;
    vector<int> x(n);
    REP(i,n) cin >> x[i];
    rep(i,n){
        x[i]-=a;
    }
    int dp[1000][1000];
    rep(i,1000){
        rep(j,1000){
            dp[i][j]=0;
        }
    }
    int l = 500;
    // 合計値　枚数
    dp[ x[0]+ l ][ 0 ]+=1;
    dp[   0 + l ][ 0 ]+=1;
    rep(i,n-1){
        rep(j,1000){
            int cnt = dp[j][i];
            dp[j][i+1]+=dp[j][i];
            if(0<=j+x[i+1]&&j+x[i+1]<1000){
                dp[j+x[i+1]][i+1]+=dp[j][i];
            }
        }
    }

    

    cout<<dp[0+l][n-1]-1<<endl;

    
}

Measured memory_bytes: 8572
H,W=map(int,input().split())
s=[input()for _ in range(H)]
a=[[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if i==j==0:a[0][0]=0
        elif i==0:a[0][j]=a[0][j-1]if s[0][j]==s[0][j-1]else a[0][j-1]+1
        elif j==0:a[i][0]=a[i-1][0]if s[i][0]==s[i-1][0]else a[i-1][0]+1
        else:a[i][j]=min(a[i][j-1]if s[i][j]==s[i][j-1]else a[i][j-1]+1,a[i-1][j]if s[i][j]==s[i-1][j]else a[i-1][j]+1)
print((a[H-1][W-1]+1)//2 if s[0][0]=='.'else a[H-1][W-1]//2+1)


Measured memory_bytes: 73792
l,r = map(int,input().split())
if r-l >= 2019 or l == 0:
    print(0)
    exit()
res = 10000000
for i in range(l,r+1):
    for j in range(i+1,r+1):
        res = min(res,(i*j)%2019)
print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int p,q,r; cin>>p>>q>>r;
	cout<<min(p+q, min(q+r,r+p));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int x,y,z;

int main(){
    cin>>x>>y>>z;

    cout<<z<<' '<<x<<' '<<y<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long[] array = {a * c, a * d, b * c, b * d};
    long max = array[0];
    for(int i = 1; i < array.length; i++) {
      if (max < array[i]) {
          max = array[i];
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 35616
#include <iostream>
#include <cstdio>

#define LEFT 0
#define UP   1
#define RIGHT 2
#define DOWN 3

#define MIN(X,Y) ((X<Y)?X:Y)
#define MAX(X,Y) ((X>Y)?X:Y)

bool map[5][5][5][5];
int direction=RIGHT;
int pos[2]={0,0};
char nul[5000];


void read(void)
{
	for(int y=0;y<4;y++)
	{
		for(int x=0;x<4;x++)
			map[x][y][x+1][y] = (getchar()-'0' == 1);
		gets(nul);
		for(int x=0;x<5;x++)
			map[x][y][x][y+1] = (getchar()-'0' == 1);
		gets(nul);
	}
	for(int x=0;x<4;x++)
		map[x][4][x+1][4] = (getchar()-'0' == 1);
	return;
}

bool isenable(int x, int y)
{
	return ((0<=x)&&(x<=4))&&((0<=y)&&(y<=4));
}

bool isconnect(int dir)
{
	int x=pos[0], y=pos[1];
	switch(dir) {
		case LEFT:   x--;
			     break;
		case UP:     y--;
			     break;
		case RIGHT:  x++;
			     break;
		case DOWN:   y++;
			     break;
	}
	return (isenable(x,y)&&(map[MIN(pos[0],x)][MIN(pos[1],y)][MAX(pos[0],x)][MAX(pos[1],y)]));
}
void step(int dir)
{
	switch(dir) {
		case LEFT:   pos[0]--; std::cout << "L" << std::flush; direction=LEFT;
			     break;
		case UP:     pos[1]--; std::cout << "U" << std::flush; direction=UP;
			     break;
		case RIGHT:  pos[0]++; std::cout << "R" << std::flush; direction=RIGHT;
			     break;
		case DOWN:   pos[1]++; std::cout << "D" << std::flush; direction=DOWN;
			     break;
	}
	return;
}

void move(void)
{
	do {
		if(isconnect((direction+LEFT-1+4)%4))
			step((direction+LEFT-1+4)%4);
		else if(isconnect((direction+UP-1+4)%4))
			step((direction+UP-1+4)%4);
		else if(isconnect((direction+RIGHT-1+4)%4))
			step((direction+RIGHT-1+4)%4);
		else
			step((direction+DOWN-1+4)%4);

		//std::cerr << "(x,y):" << pos[0] << "," << pos[1] << std::endl;
	}while(!(pos[0]==0 && pos[1]==0));

	std::cout << std::endl;
	return;
}

int main(void)
{
	for(int i=0; i<5; i++)
		for(int j=0; j<5; j++)
			for(int k=0; j<5; j++)
				for(int l=0; j<5; j++)
					map[i][j][k][l] = false;

	read();
	move();
}

Measured memory_bytes: 1116
#define	Rd(s) scanf("%d", &s)
#define	Rs(s) scanf("%s", &s)
#define	Rf(s) scanf("%f", &s)

#define RTNd(n, s, i) for (int i = 0;(i<n) ? scanf("%d", &s), true : false;i++)
#define RTNf(n, s, i) for (int i = 0;(i<n) ? scanf("%lf", &s), true : false;i++)

#define RTEs(s) while (fgets(s, sizeof(s), stdin) != NULL)
#define RTEc(s) while ((s = scanf("%c")) != EOF)

#define Pd(s) printf("%d", s);
#define Pf(s) printf("%f", s);

#define Pn printf("\n");

#define SORTV(v) sort(v.begin(), v.end())
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


int main() {
	long long int n, s;
	long long int sum = 0, c = 0;
	scanf("%lld", &n);
	for (int i = 0;(i<n) ? scanf("%lld", &s), true : false;i++) {
		if (c == 1 && s == 0) {
			c = 0;
		}
		else if (c == 1) {
			s++;
			sum += s / 2;
			c = s % 2;
		}
		else {
			sum += s / 2;
			c = s % 2;

		}

	}
	printf("%lld", sum);

	Pn;
	return 0;


}

Measured memory_bytes: 256
n=input()
n=int(n)
vll=input().split()
vll=[int(i) for i in vll]
cll=input().split()
cll=[int(i) for i in cll]
count=0
ofset=0
for i in range(n):
    x=vll[ofset]
    y=cll[ofset]
    z=x-y
    if z>=0:
        count+=z
    ofset+=1
print(count)


Measured memory_bytes: 3060
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
//#define MOD 1000000007
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N,M;
    cin >> N >> M;
    ll sum = 1;
    if (N == M) {
        rep(i, N) {
            sum *= i+1;
            sum %= MOD;
        }
        sum *= sum;
        sum %= MOD;
        sum *= 2;
        sum %= MOD;
    } else if (abs(N-M) == 1) {
        rep(i, N) {
            sum *= i+1;
            sum %= MOD;
        }
        rep(i, M) {
            sum *= i+1;
            sum %= MOD;
        }
    } else {
        sum = 0;
    }
    print(sum);
    return 0;
}

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

int main(){
  int N,K,V[100];
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>V[i];
  ll ans(0);
  for (int i(0);i<=min(N,K);i++){//とる個数
    int suteru_cnt = min(i,K - i);
    for (int j(0);j<=i;j++){//とるうち左からとる個数
      vector <int> get;
      for (int k(0);k<j;k++) get.push_back(V[k]);
      for (int k(0);k<(i-j);k++) get.push_back(V[N-k-1]);
      sort(get.begin(),get.end());
      ll tmp(0);
      for (int k(0);k<i;k++){
        if (k<suteru_cnt && get[k]<0) continue; 
        tmp+=get[k];
      }
      ans = max(tmp,ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int64_t sum_a = 0;
  int64_t a = 0;
  int64_t b = N-2;
  for(int i=0; i<(N+1)/2-1; i++){
    sum_a += abs(vec.at(a) - vec.at(b));
    if(i%2 == 0){
      a += 2;
    }
    else{
      b -= 2;
    }
  }
  a = N-1;
  b = 1;
  for(int i=0; i<N/2-1; i++){
    sum_a += abs(vec.at(a) - vec.at(b));
    if(i %2 == 0){
      a -= 2;
    }
    else{
      b += 2;
    }
  }
  sum_a += (vec.at(N-1) - vec.at(0));
  
  
  int64_t sum_b = 0;
  
  a = N-1;
  b = 0;
  for(int i=0; i<(N+1)/2-1; i++){
    sum_b += abs(vec.at(a) - vec.at(b));
    if(i%2 == 0){
      a -= 2;
    }
    else{
      b += 2;
    }
  }
  a = 1;
  b = N-2;
  for(int i=0; i<N/2-1; i++){
    sum_b += abs(vec.at(a) - vec.at(b));
    if(i %2 == 0){
      a += 2;
    }
    else{
      b -= 2;
    }
  }
  sum_b += vec.at(N-1) - vec.at(1);
  
  cout << max(sum_a,sum_b) << endl;
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    for(auto& i : A)cin >> i;
    partial_sum(A.begin(), A.end(), A.begin());
    auto S = A.back();
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(const auto& i : A)ans = min(ans, max(S - i, i) - min(S - i, i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256