akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    int n;
  cin>>n;
  int k=n%10;
  if(k==2||k==4||k==5||k==7||k==9)
    cout<<"hon\n";
  else if(k==0||k==1||k==6||k==8)
    cout<<"pon\n";
  else
    cout<<"bon\n";
    return 0;
}

Measured memory_bytes: 3604
month = lambda x: 1 <= x <= 12

S = input()
a,b = int(S[:2]), int(S[2:])

if month(a) and month(b):
    print('AMBIGUOUS')
elif month(a):
    print('MMYY')
elif month(b):
    print('YYMM')
else:
    print('NA')

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;;
    return 0;
}


Measured memory_bytes: 256
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    fr(i,n) cin >> a[i];

    int c = 1;
    int l = a[0];
    int d = 0;
    for (int i = 1; i < n; ++i) {
        if (d == 0) {
            if (a[i] > l) {
                d = 1;
            } else if (a[i] < l) {
                d = -1;
            }
        } else if (d > 0) {
            if (a[i] < l) {
                d = 0;
                ++c;
            }
        } else {
            if (a[i] > l) {
                d = 0;
                ++c;
            }
        }
        l = a[i];
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
  int D, G, p[11], c[11];
  cin >> D >> G;
  for(int i=0; i<D; ++i){
    cin >> p[i] >> c[i]; 
  }
  
  int ans= 1e9;
  for(int mask=0; mask< (1<<D); ++mask){
    int s=0, num=0, rest_max=-1;
    for(int i=0; i<D; ++i){
      if(mask>>i &1){//1ってのが0001みたいなこと。&はアンド演算子。maskと1とを比較して、同じなら1．違うなら0を返す。
        s+= p[i]*100*(i+1)+c[i]; 
        num+= p[i];
      }
      else{
        rest_max= i;
      }
    }
    if(s<G){
      int s1= 100*(rest_max+1);
      int need= (G-s+s1-1)/s1;
      if(need>= p[rest_max]) continue;
      num+= need;     
    }
    ans=min(ans,num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

Adj = [ [] for _ in range(n) ]
V = []

for i in range(n):
    V = list(map(int, input().split()))
    for i in range(V[1]):
        Adj[V[0]-1].append(V[2+i])

G = [ [0]*n for _ in range(n) ]

for i in range(n):
    for j in Adj[i]:
        G[i][j-1] = 1

    print(*G[i])



Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <unordered_set>

#define NMAX 100001
#define MOD 1000000007
#define INF 2000000000

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

typedef unsigned long long ull;

using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i < 10; i++)
		for(int j = 1; j < 10; j++)
			if (i * j == n)
			{
				cout << "Yes\n";
				exit(0);
			}

	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#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 H, A;
    cin >> H >> A;

    cout << (H + A - 1) / A << endl;
}

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

using LL = long long;

int main() {
  LL N, M;
  cin >> N >> M;
  vector<LL> A(N);
  for(auto& i: A) cin >> i;

  sort(begin(A), end(A));
  vector<LL> S = {0};
  for(auto i: A) S.emplace_back(S.back() + i);

  auto sum = [&](auto l, auto r) {return max(0ll, S[r + 1] - S[l]);};

  auto score = [&](auto x) {
    LL s = 0, m = 0;
    for(LL i = N - 1; 0 <= i; --i) {
      LL n = lower_bound(begin(A), end(A), x - A[i]) - begin(A);
      if(i < n) continue;
      m += 2 * (i - n) + 1;
      s += 2 * sum(n, i - 1) + 2 * (i - n) * A[i] + 2 * A[i];
    }
    m -= M;
    return s - m * x;
  };

  auto ok = [&](auto x) {
    LL m = 0;
    for(LL i = 0; i < N; ++i) {
      LL n = lower_bound(begin(A), end(A), x - A[i]) - begin(A);
      if(n <= i) m += 2 * (i - n) + 1;
    }
    return M <= m;
  };

  LL l = 0, h = 1e18;
  while(h - l != 1) {
    auto m = (l + h) / 2;
    if(ok(m)) l = m;
    else      h = m;
  }
  cout << score(l) << endl;
}


Measured memory_bytes: 2168
from math import gcd

N = int(input())
num_lis = list(map(int, input().split()))
c1 = True
c2 = True

def osa_k(max_num):
  lis = [i for i in range(max_num+1)]
  p = 2
  while p**2 <= max_num:
    if lis[p] == p:
      for q in range(2*p, max_num+1, p):
        if lis[q] == q:
          lis[q] = p
    p += 1
  return lis

hoge = 0
for i in num_lis:
  hoge = gcd(hoge, i)
if hoge > 1:
  print("not coprime")
  exit()

d_lis = osa_k(max(num_lis))
tmp = set()
for i in num_lis:
  num = i
  new_tmp = set()
  while num > 1:
    d = d_lis[num]
    new_tmp.add(d)
    num //= d
  for j in new_tmp:
    if j in tmp:
      print("setwise coprime")
      exit()
    else:
      tmp.add(j)
print("pairwise coprime")


Measured memory_bytes: 132784
#include <stdio.h>

int main() {

  int a, b, c, d;

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

  if ( c < a ) {
    d = c;
    c = a;
    a = d;
  }
  if ( c < b ) {
    d = c;
    c = b;
    b = d;
  }
  if ( a > b ) {
    d = a;
    a = b;
    b = d;
  }
    
  printf("%d %d %d\n", a, b, c);
        
}

Measured memory_bytes: 1740
//099 B - Stone Monument 2018/06/10

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

int main(){
	vector<int> h(1000,0);
	h[0]=0; h[1]=1;
	for(int i=2;i<1000;++i) h[i]=h[i-1]+i;
	int a , b , j;
	cin >> a >> b;
	for(j=1;j<999;++j){
		if(h[j]-a==h[j+1]-b) break;
	}
	cout << h[j]-a << endl;
}

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

#define lli long long int

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

    float ans = 0.0;
    for(int i = 0; i < n; i++)
    {
        ans += (1/(float)a[i]);
    }

    cout << (1/ans);



    return 0;
}


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

int main(){
  int a, b; cin>>a >>b;
  if(a<b){
    for(int i=0;i<b;i++)cout<<a;
    cout<<endl;
  }else{
    for(int i=0;i<a;i++)cout<<b;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j, k;
	int n, m, l;
	int a[100][100]={};
	int b[100][100]={};
	long long int c[100][100]={};
	
	scanf("%d%d%d", &n, &m, &l);
	
	for(i=0; i<n; i++) {
		for(k=0; k<m; k++)
			scanf("%d", &a[i][k]);
	}
	for(k=0; k<m; k++) {
		for(j=0; j<l; j++)
			scanf("%d", &b[k][j]);
	}
	
	for(i=0; i<n; i++) {
		for(j=0; j<l; j++) {
			for(k=0; k<m; k++)
				c[i][j]+=a[i][k]*b[k][j];
		}
	}
	
	for(i=0; i<n; i++) {
		for(j=0; j<l; j++) {
			printf("%lld", c[i][j]);
			if(j!=l-1) putchar(' ');
		}
		putchar('\n');
	}
	
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    int x,y,z,n;
    cin>>a>>b>>c;
    x=a+b;
    y=a+c;
    z=b+c;
    n=min(x,y);
    cout<<min(n,z);


    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int fa[100005];
int weight[100005];
int root,sum;
void findroot(int x)
{
    sum=0;
    for (root=x;fa[root]!=-1;root=fa[root])
    {
        sum+=weight[root];
    }
    int temp;
    int t_sum=sum;
    for (;fa[x]!=-1;)
    {
        temp=fa[x];
        fa[x]=root;
        t_sum-=weight[x];
        weight[x]+=t_sum;
        x=temp;
    }
}
bool u(int l,int r,int x)
{
    findroot(l);
    int root1=root;
    int sum1=sum;
    findroot(r);
    int root2=root;
    int sum2=sum;
    if (root1==root2)
    {
        if (sum1-sum2==x)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    x-=sum1;
    x+=sum2;
    fa[root1]=root2;
    weight[root1]=x;
    return false;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m;
    scanf("%d%d",&n,&m);
    int i;
    for (i=0;i<n;i++)
    {
        fa[i]=-1;
        weight[i]=0;
    }
    for (i=0;i<m;i++)
    {
        int l,r,x;
        scanf("%d%d%d",&l,&r,&x);
        l--;
        r--;
        if (u(l,r,x))
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
} 


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,i;
	char op;
	for(;;){
	cin>> a >> op >> b;
	if(op=='+'){ 
	cout<<a+b<<endl;
	}
	else if(op=='-'){
	cout<<a-b<<endl;
	}
	else if(op=='*'){
	cout<<a*b<<endl;
	}
	else if(op=='/'){
	cout<<a/b<<endl;
	}
	else{
		break;
	}
	}
		
return 0;

}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int X, N;
    cin >> X >> N;
    int pp;
    vector<bool> p(102, true);
    for (int i = 0; i < N; i++) {
        cin >> pp;
        p[pp] = false;
    }
    int ans = -1;
    for (int i = 0; i < 102; i++) {
        if(p[i]){
            if(abs(X - i) < abs(X - ans)){
                ans = i;
            }
        }
    }
    printf("%d\n", ans);

}

Measured memory_bytes: 3684
#include <cstdio>

int main(){
    int a, b, c, t;
    scanf("%d %d %d", &a, &b, &c);
    if (a <= c && c <= b){
        t = c;
        c = b;
        b = t;
    }else if(b <= a && a <= c){
        t = b;
        b = a;
        a = t;
    }else if(b <= c && c <= a){
        t = a;
        a = b;
        b = c;
        c = t;
    }else if(c <= a && a <= b){
        t = c;
        c = b;
        b = a;
        a = t;
    }else if(c <= b && b <= a){
        t = c;
        c = a;
        a = t;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2756
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){

  vector<int> w;
  int n, x;

  cin >> n >> x;

  int tmp;
  int sum = 0;
  int min_w = 999999;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    w.push_back(tmp);
    sum += tmp;
    min_w = min(min_w, tmp);
  }

  x -= sum;
  n += x / min_w;

  cout << n << endl;
}


Measured memory_bytes: 256
/*
 * sample.c
 *
 *  Created on: 2017/05/09
 *      Author: SS-76
 */


#include <stdio.h>

int main(void) {

	int a, b;
	char op ;

	do{
		scanf("%d",&a);
		(void)getchar();
		scanf("%c",&op);
		(void)getchar();
		scanf("%d",&b);
		(void)getchar();



			if ('+' == op){
				printf("%d\n",a+b);
			}

			if ('-' == op){
				printf("%d\n",a-b);
			}

			if ('*' == op){
				printf("%d\n",a*b);
			}

			if ('/' == op){
				printf("%d\n",a/b);
			}




	}while(op != '?');

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define pb          emplace_back
#define fi          first
#define se          second
#define show(...)   fprintf(stderr, __VA_ARGS__ )
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i<(n); ++i)
#define inside(x,y,w,h) ((x)>=0 && (y)>=0 && (x)<(w) && (y)<(h))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int       INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};

int N;
int a[100010];

int f(int n)
{
    int cnt = 0;
    while (n >= 2 && n % 2 == 0) {
        n /= 2;
        ++cnt;
    }
    return (cnt);
}

signed main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> N;
    int sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += f(a[i]);
    }
    outl(sum);

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    double ans = 0;
    for (ll i = 0; i<n; i++){
        double num;
        string s;
        cin>>num>>s;
        if(s == "BTC"){
            num *= 380000;
        }
        ans += num;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }
    sort(all(A));
    sort(all(B));
    if (N % 2 == 1) {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    } else {

        cout << ((B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1])) + 1
             << endl;
    }
}

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

int main(){
    int N,D;
    cin >> N >> D;
    int X[N][D] = {};
    for (int i = 0;i < N;i++){
        for (int j = 0;j < D;j++){
            cin >> X[i][j];
        }
    }
    double d;
    int count = 0;
    for (int i = 0;i < N;i++){
        for (int j = i + 1;j < N;j++){
            d = 0;
            for (int k = 0;k < D;k++){
                d += pow(abs(X[i][k] - X[j][k]),2);
            }
            d = pow(d,0.5);
            if (d - floor(d) == 0) count += 1;
        }
    }
    cout << count << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M; cin >> N >> M;
  VI xs(N);
  REP(i,N) cin >> xs[i];
  SORT(xs);

  VI s(M), d(M);
  int prv = 0, c = 0;
  REP(i,N){
	if(xs[i] == prv) ++c;
	else{
	  s[prv%M] += c/2;
	  d[prv%M] += c%2;
	  prv = xs[i];
	  c = 1;
	}
  }
  if(c){
	s[prv%M] += c/2;
	d[prv%M] += c%2;
  }

  //REP(i,M) cout << i<<": "<<s[i] << "," << d[i] << endl;
  
  LL ans = 0;
  for(int i=1;i<(M+1)/2;++i){
	int ii = i;
	int j = M - i;
	int si = s[ii]*2 + d[ii];
	int sj = s[j]*2 + d[j];
	if(si < sj){
	  swap(si, sj);
	  swap(ii,j);
	}
	int m = min(si, sj);
	ans += m;
	ans += (s[ii] * 2 - max(0, m - d[ii])) / 2;

	//cout << j << " - " << ii << " -> " << m << " , " << (s[ii] * 2 +d[ii] - m) / 2 << endl;
  }

  ans += (s[0]*2 + d[0]) / 2;
  if(M%2 == 0)
	ans += (s[M/2]*2 + d[M/2]) / 2;

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1408
n,k =map(int,input().split())

D=[]
A=[]
C=[]
for i in range(k):
    D.append(int(input()))
    A.append(list(map(int,input().split())))
for i in range(1,n+1):
    C.append(int(i))

for i in range(k):
    for a in A[i]:
        if C.count(a)!=0:
            C.remove(a)
        
print( len(C) )



Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
struct unionfind{
  vector<int> p;
  unionfind(int n){
    p = vector<int>(n, -1);
  }
  int root(int x){
    if (p[x] == -1){
      return x;
    } else {
      p[x] = root(p[x]);
      return p[x];
    }
  }
  bool same(int x, int y){
    return root(x) == root(y);
  }
  void unite(int x, int y){
    x = root(x);
    y = root(y);
    p[x] = y;
  }
};
int main(){
  while (1){
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0){
      break;
    }
    vector<tuple<int, int, int>> E(m);
    for (int i = 0; i < m; i++){
      int a, b, w;
      cin >> a >> b >> w;
      a--;
      b--;
      E[i] = make_tuple(w, a, b);
    }
    sort(E.begin(), E.end());
    int ans = INF;
    for (int i = 0; i < m; i++){
      unionfind UF(n);
      int cnt = 0;
      for (int j = i; j < m; j++){
        int w = get<0>(E[j]);
        int a = get<1>(E[j]);
        int b = get<2>(E[j]);
        if (!UF.same(a, b)){
          UF.unite(a, b);
          cnt++;
          if (cnt == n - 1){
            ans = min(ans, w - get<0>(E[i]));
            break;
          }
        }
      }
    }
    if (ans == INF){
      cout << -1 << endl;
    } else {
     cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3152
from operator import itemgetter


def solve():
    N = int(input())
    XL = [[] for _ in range(N)]
    for i in range(N):
        XL[i] = list(map(int, input().split()))
    
    XL.sort(key=itemgetter(0))
    ans = N
    r = sum(XL[0])
    for i in range(1, N):
        if XL[i][0] - XL[i][1] < r:
            ans -= 1
            r = min(r, sum(XL[i]))
        else:
            r = sum(XL[i])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 29156
n, q = map(int, input().split())
connect = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a - 1].append(b-1)
    connect[b - 1].append(a - 1)
    
values = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    values[p - 1] += x

from collections import deque
que = deque([[-1, 0]])
while que:
    parent, child = que.popleft()
    for num in connect[child]:
        if num == parent:
            continue
        values[num] += values[child]
        que.append([child, num])
print(*values)

Measured memory_bytes: 65332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		var S = GetString();
		WriteLine(S[2] == S[3] && S[4] == S[5] ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<numeric>
using namespace std;

int gcd(int x, int y){
    if(x < y){
        int tmp = y;
        y = x;
        x = tmp;
    }
    while(y != 0){
        int tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}


unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    priority_queue<int> S;
    int N, X, maxg, x, gap, i1, i0;
    cin >> N >> X;
    S.push(X);
    for(int i = 0; i < N; i++){
        cin >> x;
        S.push(x);
    }
    i1 = S.top(); S.pop();
    for(int i = 1; i <= N; i++){
        i0 = i1;
        i1 = S.top();
        S.pop();
        gap = i0 - i1;
        if(i != 1 ) maxg = gcd(gap, maxg);
        else maxg = gap;
    }
    cout << maxg << endl;
    return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(A, B, C, D);
    out(max(A * B, C * D));
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int dp[20][20],x,y,n,ans,a,b;

int main(){

    while(1){
    cin >> x >> y;
    if(x==0&&y==0)break;
    cin >> n;

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

    for(int i=1;i<=y;i++){
        for(int j=1;j<=x;j++){
            if(dp[j][i]==0){
                if(dp[j][i-1]!=-1)dp[j][i]+=dp[j][i-1];
                if(dp[j-1][i]!=-1)dp[j][i]+=dp[j-1][i];
            }
        }
    }

    cout << dp[x][y] << endl;
    fill(dp[0],dp[19],0);
    }

return 0;
}

Measured memory_bytes: 1160
import functools

def gcd(x,y):
    big = max(x,y)
    small = min(x,y)
    while small > 0:
        big, small = small, big % small

    return big

N,X = list(map(int,input().strip().split()))
xs = list(map(int,input().strip().split()))

diffs = [abs(X - x) for x in xs]

print(functools.reduce(gcd,diffs))

Measured memory_bytes: 14596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<int> c(s.size(),0);
  int x=0;
  vector<int> p={1,0};
  for(int i=1;i<s.size();i++){
    p.at(i%2)++;
    if(s.at(i)=='L'){
      if(s.at(i-1)=='R')
        x=i;
      c.at(x)=p.at(x%2);
      c.at(x-1)=p.at((x-1)%2);
    }
    if(s.at(i-1)=='L'&&s.at(i)=='R'){
      p={0,0};
      p.at(i%2)++;
    }
  }
  for(int i=0;i<s.size();i++)
    cout<<c.at(i)<<(i<s.size()-1?" ":"");
  cout<<endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll r;
    cin>>r;
    
    cout<<2*r*3.1415926535<<endl;
    
    return 0;
}


Measured memory_bytes: 3804
def main():
    N = int(input().strip())
    stx = sty = stt = 0
    for i in range(N):
        t, x, y = [int(x) for x in input().strip().split()]
        mvt = abs(stt - t)
        mvx = abs(stx - x)
        mvy = abs(sty - y)
        
        if mvt < (mvx + mvy):
            return "No"
        if mvt == (mvx + mvy):
            stx = x
            sty = y
            stt = t
            continue
        if mvt % 2 == 0 and (mvx + mvy) % 2 == 0: #偶数同士
            stx = x
            sty = y
            stt = t
            continue
        if mvt % 2 != 0 and (mvx + mvy) % 2 != 0: #奇数同士
            stx = x
            sty = y
            stt = t
            continue
        return "No"
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n, m;

int w[110][110];
int p[4][100][100];

int main(){
	while (cin >> n >> m&&n + m){
		REP(i, n){
			REP(j, n){
				cin >> w[i][j];
			}
		}
		REP(i, m){
			REP(j, m){
				cin >> p[0][i][j];
				p[1][j][m - 1 - i] = p[0][i][j];
				p[2][m - 1 - i][m - 1 - j] = p[0][i][j];
				p[3][m - 1 - j][i] = p[0][i][j];
			}
		}
		//REP(k, 4){
		//	REP(i, m){
		//		REP(j, m){
		//			cout << p[k][i][j] << "  ";
		//		}
		//		cout << endl;
		//	}
		//	cout << endl;
		//}
		vector<P> vp;
		REP(i, n - m + 1){
			REP(j, n - m + 1){
				REP(k, 4){
					bool f = 1;
					REP(l, m){
						REP(o, m){
							if (p[k][l][o] != -1 && p[k][l][o] != w[i + l][j + o]){
								f = 0;
							}
						}
					}
					if (f){
						bool g = 1;
						REP(l, m){
							REP(o, m){
								if (p[k][l][o] != -1){
									vp.push_back(P(i + l + 1, j + o + 1));
									g = 0;
								}
								if (!g)break;
							}
							if (!g)break;
						}
					}
				}
			}
		}
		if (vp.size() == 0){
			cout << "NA" << endl;
		}
		else{
			sort(ALL(vp));
			cout << vp[0].second << " " << vp[0].first << endl;
		}
	}
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N, max;
  	cin >> N;
  	int a[N];
  	max = 0;
  	for(int i = 0; i < N; i++){
    	cin >> a[i];
    }
  	for(int i = 0; i < N; i++){
    	for(int j = 0; j < N && i != j; j++){
          int s = fabs(a[i] - a[j]);
        	if(s > max){
            	max = s;
            }
        }
    }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3628
a = []
b = []
sa = []
wa = []
n = int(input())
for i in range(n):
    p, y = map(int, input().split())
    a.append((p, y))

sa = sorted(a, key=lambda x: x[0] - x[1])
wa = sorted(sa, key=lambda x: x[0]+x[1], reverse=True)
print(sum(x[0] for x in wa[::2])-sum(x[1] for x in wa[1::2]))

Measured memory_bytes: 22788
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
map<string, int> roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } };

typedef vector<int> Ivec;
typedef pair<int, int> pii;

int main() {

	while (1) {
		array<array<int, 500>, 500> map = {};
		int n, w, h, s, t;
		scanf("%d %d %d", &n, &w, &h);

		if (n == 0)
			return 0;

		array<int, 501> bef = {};
		for (int i = 0; n > i; i++) {
			int a, b;
			scanf("%d %d", &a, &b);
			map[a - 1][b - 1] = 1;
		}

		for (int i = 0; h > i; i++) {
			for (int j = 0; w > j; j++) {
				map[j + 1][i] += map[j][i];
			}
		}
		scanf("%d %d", &s, &t);
		int Max = -1;
		for (int i = 0; h - t >= i; i++) {
			for (int j = 0; w - s >= j; j++) {
				int num = 0;
				for (int k = i; t + i > k; k++) {
					if (j == 0) num += map[j + s - 1][k] - 0;
					else num += map[j + s - 1][k] - map[j - 1][k];
				}
				Max = max(Max, num);
			}
		}
		printf("%d\n", Max);
	}
	return 0;
}

Measured memory_bytes: 4252
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int h,w,d;
vector<pair<int,int>> cost_map(310*310);
vector<int> tour_modd[310*310];
int main(void){
   cin >> h >> w >> d;
   for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
         int a;cin >> a;
         a--;
         cost_map[a] = mp(i,j);
      }
   }
   for(int i = 0;i < d;i++){
      tour_modd[i].pb(0);
      for(int j = 1;i + d*j < h*w;j++){
         int next_x = cost_map[i + d*j].ff;
         int next_y = cost_map[i + d*j].ss;
         int prev_x = cost_map[i + d*(j-1)].ff;
         int prev_y = cost_map[i + d*(j-1)].ss;
         
         tour_modd[i].pb(tour_modd[i].back() + abs(next_x - prev_x) + abs(next_y - prev_y));
      }
   }
   
   int q;cin >> q;
   rep(i,q){
      int l,r;cin >> l >> r;
      l--,r--;
      int m = l % d;
      int idx_l = (l - m)/d;
      int idx_r = (r - m)/d;
      cout << tour_modd[m][idx_r] - tour_modd[m][idx_l] << endl;
   }
   
}

Measured memory_bytes: 6272
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())

i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

ans = 1
flg = 1

for a in i:
  if(a == 0):
    print(0)
    flg = 0

if(flg==1):
  for a in i:
    if(flg==1):
      ans = ans * a
      if(ans > 1000000000000000000):
        print(-1)
        flg=0

if(flg==1):
  print(ans)


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

int main()
{
    //x + y + z == S
    //z == S - x - y

    int K, S;
    ll ans = 0;
    cin >> K >> S;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            if(S - x - y <=K && 0 <= S - x - y){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// ABC178A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (x == 0) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}


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

int comp_as( const void *, const void * );
int comp_des( const void *, const void * );

int main( void ) {
	char aStr[ 20 ][ 7 ], min[ 7 ], max[ 7 ];
	int i, j, a0, L;

	for ( ; scanf( "%d %d", &a0, &L ), L; printf( "%d %d %d\n", j, atoi( aStr[ i ] ), i - j ) ) {
		sprintf( aStr[ 0 ], "%0*d", L, a0 );

		for ( i = 1; ; i++ ) {
			strcpy( min, aStr[ i - 1 ] );
			qsort( min, L, sizeof(char), &comp_as );

			strcpy( max, aStr[ i - 1 ] );
			qsort( max, L, sizeof(char), &comp_des );

			sprintf( aStr[ i ], "%0*d", L, atoi( max ) - atoi( min ) );

			for ( j = 0; j < i; j++ )
				if ( !strcmp( aStr[ j ], aStr[ i ] ) )
					break;
			if ( j < i )
				break;
		}
	}

	return 0;
}

int comp_as( const void *a, const void *b ) {
	return *(char *)a - *(char *)b;
}

int comp_des( const void *a, const void *b ) {
	return *(char *)b - *(char *)a;
}

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

using ll=long long;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;

vi fastexp(const vi& perm, int x) {
    if (x > 1) {
        int n = perm.size();
        vi halfexp = fastexp(perm, x/2);
        vi res(n);
        for (int i=0; i<n; ++i) {
            if (x&1)
                res[i] = perm[halfexp[halfexp[i]]];
            else
                res[i] = halfexp[halfexp[i]];
        }
        return res;
    }
    assert(x == 1);
    return perm;
}


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

    int n, k;
    cin >> n >> k;
    vvi ais(6, vi(n));
    for (int i=0; i<n; ++i) {
        cin >> ais[0][i];
        --ais[0][i];
    }
    for (int i=0; i<n; ++i) {
        cin >> ais[1][i];
        --ais[1][i];
    }
    for (int j=2; j<6; ++j) {
        for (int i=0; i<n; ++i) {
            ais[j][ais[j-2][i]] = ais[j-1][i];
        }
    }

    int lowi = k%6;
    if (lowi == 0)
        lowi = 6;
    int x = (k - lowi)/6;

    vi per(n);
    for (int i=0; i<n; ++i)
        per[i] = ais[3][ais[0][i]];

    vi res;
    if (x == 0)
        res = ais[lowi-1];
    else {
        vi perexp = fastexp(per, x);
        res = vi(n);
        for (int i=0; i<n; ++i) {
            res[perexp[i]] = perexp[ais[lowi-1][i]];
        }
    }
    for (int i=0; i<n; ++i)
        cout << res[i]+1 << " ";
    cout << "\n";
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    int n;
    cin>>n;
    if(n>81)
    {
        cout<<"No";
        return 0;
    }
    vi v;
    f(i,1,10)
    {
        f(j,i,10)
        {
            v.pb(i*j);
        }
    }
    vi :: iterator it;
    it = find(v.begin(),v.end(),n);
    if(it==v.end())
    {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes";

}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var a int
	var op string
	var b int

	for {
		fmt.Scan(&a)
		fmt.Scan(&op)
		fmt.Scan(&b)

		if op == "+" {
			fmt.Println(a + b)
			continue
		}

		if op == "-" {
			fmt.Println(a - b)
			continue
		}

		if op == "*" {
			fmt.Println(a * b)
			continue
		}

		if op == "/" {
			fmt.Println(a / b)
			continue
		}

		return
	}

}



Measured memory_bytes: 1116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
#include <string.h>
#include <fstream>
#include <stdio.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define MOD 1000000007
#define INF 1000000001
#define PB push_back
#define eps 1e-5
#define X first
#define Y second

int n,a,b;

void solve(int a, int b, vector<int> v) {
    if (v.size() == 1) {
        cout << a<<" "<<b<<" ";
        return;
    }
    
    FOR (i,0,v.size())
    {
        if ((a&(1<<v[i])) != (b&(1<<v[i])))
        {
            vector<int> q;
            FOR (j,0,v.size()) {
                if (j != i) q.PB(v[j]);
            }
            
            if (q.size() > 0) {
                solve(a,a^(1<<q[0]),q);
                solve(a^(1<<q[0])^(1<<v[i]),b,q);
            }
            
            return;
        }
    }
}

int main()
{
    cin >> n >> a >> b;
    int c = b^a;
    int num = 0;
    while (c) {
        num++;
        c = c&(c-1);
    }
    
    c = b^a;
    if (num % 2 == 0) cout << "NO\n";
    else {
        cout << "YES\n";
        vector<int> v;
        FOR (i,0,n) v.PB(i);
        solve(a, b, v);
    }
}

/*
 80000
 40694
 73594
 13614
 65544
 */


Measured memory_bytes: 1024
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n == 0 && k == 0) break;

			String[] card = new String[n];
			for(int i=0;i<n;i++){
				card[i] = sc.next();
			}

			HashSet<String> set = new HashSet<String>();
			solve(card,k,new boolean[n],set,"");
			System.out.println(set.size());
		}
	}

	private static void solve(String[] card,int k,boolean[] used,HashSet<String> set,String s){
		if(k == 0){
			set.add(s);
			return;
		}

		for(int i=0;i<card.length;i++){
			if(!used[i]){
				used[i] = true;
				solve(card,k-1,used,set,s+card[i]);
				used[i] = false;
			}
		}
	}
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;

int main()
{
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define E 2.71828182845905
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define debug(x) cout<<#x<<" is "<<x<<endl;
#define PI 3.14159265
#define mem(x) memset(x,0,sizeof(x));
#define br cout<<endl
using namespace std;
  
void sol() {
	int n,W;
	cin>>n>>W;
	ll w[n],v[n];
	rep(i,0,n)
	cin>>w[i]>>v[i];
	ll dp[n+1][100005];
	rep(i,0,n+1)
		rep(j,0,100005)
		dp[i][j]=INT_MAX;
	dp[0][0]=0;
	rep(i,1,n+1){
		rep(j,0,100005){
			if(j-v[i-1]>=0){
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	ll ans=0;
	rep(j,1,100005)
	{
		if(dp[n][j]<=W)
			ans=j;
	}
	cout<<ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
 	//cin>>t;
 	while(t--){	
	sol();
 }

}

Measured memory_bytes: 79232
#include"bits/stdc++.h"
using namespace std;

int H, W;
bool MAZE[20][20];

int bfs(int sx, int sy) {
    queue<vector<int>> que;
    que.push({sx, sy, 0});

    int maxCount = 0;
    while(!que.empty()) {
        vector<int> now = que.front(); que.pop();
        int x = now[0];
        int y = now[1];
        int count = now[2];

        if (x < 0 || y < 0 || x >= H || y >= W) continue;
        if (MAZE[x][y]) continue;

        MAZE[x][y] = true;
        maxCount = max(count, maxCount);

        que.push({x + 1, y, count + 1});
        que.push({x - 1, y, count + 1});
        que.push({x, y + 1, count + 1});
        que.push({x, y - 1, count + 1});
    }

    return maxCount;
}

int main()
{
    cin >> H >> W;

    char c;
    bool init[20][20];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> c;
            if (c == '.') init[i][j] = false;
            else init[i][j] = true;
        }
    }

    int maxMove = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            memcpy(MAZE, init, sizeof(init));
            if (MAZE[i][j]) continue;
            maxMove = max(bfs(i, j), maxMove);
        }
    }

    cout << maxMove << endl;

    return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int n, l;
  cin >> n >> l;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += l + i;
  }
  int ans = 0;
  int min_difference = INT_MAX;
  for (int i = 0; i < n; i++) {
    int subSum = sum - (l + i);
    if (abs(sum - subSum) < min_difference) {
      min_difference = abs(sum - subSum);
      ans = subSum;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//ProblemA

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

#ifndef REDIRECT_STDIO
#define REDIRECT_STDIO {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
#endif // REDIRECT_STDIO

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

//vector
template<typename T> using vt = std::vector<T>;
template<typename T> using vvt = vt<vt<T>>;
template<typename T> using vvvt = vt<vvt<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vvvi = vvvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;
using vvvl = vvvt<ll>;
using vb = vt<bool>;
using vpii = vt<pii>;

static inline ll Solve();

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

	cout << Solve() << endl;
	return 0;
}

ll gcd(ll x, ll y) {
	if(x % y == 0) return y;
	return gcd(y, x % y);
}

//ProblemA
ll Solve() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;

	ll g = gcd(n, m);
	ll l = n * m / g;

	ll i = 0, j = 0;
	while(i < n && j < m) {
		if(l / n * i == l / m * j) {
			if(s[i] != t[j]) return -1;
			i++, j++;
		} else if(l / n * i < l / m * j) {
			i++;
		} else {
			j++;
		}
	}
	return l;
}


Measured memory_bytes: 640
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

N = ii()
V = li()
C = li()

max_val = 0
for i in range(N):
    if V[i] - C[i] > 0:
        max_val += V[i] - C[i]

print(max_val)

Measured memory_bytes: 3064
r,s[3];C(char*a){return*a*r-*1[&a]*r;}main(m){for(;~scanf("%*d%s"-r*3,s);printf("%d\n",atoi(s)-m))qsort(s,8,r=1,C),m=atoi(s),r=-1,qsort(s,8,1,C);}

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

int main() {
  int A, B, C, X, count = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, y,z;
    cin>>x>>y>>z;
    if (x==y){
        cout<< z;
    }
    else if (x==z){
             cout<<y;
    }
    else {
            cout<<x;
    }
	return 0;
}

Measured memory_bytes: 256