akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (b), _a = (a); i >= _a; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<"debug : "<<x<<endl
#define debug2(x,y) cout<<"debug : "<<x<<" | "<<y<<endl
#define debug3(x,y,z) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<endl
#define debug4(x,y,z,w) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<" | "<<w<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define M 1000000007          // 1e9+7
#define INF 10000000000       // 1e9
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
 
bool cus(pair<int,int> a, pair<int,int> b){
    if(a.ff<b.ff)
        return true;
    if(a.ff>b.ff)
        return false;
    return a.ss<b.ss;
}
 
ll gcd(ll a, ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void solve(){
   ll n, x, y;
   cin >> n;
   vii a(n);
   rep(i, n){
    cin >> x >> y;
    a[i] = make_pair(x, y);
   }

   ll mx = -1, mn = 1e18;
   rep(i, n){
    if(a[i].first + a[i].second > mx) mx = a[i].first + a[i].second;
    if(a[i].first + a[i].second < mn) mn = a[i].first + a[i].second; 
   }
   ll diff1 = mx - mn;

   mx = -1e12;
   mn = 1e18;
   rep(i, n){
    if(a[i].first - a[i].second > mx) mx = a[i].first - a[i].second;
    if(a[i].first - a[i].second < mn) mn = a[i].first - a[i].second; 
   }
   ll diff2 = mx - mn;   
   cout << max(diff1, diff2) << endl;
  }

int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    //ll t = 1;
    //cin>>t;
    //while(t--)
        solve();
 
    return 0;
}
  

Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=100000+10;
const int maxm=1000+10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const ll LINF=(1LL<<62);
const double PI=acos(-1.0);
#define mst(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for (int i=(a);i<b;i++)
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define lowbit(x) x&(-x)
#define X first
#define Y second
char s[10];
int a[10];
int main(){
#ifdef local
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    //ios::sync_with_stdio(false); cin.tie(0);
    scanf("%s",s);
    for (int i=0;i<4;i++) a[i]=s[i]-'0';
    for (int i=0;i<(1<<3);i++){
        int k=i,val=a[0];
        for (int j=0;j<3;j++){
            if (k&1) val-=a[j+1]; else
                val+=a[j+1];
            k>>=1;
        }
        if (val==7){
            k=i;
            printf("%d",a[0]);
            for (int j=0;j<3;j++){
                if (k&1) printf("-"); else printf("+");
                printf("%d",a[j+1]);
                k>>=1;
            }
            printf("=7\n");
            break;
        }
    }
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
	int N, K, tmp;
	cin >> N >> K;
	vector<double> vec(N);
	REP(i,0,N){
		cin >> tmp;
		if(tmp%2){
			vec[i]=tmp/2+1;
		}else{
			vec[i]=tmp/2+0.5;
		}
	}

	double sum=0, maxi=0;
	REP(i,0,K){
		sum+=vec[i];
		maxi=sum;
	}
	REP(i,1,N-K+1){
		sum-=vec[i-1];
		sum+=vec[i+K-1];
		maxi=max(maxi, sum);
	}
//	cout << maxi << endl;
	printf("%.7lf\n", maxi);
}


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

count = 0
for i in range(a, b + 1):
    c = 0
    n = str(i)
    for j in range(len(n)):
        if n[j] == n[-1-j]:
            c += 1
        
    if c == len(n):
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y,z;
  cin >> x >> y >> z;
  x-=z;
  pr(x/(y+z));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;



void solve()
{
    int n;
    cin >> n;
    int cnt = 0, f = 0;

    lop(i, 0, n)
    {
        int x, y;
        cin >> x >> y;
        if ( x != y ) cnt = 0;
        else cnt++;
        if ( cnt == 3 ) f = 1;

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

int32_t main()
{
    ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

    int test = 1;
    // cin >> test;
    while (test--)solve();


}





















Measured memory_bytes: 3648
#include <cstdio>
using namespace std;
const int N=200005;
char s[N];
int cnt;
long long ans;
int main()
{
	scanf("%s",s+1);
	for (int i=1;s[i];i++)
		if (s[i]=='B')
			cnt++;
		else
			ans+=cnt;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import numpy as np

def binstr(n):
    return np.array(list(map(int,list(bin(n)[2:].rjust(40,'0')))))

N,K = map(int,input().split())
A = list(map(int,input().split()))

AA = sum([binstr(i) for i in A])
X = 0
ans = 0
for i in range(40):
    if AA[i] > N-AA[i]:   # 0にした方がいい
        ans += AA[i]*(2**(39-i))
    else:                 # 1にした方がいい
        if X+2**(39-i) <= K:    # 1
            ans += (N-AA[i])*(2**(39-i))
            X += 2**(39-i)
        else:                  # 0
            ans += AA[i]*(2**(39-i))

print(ans)

Measured memory_bytes: 75424
fn input() -> i32 {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let mut integers = s.split_whitespace();
    let integer: i32 = integers.next().unwrap().parse().unwrap();
    integer
}

fn main() {
    let mut v = Vec::new();
    for i in 0..5 {
        v.push(input());
    }
    let k: i32 = input();

    let mut answer: bool = true;
    for i in 0..4 {
        for j in i..5 {
            let mut c = v[i] - v[j];
            if c < 0 {
                c *= (-1);
            }
            if c > k {
                answer = false;
            }
        }
    }

    if answer {
        println!("Yay!", );
    }
    else {
        println!(":(", );
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>

using ll = long long;

int main(){
    ll N, K;
    scanf("%lld %lld%*c", &N, &K);
    std::vector<ll> H(N);
    for(int i = 0; i < N; i++){
        scanf("%lld%*c", &H[i]);
    }

    std::sort(H.begin(), H.end());

    ll num_attack = 0;
    for(int i = N - K - 1; i >= 0; i--){
        num_attack += H[i];
    }

    std::cout << num_attack << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#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>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n+2);
  int mon=0;
  a[0]=0; a[n+1]=0;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    mon += abs(a[i]-a[i-1]);
  }
  mon += abs(a[n]);
  for(int i=1; i<=n; i++) {
    cout << mon-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int h[N], ma[N];
  rep(i, N) {
    cin >> h[i];
    ma[i] = 0;
  }
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    ma[a-1] = max(ma[a-1], h[b-1]);
    ma[b-1] = max(ma[b-1], h[a-1]);
  }
  int ans;
  rep(i, N) {
    if (h[i] > ma[i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PB push_back
void solve()
{
    string s;
  cin>>s;
  if (s[s.size()-1]=='s')
  {
    s+="es";
  }
  else
  {
    s+="s";
  }
  cout<<s;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(void) {
	// your code goes here
	int n,min=100000;
	cin >> n;
	for(int i=0;i<=n;i++){
		int count=0;
		int t=i;
		while(t>0) {
			count+=t%6;
			t=(t-t%6)/6;
		}
		t=n-i;
		while(t>0) {
			count+=t%9;
			t=(t-t%9)/9;
		}
		if(min>count) min=count;
	}
	cout << min << endl;
	return 0;
}


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

using namespace std;

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int ans = 0, z=0, o=0;
    for (int i = 0; i < s.size(); ++i){
        if (s[i] == '0')
            z++;
        if (s[i] == '1')
            o++;
    }
    cout << 2*min(z, o) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2*1e5+10,mod=1e9+7;;
int c[N],w[N];
int minn[N];
int numcol[N];
int cnt=0;
int n;
int fac[N],inv[N];
int poww(int x,int y)
{
	int sum=1ll;
	while(y)
	{
		if(y&1)sum=(sum*x)%mod;
		x=(x*x)%mod;
		y>>=1;
	}
	return sum;
}
void prec()
{
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=i*fac[i-1]%mod;
	inv[n]=poww(fac[n],mod-2);
	for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
int C(int x,int y)
{
	return ((fac[y]*inv[y-x])%mod*inv[x])%mod;
}
signed main()
{
	memset(minn,127,sizeof(minn));
	int x,y;
	scanf("%lld %lld %lld",&n,&x,&y);
	for(int i=1;i<=n;i++)	
	{
		scanf("%lld %lld",&c[i],&w[i]);
		minn[c[i]]=min(minn[c[i]],w[i]);
	}
	int fir_min=0,sec_min=0;
	for(int i=1;i<=n;i++)
	{
		if(minn[i]<minn[fir_min])
		{
			sec_min=fir_min;
			fir_min=i;
		}
		else if(minn[i]<minn[sec_min])sec_min=i;
	}
	for(int i=1;i<=n;i++)
	{
		if(w[i]+minn[c[i]]<=x)w[i]=minn[c[i]];
		if((c[i]==fir_min&&minn[sec_min]+w[i]<=y)||(c[i]!=fir_min&&minn[fir_min]+w[i]<=y))
		{
			numcol[c[i]]++;
			cnt++;
		}
	}
	prec();
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(numcol[i])
		{
			ans=(ans*C(numcol[i],cnt))%mod;
			cnt-=numcol[i];
		}
	}
	printf("%lld",ans);
	return 0;
}
/*
4 7 3
3 2
4 3
2 1
4 4
*/

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s, t = "CODEFESTIVAL2016";
	std::cin >> s;
	uint32 c = 0;
	rep(i, 0, s.length()) {
		if (s[i] != t[i])
			++c;
	}
	std::cout << c<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define __ ios::sync_with_stdio(false),cin.tie(0)
/*
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
*/
using namespace std;
void solve(){
int n=0;
scanf("%d", &n);
int one=n%10;
if(one==2 || one==4 || one==5 || one==7 || one==9)
    printf("hon");
if(one==0 || one==1 || one==6 || one==8)
    printf("pon");
if(one==3) printf("bon");
}
int main(){
//freopen("","",stdin);
__;
int T=1;
//cin>>T;
while(T--){
solve();
}
}


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

using namespace std;
using ll = long long;
constexpr int INF = 1000000000;
constexpr ll MOD = 998244353;


struct TakaTree {
	int al, ar;
	TakaTree *left, *right;
	int rmax;
	TakaTree(int i, int j) : al(i), ar(j), left(nullptr), right(nullptr),
	rmax(-INF) {
		if (i != j) {
			int k = (i + j) / 2;
			left = new TakaTree(i, k);
			right = new TakaTree(k + 1, j);
		}
	}
	int getMax(int i, int j) {
		if (j < al || ar < i) return -INF;
		else if (i <= al && ar <= j) return rmax;
		else return max(left->getMax(i, j), right->getMax(i, j));
	}
	void setElem(int i, int v) {
		if (i < al || ar < i) return;
		else if (al == ar) rmax = v;
		else {
			left->setElem(i, v);
			right->setElem(i, v);
			rmax = max(left->rmax, right->rmax);
		}
	}
};

int main() {
	int n; scanf("%d", &n);
	vector<int> x(n), d(n);
	set<int> edpts;
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &x[i], &d[i]);
		edpts.insert(x[i]);
		edpts.insert(x[i] + d[i] - 1);
	}
	map<int, int> comp;
	for (int x : edpts) {
		int ita = comp.size();
		comp[x] = ita;
	}
	int ect = comp.size();
	vector<int> realst(n), realed(n);
	TakaTree cfing(0, ect - 1);
	for (int i = 0; i < n; ++i) {
		realst[i] = comp[x[i]];
		realed[i] = comp[x[i] + d[i] - 1];
		cfing.setElem(realst[i], realed[i]);
//		printf("comp %d is %d %d\n", i, realst[i], realed[i]);
	}
	vector<ll> ans(ect + 1, 1);
	for (int x = ect - 1; x >= 0; --x) {
		ans[x] = ans[x + 1];
		if (cfing.getMax(x, x) > -INF) {
			int startEnd = cfing.getMax(x, x);
			int reachEnd = cfing.getMax(x, startEnd);
//			printf("int start %d really ends %d\n", x, reachEnd);
			ans[x] = (ans[x] + ans[reachEnd + 1]) % MOD;
			cfing.setElem(x, reachEnd);
		}
	}
	printf("%lld\n", ans[0]);
	return 0;
}


Measured memory_bytes: 81408
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 2.65 + c[j] * 14;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3708
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a, b = na()

print((b - a) * (b - a + 1) // 2 - b)

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

a.sort()


alice = 0
bob = 0
flg = 0

while(len(a)>0):
    if flg == 0:
        alice += a.pop()
    elif flg ==1:
        bob += a.pop()
    flg = not(flg)

print(alice-bob)

Measured memory_bytes: 3060
//Created by Aminul on 8/2/2020.

import org.omg.CORBA.WrongTransaction;

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt(), k = in.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }

        pw.println(binarySearch(n, k, arr));

        pw.close();
    }

    static boolean check(int n, int k, int[] arr, int lim) {
        long cnt = 0;
        for (int i : arr) {
            if(i > lim) cnt += (i - 1) / lim;
        }
        return cnt <= k;
    }

    static int binarySearch(int n, int k, int[] arr) {
        int l = 1, r = (int) 1e9 + 5, res = r;
        while (l <= r) {
            int mid = l + ((r - l) >> 1);
            if (check(n, k, arr, mid)) {
                res = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        return res;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;
    ll mx=-1,g=INF;

    int n,k;
    cin>>n>>k;
    vector<int>a(n);

    rep(i,n){cin>>a[i];chmax(mx,a[i]);};

    g = gcd(a[0],a[1]);
    rep(i,n)g=gcd(g,a[i]);

    //cout <<fixed<<setprecision(16)<< << endl;

    if(k <= mx && k%g==0)cout << "POSSIBLE" <<endl;
    else cout << "IMPOSSIBLE" <<endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
typedef long long ll;
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 1e15
const int N=5e5+5;

int main()
{
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++)
		cout<<"x";
}




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

int main(){
  int n;
  cin >> n;
  if(n%2 != 0){
    cout << "No\n";
    return 0;
  }
  char s1[50],s2;
  for(int i=0; i!=n/2; i++){
    cin >> s1[i];
  }
  for(int i=0; i!=n/2; i++){
    cin >> s2;
    if(s1[i] != s2){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	
	cout << (t / a) * b << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(void) {
  int N, K, A;
  cin >> N >> K;
  vector<int> d(K);
  vector<bool> has(N, false);

  for(int i = 0; i< K; i++){
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> A;
      has[A - 1] = true;
    }
  }

  int res = 0;
  for (int i = 0; i < has.size(); i++) {
    if(has[i] == false){
      res++;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

vector<char> dislike;

bool ok(ll n)
{
        string n_str = to_string(n);
        bool flg = true;
        rep(i, 0, len(dislike)) {
                if (isin(dislike[i], n_str)) flg = false;
        }
        return flg;
}

int main()
{
        ll N, K;
        cin >> N >> K;
        rep(i, 0, K) {
                char x;
                cin >> x;
                dislike.push_back(x);
        }
        ll ans = -inf;
        rep(i, 1, 1000000) {
                if (ok(i) and i >= N) {
                        ans = i;
                        break;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

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

#define M 333

int toint[M];
int used[10];
int firstflg[M];

int getvalue(string& str){
	int ret = 0;
	rep(i,str.size()){
		ret *= 10;
		ret += toint[str[i]];
	}
	return ret;
}

int wariate(vector<char>& mozi,vector<int>& time,vector<string>& input, int depth, int prevtime){
	if(depth==mozi.size()){
		int sum = 0;
		rep(i,input.size()-1){
			sum += getvalue(input[i]);
		}
		if(sum==getvalue(input[input.size()-1])){
			return 1;
		}
		return 0;
	}
	
	
	if(prevtime != time[depth]){
		int val = 0;
		rep(i,input.size()-1){
			val += getvalue(input[i]);
		}
		int mod = 1;
		rep(i,time[depth])mod*=10;
		/*
		rep(i,mozi.size()){
			printf("(%c->%d) ",mozi[i],toint[mozi[i]]);
		}*/
		
		int val2 = getvalue(input[input.size()-1]);
		if(val%mod != val2%mod){
			//printf("$$ 0 $$ (%d, %d) m(%d)\n",val%mod, val2%mod, mod);
			return 0;	
		}
		//printf("%% 1 %% (%d, %d) m(%d)\n",val%mod, val2%mod, mod);
	}
	int ans = 0;
	rep(i,10){
		if(i==0){
			if(firstflg[mozi[depth]]==1)continue;
		}
		if(used[i]==0){
			toint[mozi[depth]]=i;
			used[i]=1;
			ans += wariate(mozi, time, input, depth+1, time[depth]);
			used[i]=0;
		}
	}
	
	return ans;
}

int main(){
	
	A:;
	rep(i,M)toint[i]=firstflg[i]=0;
	rep(i,10)used[i]=0;
	
	int n;
	cin>>n;
	if(n==0)return 0;
	map<char,int> has;
	vector<char> mozi;
	vector<int> time;
	vector<string> input;
	rep(i,n){
		string str;
		cin>>str;
		input.push_back(str);
		if(str.size()!=1)firstflg[str[0]]=1;
	}
	
	int lenmax = 10;
	rep(i,lenmax){
		rep(j,n){
			if(i>=input[j].size())continue;
			char c = input[j][input[j].size()-i-1];
			if(has[c]==0){
				mozi.push_back(c);
				time.push_back(i);
			}
			has[c]=1;
		}
	}
	/*
	rep(i,mozi.size()){
		printf("(%c,%d) ",mozi[i],time[i]);
	}puts("");
	*/
	
	int ans = wariate(mozi,time,input, 0, 0);
	printf("%d\n",ans);
	goto A;
}

/*
3
SEND
MORE
MONEY
0

*/

Measured memory_bytes: 1236
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(n <=  k) {
          System.out.println(0);
          return ;
        }
        List<Integer> h = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            h.add(sc.nextInt());
        }
        h.sort(Collections.reverseOrder());
        long sum = 0;
        for(int i = k; i < n; i ++) {
            sum += h.get(i);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 91336
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();

		if (b % a == 0) {
			System.out.print(a + b);
		} else {
			System.out.print(b - a);
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000000000000
struct edge{int from,to,cost;};
int n,m,d[110];
edge es[9910];
bool NEGATIVE_CYCLE;
void bell(int s){
	fill(d,d+n,INF);
	d[s]=0;
	for(int i=0;i<=n;i++){
		bool update=false;
		for(edge e:es){
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(i==n&&update)NEGATIVE_CYCLE=1;
	}
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		es[i]={a,b,c};
	}
	rep(i,n){
		bell(i);
		if(NEGATIVE_CYCLE){
			puts("NEGATIVE CYCLE");
			return 0;
		}
	}
	rep(i,n){
		bell(i);
		rep(j,n){
			if(d[j]==INF)cout<<"INF";
			else cout<<d[j];
			if(j!=n-1)cout<<" ";
			else cout<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cout<<fixed;
//    cout<<setprecision(10);

    string a,b;
    cin>>a>>b;
    int x,y;
    map<string,int>mp;
    cin>>x;
    cin>>y;
    mp[a]=x,mp[b]=y;

    string st;
    cin>>st;
    mp[st]--;
    cout<<mp[a]<<' '<<mp[b]<<endl;
    return 0;
}


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

/*
3つの変数から2つが提示され、どちらかに+1、どちらかに-1をする
途中で負にならずにN回(<=1e5)のゲームを終わらせる
ゲームを通してA+B+Cは保存される
A,B,Cが1e5を超えても意味はない(超えた場合はどのように選んでも足りなくならない)ので考える必要はない
dp[N][A][B][C]だと1e5^4で1e20

ダメなのは{X, Y} = {0, 0}で回ってきたパターン
A B 1 1
B C 0 0 みたいな
つぎの組が今と異なり、かつ今の組が両方1でのこりの変数が0のときに、次に使われる変数の方を+1する？
*/

void apply(int *a, int *b)
{
	(*a)++;
	(*b)--;
}

void apply2(int *a, int *b, string s)
{
	(*a)++;
	(*b)--;
	cout << s << endl;
}

int	main(void)
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	int A, B, C;
	A = a;
	B = b;
	C = c;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++)
	{
		if (s[i] == "AB")
		{
			if (!A && !B)
			{
				cout << "No" << endl;
				return (0);
			}
			if (A > B) apply(&B, &A);
			else if (B > A) apply(&A, &B);
			else
			{
				if (i != n - 1 && s[i + 1] == "BC") apply(&B, &A);
				else if (i != n - 1 && s[i + 1] == "AC") apply(&A, &B);
				else apply(&B, &A);
			}
		}
		if (s[i] == "BC")
		{
			if (!B && !C)
			{
				cout << "No" << endl;
				return (0);
			}
			if (B > C) apply(&C, &B);
			else if (C > B) apply(&B, &C);
			else
			{
				if (i != n - 1 && s[i + 1] == "AC") apply(&C, &B);
				else if (i != n - 1 && s[i + 1] == "AB") apply(&B, &C);
				else apply(&C, &B);
			}
		}
		if (s[i] == "AC")
		{
			if (!A && !C)
			{
				cout << "No" << endl;
				return (0);
			}
			if (A > C) apply(&C, &A);
			else if (C > A) apply(&A, &C);
			else
			{
				if (i != n - 1 && s[i + 1] == "BC") apply(&C, &A);
				else if (i != n - 1 && s[i + 1] == "AB") apply(&A, &C);
				else apply(&C, &A);
			}
		}
	}
	cout << "Yes" << endl;
	A = a;
	B = b;
	C = c;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == "AB")
		{
			if (A > B) apply2(&B, &A, "B");
			else if (B > A) apply2(&A, &B, "A");
			else
			{
				if (i != n - 1 && s[i + 1] == "BC") apply2(&B, &A, "B");
				else if (i != n - 1 && s[i + 1] == "AC") apply2(&A, &B, "A");
				else apply2(&B, &A, "B");
			}
		}
		if (s[i] == "BC")
		{
			if (B > C) apply2(&C, &B, "C");
			else if (C > B) apply2(&B, &C, "B");
			else
			{
				if (i != n - 1 && s[i + 1] == "AC") apply2(&C, &B, "C");
				else if (i != n - 1 && s[i + 1] == "AB") apply2(&B, &C, "B");
				else apply2(&C, &B, "C");
			}
		}
		if (s[i] == "AC")
		{
			if (A > C) apply2(&C, &A, "C");
			else if (C > A) apply2(&A, &C, "A");
			else
			{
				if (i != n - 1 && s[i + 1] == "BC") apply2(&C, &A, "C");
				else if (i != n - 1 && s[i + 1] == "AB") apply2(&A, &C, "A");
				else apply2(&C, &A, "C");
			}
		}
	}
	return (0);
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const i64 INF = 1LL << 60;

template<typename T> class Matrix {
	vector<vector<T> > data;
public:
	Matrix(int size) {
		data.resize(size);
		for (int i = 0; i < size; i++) data[i].resize(size);
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				if (i == j) data[i][j] = 0;
				else data[i][j] = INF;
			}
		}
	}
	
	inline vector<T> operator[](int index) const { return data[index]; }
	inline vector<T>& operator[](int index) { return data[index]; }
	
	size_t size() {
		return data.size();
	}
};
template<typename T> void warshall_floyd(Matrix<T> &graph) {
	for (int k = 0; k < graph.size(); k++) {
		for (int i = 0; i < graph.size(); i++) {
			for (int j = 0; j < graph.size(); j++) {
				if (graph[i][k] != INF && graph[k][j] != INF) {
					graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
				}
			}
		}
	}
}

int main(void) {
	int v, e;
	cin >> v >> e;
	Matrix<i64> g(v);
	for (int i = 0; i < e; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		g[s][t] = d;
	}
	warshall_floyd(g);
	for (int i = 0; i < v; i++) {
		if (g[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for (int i = 0; i < v; i++) {
		for (int j = 0; j < v; j++) {
			if (g[i][j] < INF) cout << g[i][j];
			else cout << "INF";
			cout << " \n"[j == v - 1];
		}
	}
}


Measured memory_bytes: 3188
#!/usr/bin/env python
# coding: utf-8

# In[16]:


N,A,B = map(int, input().split())


# In[27]:


if N < 2:
    if A == B:
        print(1)
    else:
        print(0)
elif A <= B:
    ans = range((A+B) + A*(N-2), (A+B) + B*(N-2) + 1)
    print(len(ans))
else:
    print(0)


# In[ ]:






Measured memory_bytes: 9140
N = int(input())

if 400<=N<=599:
    print('8')
elif 600<=N<=799:
    print('7')
elif 800<=N<=999:
    print('6')
elif 1000<=N<=1199:
    print('5')
elif 1200<=N<=1399:
    print('4')
elif 1400<=N<=1599:
    print('3')
elif 1600<=N<=1799:
    print('2')
elif 1800<=N<=1999:
    print('1')


Measured memory_bytes: 9172
program main;
uses math;
var i, n : longint;
    m : array [1..100000] of qword;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;
 
begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p > 1e18 / m[i] then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.

Measured memory_bytes: 1368
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    rep(i, k) {
        bool flag = true;  // 全ての電球の強さがnならtrue
        rep(i, n) {
            if(a[i] < n) {
                flag = false;
            }
        }
        if(flag) {
            break;
        }
        vl b(n+1);  // b[i] : 座標iを照らす電球の個数
        rep(i, n) {
            b[max(0LL, i - a[i])]++;
            b[min(n, i + a[i] + 1)]--;
        }
        rep(i, n) {
            b[i+1] += b[i]; 
        }
        rep(i, n) {
            a[i] = b[i];
        }
    }

    rep(i, n) {
        cout << a[i];
        if(i < n-1) {
            cout << " ";
        }
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 6404
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    l = len(s)
    win_first = False

    if s[0] == s[-1]:
        if l % 2 == 0:
            win_first = True
    else:
        if l % 2 == 1:
            win_first = True

    if win_first:
        print("First")
    else:
        print("Second")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62188
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] arr = new int[N];
        double sum = 0;
        for(int i=0;i<N;i++)
        {
            arr[i] = scanner.nextInt();
            sum += arr[i];
        }
        Arrays.sort(arr);
        boolean answer = false;
        int count = 0;
        for(int i=N-1;i>=0;i--)
        {
            if(arr[i] >= sum/(4*M))
                count++;
            if(count == M)
            {
                answer = true;
                break;
            }
        }
        if(answer)
            System.out.println("Yes");
        else
            System.out.println("No");
//        System.out.println(Arrays.toString(arr));
//        if(arr[N-M] >= sum/(4*M))
//            System.out.println("YES");
//        else
//            System.out.println("NO");
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int a=read(),b=read();
if (a+b==15) puts("+");
else if (a*b==15) puts("*");
else puts("x");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int a, b, m; cin >> a >> b >> m;
  vector<int> A(a), B(b);
  for(int i = 0; i < a; i++) cin >> A[i];
  for(int i = 0; i < b; i++) cin >> B[i];
  int ans = 1e6;
  for(int i = 0; i < m; i++){
    int x, y, c; cin >> x >> y >> c;
    ans = min(ans, A[x-1]+B[y-1] - c);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  ans = min(ans, A[0]+B[0]);
  cout << ans << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 1024
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long n = read.to!long;
	
	R[] rs;
	foreach(i; 0 .. n){
		string s = read;
		long p = read.to!long;
		rs ~= new R(i + 1, s, p);
	}
	
	rs.sort!"(a.s==b.s)?(a.p>b.p):(a.s<b.s)"();
	
	foreach(r; rs) r.id.writeln;
	
}

class R{
	long id;
	string s;
	long p;
	this(long id, string s, long p){
		this.id = id;
		this.s = s;
		this.p = p;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;

struct edge {
    int from, to, cost;
};

struct UniTree {
    int *par, *rank;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};


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

edge G[2000];

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    rep(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        G[i] = {s, t, d};
    }

    int d[1000];
    fill(d, d + V, INF);
    d[r] = 0;
    bool loop = false;
    rep(i, V) {
        bool update = false;
        rep(j, E) {
            edge e = G[j];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if(i == V - 1) {
                    loop = true;
                }
                update = true;
            }
        }
        if(loop) break;
        if(!update) break;
    }

    if(loop) {
        cout << "NEGATIVE CYCLE" << endl;
    }else {
        rep(i, V) {
            if(d[i] == INF) cout << "INF" << endl;
            else cout << d[i] << endl;
        }
    }
}



Measured memory_bytes: 3124
n, m = map(int, input().split())
to = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
    

def dfs(v, n, visited):
    #print(visited)
    all_visited = True
    for i in visited:
        if not i:
            all_visited = False
            break
    if all_visited:
        return(1)
    
    ret = 0
    for i in range(1, n):
        #print(ret)
        if to[i].count(v) == 0:
            continue
        if visited[i]:
            continue
        visited[i] = True
        ret += dfs(i, n, visited)
        visited[i] = False
    return(ret)

visited = [False for _ in range(n)]
visited[0] = True
print(dfs(0, n ,visited))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  long long int tim;
  tim=0;

  int N;
  cin>>N;
 
  vector<long long int>prob(N,0);
  long long int i;
  for(i=0;i<N;i++){
      cin>>prob[i];
  }

  long long int M,j;
  cin>>M;

   vector<long long int>drink(M,0);
    vector<long long int>num(M,0);
   for(j=0;j<M;j++){
      cin>>num[j];
      cin>>drink[j];
  }

  long long int k,l;
  for(l=0;l<M;l++){
    for(k=0;k<N;k++){
      if(k==(num[l]-1)){
          
          tim+=drink[l];
      }else{
          
           tim+=prob[k];
      }
    }
      cout<<tim<<endl;
      tim=0;
      k=0;
  }
    
    return 0;
}

Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$t = [0];
$x = [0];
$y = [0];
for ($i = 0; $i < $n; $i++) {
    list($t[$i + 1], $x[$i + 1], $y[$i + 1]) = explode(' ', fgets(STDIN));
}
$can = true;
for ($i = 0; $i < $n; $i++) {
    $dt = $t[$i + 1] - $t[$i];
    $dist = abs($x[$i + 1] - $x[$i]) + abs($y[$i + 1] - $y[$i]);
    if ($dt < $dist) {
        $can = false;
    }
    if ($dist % 2 !== $dt % 2) {
        $can = false;
    }
}
echo $can ? 'Yes' : 'No';
?>

Measured memory_bytes: 42580
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

enum struct Type
{
	ROOT,
	INTERNAL,
	LEAF
};

struct OwnNode
{
	int id;
	int parent;
	int depth;
	Type type;
	vector<int> children;
};

OwnNode tree[100001];
bool isChild[100001];
const string typeStr[] = { "root","internal node","leaf" };

void TrackTree(int parentid,int id, int depth)
{
	tree[id].parent = parentid;
	tree[id].depth = depth;
	for (int i = 0; i != tree[id].children.size(); i++)
	{
		TrackTree(id,tree[id].children[i], depth + 1);
	}
}

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

	for (int i = 0; i < n; i++)
	{
		int id, cn;
		scanf("%d %d", &id, &cn);

		tree[id].id = id;
		tree[id].depth = 0;
		tree[id].parent = -1;

		for (int j = 0; j < cn; j++)
		{
			int cid;
			scanf("%d", &cid);
			tree[id].children.push_back(cid);
			isChild[cid] = true;
		}
	}

	int rootID = -1;
	for (int i = 0; i < n; i++)
	{
		if (!isChild[i])
		{
			rootID = i;
			break;
		}
	}

	TrackTree(-1,rootID, 0);

	for (int i = 0; i < n; i++)
	{
		if (tree[i].parent == -1)
		{
			tree[i].type = Type::ROOT;
		}
		else if (tree[i].children.size() == 0)
		{
			tree[i].type = Type::LEAF;
		}
		else
		{
			tree[i].type = Type::INTERNAL;
		}
	}

	for (int i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, depth = %d, %s, ", tree[i].id, tree[i].parent, tree[i].depth, typeStr[(int)tree[i].type].c_str());
		printf("[");
		if (tree[i].children.size() != 0)
		{
			printf("%d", tree[i].children[0]);
			for (int j = 1; j != tree[i].children.size(); j++)
			{
				printf(", %d", tree[i].children[j]);
			}
		}
		printf("]\n");
	}

	return 0;
}


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

const int MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    long long N, M;
    long long s[10], c[10];
    long long jikkou;
    long long answer = 0;
    long long error = 0;
    long long saikoui_ni_ichi = 1;
    cin >> N;
    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> s[i];
        cin >> c[i];
    }

    //kokomade nyuryoku

    //ichiketame = 0 ha dame(1)
    if(N > 1){
        for(int i = 0; i < M; i++){
        if(s[i] == 1){
            if(c[i] == 0){
                error = 1;}
            }
        }
    }

    //onaji kurai ni betuno kazu ha dame(2)
    for(int i = 0; i < M; i++){
        for(int j = i + 1; j < M; j++){
            if(s[i] == s[j]){
                if(c[i] != c[j]){
                    error = 1;
                }
            }
        }
    }

    for(int i = 0; i < M; i++){
        jikkou = 1;

        //chofuku no dainyu wo sakeru
        for(int j = i + 1; j < M; j++){
            if(s[i] == s[j] && c[i] == c[j]){
                jikkou = 0;
            }
        }

        //chofuku no dainyu de nainara answer ni tasu
        if(jikkou == 1){
            answer = answer + c[i] * modpow(10, N - s[i], MOD);
        }
    }

    for(int i = 0; i < M; i++){
        if(s[i] == 1){
            saikoui_ni_ichi = 0;
        }
    }
    if(saikoui_ni_ichi == 1 && N!= 1){
        answer = answer + modpow(10, N - 1, MOD);
    }

    //dame(1) ka dame(2) ni hikkakattetara -1
    if(error == 1){
        answer = -1;
    }

    cout << answer << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504