akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define BIT(n, m) (((n) >> (m)) & 1)

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

const ll inf = 1e15;
const ll mod = 1000 * 1000 * 1000 + 7;
const double eps = 1e-9;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

enum {
  TOP,
  BOTTOM,
  RIGHT,
  LEFT,
  FRONT,
  BACK
};


void shift(int &a, int &b, int &c, int &d){
  int tmp = a; a = b; b = c; c = d; d = tmp;
}

void rotate_x(vector<int> &dice){
    shift(dice[FRONT], dice[TOP], dice[BACK], dice[BOTTOM]);
}

void rotate_y(vector<int> &dice){
  shift(dice[RIGHT], dice[TOP], dice[LEFT], dice[BOTTOM]);
}

bool check(vector<int> &dice){
  return
    dice[TOP] + dice[BOTTOM] == 7 &&
    dice[RIGHT] + dice[LEFT] == 7 &&
    dice[FRONT] + dice[BACK] == 7;
}

int mesh[5][5];

void dfs(int x, int y, vector<int> &dice){
  dice[BOTTOM] = mesh[x][y];
  mesh[x][y] = 0;
  
  if (x + 1 < 5 && mesh[x + 1][y]){
    rotate_x(dice);
    dfs(x + 1, y, dice);
    rotate_x(dice);
    rotate_x(dice);
    rotate_x(dice);
  }

  if (x > 0 && mesh[x - 1][y]){
    rotate_x(dice);
    rotate_x(dice);
    rotate_x(dice);
    dfs(x + 1, y, dice);
    rotate_x(dice);
  }

  if (y + 1 < 5 && mesh[x][y + 1]){
    rotate_y(dice);
    dfs(x, y + 1, dice);
    rotate_y(dice);
    rotate_y(dice);
    rotate_y(dice);
  }

  if (y > 0 && mesh[x][y - 1]){
    rotate_y(dice);
    rotate_y(dice);
    rotate_y(dice);
    dfs(x, y - 1, dice);
    rotate_y(dice);
  }
}

bool solve(){
  vector<int> dice(6, -1);
  map<int, int> counter;
  REP(i, 5) REP(j, 5) counter[mesh[i][j]]++;

  if (counter[0] != 19) return false;
  REP2(i, 1, 7) if (counter[i] != 1) return false;
  
  REP(i, 5) REP(j, 5) if (mesh[i][j] > 0){
    dfs(i, j, dice);
    bool is_dice = check(dice);
    bool is_zero = true;
    REP(k, 5) REP(l, 5) if (mesh[k][l] > 0) is_zero = false;
    return is_dice && is_zero;
  }
  return false;
}

int main(){
  int T;
  cin >> T;
  while (T--){
    REP(i, 5) REP(j, 5) cin >> mesh[i][j];
    if (solve()){
      cout << "true" << endl;
    } else {
      cout << "false" << endl;
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b, c, d; cin >> a >> b >> c >> d;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = -INF;
  ans = max(ans, a * c);
  ans = max(ans, b * c);
  ans = max(ans, a * d);
  ans = max(ans, b * d);

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3680
import sys
sys.setrecursionlimit(10 ** 5)

N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
a.reverse()
a += [W] #最後にYさんの手札を加えておく
dp_T = [-1] * (N + 1) #Xの手番
dp_F = [-1] * (N + 1) #Yの手番

def calc(n, flag): #n: 残りの山の枚数　flag: ターンの管理
    #既に計算済みの場合その値を返す
    if flag == True and dp_T[n] != -1:
        return dp_T[n]
    if flag == False and dp_F[n] != -1:
        return dp_F[n]

    if n == 1: #山の残り枚数が1枚の時 -->引くしかなく得点が決定
        return abs(a[0] - a[n])
    if flag == True: #Xのターン-->大きくしたい
        tmp = 0
        for i in range(1, n + 1): #自分が引く枚数 = 1 ~ n枚
            if i == n: #残り枚数0で相手に渡す = 自分が最後の1枚を引く -->相手の手札が決まっているから得点が決定
                tmp = max(tmp, abs(a[0]-a[n]))
            else: #残り枚数が1枚以上ある時、手番は相手に変える
                tmp = max(tmp, calc(n-i, not flag))
        dp_T[n] = tmp
        return tmp
    if flag == False: #Yのターン-->小さくしたい
        tmp = 10 ** 10 #最大値
        for i in range(1, n + 1): #自分が引く枚数 = 1 ~ n枚
            if i == n - 1: #残り0枚で相手に渡す
                tmp = min(tmp, abs(a[0] - a[n]))
            else:
                tmp = min(tmp, calc(n-i, not flag))
        dp_F[n] = tmp
        return tmp

print (calc(N, True))


Measured memory_bytes: 49292
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rer(i, a, b) for(ll i=a-1; i>=b; i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int n;

signed main(){
    int a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s,t;
	cin>>s;
	rrep(i,s.size()){
		if(s[i]=='p')t+='q';
		if(s[i]=='q')t+='p';
		if(s[i]=='b')t+='d';
		if(s[i]=='d')t+='b';
	}
	if(s==t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

const int A = 1000005;

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

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

    vector<int> a(n);
    vector<int> c(A);

    rep(i, n) {
      cin >> a[i];
      c[a[i]]++;
    }
    bool pairwise = true;
    for (int i = 2; i < A; i++) {
      int cnt = 0;
      for (int j = i; j < A; j += i) {
        cnt += c[j];
      }
      if (cnt > 1) {
        pairwise = false;
      }
    }

    if (pairwise) {
      cout << "pairwise coprime" << endl;
      return 0;
    }
    
    int g = 0;
    rep(i, n) g = gcd(g, a[i]);
    if (g == 1) {
      cout << "setwise coprime" << endl;
      return 0;
    }

    cout << "not coprime" << endl;
    return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  sort(v.begin(),v.end());
  ll M=0,m=0;
  ll cmb = 1LL;
  for(ll i= K-1;i<N;i++){
    M=(M+v[i]*cmb)%mod;
    cmb=((cmb*(i+1)%mod)*pow(i+2-K,mod-2,mod))%mod;
  }
  reverse(v.begin(),v.end());
  cmb=1LL;
  for(ll i= K-1;i<N;i++){
    m=(m+v[i]*(cmb))%mod;
    cmb=((cmb*(i+1)%mod)*pow(i+2-K,mod-2,mod))%mod;
  }
  ll ans = (M-m)%mod;
  if(ans<0) ans+=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	V a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			if (i >= j)continue;
			if (a[i] > a[j]) {
				ans += k; ans %= MOD;
			}
		}
	}
	int tmp = 0;
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			if (a[i] > a[j])tmp++;
		}
	}
	ans += (tmp * ((k*(k - 1) / 2)%MOD))%MOD;
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    if(n == 1){
        println(m)
        return
    }
    var ans = 0
    for(i in 1 .. Math.sqrt(m.toDouble()).toInt()){
        if(m % i == 0){
            if(m / i >= n) ans = Math.max(ans, i)
            if(m / (m / i) >= n) ans = Math.max(ans, m / i)
        }
    }
    println(ans)
}


Measured memory_bytes: 35980
from collections import deque
n = int(input())
max_n = 100000
dp = [10000 for i in range(max_n+1)]
dp[0] = 0
que = deque()
que.append(0)

while len(que) > 0:
  v = que.popleft()
  k = 1
  while v + k <= n:
    if dp[v+k] == 10000:
      dp[v+k]=dp[v]+1
      que.append(v+k)
    k *= 6
  k = 1
  while v + k <= n:
    if dp[v+k] == 10000:
      dp[v+k]=dp[v]+1
      que.append(v+k)
    k *= 9
print(dp[n])

Measured memory_bytes: 4920
n = int(input())
a = list(map(int,input().split()))
ans = "APPROVED"
for i in range (n):
  if a[i] % 2 == 1:
    continue
  elif a[i] % 3 == 0:
    continue
  elif a[i] % 5 == 0:
    continue
  else:
    ans = "DENIED"
    break
print(ans)

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

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

	int N, M;
	scanf("%d %d", &N, &M);

	vector<vector<bool>> edge(N + 1, vector<bool>(N + 1, false)); //0は使わない
	int a;
	int b;
	for (int i = 0; i < M; i++)
	{
		scanf("%d %d", &a, &b);
		edge[a][b] = true;
		edge[b][a] = true;
	}
	long long num = 1;
	vector<int> path;
	for (int i = 1; i <= N; i++)
	{
		num = num * i;
		path.insert(path.end(), i);
	}
	bool flag;
	long long result = 0;
	for (int i = 0; i < num; i++)
	{
		if (path[0] != 1)
		{
			next_permutation(path.begin(), path.end());
			continue;
		}
		flag = true;
		// cout << path[0] << " ";
		for (int j = 1; j < N; j++)
		{
			// cout << path[j] << " ";
			if (!edge[path[j - 1]][path[j]])
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			result++;
		}
		// cout << ":" << flag << "\n";
		next_permutation(path.begin(), path.end());
	}

	cout << result;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void){
    int i,n,s[1000];
    double h,sum;
     
    while(1){
 
        scanf("%d",&n);
        if(!n) break;
         
        sum = 0;
        h = 0;
         
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum += s[i];
        }
     
        sum /= n;
     
   //     printf("%lf ",sum);
         
        for(i=0;i<n;i++){
            h += pow(s[i]-sum, 2.0);
        }
             
        h /= n;
 
   //     printf("%lf ",h);
 
        printf("%lf\n",pow(h,1.0/2.0));
     
    }
     
    return 0;
}


Measured memory_bytes: 2104
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

int n;
vector<int> g[110000];
vector<int> pt;
int tam[110000];

bool dfsf(int v, int p) {
    pt.push_back(v);

    if (v == n-1) return true;
    for (int x : g[v]) if (x != p) {
        if (dfsf(x, v)) return true;
    }

    pt.pop_back();
    return false;
}

int dfsz(int v, int p) {
    tam[v]=1;
    for (int x : g[v]) if (x != p) tam[v] += dfsz(x,v);
    return tam[v];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int u,v; cin >> u >> v; u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfsf(0,-1);
    dfsz(0,-1);

    int len = pt.size();

    int idx_fen = (len-1)/2;
    int has_fen = tam[pt[idx_fen]];
    int has_snu = tam[pt[idx_fen+1]];

    if (has_fen > has_snu) has_fen = n - has_snu;
    else has_snu = n - has_fen;

    if (has_fen > has_snu) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 11512
t = input()+"@"
n = len(t)
alph = "abcdefghijklmnopqrstuvwxyz"

ans = len(t)

for char in alph:
    tmp_ans = 0
    tmp = 0
    for i in range(n):
        if i == n-1:
            tmp_ans = max(tmp_ans, tmp)
        if t[i] == char:
            tmp_ans = max(tmp_ans, tmp)
            tmp = 0
        else:
            tmp += 1
    ans = min(ans, tmp_ans)
print(ans)

Measured memory_bytes: 38640
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int tmp = 0;
  int m = n;

  while(n) {
    tmp += n % 10;
    n /= 10;
  }

  if (m % tmp == 0) cout << "Yes" << endl;
  else              cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 384
from math import sqrt
N,D=map(int,input().split())
cnt=0
points=[list(map(int,input().split())) for n in range(N)]

for i in range(N):
    for j in range(i+1,N):
        dist=0
        for d in range(D):
            dist+=(points[i][d]-points[j][d])**2
        if sqrt(dist)-int(sqrt(dist))==0:
            cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
	while(1){
		int n,m;
		cin >> n >> m;
		if(n == 0) break;

		vector<int> atmost(n, 0), atleast(n, 0);
		for(int i=0; i<m; i++){
			int s,k;
			cin >> s >> k;
			for(int i=0; i<k; i++){
				int c;
				cin >> c;
				c--;
				atmost[c] += s;
				if(k == 1) atleast[c] += s;
			}
		}

		vector<pair<int, int> > a(n), b(n);
		for(int i=0; i<n; i++){
			a[i] = make_pair(atmost[i], i);
			b[i] = make_pair(atleast[i], i);
		}
		sort(a.begin(), a.end(), greater<pair<int, int> >());
		sort(b.begin(), b.end());
		if(a[0].second == b[0].second){
			cout << max(a[0].first -b[1].first, a[1].first -b[0].first) +1 << endl;
		}else{
			cout << a[0].first -b[0].first +1 << endl;
		}
	}
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  if(N<10){
    cout << N << endl;
  }else if(N<100){
    cout << 9 << endl;
  }else if(N<1000){
    cout << N-90 << endl;
  }else if(N<10000){
    cout << 909 << endl;
  }else if(N<100000){
    cout << N-9090 << endl;
  }else if(N==100000){
    cout << 90909 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  string s;
  cin >> s;
  int d;
  int t;
  for (int i = 0; i < (int)s.length()-2; i++){
    t = (int)(s[i]-48)*100 + (int)(s[i+1]-48)*10 + (int)(s[i+2]-48);
    if (i == 0){
      d = abs(t-753);
    } else {
      if (abs(t-753) < d){
        d = abs(t-753);
      }
    }
  }
  cout << d;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
ll INF=2000000000;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(ll i=0; i<N; i++){
        cin>>A[i];
    }
    reverse(A.begin(), A.end());
    vector<ll> B(0);
    B.push_back(A[0]);
    ll BSz=1;
    for(int i=1; i<N; i++){
        auto It=upper_bound(B.begin(), B.end(), A[i]);
        if(It-B.begin()==BSz){
            B.push_back(A[i]);
            BSz ++;
        }
        else{
            B.at(It-B.begin())=A[i];
        }
      	/*for(int j=0; j<BSz; j++){
          	cout<<B[j]<<" ";
        }
      	cout<<endl;*/
    }
    cout<<BSz<<endl;
    return 0;
}

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

using namespace std;

long long x, y, d; // ax + by = d
void extendedEuclidean(long long a, long long b) {
  if(b == 0) { x = 1; y = 0; d = a; return; } 
  extendedEuclidean(b, a % b); 
  long long xx, yy;
  xx = y;
  yy = x - (a/b)*y;
  x = xx; y = yy;
}

const int N = 1e6 + 6, mod = 998244353;

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}
long long fac[N], inv[N];
long long C(long long n, long long k) {
  return (fac[n] * inv[k] % mod) * inv[n-k] % mod;
}

int main() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = powmod(fac[i], mod-2);
  }
  long long n, a, b, k;
  cin >> n >> a >> b >> k;
  extendedEuclidean(a, b);
  if (k % d) {
    puts("0");
    return 0;
  }
  a /= d;
  b /= d;
  k /= d;
  x *= k;
  y *= k;
  long long z = x/b;
  x -= z * b;
  y += z * a;
  while (x > 0) x -= b, y += a;
  long long ans = 0;
  while (x <= n) {
    if (0 <= min(x, y) && max(x, y) <= n) {
      ans = (ans + C(n, x) * C(n, y)) % mod;
    }
    x += b;
    y -= a;
  }
  ans %= mod;
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>

using namespace std;

int main() {
  char enki;
  cin >> enki;

  char out;
  if(enki == 'A') {
    out = 'T';
  }else if(enki == 'T'){
    out = 'A';
  }else if(enki == 'C'){
    out = 'G';
  }else if(enki == 'G'){
    out = 'C';
  }

  cout << out << endl;

  return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

ll a, i;
map<ll, int> mp;
ll f(ll n){
    if(n%2){
        return 3 * n + 1;
    }
    return n / 2;
}
int main(){
    scanf("%lld", &a);
    i++;
    while(mp[a]==0){
        mp[a] = 1;
        a = f(a);
        i++;
    }
    printf("%lld", i);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;
ll n,hhh;
int a[110000];
ll mod_=1000000007;
ll pow_(ll a,ll b)
{
   ll ans=1;
   a=a%mod_;
   while(b)
   {
      if(b%2==1)
         ans=(ans*a)%mod_;
      b=b/2;
      a=(a*a)%mod_;
      //cout<<a<< " "<<b<<" "<<ans<<endl;
   }
   return ans;
}
int main()
{
    cin>>n;

//    if(n==1)
//    {
//        cin>>hhh;
//        if(hhh==0)
//        {
//            cout<<"1"<<endl;
//        }
//        else
//            cout<<"0"<<endl;
//
//        return 0;
//    }

    FOR(i,1,n)
    {
        cin>>hhh;
        a[hhh]++;
    }
    if(n%2==0)
    {
        for(int i=1;i<=n-1;i=i+2)
        {
            if(a[i]==2)
            {
                continue;
            }
            else
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
//        if(n==2)
//        {
//            cout<<"2"<<endl;
//            return 0;
//        }
        cout<<pow_(2,n/2)<<endl;
    }
    else
    {
        if(a[0]!=1)
        {
            cout<<"0"<<endl;
            return 0;
        }
        for(int i=2;i<=n-1;i=i+2)
        {
            if(a[i]==2)
            {
                continue;
            }
            else
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
////        if(n==3)
////        {
////            cout<<"2"<<endl;
////            return 0;
////        }
        cout<<pow_(2,n/2)<<endl;
    }






}



Measured memory_bytes: 640
n=int(input())
p=1
while n > 0:
  n-=26**p
  p+=1
else:
  p-=1
  if n==0:
    ans="z"*p
    print(ans)
  else:
    n+=26**p
    num=[]
    for i in range(1,p+1):
      if n%(26**(p-i))==0:
        a=int(n/(26**(p-i)))-1
        q=p-i
        num.append(a)
        break
      else:
        a=n//(26**(p-i))
        num.append(a)
        n-=a*(26**(p-i))
    al=[]
    if n==0:
      for i in range(p-1):
        m=chr(97+num[i])
        al.append(m)
      al.append(chr(96+num[p-1]))
      ans=''.join(al)
    else:
      for i in num:
        m=chr(97+i)
        al.append(m)
      al.append("z"*q)
      ans=''.join(al)
    print(ans)

Measured memory_bytes: 9192
class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　par[x]==xのときそのノードは根 1からn
        self.par = [i for i in range(n+1)]
        #木の高さを格納
        self.rank = [0] * (n+1)

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        #根が同じならTrue
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        #木の高さを比較し、低いほうから高いほうへつなぐ
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

N, M = map(int, input().split())
query = []
for i in range(M):
    query.append(list(map(int, input().split())))

ans = 0
for ignore in range(0, M):
    union = UnionFind(N)
    for i, q in enumerate(query):
        if i == ignore:
            a, b = q[0], q[1]
            continue
        union.union(q[0], q[1])

    if not union.same_check(a, b):
        ans += 1

print(ans)

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

int main()
{
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (s == u)
  {
    cout << a - 1 << ' ' << b << endl;
  }
  else if (t == u)
  {
    cout << a << ' ' << b - 1 << endl;
  }
  else
  {
    cout << a << ' ' << b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int sum = 0, maxL = 0;
  for(int i = 0; i < n; ++i){
    int L; cin >> L;
    sum += L;
    maxL = max(maxL, L);
  }
  if(maxL < sum - maxL){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}

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

int main() {
  int count5 = 0, count7 = 0;//整数でcount5,count7を初期値0でそれぞれ定義
  vector<int> abc(3);//配列abcを定義
  
  for(int i = 0 ; i < 3 ; i++) {
    cin >> abc.at(i);
  }
  //入力されたA,B,Cを配列abcの0,1,2項目としてそれぞれ受け取る
  
  for(int i = 0 ; i < 3 ; i++) {
    if(abc.at(i) == 5) count5++;
    else if(abc.at(i) == 7) count7++;
  }
  //配列abcのi項目が5だった時、変数count5の値を+1して
  //i項目が7だった時、変数count7の値を+1する
  
  
  if(count5 == 2 && count7 == 1) cout << "YES" << endl;
  //count5が2でcount7が1だったらYESを出力
  
  else cout << "NO" << endl;
  //それ以外だったらNOを出力
}

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

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

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

const long long INF = 1LL << 60;
long long a[100010];
long long dp[100010];

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < 100010; i++)
    {
        if (i < M)
        {
            cin >> a[i];
        }
        else
        {
            a[i] = -1;
        }
    }

    for (int i = 0; i < 100010; i++)
    {
        dp[i] = 0;
    }

    dp[0] = 1;
    int j = 0;
    for (int i = 1; i < N + 1; i++)
    {
        if (i == a[j])
        {
            j++;
            continue;
        }
        dp[i] += dp[i - 1];
        dp[i] %= mod;
        if (i > 1)
        {
            dp[i] += dp[i - 2];
            dp[i] %= mod;
        }
    }
    long long ans = dp[N] % mod;
    cout << ans << endl;
}

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

int main() {
    int S;
    int h, m, s;

    cin >> S;

    s = S % 60;
    S /= 60;
    m = S % 60;
    h = S / 60;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


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

vector<int>graph[100001];
bool visit[100001];
int d[100001];
int n;
int tim;

void dfs(int now,int t){
  visit[now] = false;
  
  d[now] = t;
  for (int i = 0; i < graph[now].size() ; ++i) {
    if ( visit[graph[now][i]] ){
      dfs(graph[now][i],t);
    }
  }

  return;
}

main()
{
  int m, q;
  int s, t;
  
  scanf("%d %d", &n, &m);
  for ( int i = n; i < n*2 ; ++i) {
    d[i - n] = i;
    visit[i-n] = true;
  }

  for ( int i = 0; i < m ; ++i) {
    scanf("%d %d", &s, &t);
    graph[s].push_back(t);
    graph[t].push_back(s);
  }

  for ( int i = 0; i < n ; ++i) {
    if ( visit[i] ) {
      dfs(i,tim);
      tim++;
    }
  }
  
  scanf("%d", &q);
  for ( int i = 0; i < q ; ++i) {
    scanf("%d %d", &s, &t);
    if ( d[s] == d[t] ) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return (0);
}



Measured memory_bytes: 12304
#include<stdio.h>

int main(void)
{
  int S;
  int h,m,s;

  scanf("%d",&S);

  h = S/60/60;
  m = S/60 - h*60;
  s = S - m*60 -h*60*60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}
  



Measured memory_bytes: 2144
N, M = map(int, input().split())
edges = [[] for i in range(N)]
 
for i in range(M):
    a, b = map(int, input().split())
    edges[a].append(b)
    
#スタートは1なのでedges[1]をみる
for i in edges[1]:
    #edges[1]のつながり先にNがあるかどうか
    if N in edges[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")    

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	cout << string(sz(s),'x') << endl;

}



Measured memory_bytes: 256
# input
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

check = []
append = check.append
for i, h in enumerate(H):
    append(
        {
            "index": i + 1,
            "temp": T - h * 0.006
        }
    )
check.sort(key=lambda x: abs(A - x["temp"]))

print(check[0]["index"])

Measured memory_bytes: 3444
/*
 *  Created on: 3 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

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

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll n; cin >> n;
    ll ans = (n / 500) * 1000;
    ans += ((n % 500) / 5) * 5;
    cout << ans;
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(list)
N = int(input())

for i in range(N):
	s,p = input().split(' ')
	p = int(p)
	d[s].append((p,i+1))

l = list(d.items())
l.sort()

for s,t in l:
	t.sort(reverse = True)
	for a,b in t:
		print(b)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int main(){
  string s;
  int k;
  cin >> s;
  cin >> k;
  map<string, int> mp;
  REP(i,s.size()){
    for(int j = max(i-5,0); j < i+1; j++){
      mp[s.substr(j,i-j+1)]++;
    }
  }

  int i = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    i++;
    if(i==k)cout << itr->first << endl;
  }




  return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<cstdint>

int64_t const MOD = 998244353;

int const MAXN = 3000;

int64_t dp1[MAXN+1][MAXN+1];
int64_t dp2[MAXN+1][MAXN+1];
int N, S;

int main() {
  std::cin >> N >> S;
  for(int i = 1; i <= N; ++i) {
    // don't choose i'th num
    std::copy_n(dp1[i-1], S+1, dp1[i]);
    for(int s = 1; s <= S; ++s) dp2[i][s] = (dp2[i-1][s]+dp1[i-1][s])%MOD;
    int a; std::cin >> a;
    // x_1 = i
    (dp1[i][a] += i) %= MOD;
    (dp2[i][a] += i) %= MOD;
    // x_2+ = i
    for(int s = a+1; s <= S; ++s) {
      (dp1[i][s] += dp1[i-1][s-a]) %= MOD;
      (dp2[i][s] += dp1[i-1][s-a]) %= MOD;
    }
  }
  std::cout << dp2[N][S] << std::endl;
  return 0;
}


Measured memory_bytes: 140928
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	map<int, int>mp;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		mp[a]++;
	}
	int ans = 0;
	for (auto p : mp) {
		if (p.first > p.second) {
			ans += p.second;
		}
		else {
			ans += p.second - p.first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(){
 
  int i,j,a[101][101],b[1001],n,m;
  int sum;
  scanf("%d%d",&n,&m);
 
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
 
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
 
  for(i=0;i<n;i++){
    sum=0;
    for(j=0;j<m;j++){
      sum+= a[i][j]*b[j];
    }
    printf("%d\n",sum);
  }
 
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

/*二項定理ライブラリ*/
constexpr lint MOD = 1e9 + 7;
vector<lint> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}
lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    if (n >= (int)fac.size()) facInit(n);
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}
lint nPr(int n, int r)
{
    if (n<r || r<0) return 0;
    if (n >= (int)fac.size()) facInit(n);
    return fac[n] * facInv[n-r] % MOD;
}
lint power(lint x, lint n, lint mod=MOD)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) (ans *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ans;
}
lint doublefac(lint n)
{
    if (n < 0) return 0;
    lint k = (n + 1) / 2;
    if (n & 1) return fac[k * 2] * power(facInv[2], k) % MOD * power(fac[k], MOD - 2) % MOD;
    else return fac[k] * power(facInv[2], k) % MOD;
}

int main() {
    fast_ios();
    int N, K;
    cin >> N >> K;
    facInit(N * 2);
    FOR(i, 1, K + 1) {
        cout << nCr(K - 1, i - 1) * nCr(N - K + 1, i) % MOD << endl;
    }
    
    return 0;
}



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

int main() {
    int D, E;
    int x, y;
    while(std::cin >> D >> E, D != 0 && E != 0) {
        double min = std::numeric_limits<double>::max();
        for(x = 0; x <= D; ++x) {
            y = D - x;
            min = std::min(min, std::fabs(std::sqrt(x*x+y*y)-E));
        }
        std::cout << std::fixed << std::setprecision(5) << min << std::endl;
    }
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
string k;
int d;
int dp[10001][102][2];
int fun(int pos,int rem,int flag)
{
    if(pos==k.length())
    return (rem==0);
    if(dp[pos][rem][flag]!=-1)
    return dp[pos][rem][flag];
    int ans=0;
    if(flag==0)
    {
        int x=k[pos]-'0';
        for(int i=0;i<=x;i++)
        ans=(0LL+ans+fun(pos+1,(rem+i)%d,i!=x))%mod;
    }
    else
    {
        for(int i=0;i<10;i++)
        ans=(0LL+ans+fun(pos+1,(rem+i)%d,1))%mod;
    }
    return (dp[pos][rem][flag]=ans);
}
int main()
{
    cin>>k>>d;
    for(int i=0;i<10001;i++)
    {
        for(int j=0;j<102;j++)
        {
            dp[i][j][0]=-1;
            dp[i][j][1]=-1;
        }
    }
    cout<<(0LL+fun(0,0,0)-1+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 8960
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

B = [i for i in range(1, m+1)]
# 重複組み合わせ
A = combinations_with_replacement(B, n)
ans = []
for item in A:
    res = 0
    for i in range(q):
        if item[b[i]-1] - item[a[i]-1] == c[i]:
            res += d[i]
            ans.append(res)
print(max(ans))







Measured memory_bytes: 114076
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
const int MaxN = 1e6 + 10;
int poww(int a, int b) {
	if(a == 0) return 0;
	if(b == 0) return 1;
	if(b % 2 == 0) {
		return (poww(a, b / 2) * poww(a, b / 2)) % mod;
	}
	else {
		return (((poww(a, b / 2) * poww(a, b / 2)) % mod) * a) % mod;
	}
}
signed main() {
	int n;
	cin >> n;
	cout << (((poww(10, n) - 2 * poww(9, n) + poww(8, n)) % mod) + mod) % mod;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */
int main() {
	boost();
	int n;cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	if(a[n/2]==a[n/2-1])
	cout<<0<<endl;
	else{
		ll ans = a[n/2]-a[n/2-1];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[])
{
  string s;
  cin >> s;

  string result;
  for (int i = 0; i < s.size(); i++) {
    result += "x";
  }

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

Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define ll long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL a[200005];
map<LL,LL> m;

int main()
{
    int n;
    cin>>n;
    rep(i,n)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    LL ans=0;
    for(auto it:m)ans+=it.second*(it.second-1)/2;
    rep(i,n)
    {
        if(m[a[i]]>1)ans-=(m[a[i]]-1);
        cout<<ans<<endl;
        ans+=(m[a[i]]-1);
    }
    return 0;
}













Measured memory_bytes: 11008
s = input()
odd = []
even = []

if len(s) == 1:
    odd.append(s)
    if not 'L' in odd:
        print('Yes')
    else:
        print('No')
else:
    for i in range(len(s)):
        if i%2 == 0:
            odd.append(s[i])
        else:
            even.append(s[i])

    if (not 'L' in odd) and (not 'R' in even):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int A = in.nextInt();
            if (X < A) {
                out.println(0);
            } else {
                out.println(10);
            }
        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, x,a;
	cin >> n >> x;
	vector<int>vec(n);
	rep(i, n) {
		cin >> a;
		vec[i] = a - x;
	}
	a = abs(vec[0]);
	rep(i, n - 1) {
		a = gcd(a, abs(vec[i + 1]));
	}
	cout << a << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, a;
    cin >> n >> a;

    if(n%500<=a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import re

def revPolish(f):
    f = re.sub(r'(\-?\d+\.?\d*?)\s(\-?\d+\.?\d*?)\s([\+\-\*/])(?!\d)',
        lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),
        f)
    if f[-1] in ('+','-','*','/'):
        return revPolish(f)
    else:
        return f

print(revPolish(input()))


Measured memory_bytes: 6596
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))
a_all=[]
c=[[""]*W for i in range(H)]

for i in range(N):
    b=[i+1]*a[i]
    a_all.extend(b)

i=0
for j in range(H):
    if j%2==0:
        for k in range(W):
            c[j][k]=str(a_all[i])
            i+=1
    else:
        for k in range(W-1,-1,-1):
            c[j][k]=str(a_all[i])
            i+=1

for i in range(H):
    print(" ".join(c[i]))



Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); i++)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << "AB" << ((n < 1000) ? "C" : "D") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,cnt=0;
  cin >> n;
  long long a[n];
  pair<long long,int> p[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    p[i]=make_pair(a[i],i%2);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    if(p[i].second!=i%2){
      cnt++;
    }
  }
  cout << cnt/2 << endl;
  return 0;
}


Measured memory_bytes: 2560
import sys
from itertools import accumulate
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
abcs = [tuple(map(int, input().split())) for _ in range(N)]
defs = [tuple(map(int, input().split())) for _ in range(M)]


xs = set([-10**9-2, 0, 10**9+2])
ys = set([-10**9-2, 0, 10**9+2])
for a, b, c in abcs:
    xs.add(a)
    xs.add(b)
    ys.add(c)
for d, e, f in defs:
    xs.add(d)
    ys.add(e)
    ys.add(f)

scatter_x = sorted(xs)
scatter_y = sorted(ys)

gather_x = {e:i for i, e in enumerate(scatter_x)}
gather_y = {e:i for i, e in enumerate(scatter_y)}

x_size = 2 * len(scatter_x)
y_size = 2 * len(scatter_y)

field = [[0] * y_size for _ in range(x_size)]

for a, b, c in abcs:
    field[2 * gather_x[a]][2 * gather_y[c]] += 1
    field[2 * gather_x[b] + 1][2 * gather_y[c]] -= 1
    field[2 * gather_x[a]][2 * gather_y[c] + 1] -= 1
    field[2 * gather_x[b] + 1][2 * gather_y[c] + 1] += 1

for d, e, f in defs:
    field[2 * gather_x[d]][2 * gather_y[e]] += 1
    field[2 * gather_x[d]][2 * gather_y[f] + 1] -= 1
    field[2 * gather_x[d] + 1][2 * gather_y[e]] -= 1
    field[2 * gather_x[d] + 1][2 * gather_y[f] + 1] += 1


for x in range(x_size):
    field[x] = list(accumulate(field[x]))

for x in range(x_size-1):
    for y in range(y_size):
        field[x+1][y] += field[x][y]


#print(*[''.join(map(lambda c: str(c).center(3, ' '), row)) for row in field], sep = '\n')

area = 0
sx = gather_x[0] * 2 + 1
sy = gather_y[0] * 2 + 1
field[sx][sy] = 1
stack_x = [sx]
stack_y = [sy]
while stack_x:
    x = stack_x.pop()
    y = stack_y.pop()
    if x == 1 or y == 1 or x == x_size-1 or y == y_size-1:
        print("INF")
        exit()
    
    if field[x+1][y] == field[x+2][y] == 0:
        stack_x.append(x+2)
        stack_y.append(y)
        field[x+2][y] = 1
    if field[x][y+1] == field[x][y+2] == 0:
        stack_x.append(x)
        stack_y.append(y+2)
        field[x][y+2] = 1
    if field[x-1][y] == field[x-2][y] == 0:
        stack_x.append(x-2)
        stack_y.append(y)
        field[x-2][y] = 1
    if field[x][y-1] == field[x][y-2] == 0:
        stack_x.append(x)
        stack_y.append(y-2)
        field[x][y-2] = 1

    delta_x = scatter_x[x//2 + 1] - scatter_x[x//2]
    delta_y = scatter_y[y//2 + 1] - scatter_y[y//2]       
    area += delta_x * delta_y

print(area)


Measured memory_bytes: 705684