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

int main()
{
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == n * 2 - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(x <= n){
        for(int i = 1; i <= x - 2; i++) cout << i << " ";
        for(int i = x + 1; i <= n; i++) cout << i << " ";
        cout << x - 1 << " " << x << " ";
        for(int i = n + 1; i <= n * 2 - 1; i++) cout << i << " ";
    }
    else{
        for(int i = 1; i <= n - 1; i++) cout << i << " ";
        cout << x << " " << x + 1 << " ";
        for(int i = n; i <= x - 1; i++) cout << i << " ";
        for(int i = x + 2; i <= n * 2 - 1; i++) cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  




signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n,k;
  cin>>n>>k;
  int ans[k+1]={0};
  int res=0;
  for(int i=k;i>=1;i--)
  {
    int tot=k/i;
    tot=power(tot,n,mod);
    for(int j=2*i;j<=k;j+=i)
    {
      tot=(tot-ans[j]+mod)%mod;
    }
    ans[i]=tot;
    res+=(ans[i]*i)%mod;
    res%=mod;
  }

  cout<<res;


// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=1e9+7;
const int INF=1e18;


signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    string s,t;cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int ans=m;
    for(int i=0;i<=n-m;i++){
        string tmp=s.substr(i,m);
        int cnt=0;
        for(int j=0;j<m;j++){
            cnt+=tmp[j]!=t[j];
        }
        ans=min(ans,cnt);
    }
    cout<<ans;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> v(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		v[a]++;
		v[b]++;
	}
	rep(i,n){
		cout << v[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
L = list(sorted(map(int, input().split())))

res = 0

for i in range(N):
    for j in range(i + 1, N):
        k = bisect_left(L, L[i] + L[j])

        res += k - j - 1

print(res)


Measured memory_bytes: 3188
#include<stdio.h>
struct Card{char suit;int value; };
int main()
{
  struct Card a[101],b[101];
  int n,i,j,k,mini,m,sum=0; 
  char ch;
  scanf("%d%c",&n,&ch);

  for(i=0;i<n;i++){ 
    if(i<n)break;
  }
  
  for(i=0;i<n;i++){ 
    scanf("%c%d%c",&a[i].suit,&a[i].value,&ch);
  }
  for(i=0;i<n+1;i++){
    b[i]=a[i];
  }
  
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j].value<a[j-1].value){
	m=a[j].value;
	a[j].value=a[j-1].value;
 	a[j-1].value=m;
	ch=a[j].suit;
        a[j].suit=a[j-1].suit;
        a[j-1].suit=ch;
      }
    }
  }  
  for(i=0;i<n-1;i++){
    mini=i; 
    m=b[i].value;
    for(j=i;j<n;j++){
      if(b[j].value<m){
	m=b[j].value;
	mini=j;
      }
    }
    if(m!=b[i].value){
      k=b[i].value;
      b[i].value=b[mini].value;
      b[mini].value=k;
      ch=b[i].suit;
      b[i].suit=b[mini].suit;
      b[mini].suit=ch;
    }
  }

  for(i=0;i<n;i++){
    if(a[i].suit==b[i].suit && a[i].value==b[i].value){
    sum++;
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",a[i].suit,a[i].value);
  }
  printf("%c%d",a[i].suit,a[i].value);
  printf("\nStable\n");

  for(i=0;i<n-1;i++){
    printf("%c%d ",b[i].suit,b[i].value);
  }
  printf("%c%d",b[i].suit,b[i].value);
  if(sum==n)printf("\nStable\n");
  else printf("\nNot stable\n");

  return 0;
}



Measured memory_bytes: 2148
import math

k = int(input())

tb = [
    [math.gcd(a, b) for a in range(0, 201)]
    for b in range(0, 201)
]

x = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        t = tb[a][b]
        for c in range(1, k + 1):
            x += tb[t][c]
print(x)


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

int Trans(string s){

  if(s=="yotta")return 24;
  else if(s=="zetta")return 21;
  else if(s=="exa")return 18;
  else if(s=="peta")return 15;
  else if(s=="tera")return 12;
  else if(s=="giga")return 9;
  else if(s=="mega")return 6;
  else if(s=="kilo")return 3;
  else if(s=="hecto")return 2;
  else if(s=="deca")return 1;
  else if(s=="deci")return -1;
  else if(s=="centi")return -2;
  else if(s=="milli")return -3;
  else if(s=="micro")return -6;
  else if(s=="nano")return -9;
  else if(s=="pico")return -12;
  else if(s=="femto")return -15;
  else if(s=="ato")return -18;
  else if(s=="zepto")return -21;
  else if(s=="yocto")return -24;
  
  else return 0;  

}

int main(){

  string x,head,tanni;
  int keta,ad,sisu;
  int indx;
  int n;

  cin >> n;

  for(int i=0; i<n; i++){


    cin >> x >> head;
    ad = Trans(head);
    if(ad==0){ tanni=head; }
    else{ cin>>tanni; }

    keta=0;
    sisu=x.size()-1;
    indx = -1;
    bool flg=false;


    for(int j=0; j<(int)x.size(); j++){

      if(x[j]=='.'){ if(indx!=-1)sisu=j-1;else sisu = j;}
      
      if(x[j]!='0' && x[j]!='.' && flg==false){flg=true; indx=j;}

      if(flg && x[j]!='.'){
	keta++;
      }

    }

    //  cout << "test " << sisu<<' ' << keta<<' ' << ad << endl;


    //Output
    cout << x[indx];
    if(keta >= 2){
      cout << '.';

      for(int j=indx+1; j<(int)x.size(); j++){
	if(x[j]!='.')
	  cout << x[j];
      }
    }

    cout << " * 10^";
    // cout<<endl;
    //cout<<sisu-indx<<" "<<ad<<endl;

    cout << sisu-indx+ad << ' ' << tanni << endl;

  }



  return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct P{
char name[100];
int t;
}p;
P Q[LEN];
int head,tail,n;
void enqueue(P x){
Q[tail]=x;
tail=(tail+1)%LEN;
}
P dequeue(){
P x=Q[head];
head=(head+1)%LEN;
return x;
}
int min(int a,int b){return a<b?a:b;}
int main()
{
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;
    while(head!=tail){
            u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
        printf("%s %d\n",u.name,elaps);
    }
            }
            return 0;
}

Measured memory_bytes: 12720
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#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>
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    V<string> s(h); REP(i, h) cin >> s[i];
    vvll l2r(h+2, vll(w+2, 0)), r2l(h+2, vll(w+2, 0)), u2d(h+2, vll(w+2, 0)), d2u(h+2, vll(w+2, 0));
    REP(i, h) REP(j, w) {
        if (s[i][j] == '.') {
            l2r[i+1][j+1] = l2r[i+1][j]+1;
            u2d[i+1][j+1] = u2d[i][j+1]+1;
        }
    }
    for (ll i=h-1; i>=0; i--) {
        for (ll j=w-1; j>=0; j--) {
            if (s[i][j] == '.') {
                r2l[i+1][j+1] = r2l[i+1][j+2]+1;
                d2u[i+1][j+1] = d2u[i+2][j+1]+1;
            }
        }
    }
    ll ans = 0;
    REP(i, h) REP(j, w) chmax(ans, l2r[i+1][j+1]+r2l[i+1][j+1]+u2d[i+1][j+1]+d2u[i+1][j+1] - 3);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 130048
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101];
int num[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i], num[A[i]]++;
	
	for(i=100;i>=0;i--) if(num[i]) {
		if(num[i]==1) return _P("Impossible\n");
		num[i]-=2;
		for(x=1;x<i;x++) {
			if(num[max(i-x,x)]==0) return _P("Impossible\n");
			num[max(i-x,x)]--;
		}
		for(x=1;x<=(i+1)/2;x++) if(num[x]) return _P("Impossible\n");
		
		
		break;
	}
	
	
	
	_P("Possible\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

c = 1; w = 0
for i in range(N-1):
    if w == 0:
        if A[i] < A[i+1]:
            w = 1
        elif A[i] > A[i+1]:
            w = -1
    elif (w > 0 and A[i] > A[i+1]) or (w < 0 and A[i] < A[i+1]):
         w = 0
         c += 1

print(c)


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

double f(double n){
  return (1+n) *n/2/n;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  for(int i = 0;i < n;i++){
    p[i]++;
  }
  
  int mx = 0;
  int s = 0;
  queue<int> q;
  for(int i = 0;i < n;i++){
    s += p[i];
    q.push(p[i]);
    if(q.size() > k){
      s -= q.front();
      q.pop();
    }
    if(q.size() == k){
      mx = max(mx,s);
    }
  }
  
  double ans = mx;
  ans /= 2;
  cout << fixed <<ans << endl;
}

Measured memory_bytes: 1792
S=input()
T=input()
q=int(input())
table=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    a,b,c,d=a-1,b-1,c-1,d-1
    table.append((a,b,c,d))
N=len(S)
M=len(T)
A=[[0]*(N+1) for i in range(2)]
B=[[0]*(N+1) for i in range(2)]
for i in range(1,N+1):
    if S[i-1]=='A':
        A[0][i]+=A[0][i-1]+1
        A[1][i]+=A[1][i-1]
    else:
        A[0][i]+=A[0][i-1]
        A[1][i]+=A[1][i-1]+1
for i in range(1,M+1):
    if T[i-1]=='A':
        B[0][i]+=B[0][i-1]+1
        B[1][i]+=B[1][i-1]
    else:
        B[0][i]+=B[0][i-1]
        B[1][i]+=B[1][i-1]+1
#print(A)
#print(B)
for i in range(q):
    a,b,c,d = table[i]
    #print(S[a:b+1])
    #print(T[c:d+1])
    x=A[0][b+1]-A[0][a]
    y=A[1][b+1]-A[1][a]
    z=B[0][d+1]-B[0][c]
    w=B[1][d+1]-B[1][c]
    #print(x,y,z,w)
    if (x+2*y)%3==(z+2*w)%3:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 76760
from operator import add

ans = 10000000
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
for i in range(2 ** N):
    cnt = 0
    res = [0] * (M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            res = list(map(add, res, C[j]))
    for r in res[1:]:
        if r >= X:
            cnt += 1
    if cnt == len(res[1:]) and ans > res[0]:
        ans = res[0]

if ans == 10000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9336
#include<iostream>
using namespace std;
int main() {
  int a,b;
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++){
    if(s[i] == 'A'){
      a=i;
      break;
    }
  }

  for(int i=s.length(); i>=0; i--){
    if(s[i] == 'Z'){
      b=i;
      break;
    }
  }

  cout << b-a+1 << endl;
  return 0;
}

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

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;

    vector<int> a(n);

    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    a.push_back(x);
    sort(a.begin(), a.end());

    int ans = 0;

    for(int i = 1; i < n + 1; i++) {
        ans = __gcd(ans, a[i] - a[i - 1]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n,h,w;
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
	return 0;
}


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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    int n=str.length();
    int c=0,ans=0;
    for(int i=0;i<n;i++)
    {
         if(str[i]=='R')
         c++;
         else
         {
              ans=max(ans,c);
              c=0;
         }
         ans=max(ans,c);
    }
    cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 3648
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 1000010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
LL a[N],b[N],p[N],v[N];
char c[N];

struct Data{
	LL x,y;
}d[N];

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

inline int Gcd(int x,int y){return (y==0)?x:Gcd(y,x%y);}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i]=read();
	a[0]=a[1];
	for (i=1;i<=n;i++)	a[0]=Gcd(a[0],a[i]);
	if (a[0]!=1){
		puts("not coprime");
		return 0;
	}

	for (i=2;i<=1000000;i++){
		if (v[i])	continue;
		++cnt;	p[cnt]=i;	v[i]=i;
		for (j=i*i;j<=1000000;j+=i)
			if (!v[j])	v[j]=i;
	}
	v[1]=1;
	for (i=1;i<=n;i++){
		x=a[i];
		while (v[x]>1){
			if (b[v[x]] && b[v[x]]!=i)	goto END;
			b[v[x]]=i;	x/=v[x];
		}
	}
	puts("pairwise coprime");
	return 0;
	END:;
	puts("setwise coprime");
	return 0;
}

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

int N, M, X;
int A[100];

int main() {
    cin >> N >> M >> X;
    rep(i, M) cin >> A[i];

    int left = 0;
    int right = 0;

    rep(i, M) {
        if (A[i] < X) left++;
        else right++;
    }

    cout << min(left, right) << endl;
}

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

using namespace std;

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

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

int binpow(int n, int k){
  if(k == 0){
    return 1 % inf;
  }
  int z = binpow(n, k / 2);
  z = z * 1ll * z % inf;
  if(k & 1){
    z = z * 1ll * n % inf;
  }
  return z;
}

int n;
int a[N], u[N], p1, p2;
int f[N], rf[N];

int cnk(int n, int k){
  if(n < k){
    return 0;
  }
  return (f[n] * 1ll * rf[k] % inf) * 1ll * rf[n - k] % inf;
}

int main(){
  scanf("%d", &n);
  f[0] = 1;
  for(int i = 1; i <= n * 2 + 3; ++i){
    f[i] = f[i - 1] * 1ll * i % inf;
  }
  rf[n * 2 + 3] = binpow(f[n * 2 + 3], inf - 2);
  for(int i = n * 2 + 2; i >= 0; --i){
    rf[i] = rf[i + 1] * 1ll * (i + 1) % inf;
  }
  for(int i = 1; i <= n + 1; ++i){
    scanf("%d", a + i);
    if(u[a[i]]){
      p2 = i;
      p1 = u[a[i]];
    }
    u[a[i]] = i;
  }
  printf("%d\n", n);
  // sum cnk(a, x) * cnk(b, len - x)
  for(int len = 2; len <= n + 1; ++len){
    int ans = cnk(n + 1, len);
    int tot = p1 - 1 + (n + 1) - p2;
    ans -= cnk(tot, len - 1);
    if(ans < 0){
      ans += inf;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r,g,b,n;
ll ans=0,tmp=0;

int main(void){
    cin>>r>>g>>b>>n;
    //memset(m,0,sizeof(m));
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=n;j++){
    		/*if(i*r+j*g==n){
    			cout<<i<<j<<endl;
    			ans++;
    		}*/
    		if((n-i*r-j*g)%b==0&&(n-i*r-j*g)>=0){
    		//	cout<<i<<j<<endl;
    			ans++;
    		}
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    rep(i, n) std::cin >> a.at(i);
    
    std::vector<int> ans(n);
    rep(i, n) ans.at(a.at(i) - 1) = i + 1;
    
    rep(i, n) std::cout << ans.at(i) << std::endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int s = Integer.parseInt(sc.nextLine());
            if (s >= 86400 || s < 0) {
                System.out.println("Input is incorrect");
                return;
            }
            int h = s / (60 * 60);
            int r = s % (60 * 60);
            int m = r / 60;
            r = s % 60;
            System.out.printf("%d:%d:%d\n", h, m, r);
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
        }
    }
}



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

using namespace std;

#define db(a) cout<<#a<<" = "<<a<<endl
#define db2(a,b) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<endl
#define db3(a,b,c) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<endl
#define db4(a,b,c,d) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<", "<<#d<<" = "<<d<<endl

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/*
Sample input/outputs


*/

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
    int a, b;
    cin>>a>>b;
    
    int x = a - 2*b;
    if(x <= 0)
     cout<<"0"<<endl;
     else
     cout<<x<<endl;
     
     
	return 0;
}



















Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n , a , b;
    cin >> n >> a >> b;
    for(int i = a ; i <= b ; i++)
    {
        if(i % n == 0)
        {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d",&a,&b);
  c=a%b;
  while(c!=0)
    {
      a=b;
      b=c;
      c=a%b;
    }
  printf("%d\n",b);

  return 0;
}
  

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

int main(){
  int N; cin>>N;
  string ans="";
  while(N!=0){
    ans+=(N%2==0)?'0':'1';
    N=-N/2+(N<0&&N%2!=0?1:0);
  }
  reverse(ans.begin(),ans.end());
  if(ans.empty()) ans="0";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=str(input())
    if int(n)%sum([int(i) for i in n])==0:
        print('Yes')
    else:
        print('No')


resolve()

Measured memory_bytes: 38384
a = input()
l = map(int, raw_input().split())
c = 0
ll = []

for i in l:
	if i < 0:
		c += 1
		ll.append(i * -1)
	else:
		ll.append(i)

if c % 2 == 0:
	print sum(ll)
else:
	print sum(ll) - min(ll)*2

Measured memory_bytes: 11320
n = int(input())
ss = [sorted(input()) for i in range(n)]
ss.sort()

tmp = ss[0]
cnt = 0
ans = 0
for i in range(n):
    if tmp == ss[i]: cnt+=1
    else:
        tmp = ss[i]
        ans += cnt*(cnt-1)//2
        cnt=1
print(ans+cnt*(cnt-1)//2)

Measured memory_bytes: 24652
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    vector<ll>v;
    ll x,i,j,k,n,t;
    cin>>x>>k;
    if(k%2==0&&(k>=x*2&&k<=x*4))
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#define N 500000

struct BiT_Node{
  int key;
  struct BiT_Node *p;
  struct BiT_Node *left;
  struct BiT_Node *right;
};

typedef struct BiT_Node *Node;

Node root;

Node getMinimum(Node x){
  while(x->left != NULL) x = x->left;
  return x;
}

void insert (int v){
  Node y = NULL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct BiT_Node));
  z->key = v;
  z->left = NULL;
  z->right = NULL;
  y = NULL;
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  
  z->p = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

Node treeSuccessor(Node u){
  if(u->right != NULL)  return getMinimum(u->right);
  Node v = u->p;
  while(v != NULL && u == v->right ){
    u = v;
    v = v->p;
  }
  return v;
}

void in_walk(Node u){
  if(u != NULL){
    in_walk(u->left);
    printf(" %d",u->key);
    in_walk(u->right);
  }
}

void pre_walk(Node u){
  if(u == NULL) return;
  printf(" %d",u->key);
  if(u->left != NULL) pre_walk(u->left);
  if(u->right != NULL) pre_walk(u->right);
}

Node find(int key){
  Node u;
  u = root;
  while(u != NULL && key != u->key){
    if(key < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void delete(Node u){
  Node y;
  Node x;
  if(u->left == NULL || u->right == NULL) y = u;
  else y = treeSuccessor(u);
  if(y->left != NULL){
    x = y->left;
  }
  else x = y->right;

  if(x != NULL) x->p = y->p;
  if(y->p == NULL) root = x;
  else {
    if(y == y->p->left){
      y->p->left = x;
    }
    else y->p->right = x;
  }

  if(y != u) u->key = y->key;

  free(y);
}

int main()
{
  int n,i,tmp;
  char buf[20];
  scanf("%d",&n);
  for(i = 0 ; i < n; i++){
    scanf("%s",buf);
    if(buf[0] == 'i'){
      scanf("%d",&tmp);
      insert(tmp);
    }
    else if(buf[0] == 'f') {
      scanf("%d",&tmp);
      if(find(tmp) != NULL) printf("yes\n");
      else printf("no\n");
    }
    else if(buf[0] == 'd'){
      scanf("%d",&tmp);
      delete(find(tmp));
    }
    else if(buf[0] == 'p') {
      in_walk(root);
      printf("\n");
      pre_walk(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20480
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ll a[1000];
int main()
{
    ll n;
    sl(n);
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        sl(a[i]);
        if(i%2==1&&a[i]%2==1)
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3768
n,l=map(int,input().split())
motomoto=n*l-n+n*(n+1)//2
zettaisa=10**100
keep=0
for i in range(1,n+1):
  aji=motomoto-(l+i-1)
  sa=abs(motomoto-aji)
  if sa<=zettaisa:
    zettaisa=sa
    keep=aji
print(keep)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC005A();


#if 1
int main()
{
	AGC005A();
	fflush(stdout);
	return 0;
}
#endif

static void AGC005A()
{
	std::string orgs;
	std::cin >> orgs;

	int sCount = 0, eraseCount = 0;
	int len = orgs.length();
	for (int i = 0; i < len; i++) {
		if (orgs[i] == 'S') {
			sCount++;
		}
		else {
			if (sCount) {
				sCount--;
				eraseCount += 2;
			}
		}
	}
	printf("%d\n", len - eraseCount);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int N,K;
    int V[57];
    int Vsum=0;
    cin >> N >> K;
    REP(i,N){
        cin >> V[i];
        Vsum+=V[i];
    }
    
    int Ans=-INF;
    vector<int> G;
    REP(k,K+1){
        REP(i,N+1){
            REP(j,N+1){//左からi個、右からj個取る
                int num=0;
                if(i+j<(k+1)/2)continue;
                if(i+j>k)continue;
                G.clear();
                if(i+j>N){
                    REP(l,N){
                        G.push_back(V[l]);
                    }
                }else{
                REP(l,i){
                        G.push_back(V[l]);
                    }
                    REP(l,j){
                        G.push_back(V[N-1-l]);
                    }
                }
                REP(l,(G.size())){
                    num+=G[l];
                }
                sort(G.begin(),G.end());
                int b=k-i-j;
                REP(l,b){
                    num-=G[l];
                }
                Ans=max(Ans,num);
                //cout << i << " " << j << " " << num << endl;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

string res[6];

const char OFS = '1';
int main()
{
    res[0] = "abcde";
    res[1] = "fghij";
    res[2] = "klmno";
    res[3] = "pqrst";
    res[4] = "uvwxy";
    res[5] = "z.?! ";

    string s;
    while(getline(cin, s))
    {
        bool na = false;
        int l = s.size();
        if(l%2) na = true;
        s = s + "z";
        REP(l/2)
        {
            if(s[i * 2] >= '7' || s[i*2] == '0') na = true;
            if(s[i * 2 + 1] >= '6' || s[i*2] == '0') na = true;
        }

        if(na){ cout << "NA" << endl; continue;}
        
        int v, h;
        REP(l/2){
            v = (int)(s[i*2] - OFS);
            h = (int)(s[i*2 +1] - OFS);
            cout << res[v][h] ;
            //cout << res[(char)(s[i*2] - OFS)][(char)(s[i*2+1] - OFS)];
        
        }
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner  sc = new Scanner(System.in);
    long n , k ,i,t;
    n = sc.nextLong();
    k = sc.nextLong();
    i = n%k;
    t = Math.abs(k-i);
    if(i > t){
      i = t;
    }
    System.out.println(i);
  }
}


Measured memory_bytes: 21844
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), k = scanner.nextInt();
        int[] h = IntStream.range(0, n).map(i -> scanner.nextInt()).sorted().toArray();
        System.out.println(IntStream.range(k - 1, n).map(i -> h[i] - h[i - k + 1]).min().getAsInt());
    }
}

Measured memory_bytes: 61260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    if(s=="SUN")puts("7");
    else if(s=="SAT")puts("1");
    else if(s=="FRI")puts("2");
    else if(s=="THU")puts("3");
    else if(s=="WED")puts("4");
    else if(s=="TUE")puts("5");
    else if(s=="MON")puts("6");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N, K; cin >> N >> K;
  V h(N);
  rep(i, N) cin >> h[i];

  V dp(N);
  rep2(i, 1, N) dp[i] = INF;
  rep(i, N) rep(k, K) {
    int j = i+k+1;
    chmin(dp[j], dp[i] + abs(h[i] - h[j]));
  }

  int ans = dp[N-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
  int n,i,j,k,sum=0;
  scanf("%d",&n);
  int a[n+1];//+1しとく
  int b[n+1];
  int c[n];
  
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);}
  
    for(i=1;i<=n;i++){
      scanf("%d",&j);
      b[i]=j;
      sum+=j;}
  
  for(i=1;i<n;i++){
    scanf("%d",&c[i]);}
  
      for(i=1;i<n;i++){
      	if(a[i]==a[i+1]-1)//そしたらエラー出ない
          sum+=c[a[i]];//ここが鬼門
      }
  
	printf("%d\n",sum);
 
 
return 0;}

Measured memory_bytes: 128
#include <stdio.h>
int L[200000], R[200000], p[100000], q[100000];

int main(void){
    int N, M, Q;
    int i, j, k;
    int S[500][500];//1：スタート，2：ストップ
    for(i = 0; i < 500; i++){
        for(j = 0; j < 500; j++){
            S[i][j] = 0;
        }
    }
    scanf("%d%d%d", &N, &M, &Q);

    for(i = 0; i < M; i++){
        scanf("%d%d", &L[i], &R[i]);
        S[L[i] - 1][R[i] - 1]++;
    }
    for(i = 0; i < N; i++){
        for(j = 1; j < N; j++){
            S[i][j] += S[i][j-1];
        }
    }
    for(j = 0; j < N; j++){
        for(i = N - 2; i >= 0; i--){
            S[i][j] += S[i+1][j];
        }
    }    
    for(i = 0; i < Q; i++){
        scanf("%d%d", &p[i], &q[i]);
        printf("%d\n", S[p[i]-1][q[i]-1]);
    }
    // for(i = 0; i < N; i++){
    //     for(j = 0; j< N; j++){
    //         printf("%d ", S[i][j]);
    //     }
    //     printf("\n");
    // }
    

}

Measured memory_bytes: 5024
import numpy as np

num = np.array(list(map(int, input().split())))
num_1 = 0

if num[0] > num[1]:
  for i in range(0,num[0]) :
    num_1 = num_1 + num[1]*(10**i)
else:
  for i in range(0,num[1]) :
    num_1 = num_1 + num[0]*(10**i)
    
print(num_1)

Measured memory_bytes: 12488
#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 N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];

    vector<int> acs(N);
    acs[0] = 0;
    for(int i=1; i<N; i++) {
        if(S[i-1] == 'A' && S[i] == 'C') acs[i] = acs[i-1] + 1;
        else acs[i] = acs[i-1];
    }

    rep(i, Q) {
        cout << acs[r[i]-1] - acs[l[i]-1] << endl;
    }

    return 0;


}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
using namespace std;
struct UnionFindTree {
	//これはUnion-Find木の構造体です.

	//Parent[i] : i の親の番号　例）Parent[3] = 2 のとき、3 の親の番号は 2.
	vector<int>Parent;

	//最初は全てのノードが根であるとして配列Parentを初期化する.
	UnionFindTree(int N) : Parent(N) {
		for (int i = 0; i < N; i++) Parent.at(i) = i;
	}

	//ノードnodeが属する木の根の番号を再起関数により得る. root(node) = { node の木の根 }.
	int root(int node) {
		if (Parent.at(node) == node) return node;
		else return Parent.at(node) = root(Parent.at(node));
	}

	//Union-Find木の操作① xとyの木を併合させる. 但し、root(x) != root(y).
	//※Union-Find木は、併合はできるが、分割ができないことに注意.
	void unite(int x, int y) {
		int root_x = root(x); //root_x : xの木の根の番号
		int root_y = root(y); //root_y : yの木の根の番号
		//併合させる2つの木の根が異なる場合のみ、2つの木を併合させることができるので、
		//2つの木の根が同じ場合はそのままで返す.
		if (root_x == root_y) return;
		//2つの木の根が異なる場合は、x の木の根 root_x を、y の木の根 root_y につける.
		Parent.at(root_x) = root_y;	
	}

	//Union-Find木の操作② xとyの属する木が同じかどうかを調べる.
	//すなわち、xとyの属する木の根が同じかどうかを調べる.
	bool same(int x, int y) {
		int root_x = root(x);
		int root_y = root(y);
		return root_x == root_y;
	}
};

int main() {
	int N;
	cin >> N;
	UnionFindTree A(N);
	long long int Q; cin >> Q;
	long long com, x, y;
	for (int i = 0; i < Q; i++) {
		cin >> com >> x >> y;
		if (com == 0) {
			A.unite(x, y);
		}
		else {
			bool check = A.same(x, y);
			if (check) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
}


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

using namespace std;

int num_dig(int x) {
    int res = 0;
    while (x) {
        ++res;
        x /= 10;
    }
    return res;
}

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

    int N;
    cin >> N;
    int res = 0;
    for (int i = 1; i <= N; ++i) {
        res += (num_dig(i) % 2);
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Garden
 */

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

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (a - 1) * (b - 1));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
signed main(){
	string s;
	cin>>s;
	if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3])cout<<"No"<<endl;
	else if(s[0]==s[1] && s[2]==s[3])cout<<"Yes"<<endl;
	else if(s[0]==s[2] && s[1]==s[3])cout<<"Yes"<<endl;
	else if(s[0]==s[3] && s[2]==s[1])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from itertools import permutations
k=int(input())
A=[list(map(int,input().split())) for _ in range(k)]

for i in permutations(range(8)):
    if len(set([j+k for j,k in enumerate(i)]))!=8:continue
    if len(set([j-k for j,k in enumerate(i)]))!=8:continue
    flag=1
    for x,y in A:
        if i[x]!=y:flag=0
    if flag:
        for num in i:
            point=["."]*8
            point[num]="Q"
            print("".join(point))


Measured memory_bytes: 5648
#!/usr/bin/perl

my ($a) = map {$_ - 0} split(/\s+/o,<STDIN>);
my ($b) = map {$_ - 0} split(/\s+/o,<STDIN>);
my ($c) = map {$_ - 0} split(/\s+/o,<STDIN>);
my ($d) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $r = ( $a < $b ? $a : $b ) + ( $c < $d ? $c : $d );
print "$r\n";

exit(0);



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void chkmax(T &x, T y) {x = x > y ? x : y;}
template <typename T> void chkmin(T &x, T y) {x = x > y ? y : x;}
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); x *= f;
}
const int N = 1000010, Mod = 998244353;
int a[N], w[N], inv[N], val[N], sum[N];
void Init(int n) {
	int len = 0; inv[1] = 1;
	for (int i = 2; i <= n; i++) inv[i] = 1ll * (Mod - Mod / i) * inv[Mod % i] % Mod;
}
int main() {
	int n, m = 1e6; read(n), Init(m);
	for (int i = 1; i <= n; i++) read(a[i]), (val[a[i]] += a[i]) %= Mod;
	for (int i = 1; i <= m; i++) w[i] = inv[i];
	for (int i = 1; i <= m; i++)
		for (int j = i + i; j <= m; j += i)
			(w[j] += Mod - w[i]) %= Mod;
	for (int i = m; i; i--)
		for (int j = i; j <= m; j += i)
			(sum[i] += val[j]) %= Mod;
	int ans = 0;
	for (int i = 1; i <= m; i++) (ans += 1ll * w[i] * sum[i] % Mod * sum[i] % Mod) %= Mod;
	for (int i = 1; i <= n; i++) (ans += Mod - a[i]) %= Mod;
	cout << 1ll * ans * inv[2] % Mod << '\n';
	return 0;
}

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

int main()
{
  while(true){
    int x,y,s;
    cin>>x>>y>>s;

    if(x==0&&y==0&&s==0)
    break;

    int tmax =-1;

    for(int a=1;a<=s-1;a++){
      int ax=a*(100+x)/100;
      int ay=a*(100+y)/100;

      for(int b=1; b<=s-1; b++){
        int bx=b*(100+x)/100;
        int by=b*(100+y)/100;

        if(ax+bx==s){
          tmax=max(tmax,ay+by);
        }
        else if(ax+bx>s){
          break;
        }
      }
    }
    cout<<tmax<<endl;

  }
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

int main() {
    uint32_t K,N;
	cin >> N >> K;

	vector<uint32_t>Pi(N);
	for (uint32_t i = 0; i < N; ++i)
		cin >> Pi[i];

	sort(Pi.begin(), Pi.end());
	cout << accumulate(Pi.begin(), next(Pi.begin(), K), 0 )<< endl;

	return 0;
}



Measured memory_bytes: 3160
import copy
import numpy as np
N = int(input())
sequences = [int(input()) for _ in range(N)]
np_sequences = np.array(sequences)
max_index = np_sequences.argmax()
for i in range(N):
        if i != max_index:
            print(sequences[max_index])
        else:
            tmp = copy.copy(sequences)
            tmp.pop(i)
            tmp_set = set(tmp)
            print(max(tmp_set))

Measured memory_bytes: 30544
a, b = map(int, input().split())
coin = 0

if a == b:
    coin = a + b
else:
    if a > b:
        coin = a
        a -= 1
    elif b > a:
        coin = b
        b -= 1

    if a > b:
        coin += a
        a -= 1
    elif b > a:
        coin += b
        b -= 1
    else:
        coin += a

print(coin)

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

int main()
{
    long long x,res=0;
    cin>>x;
    if(x>=500)
    {
        res=(x/500)*1000;
        x=x%500;
    }
    res=res+(x/5)*5;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
A = list(map(int,input().split()))
wa = []
ans = 0

if A[0] > X:
  ans += A[0]-X
  A[0] = X

for i in range(N-1):
  wa.append(A[i]+A[i+1])

for j in range(N-2):
  if wa[j] > X:
    ans += wa[j]-X
    wa[j+1] -= wa[j]-X

if wa[N-2] > X:
  ans += wa[N-2]-X

print(ans)

Measured memory_bytes: 19972
K = input()
D = int(input())
lenK = len(K)
mod = 10**9+7
#dp[i][smaller][k]はi桁まで見たあまりkの物の数とする.ただしsmaller=0のときはまだK以下かわかってないとする. 
dp = [[[0]*D for i in range(2)] for _ in range(lenK + 1)]
dp[0][0][0] = 1
for i,c in enumerate(K):
    for less in range(2):
        lim = 9 if less else int(c)
        for r in range(D):
            for d in range(lim+1):
                dp[i+1][less or d < lim][(r+d)%D] += dp[i][less][r]
                dp[i+1][less or d < lim][(r+d)%D] %= mod
print((dp[-1][0][0] + dp[-1][1][0] - 1)%mod)

Measured memory_bytes: 62940
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 20
int n; char s[N]; ll ans=0;
void dfs(int k,ll all,ll now){
	if (k>=n){
		ans+=all+now; return;
	}
	dfs(k+1,all,now*10+s[k+1]-'0');
	dfs(k+1,all+now,s[k+1]-'0');
}
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	scanf("%s",s+1); n=strlen(s+1); dfs(1,0,s[1]-'0'); cout<<ans<<endl;
	return 0;
}
// sample data:
/*
125

9999999999

*/

// rest:
/*

*/

/*
If you find any bug in my code or solution, please tell me. Thanks so much.
email: 2411280037@qq.com
*/

Measured memory_bytes: 256
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main(){
  bool ans=true;
  string w; cin>>w;
  for(int i=97;i<=122;i++){
    int count=0;
    for(int j=0;j<w.length();j++){
      if((char)i==w[j]) count++;
    }
    if(count%2) ans=false;
  }

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

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

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

inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num<<3) + (num<<1) + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int h, w; fastin(h); fastin(w);
    int c[10][10];
    rep(i, 10){
        rep(j, 10) fastin(c[i][j]);
    }

    rep(k, 10){
        rep(i, 10){
            rep(j, 10) c[i][j] = std::min(c[i][j], c[i][k] + c[k][j]);
        }
    }

    int ans = 0;

    rep(i, h){
        rep(j, w){
            int a; fastin(a);
            if (a == -1 || a == 1) continue;
            else ans += c[a][1];
        }
    }

    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if (B >= A && D >= C) {
			System.out.println(A + C);
		} else if (B >= A && C >= D) {
			System.out.println(A + D);
		} else if (A >= B && D >= C) {
			System.out.println(B + C);
		} else if (A >= B && C >= D) {
			System.out.println(B + D);
		}
	}
}

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

#define MAX_BIT 60

uint64_t f(uint64_t x, const vector<uint64_t>& a){
    uint64_t sum = 0;
    for (auto& a_i : a){
        sum += a_i ^ x;
    }
    return sum;
}

int main() {
    uint64_t n, k;
    cin >> n >> k;
    vector<vector<int>> a_bit(n);
    vector<uint64_t> a(n);
    for(int i = 0; i < n; i++)
    {   
        a_bit[i].resize(MAX_BIT);
        cin >> a[i];

        for(int j = 0; j < MAX_BIT; j++)
            a_bit[i][j] = (a[i] & ((uint64_t)0x1 << j)) >> j;
    }

    uint64_t result[MAX_BIT] = { 0 };
    uint64_t aaa = 0;
    for(int i = MAX_BIT - 1; i >= 0; i--){
        if (((uint64_t)0x1 << i) <= (k - aaa)){
            int count_0 = 0;
            int count_1 = 0;
            for (const auto& a_i : a_bit){
                if (a_i[i] == 0){
                    count_0++;
                }else{
                    count_1++;
                }
            }
            if (count_0 > count_1) {
                result[i] = 1;
                aaa += (uint64_t)0x1 << i;
            }
        }
    }
    
    uint64_t sum = 0;
    for(int i = 0; i < MAX_BIT; i++){
        sum += result[i] << i;
    }

    cout << f(sum, a) << endl;
    return 0;
}

Measured memory_bytes: 28416