akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	ll a,b;
	cin>>a>>b;
	if(a>=1&&a<=9&&b>=1&&b<=9)
		cout<<a*b<<endl;
	else
		cout<<"-1\n";
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
int N,Y;scanf("%d %d",&N,&Y);
int t=(Y-1000*N)/1000, k = -t/4>(-t-N)/5?-t/4:(-t-N)/5;
if(k>-2.0*t/9||t<0){printf("-1 -1 -1\n");return 0;}
printf("%d %d %d\n",4*k+t,-9*k-2*t,N-(4*k+t)-(-9*k-2*t));}

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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    ll n, x, t;

    cin >> n >> x >> t;

    ll tmp = (n / x);

    if(n % x) tmp++;

    cout << tmp * t << endl;

    return 0;
}


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

using namespace std;

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define in insert
#define sz(x) (int) x.size()
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define y1 ksjdkf

template<typename T>
void vout(T x) {
    cout << x << endl;
    exit(0);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;

const int inf = 1e9 + 1;
const ll INF = 1e18 + 1e2;
const int mod = 1e9 + 7;

void solve() {
    int n, k; cin >> n >> k;
    vl p(n);
    forn(i, n) cin >> p[i];
    sort(all(p));
    ll res = 0;
    forn(i, k) res += p[i];
    cout << res;
}

int main() {
    fast_io

    int q = 1;
//    cin >> q;
    while(q--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    int d,n;
    IN d >> n;

    if(n == 100)n++;
    
    if(d == 0){
        P(n);
    }else{
        P(((int)pow(100,d))*n);
    }
    
	return  0;
}

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

using namespace std;

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

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

  int dl = 0;
  int dr = 0;
  int a;
  for (int i = 0; i < m; ++i) {
    cin >> a;
    if (a < x)
      ++dl;
    else if (a > x)
      ++dr;
  }
  cout << min(dl, dr) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

int N;
std::vector<int> G[200010];
bool used[200010];
std::vector<int> us, vs;
ll ans = 0;

void dfs( int v )
{
  used[v] = true;

  (v>100000?vs:us).push_back( v );

  for( auto &u : G[v] )
  {
    if( !used[u] )
      dfs( u );
  }
}

int main()
{
  scanf( "%d", &N );
  rep( i, N )
  {
    int x, y;
    scanf( "%d%d", &x, &y );
    --x; --y;
    y += 100001;

    G[x].push_back( y );
    G[y].push_back( x );
  }

  rep( i, 100000 )
  {
    us.clear();
    vs.clear();

    if( !used[i] )
    {
      dfs( i );

      ans += us.size()*vs.size();
    }
  }

  printf( "%lld\n", ans-N );

  return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
//#define DEBUG
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << '=' << x << " ";
using namespace std;
using ll = long long;
using ull = unsigned long long;

inline bool is_triangle(int a, int b, int c)
{
	if(a==b || b==c || a==c)
		return false;
	return (a + b > c) && (b + c > a) && (a + c > b);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int count = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			for (int k = j + 1; k < n; k++)
			{
				if (is_triangle(arr[i], arr[j], arr[k]))
				{
					count++;
				}
			}
	cout << count;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <complex>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	stack<ll> ss;
	ll a, s;
	s = n;
	ll cnt = 0;
	while (s != 0) {
		a = s % 26;
		s = s / 26;
		if (a == 0)
			s--;
		ss.push(a);
		cnt++;
		if (s <= 0 && a == 0)
			break;
	}
	char moji;
	for (ll i = 0; i < cnt; i++) {
		int n = 0;
		int x = 1;
		for (moji = 'a'; moji <= 'z'; moji++) {
			if (n + 1 == ss.top()) {
				cout << moji;
				x = 2;
			}
			n++;
		}
		if (ss.top() == 0 && x == 1) {
			cout << 'z';
		}
		ss.pop();
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define fun i*A+B*j+C*k

const int A = 500,B = 100,C = 50;

int a,b,c;

long long ans;

int x;

int main()
{
  	cin>>a>>b>>c;
  	cin>>x;
 	for(int i=0;i<=a;++i)
  	{
  		for(int j=0;j<=b;++j)
		{
			for(int k=0;k<=c;++k)
				if(fun==x)
					ans++;
					
		}	
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

bool checkprime(int x) {
    for(int a = 2; x > a * a; a++) {
        if( x % a == 0) {
            return false;
        }
    }
    return true;
}
int main(void) {
    int x;
    cin >> x;

    ll i = x;
    while(!checkprime(i)) {
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
ll MAX=1e15;
ll MIN=-1*(1e15);
ll a[200001];
void  solve()
{
    ll n,i,j,k,l,m,o,q,r,t;
    ll ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans+=a[n-1];
    j=n-2;
    for(i=n-3;i>=0;)
    {
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      j--;
    }
    cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
    int h,r;
    cin>>h>>r;
    if(h==-r){
        cout<<0<<"\n";
    }
    if(h<-r){
        cout<<-1<<"\n";
        }
    if(h>-r){
        cout<<1<<"\n";
    }
    return(0);
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int n;
string c;
bool first[15];
char ch;
vector <string> vec;

void dfs(int x)
{
	if(x==n)
	{
		cout<<c<<endl;
//		vec.push_back(c);
		return;
	}
	for(int i=0;i<x;i++)
	{
		if(!first[i]) continue;
		first[x]=false;
		c[x]=c[i];
		dfs(x+1);
	}
	first[x]=true;
	c[x]=ch++;
	dfs(x+1);
	ch--;
	first[x]=false;
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	c.resize(n);
	ch='a';
	dfs(0);
	return 0;
}

Measured memory_bytes: 1536
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,k;
    string s;
    a=0;
    b=0;
    cin>>s;
    if(s[0]=='0'&&s[1]!='0')
    a=1;
    else if(s[0]=='1'&&s[1]=='1'||s[0]=='1'&&s[1]=='0'||s[0]=='1'&&s[1]=='2')
    a=1;
    if(s[2]=='0'&&s[3]!='0')
    b=1;
    else if(s[2]=='1'&&s[3]=='1'||s[2]=='1'&&s[3]=='0'||s[2]=='1'&&s[3]=='2')
    b=1;
    if(a==0){
        if(b==0)
        cout<<"NA"<<endl;
        else
        cout<<"YYMM"<<endl;
    }
    else if(b==0)
    cout<<"MMYY"<<endl;
    else
    cout<<"AMBIGUOUS"<<endl;
   
}


Measured memory_bytes: 384
#include <stdio.h>

int x, y, z;

int check(int n, int t)
{
	int a;
	int t_5 = t / 5 ;
	int t_4 = (t - n) / 4;
	int up = (t_5 < t_4) ? t_5 : t_4;
	int down = (2 * (t - n) / 9);
	for (a = down; a <= up; a++){
		x = t - n - 4 * a;
		y = 2 * (n - t) + 9 * a;
		z = t - 5 * a;
		if (x >= 0 && y >= 0 && z >= 0) return 1;
	}
	return 0;
}

int main(void)
{
	int N;
	long Y;
	scanf("%d %ld", &N, &Y);
	int t = (int)(Y / 1000);
	if(check(N, t)) printf("%d  %d  %d\n", x, y, z);
	else            printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll a,b,c,d,n;
	cin>>a>>b>>c>>d>>n;
	ll t=min(a*2,b);
	t=min(t*2,c);
	cout<<n/2*min(t*2,d)+n%2*t<<endl;
}








Measured memory_bytes: 256
import queue
from queue import Queue

n = int(input())
g = []
k = []
for i in range(n+1):
  g.append([])
  k.append([])
  
for i in range(n-1):
  u,v,w = map(int,input().split())
  if w%2 == 0:
    g[v].append(u)
    g[u].append(v)
  else:
    k[v].append(u)
    k[u].append(v)
#print(g)
#print(k)

#色
c = [-1]*(n+1)
c[1] = 0

q = Queue()
q.put(1)

while not q.empty():
  x = q.get()
  for y in g[x]:
    if c[y] == -1:
      q.put(y)
      c[y] = c[x]
  for y in k[x]:
    if c[y] == -1:
      q.put(y)
      c[y] = (c[x]+1)%2
    
for i in range(1,n+1):
  print(c[i])

  


Measured memory_bytes: 32656
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
p = tuple(na())
q = tuple(na())

permutations = list(itertools.permutations(range(1,n+1)))
#print(permutations)
ans = abs(permutations.index(p) - permutations.index(q))
print(ans)

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


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


    int num;
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i=0; i<n; ++i){
        cin >> num;
        arr[i] = num;
    }

    vector<int> dp(n,1e9+5);
    dp[0] = 0;

    for(int i=0; i<n; ++i){
        for(int j=i+1; j<=i+k; j++){
            if(j<n){
            dp[j]= min(dp[j],dp[i]+abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 3964
// created by anaksoleh
// 27 Feb 2020
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<double,double> pd;

bool isMultiple(ll L,ll R){
    if(((L-1)/2019) != (R/2019))
        return true;
    return false;
}

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

    ll L,R;
    cin >> L >> R;
    
    ll ans = 0;
    if(!isMultiple(L,R)){
        ans = LLONG_MAX;
        for(ll i = L ; i < R ; i++){
            for(ll j = i+1 ; j <= R ; j++){
                ans = min(ans,(i*j)%2019);
            }
        }
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main()
{
  int i, j, bubble[N], temp, n, ccount=0, count = 0, flag;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&bubble[i]);
    }
  for(i = 0 ; i < n ; i++ )
    {
  flag = 1;
  while(flag)
	{
	  flag = 0;
	  for(j = n - 1 ; j > 0 ; j--)
	    {
	      if(bubble[j] < bubble[j-1])
		{
		  temp = bubble[j];
		  bubble[j] = bubble[j-1];
		  bubble[j-1] = temp;
		  ccount++;
		  flag = 1;
		}	      
	}
	}
    }
      for(i = 0 ; i < n ; i++)
	{
	  if(i == n - 1){
	    printf("%d\n",bubble[i]);
	  } else{
printf("%d ",bubble[i]);
	  }
	}
      printf("%d\n",ccount);

  return 0;
}

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

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if(b-a+1 <=2*c){
    for(int i=a;i<=b;i++) cout <<i<<endl;
    return 0;
  }
  for(int i=0;i<c;i++) cout << a+i<<endl;
  for(int i=c-1;i>=0;i--) cout << b-i << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
   
    int n;
    scanf("%d", &n);
    vector<int> l(n);
    rep(i, n) scanf("%d", &l[i]);
    sort(l.begin(), l.end());
    int cnt = 0;
    for(int i = n-1; i >= 0; --i){
        for(int j = i-1; j >= 0; --j){
            auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
            cnt += n-1-i-(l.end()-itr);
        }
    } 
    ppp(cnt);
   
    return 0;
}



Measured memory_bytes: 256
import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
row.sort(reverse=True)
col.sort(reverse=True)
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1)

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

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

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe\n";
    else cout<<"safe\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 info[200010][2];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  zero(info);
  int arr[n];
  fi(0, n) {
    cin >> arr[i];
    info[arr[i]][0]++;
  }
  ll total = 0;
  fi(0, 200010) {
    if(info[i][0] > 1){
      info[i][1] = info[i][0] * (info[i][0] - 1) / 2;
      total += info[i][1]; 
    }
  }
  fi(0, n) {
    int x = arr[i];
    ans = total - info[x][1] + (info[x][0] - 1) * (info[x][0] - 2) / 2;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main()
{
    int N;
    int V[32], C[32];
    int benefit;

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> V[i];
    for (int i = 0; i < N; i++)
        cin >> C[i];
    benefit = 0;
    
    for (int i = 0; i < N; i++)
        if (V[i] > C[i])
            benefit += V[i] - C[i];
    
    cout << benefit << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
parent = [0] * (N+1) # 1-indexed
for i in range(2, N+1):
    a = ir()
    parent[i] = a
    graph[a].append(i)
    graph[i].append(a)

root = 1
order = []
stack = [root]
while stack:
    cur = stack.pop()
    order.append(cur)
    for next in graph[cur]:
        if next == parent[cur]: continue
        stack.append(next)

dp = [0] * (N+1)
for x in order[::-1]:
    p = parent[x]
    A = [dp[c] for c in graph[x] if c != p]
    if not A: continue
    A.sort(reverse=True)
    A = [y + i for i, y in enumerate(A, 1)]
    dp[x] = max(A)

answer = dp[1]
print(answer)
# 44

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ''
#define L(i) ((i) - (&i))

const int MAXN = 2 * 1e5 + 10;
	
int main(){	
	int a; cin >> a;
	cout << a + pow(a,2) + pow(a,3) << endl;

	return 0;
}


Measured memory_bytes: 4216
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<String> list = new ArrayList<String>();
    String X = sc.next();
    String Y = sc.next();
    String Z = sc.next();
    list.add(X);
    list.add(Y);
    list.add(0, Z);
    for(String i : list){
      System.out.print(i + " ");
    }
  }
}
      


Measured memory_bytes: 38372
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
using namespace std;

using Graph = vector<vector<int>>;
/*vector<int> A(n); 要素数nの一次元ベクトル
  vector<int> A[n]; 各要素がintのベクトルである要素数nの配列(二次元)
  vector<vector<int> > A(n); 各要素がintのベクトルである要素数nのベクトル*/

/*struct Edge{
  int to;
  int from;
  Edge(int t, int w) : to(t), weight(w) { }
}*/



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

  vector< pair<int, int>> edge;

  Graph G(N);
  for (int i = 0; i < N - 1 ; i++){
   int a, b;
   scanf ("%d %d", &a, &b);
   edge.emplace_back(a-1, b-1);
   G[a-1].push_back(b-1);
   G[b-1].push_back(a-1);

  }

  int K = 0;
  map< pair<int , int>, int> I;
  vector<int> cs(N ,0);  //親との辺の色

  vector<bool> used(N, false);

  queue<int> que;

  //初期状態
  used[0] = true;
  que.push(0);   //queue push 末尾に要素追加

  //bfs開始
  while(!que.empty()){
   int v = que.front();  //vにqueの先頭要素
   que.pop();   //queの先頭要素削除

   if(K < G[v].size() ) K = G[v].size();  //最大次数更新

   int cur = 1;
   for(int u : G[v]){
     if(used[u] == true) continue;
     if(cur == cs[v]) cur++;
     cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
     used[u] = true;
     que.push(u);
   }
}

// 結果出力
cout << K << endl;
for(auto p : edge) cout << I[p] << endl;

  return 0;
}

Measured memory_bytes: 19700
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	int power(long a, int k) {
		long p = 1;
		while (k > 0) {
			if ((k & 1) == 1)
				p = p * a % MD;
			a = a * a % MD;
			k >>= 1;
		}
		return (int) p;
	}
	int[] ff, gg;
	void init(int n) {
		ff = new int[n + 1];
		gg = new int[n + 1];
		for (int f = 1, i = 0; i <= n; i++) {
			gg[i] = power(ff[i] = f, MD - 2);
			f = (int) ((long) f * (i + 1) % MD);
		}
	}
	long ch(int n, int k) {
		return (long) ff[n] * gg[k] % MD * gg[n - k] % MD;
	}
	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		k = Math.min(k, n - 1);
		init(n);
		long ans = 0;
		for (int i = 0; i <= k; i++)
			ans = (ans + ch(n, i) * ch(n - 1, i)) % MD;
		println(ans);
	}
}


Measured memory_bytes: 37416
x,y=map(int, input().split())
L=[]
if x in [1,3,5,7,8,10,12]:
  L=[1,3,5,7,8,10,12]
elif x in [4,6,9,11]:
  L=[4,6,9,11]
else:
  L=[2]

if y in L:
  print('Yes')
else:
  print('No')

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(k);
  for(int i=0;i<k;i++){
    cin >> a.at(i);
  }
  int num = n;
  int num2 = n;
  bool flag = true;
  bool flag2 = false;
  vector<int> b;
  while(flag){
    num = num2;
    int sz = to_string(num).size();
    //
    flag2 = true;
    for(int j=0;j<sz;j++){
      int h = num % 10;
      b.push_back(num % 10);
      num = (num - (num%10))/10;
      for(int i=0;i<k;i++){
        if(a.at(i) == h){
          flag2 = false;
        }
      }
      
    }
    //
    if(flag2){
      break;
    }
    num2++;
    b.clear();
  }
  cout << num2 << endl;
}
  
  

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

using namespace std;
typedef long long ll;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> c(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    int ans=0;
    for(int bit1=0;bit1<1<<h;bit1++){
        vector<int> hvec(7);
        for(int i=0;i<h;i++){
            if(bit1&(1<<i)){
                hvec[i]++;
            }
        }
        for(int bit2=0;bit2<1<<w;bit2++){
            vector<int> wvec(7);
                for(int i=0;i<w;i++){
                    if(bit2&(1<<i)){
                        wvec[i]++;
                    }
            }
            int res=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(hvec[i]>0||wvec[j]>0) continue;
                    if('#'==c[i][j]){
                        res++;
                    }
                }
            }
            if(k==res){
                ans++;
            }
        }

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

Measured memory_bytes: 3612
#include <iostream>

int main() {
	int w;
	while (std::cin >> w) {
		bool f = false;
		for (int s = 1; s <= 512; s <<= 1, w >>= 1) {
			if ((w & 1) != 0) {
				if (f) { std::cout << ' '; }
				else { f = true; }
				std::cout << s;
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;

    long long ans = 0;

    for (int i = 0; i < N; i++){
        char head = S[i];

        bool found1 = false;
        char C1 = 'x';
        vector<int> C1_idx = {};

        bool found2 = false;
        char C2 = 'x';
        vector<int> C2_idx = {};

        for (int j = i; j < N; j++){
            if ((S[j] != head) and (!found1)){
                found1 = true;
                C1 = S[j];
                C1_idx.push_back(j);
            }
            else if ((S[j] != head) and (S[j] != C1) and (!found2)){
                found2 = true;
                C2 = S[j];
                C2_idx.push_back(j);

                ans += (long long)C1_idx.size();
                if ((j-i) % 2 == 0){
                    int mid = i + (j-i)/2;
                    if (binary_search(C1_idx.begin(), C1_idx.end(), mid)){
                        ans -= 1;
                    }
                }
            }
            else if (S[j] == C1){
                C1_idx.push_back(j);
                ans += (long long)C2_idx.size();
                if ((j-i) % 2 == 0){
                    int mid = i + (j-i)/2;
                    if (binary_search(C2_idx.begin(), C2_idx.end(), mid)){
                        ans -= 1;
                    }
                }
            }
            else if (S[j] == C2){
                C2_idx.push_back(j);
                ans += (long long)C1_idx.size();
                if ((j-i) % 2 == 0){
                    int mid = i + (j-i)/2;
                    if (binary_search(C1_idx.begin(), C1_idx.end(), mid)){
                        ans -= 1;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

        final String S = sc.next();

        System.out.print(S.charAt(0));
        System.out.print(S.length() - 2);
        System.out.println(S.charAt(S.length()-1));
    }
}


Measured memory_bytes: 22996
#include <stdio.h>

int main(void)
{
    int n, p[100000] = {}, count = 0;
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (p[i] == i + 1)
        {
            count++;
            i++;
        }
    }

    printf("%d", count);
    return (0);
}

Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e12;//ごめん
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int A,B,i,j,x,y;cin>>A>>B;
	int d[11][11]={0};
	int mydis[11][11]={0};
	int ans[101][101]={0};
	for(i=1;i<=A;i++){
		for(j=1;j<=B;j++){cin>>d[i][j];mydis[i][j]=9999;}
	}
	for(i=0;i<=100;i++){for(j=0;j<=100;j++){ans[i][j]=-1;}}
	for(x=0;x<=100;x++){
		for(y=0;y<=100;y++){
			//この数でやってみる
			int gen=-1;
			for(i=1;i<=A;i++){
				for(j=1;j<=B;j++){
					maxeq(gen,d[i][j]-x*i-y*j);
				}
			}
			if(gen<0){continue;}
			ans[x][y]=gen;
			for(i=1;i<=A;i++){
				for(j=1;j<=B;j++){
					mineq(mydis[i][j],gen+x*i+y*j);
				}
			}
		}
	}
	for(i=1;i<=A;i++){
		for(j=1;j<=B;j++){
			if(mydis[i][j]!=d[i][j]){cout<<"Impossible"<<endl;RE;}
		}
	}
	cout<<"Possible"<<endl;
	vector<tuple<int,int,int>> ret;
	int use=3;
	for(x=0;x<=100;x++){
		for(y=0;y<=100;y++){
			if(ans[x][y]==-1){continue;}
			ret.pub(mt(1+x,102+y,ans[x][y]));
		}
	}
	cout<<"202 "<<ret.size()+200<<endl;
	for(x=0;x<100;x++){cout<<x+1<<" "<<x+2<<" X"<<endl;}
	for(y=0;y<100;y++){cout<<y+103<<" "<<y+102<<" Y"<<endl;}
	for(auto it:ret){cout<<get<0>(it)<<" "<<get<1>(it)<<" "<<get<2>(it)<<endl;}
	cout<<"1 102"<<endl;
	RE;
}


Measured memory_bytes: 512
use std::io;
use std::cmp;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    return buf
}

fn main() {
    let line = gets();
    let mut it = line.split_whitespace().map(|n| n.parse::<i64>().unwrap());
    let (a, b, c, d) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap(), it.next().unwrap());
    let ret;
    if b <= c || d <= a {
       ret = 0;
    } else if (a < c && d < b) || (a > c && d > b) {
       ret = cmp::min(d - c, b - a);
    } else {
        ret = cmp::min(b - c, d - a);
    }
    println!("{}", ret);
}



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

using namespace std;
typedef long long int lli;

const int MOD = 1000000007;

int X, Y;

lli inv(lli k)
{
	if( k == 1 ) return 1;

	lli val = MOD - MOD/k;
	val *= inv( MOD%k );

	return val%MOD;
}

int main()
{
	scanf("%d %d",&X,&Y);

	int A, B;

	A = (2*Y - X)/3;
	B = (2*X - Y)/3;

	if( (2*Y - X)%3 != 0 || (2*X - Y)%3 != 0 || A < 0 || B < 0 )
	{
		printf("0\n");
		return 0;
	}

	lli ans = 1;

	for(int i = 1 ; i <= A + B ; i++)
	{
		ans *= i;
		ans %= MOD;
	}

	for(int i = 0 ; i < 2 ; i++)
	{
		lli fat = 1;

		for(int j = 1 ; j <= A ; j++)
		{
			fat *= j;
			fat %= MOD;
		}

		ans *= inv( fat );
		ans %= MOD;
		
		swap( A , B );
	}

	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int divide, cnt = 0;

    scanf("%d %d %d", &a, &b, &c);
    for (divide = a; divide <= b; divide++){
        if (c % divide == 0){
            cnt++;
        }
    }
    printf("%d\n", cnt);

    return 0;
}

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

#define fi first
#define se second
typedef pair<int,int> PII;


int n, mx, cnt[111];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        cnt[x]++;
        mx = max(mx,x);
    }
    for (int i = mx; i > (mx+1)/2; i--) {
        if (cnt[i] < 2) {
            cout << "Impossible";
            return 0;
        }
    }
    if (cnt[(mx+1)/2] != 1 + (mx%2)) {
        cout << "Impossible";
        return 0;
    }
    for (int i = (mx-1)/2; i > 0; i--) {
        if (cnt[i] > 0) {
            cout << "Impossible";
            return 0;
        }
    }

    cout << "Possible";
}


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

int main() {
	ll n;
	ll res = 1000000000000000000;
	cin >> n;
	for (int i = 1; i <= sqrt(n) + 1; i++) {
		if (n % i == 0) {
			res = min(res, i + (n / i) - 2);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 384
let N =
    stdin.ReadLine()
    |> int
let A =
    stdin.ReadLine().Split()
    |> Array.map int

let A' = Array.concat [|[|0|];A;[|0|]|]

let dist =
    Array.pairwise A'
    |> Array.sumBy (fun (x,y) -> abs (x-y))

Array.windowed 3 A'
|> Array.map (fun [|a;b;c|] ->
    dist - (abs (b-a)) - (abs (c-b)) + (abs (c-a))
    |> stdout.WriteLine)
|> ignore

Measured memory_bytes: 48920
N = int(input())
a = 0
ans = 0
rob = []
for i in range(N):
    x,l = map(int,input().split())
    rob.append((x-l,x+l,x,l))
rob.sort()
for i in range(N):
    a,b,c,d = rob[i]
    rob[i] = (b,a,c,d)
rob.sort()
for i in range(N):
    p,q,x,l = rob[i]
    if i == 0:
        a = x + l
        ans += 1
    if x - l >= a:
        a = x + l
        ans += 1
print(ans)

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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  string g;
  vector<string> grid;
  for (int i = 0; i < h; ++i) {
    cin >> g;
    if (g != string(w, '.')) 
      grid.push_back(g);
  }
  vector<string> res;
  h = grid.size();
  for (int i = 0; i < w; ++i) {
    string col;
    for (int j = 0; j < h; ++j) {
      col += grid[j][i];
    }
    if (col != string(h, '.')) 
      res.push_back(col);
  }

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

  return 0;
}



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

constexpr int MOD = 1000000007;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

map<long, int> MA;

void pf(long n) {
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) MA[i]++, n /= i;
  }
  if (n != 1) MA[n]++;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) pf(i);
  int c75 = 0, c25 = 0, c15 = 0, c5 = 0, c3 = 0;
  for (auto ma : MA) {
    if (ma.second >= 74) c75++;
    else if (ma.second >= 24) c25++;
    else if (ma.second >= 14) c15++;
    else if (ma.second >= 4) c5++;
    else if (ma.second >= 2) c3++;
  }
  int ans = 0;
  ans += com(c75, 1);
  ans += com(c75 + c25, 1) * com((c75 + c25 - 1) + c15 + c5 + c3, 1);
  ans += com(c75 + c25 + c15, 1) * com((c75 + c25 + c15 - 1) + c5, 1);
  ans += com(c75 + c25 + c15 + c5, 2) * com((c75 + c25 + c15 + c5 - 2) + c3, 1);
  cout << ans << "\n";
}

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

int main(){
    #define REP(i, n) for(int i = 0;i < n;i++)

    int n,k,mark,c;
    cin >> n >> k;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    
    REP(i,k-1){
        if((n-1+i)%(k-1)==0){
            cout << (n+i-1)/(k-1) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    map<int,int> mp;
    rep(i, n) mp[a[i]]++;

    if(mp.size() == 1){
        auto it = *mp.begin();
        if(!it.first) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(mp.size() == 2){
        auto it = mp.begin();
        auto p = *it, q = *++it;
        if(p.first == 0 and n % 3 == 0 and
        p.second == n / 3 and q.second == 2 * n / 3){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }  
    }
    if(mp.size() == 3){
        auto it = mp.begin();
        auto p = *it, q = *++it, r = *++it;
        if(!(p.first ^ q.first ^ r.first) and n % 3 == 0 and
        p.second == n / 3 and q.second == n / 3 and r.second == n / 3){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    if(mp.size() > 3) cout << "No" << endl;
}

Measured memory_bytes: 4224
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000003;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}


int powm(int a, int b) {
	a%=mod;
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res;
}

int pre[1000006];
void solve() {
	pre[0]=1;
	for(int i=1; i<mod; i++)
		pre[i]=(pre[i-1]*i)%mod;
	int q;
	cin>>q;
	while(q--) {
		int x,d,n;
		cin>>x>>d>>n;
		if(d==0) {
			cout<<powm(x,n)<<endl;
			continue;
		}
		int ans=powm(d,n);
		x=(x*powm(d,mod-2))%mod;
		d=1;
		if(x+n>mod) {
			cout<<0<<endl;
		} else {
			cout<<(ans*(pre[x+n-1]*powm(pre[x-1],mod-2))%mod)%mod<<endl;
		}
	}

}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 8704