akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 100005
#define NIL -1

struct Node{int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(int c=T[u].l; c!=NIL; c=T[c].r){
    if(c!=T[u].l) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) rec(T[u].l, p+1);
  if(T[u].r != NIL) rec(T[u].r, p);
}

int main(){
  cin >> n;

  rep(i, n){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  
  rep(i, n){
    int u, m; cin >> u >> m;
    if(m == 0) continue;
    int l;
    rep(j, m){
      int c; cin >> c;
      if(j == 0) T[u].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = u;
    }
  }

  int r;
  rep(i, n) if(T[i].p == NIL) r = i;
  rec(r, 0);

  rep(i, n) print(i);

  return 0;
}



Measured memory_bytes: 4676
#include<cstdio>
#include<iostream>
#include<cmath>

#define R 1
#define D 2
#define L 3
#define U 4

using namespace std;

int main(void){

	int card[14];
	int inp;
	int tmp;
	char gava;
	bool f1,f2,f3;

	while(cin>>inp>>gava){

		for(int i=0;i<14;i++) card[i]=0;
		card[inp]++;
		for(int i=0;i<3;i++){
			cin>>inp>>gava;
			card[inp]++;
		}
		cin>>inp;
		card[inp]++;
		f3=false;

		/*four card*/
		for(int i=0;i<14;i++){
			if(card[i]==4){
				f3=true;
				cout<<"four card"<<endl;
				break;
			}
		}
		if(f3) continue;

		/*full house*/
		f1=false,f2=false;
		for(int i=0;i<14;i++){
			if(card[i]==3) f1=true;
			if(card[i]==2) f2=true;
			if(f1==true&&f2==true){
				f3=true;
				cout<<"full house"<<endl;
				break;
			}
		}
		if(f3) continue;

		/*straight*/
		for(int i=0;i<14;i++){
			if(card[i]==0&&card[i+1]==1){
				tmp=i+1;
				f1=true;
				for(int j=0;j<5;j++){
					if(tmp==14){
						tmp=1;
						if(card[tmp+1]==1){
							f1=false;
							break;
						}
					}
					if(card[tmp]!=1) f1=false;
					tmp++;
				}
				if(f1){
					f3=true;
					cout<<"straight"<<endl;
					break;
				}
			}
		}
		if(f3) continue;

		/*three card*/
		for(int i=0;i<14;i++){
			if(card[i]==3){
				f3=true;
				cout<<"three card"<<endl;
				break;
			}
		}
		if(f3) continue;

		/*two pair */
		f1=false,f2=false;
		for(int i=0;i<14;i++){
			if(card[i]==2&&f1==false){
				f1=true;
				continue;
			}
			if(card[i]==2) f2=true;
			if(f1==true&&f2==true){
				cout<<"two pair"<<endl;
				f3=true;
				break;
			}
		}
		if(f3) continue;

		/*one pair*/
		for(int i=0;i<14;i++){
			if(card[i]==2){
				f3=true;
				cout<<"one pair"<<endl;
				break;
			}
		}
		if(f3) continue;

		/*null*/
		cout<<"null"<<endl;
	}

	return 0;
}

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

int m[3][3],sum;
bool f(int a,int b,int c){
	return a+b+c==sum;
}
bool check(){
	if(!f(m[0][0],m[1][1],m[2][2])||!f(m[0][2],m[1][1],m[2][0]))
		return false;
	for(int i=0;i<3;i++)
		if(!f(m[0][i],m[1][i],m[2][i])||!f(m[i][2],m[i][1],m[i][0]))
			return false;
	return true;
	
}
int main(){
	scanf("%d%d%d",&m[0][0],&m[0][1],&m[1][1]);
	for(;;m[2][2]++){
		sum=m[0][0]+m[1][1]+m[2][2];
		m[2][1]=sum-m[0][1]-m[1][1];
		m[2][0]=sum-m[2][1]-m[2][2];
		m[1][0]=sum-m[0][0]-m[2][0];
		m[1][2]=sum-m[1][0]-m[1][1];
		m[0][2]=sum-m[2][2]-m[1][2];
		if(check()){
			for(int i=0;i<9;i++)
				printf(i%3==2?"%d\n":"%d ",m[i/3][i%3]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
typedef struct{ 
  int left;
  int right;
  int parent;
}id;
   
int main(){ 
  int n,i,j,k,d,t,x,c;
  id A[N];
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    A[i].parent = A[i].right = A[i].left = -1; 

  for(i=0;i<n;i++){
    scanf("%d %d",&k,&t); 

    for(j=0;j<t;j++){
      scanf("%d",&c);
      A[c].parent = k;

      if(j == 0)A[k].left = c;
      else A[x].right = c;

      x = c;
    }
  }
  
  for(i=0;i<n;i++){  
    x = A[i].parent;
    d = 0;
    
    while(x != -1){
      x = A[x].parent;
      d++;
    }
    
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,d);
    
    if(A[i].parent == -1)printf("root, [");
    else if(A[i].left == -1)printf("leaf, [");
    else printf("internal node, [");
    
    x = A[i].left;
    
    if(x != -1){
      printf("%d",A[i].left);
      
      while(A[x].right != -1){
	printf(", %d",A[x].right);
	x = A[x].right;
      }
    }
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 1784
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    rip(i,n,0) {
        int x,y; cin >> x >> y;
        a[i] = x+y;
        b[i] = x-y;
    }
    sort(all(a));
    sort(all(b));
    cout << max(a[n-1]-a[0], b[n-1]-b[0]) << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = 25;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int h, w;
char a[N][N];
int f[N * N][N * N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
2 3
...
...
    */
    cin >> h >> w;
    FOR(i, 1, 20 * 20)
        FOR(j, 1, 20 * 20)
            if(i == j) f[i][j] = 0;
            else
            f[i][j] = INF;
    FOR(i, 1, h)
        FOR(j, 1, w)
            cin >> a[i][j];
    int m = h * w;
    FOR(i, 1, h)
        FOR(j, 1, w)
        {
            if(a[i][j] == '#') continue;
            int pos = (i - 1) * w + j;
            if(a[i][j + 1] == '.' && j + 1 <= w) /// right
            {
                f[pos][pos + 1] = 1;
                f[pos + 1][pos] = 1;
            }
            if(a[i + 1][j] == '.' && i + 1 <= h) /// bottom
            {
                f[pos + w][pos] = 1;
                f[pos][pos + w] = 1;
            }
        }
    int ma = 0;
    pi pos;
    FOR(k, 1, m)
        FOR(i, 1, m)
            FOR(j, 1, m)
                if(f[i][j] > f[i][k] + f[k][j])
                {
                    f[i][j] = f[i][k] + f[k][j];
                }
    //cout << f[1][5];
    FOR(i, 1, m)
    {
        FOR(j, 1, m)
            {
                if(f[i][j] != INF) ma = max(ma, f[i][j]);
            }
    }
    //cout << pos.fi << " " << pos.se << endl;
    cout << ma;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  REP(i,N){
    cin >> h[i];
  }
  ll ans = 0;
  REP(i,N){
    if(K<=h[i])ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, K, ans, res;

int main()
{
	in >> N >> K;
	std::vector<LL>A(N), B(N);
	rep(i, N)
	{
		in >> A[i] >> B[i];
		if (A[i] > K) B[i] = 0;
	}
	rep(k, 30)
	{
		if (K & (1LL << k))
		{
			LL tmp = 0;
			rep(i, N)
			{
				bool flag = !(A[i] & (1LL << k));
				for (int j = k + 1; j < 30; ++j)
				{
					if ((A[i] & (1LL << j)) && !(K & (1LL << j)))
					{
						flag = false;
						break;
					}
				}
				if (flag) tmp += B[i];
			}
			ans = std::max(ans, tmp);
		}
	}
	rep(i, N)
	{
		bool flag = true;
		rep(k, 30)
		{
			if (!(K & (1LL << k)) && (A[i] & (1LL << k)))
			{
				flag = false;
				break;
			}
		}
		if (flag) res += B[i];
	}
	out << std::max(ans, res) << std::endl;
	return 0;
}


Measured memory_bytes: 1792
n_store, n_drink = [int(i) for i in input().split()]
stores = [[int(i) for i in input().split()] for _ in range(n_store)]  # price, n_stock
stores.sort(key=lambda x: x[0], reverse=True)  # priceでソート

ans = 0
while True:
    if n_drink == 0:
        # n_drinkが0になったら終了
        break
    store = stores.pop()
    price, n_stock = store

    n_buy = min(n_stock, n_drink)  # stockがなくなるかn_drinkに到達するまで買う
    ans += n_buy * price
    n_drink -= n_buy
print(ans)


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

int main(){
   int N, K;
   std::cin >> N >> K;
   std::vector<int> h(N);
   for (int i=0; i<N; i++){
      std::cin >> h.at(i);
   }
   std::sort(h.begin(), h.end());
   int min = 1000000000;
   for (int i=0; i<N-K+1; i++){
      int temp = h.at(i+K-1) - h.at(i);
      if (temp < min){
         min = temp;
      }
   }
   std::cout << min << std::endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

template<class T>
struct WeightUnionFind {
  vector<int> tree;
  vector<int> rank;
  vector<T> diff_weight;

  WeightUnionFind (int size) : tree(size, -1), rank(size, 0), diff_weight(size, 0) {} ;

  int root(int a) {
    if (tree[a] < 0) return a;
    int res = root(tree[a]);
    diff_weight[a] += diff_weight[tree[a]];
    return tree[a] = res;
  }

  bool same(int a, int b) {
    return root(a) == root(b);
  }

  bool unite(int a, int b, T w) {
    w += weight(a); w -= weight(b);
    a = root(a); b = root(b);
    if (a == b) return false;
    if (rank[a] < rank[b]) {
      swap(a, b);
      w *= -1;
    }
    if (rank[a] == rank[b]) ++rank[a];
    tree[b] = a;
    diff_weight[b] = w;
    return true;
  }

  T weight(int a) {
    root(a);
    return diff_weight[a];
  }

  T diff(int a, int b) {
    return weight(b) - weight(a);
  }
};

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

int main(){
  int n, m;
  cin >> n >> m;
  
  WeightUnionFind<int> wuf(n);
  rep(i, 0, m) {
    int a, b, c, d;
    cin >> a >> b >> c;
    if (a == 0) {
      cin >> d;
      wuf.unite(b, c, d);
    } else {
      if (wuf.same(b, c)) {
        cout << wuf.diff(b, c) << endl;
      } else {
        cout << "?" << endl;
      }
    }
  }
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int k;
int now;
int ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> k;
    if((k % 2 == 0) || (k % 5 == 0)){
        cout << -1;
        return 0;
    }

    now = 7 % k;
    ans = 1;
    while(now){
        now = 10 * now + 7;
        now %= k;
        ans++;
    }
    cout << ans;
    return 0;  
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){

    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int bcnt = 0;
    int acnt = 0;

    REP(i,n){
        if(s[i] == 'c'){
            cout << "No\n";
            continue;
        }
        if(acnt + bcnt < a + b){
            if(s[i] == 'a'){
                acnt++;
                cout << "Yes\n";
            }else if(s[i] == 'b' && bcnt < b){
                bcnt++;
                cout << "Yes\n";
            }else{
                cout << "No\n";
            }
            
        }else{
            cout << "No\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 3728
A,B,Q=map(int,input().split())
S=[int(input()) for i in range(A)]+[0,10**10+1]
T=[int(input()) for i in range(B)]+[0,10**10+1]
S=sorted(S)
T=sorted(T)
import bisect
for i in range(Q):
  x=int(input())
  si=bisect.bisect_left(S,x)
  if si==1:
    s1,s2=S[si],S[si]
  elif si==A+1:
    s1,s2=S[si-1],S[si-1]
  else:
    s1,s2=S[si-1],S[si]
  ti=bisect.bisect_left(T,x)
  if ti==1:
    t1,t2=T[ti],T[ti]
  elif ti==B+1:
    t1,t2=T[ti-1],T[ti-1]
  else:
    t1,t2=T[ti-1],T[ti]
  ans=min(abs(x-s1)+min(abs(s1-t1),abs(s1-t2)),
         abs(s2-x)+min(abs(s2-t1),abs(s2-t2)),
         abs(x-t1)+min(abs(t1-s1),abs(t1-s2)),
         abs(t2-x)+min(abs(t2-s1),abs(t2-s2)))
  print(ans)

Measured memory_bytes: 13568
// C++ code to find number of distinct numbers
// in a subarray
#include<bits/stdc++.h>
using namespace std;

const int MAX = 1000001;

// structure to store queries
struct Query
{
	int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
	// initialising bit array
	int bit[n+1];
	memset(bit, 0, sizeof(bit));

	// holds the rightmost index of any number
	// as numbers of a[i] are less than or equal to 10^6
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));

	// answer for each query
	int ans[q];
	int query_counter = 0;
	for (int i=0; i<n; i++)
	{
		// If last visit is not -1 update -1 at the
		// idx equal to last_visit[arr[i]]
		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);

		// Setting last_visit[arr[i]] as i and updating
		// the bit array accordingly
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);

		// If i is equal to r of any query store answer
		// for that query in ans[]
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
					query(queries[query_counter].r + 1, bit, n)-
					query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}

	// print answer for each query
	for (int i=0; i<q; i++)
		cout << ans[i] << endl;
}

// driver code
int main()
{
    int n;
    cin>>n;
    int q;
    cin>>q;
    int i;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
	Query queries[q];
	for(i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        y--;
        x--;
        queries[i].l=x;
        queries[i].r=y;
        queries[i].idx=i;
    }
	sort(queries, queries+q, cmp);
	answeringQueries(a, n, queries, q);
	return 0;
}


Measured memory_bytes: 19328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=805;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(max(max(2*a-1,2*b-1),a+b));
	return 0;
}


Measured memory_bytes: 256
while line = gets do
	26.times{
		if line.include?("the") || line.include?("this") || line.include?("that")
		  puts line
		  break
		end
		
		line.length.times{ |i|
			if "a" <= line[i] && line[i] < "z" then
				line[i] = line[i].next
			elsif line[i] == "z" then
				line[i] = "a"
			end
		}
	}
end

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

int main(){
  long long int L,R;
  cin >> L >> R;

  long long int modL, modR;
  modL = L / 2019;
  modR = R / 2019;

  if(modL != modR){
    cout << 0 << endl;
  }else{
    L = L % 2019;
    R = R % 2019;
    int minimum=2019;
    for(int i = L;i<=R-1;i++){
      for(int j = 1; j<=R-i;j++){
        if((i*(i+j))%2019 < minimum){
          minimum = (i*(i+j))%2019;
        }
      }
    }
    cout << minimum << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807

struct edge
{
  ll to;
  ll cost;
  edge() {}
  edge(ll to, ll cost) : to(to), cost(cost){};
};
int main()
{
ll n, m;
cin >> n >> m;
vector<vector<edge>> g(n);
rep(i, m)
{
  ll a, b, c;
  cin >> a >> b >> c;
  g[a - 1].emplace_back(b - 1, c);
  g[b - 1].emplace_back(a - 1, c); //無向辺
}
vector<vector<ll>> v(n, vector<ll>(2,INF) );
v[0][0]=0;
queue<pair<ll,bool>> q;
q.push({0,0});
while(!q.empty()){
  auto p=q.front();
  q.pop();
  for(auto r:g[p.first]){
    if(v[r.to][!p.second]==INF){
      v[r.to][!p.second]=r.cost-v[p.first][p.second];
      q.push({r.to,!p.second});
    }
    else if(v[r.to][!p.second]!=r.cost-v[p.first][p.second]){
      cout << 0 << endl;
      return 0;
    }
  }
}
ll mi1=INF,mi2=INF,a=0;
rep(i,n){
  if(v[i][0]!=INF&&v[i][1]!=INF){
    a=1;
    if(abs(v[i][0]-v[i][1])%2){
      cout << 0 << endl;
      return 0;
    }
    if(abs(v[i][0]-v[i][1])/2+min(v[i][0],v[i][1])<=0){
      cout << 0 << endl;
      return 0;
    }
  }
  mi1=min(mi1,v[i][0]);
  mi2=min(mi2,v[i][1]);
}
ans=max(0LL,mi1+mi2-1);
if(a)ans=1;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 14832
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  string s,t;
  cin >> s >> t;

  cout << (s == t.substr(0, s.length()) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3656
# coding: utf-8
import collections
import bisect
#N, M = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = []
D_ = []
yoyu = 0
husoku = 0
cnt = 0
tmp = 0
for i in range(N):
    d = A[i]-B[i]
    if d > 0:
        D.append(d)
        yoyu += d
        cnt += 1
    elif d < 0:
        D_.append(abs(d))
        husoku += abs(d)
        tmp += 1
#print(yoyu, husoku)
#print(cnt, tmp)
#print(sorted(D))
if yoyu < husoku:
    print(-1)
else:
    D.sort()
    for i in range(cnt-1):
        D[i+1] += D[i]
    amari = yoyu - husoku
    #print(amari, bisect.bisect_right(D, amari))
    print(tmp + cnt - bisect.bisect_right(D, amari))
    

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){
    int x = 0;
    cin >> x;
    call(x);
    return 0;
}


Measured memory_bytes: 3116
line = input()
n, q = list(map(int, line.split()))
rel = {}
for i in range(0, n):
    rel[i] = []
parent = [i for i in range(0, n)]
rank = [0] * n
weight = [0] * n

def find(x):
    if parent[x] == x:
        return x
    else:
        y = find(parent[x])
        weight[x] += weight[parent[x]]
        parent[x] = y
        return y

def union(x, y, w):
    rx = find(x)
    ry = find(y)
    if rank[rx] < rank[ry]:
        parent[rx] = ry
        weight[rx] = w - weight[x] + weight[y]
    else:
        parent[ry] = rx
        weight[ry] = - w - weight[y] + weight[x]
        if rank[rx] == rank[ry]:
            rank[rx] += 1

def same(x, y):
    return find(x) == find(y)

def diff(x, y):
    return weight[x] - weight[y]

for _ in range(0, q):
    line = input()
    query = list(map(int, line.split()))
    if query[0] == 0:
        x, y, z = query[1:]
        union(x, y, z)
    elif query[0] == 1:
        x, y = query[1:]
        if same(x, y):
            print(diff(x, y))
        else:
            print("?")


Measured memory_bytes: 26544
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}

const int N = 18 + 5;
int n,a[N],b[N],ans;
int f[19][1<<18],g[19][1<<18];
int L;
inline void upd(int &x,int v){ v < x ? x = v : 0; }
int val[N][N];
inline void DP(int x){
	int i,j,k,cnt;
	for (i = 0; i <= n; ++i)
	for (j = 0; j < L; ++j) g[i][j] = f[i][j],f[i][j] = 1000000;
	for (i = 0; i <= n; ++i)
	for (j = 0; j < L; ++j) if (g[i][j]<=10000){
		cnt = 0;
		for (k = 1; k <= n; ++k) if (!(j>>(k-1)&1)){
			if (val[i][x-1] <= val[k][x]) upd(f[k][j|(1<<k-1)],g[i][j]+cnt);
			++cnt;
		}
	}
}
int main(){
	int i,j;
	ans = 1000000;
	n = read(),L = 1<<n;
	for (i = 1; i <= n; ++i) a[i] = read();
	for (i = 1; i <= n; ++i) b[i] = read();
	for (i = 1; i <= n; ++i)
	for (j = 1; j <= n; ++j) val[i][j] = ((i^j)&1) ? (b[i]) : (a[i]);
	for (i = 0; i <= n; ++i) for (j = 0; j < L; ++j) f[i][j] = 1000000;
	f[0][0] = 0;
	for (i = 1; i <= n; ++i) DP(i);
	for (i = 1; i <= n; ++i) ans = min(ans,f[i][(1<<n)-1]);
	if (ans > 10000) ans = -1;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 39296
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N <= 111) {
			System.out.println("111");
		} else if(N <= 222) {
			System.out.println("222");
		} else if(N <= 333) {
			System.out.println("333");
		} else if(N <= 444) {
			System.out.println("444");
		} else if(N <= 555) {
			System.out.println("555");
		} else if(N <= 666) {
			System.out.println("666");
		} else if(N <= 777) {
			System.out.println("777");
		} else if(N <= 888) {
			System.out.println("888");
		} else if(N <= 999) {
			System.out.println("999");
		}
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std ;
typedef long long ll ;
int main()
{
    ll k,n,p=0,sum=0,minn=0;
    cin >> k >> n ;
    ll arr[n+5],x,brr[n+5];
    brr[0]=0;
    for(int i=1;i<=n;i++)
    {
        int x ;
        cin >> x ;
        arr[i]=x;
        if(i>1)
        {
            brr[i-1] = x-arr[i-1];
        }
    }
    brr[n]=k-arr[n]+arr[1];
    sort(brr,brr+n+1,greater<int>());
    cout << k - brr[0] << endl;
    return 0 ;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



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


Measured memory_bytes: 3644
/*input
314159265358
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld cnt=0;
	lld n;
	cin >> n;
	set <lld> s;
	for(lld i=2;i*i<=n;i++){
		if(n%i==0){
			lld x=n/i;
			lld n2=n;
			while(n2%i==0){
				n2/=i;
			}
			lld t=n2/i;
			n2-=t*i;
			if(n2==1){
				if(i>=2)
					s.insert(i);
			}
			if(x!=i){
				n2=n;
				while(n2%x==0){
					n2/=x;
				}
				lld tt=n2/x;
				n2-=x*tt;
				if(n2==1){
					if(x>=2)
						s.insert(x);
				}
			}
		}
	}
	s.insert(n);
	n--;
	if(n>=2)
		s.insert(n);
	for(lld i=2;i*i<=n;i++){
		if(n%i==0){
			if(i>=2)
				s.insert(i);
			if(n/i>=2)
				s.insert(n/i);
		}
	}
	cout << s.size() << endl;
	// cout << cnt << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		long N = scan.nextLong();
		StringBuilder sb = new StringBuilder();

		while(true) {
			N--;
			sb.append((char)('a' + (N % 26)));
			if(N < 26) {
				break;
			}
			N /= 26;
		}

		System.out.println(sb.reverse().toString());

	}
}

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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<int> h(N);
    rep(i,N) cin >> h[i];
    
    int ans = 0;
    rep(i,N)
    {
        if( K <= h[i] ) ans++;
    }
    cout << ans << endl;


}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main() {
  string s;
  cin >> s;
  set<char> z;
  for(int i = 0; i < s.size(); i++) {
    z.insert(s[i]);
  }
  if(s.size() == z.size()) {
    cout << "yes";
  } else {
    cout << "no";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    rep(i,3){
        cin>>S;
        cout<<S[0];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		rep(i,n){
			vint v(3);
			rep(j,3) cin>>v[j];
			vint w=v;
			sort(ALL(w));
			if(w[2]==100) cout<<"A"<<endl;
			else if(v[0]+v[1]>=180) cout<<"A"<<endl;
			else if(v[0]+v[1]+v[2]>=240) cout<<"A"<<endl;
			else if(v[0]+v[1]+v[2]>=210) cout<<"B"<<endl;
			else if(v[0]+v[1]+v[2]>=150&&max(v[0],v[1])>=80) cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

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



int main(){
  int n,ans=0;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

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

    for(int j=0;j<i;j++){
      if(a[j]>a[i])
        val=false;
    }
    if(val){
      ans+=1;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,b,c=0;
    cin >> n >> b;
    if(n==0)
    {
        cout << 1;
        return 0;
    }
    while(n!=0)
    {
        n/=b;
        c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int X[10][10];
int sqr(int x){return x*x;}
bool dis(int x,int y,int D){
    int v=0;
    REP(i,D){
        v+=sqr(X[x][i]-X[y][i]);
    }
    int u=sqrt(v);
    return u*u==v;
}
int main(){
    int N,D;
    R(N,D);
    REP(i,N)REP(j,D)R(X[i][j]);
    int an=0;
    REP(i,N)REP(j,i){
        if(dis(i,j,D))an++;
    }
    W(an);
    return 0;
}


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

int main() {
	int a,b,n;
	while(true){
		cin>>a>>b>>n;
		if(a==0,b==0){
			break;
		}
		int map[a+1][b+1];
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				map[i][j]=0;
			}
		}
		
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			map[x][y]=1;
		}
		
		int dp[a+1][b+1];
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				dp[i][j]=0;
			}
		}
		dp[0][1]=1;
		
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				if(map[i][j]==1){
					dp[i][j]=0;
				}
				else dp[i][j]=dp[i-1][j]+dp[i][j-1];
			}
		}
		cout<<dp[a][b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;bitset<55560>p;int main(){int n;scanf("%d",&n);printf("2");for(int i=2;n>1;++i){if(p[i])continue;if(i%10==1){printf(" %d",i);--n;}for(int j=i*i;j<=55555;j+=i)p[j]=1;}return 0;}

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

int ans[3];

void solve(int n, int y){
  ans[0] = -1;
  for(int i=0; i<n+1; i++){
    for(int j=0; j<n-i+1; j++){
      int k= n -i -j;
      int check = 10000*i + 5000*j + 1000*k;
      if(check == y){
        ans[0] = i;
        ans[1] = j;
        ans[2] = k;
      }
    }
  }//for(i)ループ
}

int main(){
  int n,y;
  cin >> n >> y;
  if(y % 1000 == 0){
    solve (n, y);
  }
  else ans[0] = -1;
  if(ans[0] >= 0){
    for(int l =0; l < 3; l++){
      cout << ans[l] << " ";
    }
  }
  else{
    cout << -1 << " " << -1 << " " << -1;
  }
}


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

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

	set<string> v;
	string t;
	rep(i, N) {
		cin >> t;
		v.insert(t);
	}

	std::cout << v.size() << '\n';
}


Measured memory_bytes: 19180
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		
		int adjLen = adjMatrix.length;
		int adjLenSecond = adjMatrix[0].length;
		for(int i = 0; i < adjLen; i++) {
			for(int j = 0; j < adjLenSecond; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		int flag = 0;
		for( LinkedList<Integer> vertex : adjList) {
			
				if(!vertex.isEmpty()) {
					for(int edge : vertex) {
						adjMatrix[flag][edge] = 1;
					}
				}
				flag++;
		}
		for ( int i = 0; i < totalVertex; i++) {
			String ab = ""; 
			for(int j = 0; j < totalVertex; j++) {
				ab += adjMatrix[i][j];
				if (j < totalVertex - 1) {
					ab += " ";
				}
			}
			System.out.println(ab);
		}
	}
		//complete the following
	}


//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 49140
x,k,d = map(int, input().split())

dist = abs(x)

if dist-k*d <= 0:
    k -= dist//d
    if k%2 == 0:
        print(abs(dist%d))
    else:
        print(abs(dist%d-d))
    # print(min(abs(dist%d),abs(dist%d-d)))
else:
    print(dist-k*d)


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    ios::sync_with_stdio(0) ;
    int x , y , z ;
    scanf("%d %d %d" ,&x , &y ,&z) ;
    x-=(2*z + y) ;
    cout << x/(y+z) + 1 << endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
using namespace std;
int main() {
	vector<int> vc; // <T>でT型のvector
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		vc.push_back(x);
	}
	int min=10000;
	for(int i=0; i<vc.size(); i++){
		int sum1 = 0, sum2 = 0;
		for(int j=0; j<i; j++) sum1 = sum1+vc[j];
		for(int j=i; j<vc.size(); j++) sum2 = sum2+vc[j];
		int diff = sum1-sum2;
		if(diff<0) diff = -diff;

		if(diff<min) min = diff;

	}

	cout << min << '\n';
}


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

string repeat(string str, int num)
{
  string ans = "";
  for(int i = 0; i < num; i++)
  {
    ans += str;
  }
  return ans;
}

int main()
{
  int sx, tx, sy, ty;
  cin >> sx >> sy >> tx >> ty;
  
  int w, h;
  w = tx - sx;
  h = ty - sy;
  string ans = "";
  ans += repeat("U", h);
  ans += repeat("R", w);
  ans += "U";
  ans += repeat("L", w+1);
  ans += repeat("D", h+1);
  ans += "R";
  ans += repeat("R", w);
  ans += repeat("U", h);
  ans += "R";
  ans += repeat("D", h+1);
  ans += repeat("L", w+1);
  ans += "U";
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
	
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] A = new long[N];
        long ans=0;
        for(int i=0;i<N;i++) {
            A[i] = sc.nextLong();
        }
        Arrays.sort(A);
//        System.out.println(sum);
/*
        if(A[0]<0) {
        	long c=A[0];
        	for(int i=0;i<N;i++) {
        		A[i]=A[i]+c;
        	}
        }
*/       
        kaijo = new long[N+100];
        kaijo[0]=1;
        for(int i=1;i<=N+88;i++) {
        	kaijo[i]=(kaijo[i-1]*i)%mod;
        }
        kaiinv = new long[N+100];
        kaiinv[0]=1;
        kaiinv[1]=1;
        for(int i=2;i<N+88;i++) {
        	kaiinv[i]=modinv(kaijo[i])%mod;
        }
        
//        System.out.println(nCr(10,3));
        		
        long maxS=0;
        long minS=0;
        for(int i=0;i<N;i++) {
        	maxS=(maxS+ A[i]*nCr(i,K-1))%mod;
        }
        for(int i=0;i<N;i++) {
        	minS=(minS+ A[i]*nCr(N-i-1,K-1))%mod;
        }
        ans=(maxS-minS+mod)%mod;
        System.out.println(ans);
    }
 
	static long nCr(int n, int r) {
		if(n<r) {
			return 0;
		} else {
			return (kaijo[n]*(kaiinv[r]*kaiinv[n-r]%mod))%mod;
		}
	}

	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%mod;
	        }
	        a=(a*a)%mod;
	        n>>=1;
	    }
	    return res;
	}
 
	public static long modinv(long n) {
		return pow(n, mod-2);
	}
}

Measured memory_bytes: 50852
#include <iostream>
using namespace std;
#define N_MAX 100

int main(){
  int x,y,N,i,k;
  int rc[N_MAX][2]={0},bc[N_MAX][2]={0};
  int usedR[N_MAX]={0};
  cin>>N;
  for(i=0;i<N;i++){
    cin >> rc[i][0] >> rc[i][1] ;
  }
  for(i=0;i<N;i++){
    cin >> bc[i][0] >> bc[i][1];
  }
  //bubblr sort / greater
  bool flag;
  do{
    flag=true;
    for(i=0;i<N-1;i++){
      if(bc[i][0] > bc[i+1][0]){
        swap(bc[i],bc[i+1]);
        flag=false;
      }
    }
  }while(!flag);
  
  //計算結果
  int cnt=0;
  int Ymax,Cmax;
  for(i=0;i<N;i++){
    Ymax=-1;Cmax=-1;
    for(k=0;k<N;k++){
      if(!usedR[k] && rc[k][0]<bc[i][0] 
         && rc[k][1]<bc[i][1] ){
        if(Ymax<rc[k][1]){
          Ymax=rc[k][1];Cmax=k;
        }
      }
    }
    if(Cmax>-1){
      usedR[Cmax]=1;cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100009];
main(){
    int n;
    cin >> n;
    long long S = 0;
    for (int i = 1 ; i <= n; i++){
        cin >> a[i];
        S+=abs(a[i]-a[i-1]);
    }
    S += abs(a[n+1]-a[n]);
    for (int i = 1; i <= n; i++){
        cout << S - abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])  << endl;
    }

}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, a[200000];
    ll count=0;
    cin>>N;
    rep1(i, N) cin>>a[i];
    rep1(i, N){
        if(i==a[a[i]]) count++;
    }
    cout<<count/2<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll f[200005], fi[200005];

void init() {
    f[0] = 1;
    for (int i = 1; i <= 200000; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[200000] = modpow(f[200000], MOD - 2);
    for (int i = 200000; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }
}

ll comb(ll r, ll c) {
    if (r < c) return 0;
    return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

ll calc(ll n, ll m, ll K) {
    ll res = 0;
    for (ll i = 1; i < n; i++) {
        ll hoge = i * (n - i) % MOD * m % MOD * m % MOD * comb(n * m - 2, K - 2) % MOD;
        (res += hoge) %= MOD;
    }
    return res;
}

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

    ll n, m, K;
    cin >> n >> m >> K;
    cout << (calc(n, m, K) + calc(m, n, K)) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3328