akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	char str[10001];
	int i;
	
	scanf("%[a-z .]", str);
	
	i = 0;
	while (str[i] != '\0'){
		if ('a' <= str[i] && str[i] <= 'z'){
			str[i] = str[i] - 'a' + 'A';
		}
		i++;
	}
	
	printf("%s\n", str);
	
	return (0);
}

Measured memory_bytes: 0
n=int(input())
l=[]
mod=10**9+7
d=dict()
for i in range(1,n):
  cnt=0
  k=i+1
  for j in range(1,k):
    if k<j+1:
      break
    while k%(j+1)==0:
      k//=j+1
      cnt+=1
    if j+1 not in d:
      d[j+1]=cnt
    else:
      d[j+1]+=cnt
    cnt=0
d=list(d.items())
if len(d)==0:
  print(1)
else:
  ans=1
  for i in range(len(d)):
    ans*=(d[i][1]+1)%mod
  print(ans%mod)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


int cmb(int a, int b){
    if(a+b > 1){
        return (a+b)*(a+b-1)/2;
    }
    return 1;
}
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,n;
    
    cin >> a >> b;
    int tmp = a*b;
    int ans = cmb(a,b);
    cout << ans-tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool h[100000];
int main(){
	int n,l[100000];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(l[l[i]]==i){
			ans++;
		}
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
#define rl rd<LL>
typedef long long LL;
using namespace std;
const int maxN = 1e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

LL q[maxN]; int m, Top, V;
LL a[maxN], f[maxN];

int find(int l, int r, LL d) {
	int mid;
	while (l < r) {
		mid = (l + r) / 2 + 1;
		if (q[mid] <= d) l = mid;
		else r = mid - 1;
	}
	return l;
}

void F(int n, LL d, LL t) {
	if (d == 0 || t == 0) return;
	if (n == 1) {a[d] += t; return;}
	int p = find(1, n-1, d);
	f[p] += t * (d / q[p]);
	F(p, d % q[p], t);
}

int main() {

	V = q[Top = 1] = rl(); m = ri();
	while (m --) {
		LL x = rl();
		while (Top && q[Top] >= x) -- Top;
		q[++Top] = x;
	}
	m = Top;
	f[m] = 1;
	per (i, m, 1) F(i, q[i], f[i]);

	per (i, V, 1) a[i] += a[i+1];
	rep (i, 1, V) printf("%lld\n", a[i]);

	return 0;
}

Measured memory_bytes: 3968
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		int N=sc.nextInt();
		long  a[]=new long[N];
		long sum=0;
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		long sum2=0;
		long ans=(long) (Math.pow(10,18)+9);
		for(int i=0;i<N-1;i++) {
			//p(i);
			sum2+=a[i];
			
			ans=Math.min(Math.abs((sum-sum2)-sum2), ans);
				
		}
		p(ans);
		}
		
		
	
	
	

	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 63764
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n;
    cin >> n;

    string a, b;
    cin >> a >> b;

    for (int i = n; i >= 0; --i)
    {
        bool ok = true;
        for (int j = 0; j < i && ok; ++j)
        {
            if (b[j] != a[n - i + j])
                ok = false;
        }

        if (ok)
        {
            cout << 2 * n - i << endl;
            return 0;
        }
    }

    assert(false);

    return 0;
}

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

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

using namespace std;

using ll = long long;

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

  ll ans = pow(n/k, 3);
  if(!(k%2)) ans += pow((n+(k/2))/k, 3);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
const int maxn=3e3+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();}
	x*=f;
}
double f[maxn][maxn];
double a[maxn];
int n;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(re int i=0;i<n;i++){
		cin>>a[i];
	}
	f[0][0]=1.0;
	for(re int i=0;i<n;i++){
		for(re int j=0;j<=i;j++){
			f[i+1][j+1]+=f[i][j]*a[i];
			f[i+1][j]+=f[i][j]*(1.0-a[i]);
		}
	}
	double ans=0.0;
	for(re int i=(n+1)/2;i<=n;i++){
		ans+=f[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 69120
#include<iostream>
#include<vector>
#include<set>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long int

int main()
{
	
     ll a,b,c;
	 cin>>a>>b>>c;
	 
	 ll s=0;
	 
	 s=s+a+b+c;
	 
	 if(s==17)
	 {
	 	
	   cout<<"YES"<<endl; 	
	 	
	 	
	}	
	
	
	
	else
	{
	  	
	   cout<<"NO"<<endl;	
		
		
	}
   
	
	return 0;
	
}

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

/*
  idea : find difference between each adjacent boxes :
  d[i] = a[i+1] - a[i]

  for each "taking", each d[i] is decreased by 1 
  (for example if the box consists 3 balls and 2 balls at beginning, this d[i] = -1
  taking 1 balls at 3 makes it become 2
  taking 2 balls at 2 makes it become 0
  now d[i] becomes -2)

  but for the last box in the taking, the d[i] is no longer decreased by 1, rather it's increased by (n-1) 
  because it's a circular.
  (for example there are 5 total boxes 
  the last box at first has 7 balls and the first box at first has 10 balls. d[i] = 3 at first
  taking 5 balls at 7 makes it become 2
  taking 1 balls at 10 makes it become 9
  now d[i] = 7)
  
  ----------------------

  first, add all balls in total (call it S). In each taking, we take n*(n+1)/2 balls
  therefore, S has to be a multiple of n*(n+1)/2 to be possible

  now assume the number of operation K is S / (n*(n+1)/2), now :
  for each i :
  so for each d[i], we find :
  - how many times it is increased by (n-1)       --> call it x
  - how many times it is decreased by 1           --> call it (K-x)

  therefore : 
  d[i] + x*(n-1) - 1*(K-x) = 0      --> because in the end, to be possible, difference between two adjacent box must be 0
  so :
  d[i] + xn - x - K + x = 0
  d[i] + xn - K = 0
  xn = K - d[i]
  x = (K - d[i]) / n
  
  thus :
  for each i :
    --> K - d[i] must be >= 0
    --> K - d[i] must be multiples of n
  to be POSSIBLE
*/

# define ll long long
int main(){

  ll n, ball[100005];
  cin >> n;
  ll S = 0;
  for(int i=0; i<n; i++){
    cin >> ball[i];
    S += ball[i];
  }

  if(S % (n*(n+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }

  ll K = S / (n*(n+1)/2);
  for(int i=0; i<n; i++){
    ll di = (ball[(i+1)%n] - ball[i]);
    if(K - di < 0 || (K - di)%n != 0){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 4396
[n, m, l] = [int(x) for x in raw_input().split()]

A = []
B = []
counter = 0
while counter < n:
    A.append([int(x) for x in raw_input().split()])
    counter += 1

counter = 0
while counter < m:
    B.append([int(x) for x in raw_input().split()])
    counter += 1

B = list(zip(*B))

for i in range(n):
    data = []
    for j in range(l):
        data.append(sum([x[0] * x[1] for x in zip(A[i], B[j])]))
    print(' '.join([str(x) for x in data]))

Measured memory_bytes: 7112
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long h;
    cin >> h;
    long long cnt=0;
    while(h>1) {
        h=h/2;
        ++cnt;
        if(h==1) break;
    }
    long long ans=0;
    for(long long i=0;i<=cnt;++i) {
        ans+=pow(2,i);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof a)
#define rep(i, a, b) for(int i(a), i##_END_(b); i <= i##_END_; i++) 
#define drep(i, a, b) for(int i(a), i##_END_(b); i >= i##_END_; i--)
using namespace std;
template<class T> inline bool tomax(T &a, T b) {return a < b ? a = b, 1 : 0;}
template<class T> inline bool tomin(T &a, T b) {return b < a ? a = b, 1 : 0;}
typedef long long ll;
typedef double db;


int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", min(a * b, c));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int a,b;
	cin >> a >> b;
	for(int i=0; i<11000; i++){
		int x = i*0.08;
		int y = i*0.1;
		if(x == a && y == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n, p; cin >> n >> p;
    if (n == 0) return;
    vi32 v(n);
    int idx = 0;
    while (true) {
      if (p) v[idx]++, p--;
      else {
        p += v[idx], v[idx] = 0;
      }
      if (p == 0) {
        bool f = false;
        rep(i, n) if (idx != i && v[i] > 0) f = true;
        if (!f) {
          cout << idx << '\n';
          break;
        }
      }
      idx++;
      if (idx >= n) idx -= n;
    }
  }
}



Measured memory_bytes: 3156
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B(x) x.begin(),x.end()
#define B2(x,cmp) x.begin(),x.end(),cmp
#define el endl

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

///ifstream fin("input.txt");
///ofstream fout("output.txt");


bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}

bool cmp(int x, int y)
{
	return x>y;
}
int n,m;
const int N=2e5+10;
vector <int> vv;
vector < vector <int> > adj(N,vv);
vector <int> mark(N,0);
vector <int> scc(N,0);
vector <int> topol;
int now_scc=0;

void dfs(int v)
{
    mark[v-1]=1;
    for (auto i:adj[v-1])
        if (!mark[i-1])
            dfs(i);
    topol.pb(v);
}

void dfs2(int v)
{
    mark[v-1]=1;
    scc[v-1]=now_scc;
    for (auto i:adj[v-1])
        if (!mark[i-1])
            dfs2(i);

}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,j;
	cin >> n >> m;
	int x[m],y[m];
	for (i=0;i<m;i++)
        cin >> x[i] >> y[i], adj[x[i]].pb(y[i]+1);
    for (i=0;i<n;i++)
        if (!mark[i])
            dfs(i+1);
    reverse(topol.begin(),topol.end());
    //adj.erase(adj.begin(),adj.end());
    fill(adj.begin(),adj.end(),vv);
    for (i=0;i<m;i++)
        adj[y[i]].pb(x[i]+1);
    fill(mark.begin(),mark.end(),0);
    /*for (i=0;i<adj.size();i++)
    {
        for (j=0;j<adj[i].size();j++)
            cout << i+1 << ' '<< adj[i][j] << ' ';
        cout << endl;
    }*/
    for (i=0;i<n;i++)
    {
       // cout << topol[i] << endl;
        if (!mark[topol[i]-1])
            now_scc++, dfs2(topol[i]);
    }
    int q;
    cin >> q;
    int a,b;
    for (i=0;i<q;i++)
    {
        cin >> a >> b;
        if (scc[a]==scc[b])
            cout << 1;
        else
            cout << 0;
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 10292
// 16:48 - 16:52
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 100 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

bool vst[N];
pint r[N], b[N];

int main(){
	ios::sync_with_stdio(0);

	int n; cin >> n;
	for(int i=1; i<=n; i++)
		cin >> r[i].fi >> r[i].se;
	for(int i=1; i<=n; i++)
		cin >> b[i].fi >> b[i].se;
	sort(r+1, r+n+1);
	sort(b+1, b+n+1);

	int cnt = 0;
	for(int i=1; i<=n; i++){
		int id = 0;
		for(int j=1; j<=n; j++)
			if(!vst[j] && r[j].fi < b[i].fi && r[j].se < b[i].se)
				if(r[j].se >= r[id].se)
					id = j;
		if(!id) continue;
		vst[id] = 1;
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update> ost;
// name.find_by_order(x) or name.order_of_key(x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;

void yes() {printf("YES\n");}
void no() {printf("NO\n");}

int dx4[] = {-1, 1, 0, 0};
int dy4[] = {0, 0, -1, 1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int maxn = 2e5 + 5, maxv = 2e6 + 5;
const int MOD = 1e9 + 7;

int mult(ll a, ll b) {return (a * b) % MOD;}
int pot(int n, int k) {
	int ret = 1, pot = n;
	for(;k > 0;k >>= 1, pot = mult(pot, pot)) 
		ret = mult(ret, (k & 1) ? pot : 1);
	return ret;
}
int divide(int a, int b) {return mult(a, pot(b, MOD - 2));}
int add(int a, int b) {a += b;if(a >= MOD) a -= MOD;return a;}
int sub(int a, int b) {a -= b;if(a < 0) a += MOD;return a;}

vector<int> fact;
void calc_fact(int n) {
	fact = vector<int>(n + 1, 1);
	for(int i = 1;i <= n;i++) fact[i] = mult(fact[i - 1], i);
}
int choose(int n, int k) {return divide(fact[n], mult(fact[n - k], fact[k]));}

bool prime(ll a) {
	if (a == 1) return 0;
	for(ll i = 2;i * i <= a;i++) 
		if (a % i == 0) return 0;
	return 1;
}

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

ll phi(ll x) {
	double ret = x;
	for(ll i = 2;i * i <= x;i++) {
		if (x % i) continue;
		ret *= (1.0 - 1.0 / (double)i);
		while (x % i == 0) x /= i;
	}
	if (x > 1) ret *= (1.0 - 1.0 / (double)x );
	return (ll)ret;
}

void solve() {
	string s;
	cin >> s;
	if(s[s.size() - 1] == 's') s += 'e';
	s += 's';
	printf("%s\n", s.c_str());
}

int main() {
	int t = 1;
	//scanf("%d", &t);
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3620
X, K, D = list(map(int, input().split()))
X = abs(X)
step = int(X / D)

if step > K :
  print(X - D * K)

else :
  if (K-step)%2 == 0 :
    print(X - D * step)
  else :
    print(abs(X - D * (step + 1)))

Measured memory_bytes: 9180
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

        int X = in.nextInt();
        List<Integer> primeNumbers = new ArrayList<>();
        primeNumbers.add(2);

        int num = (X - 3) / 2;
        int[] primeList = new int[num];
        for (int i = 0; i < num; i++) {
            primeList[i] = 1;
        }
        for (int i = 0; i < num; i++) {
            if (primeList[i] == 1) {
                int primeNum = i + i + 3;
                // 遅くなるのでコメントアウト
                primeNumbers.add(primeNum);
                for (int j = i + primeNum; j < num; j += primeNum) {
                    primeList[j] = 0;
                }
            }
        }

        if(X == 2) {
        	System.out.println(2);
        	return;
        }

        if(X % 2 == 0) {
        	X++;
        }

        while(true) {
            boolean b = false;
        	for(int p: primeNumbers) {
        		if (X % p == 0) b = true;
        	}
        	if (b) {
        		X += 2;
        	} else {
        		break;
        	}
        }

        System.out.println(X);
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 24020
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
vector<int>color[maxn];
typedef pair<int,int>PII;
map<PII,int>ans;
vector<PII>bc;
bool st[maxn];
int mx=0;
int cs[maxn];
vector<int>G[maxn];
void bfs(int x) {
	int rs=1;
	queue<int>q;
	q.push(x);
	st[x]=1;
	while(q.size()) {
		int t=q.front();
		mx=max(mx,(int)G[t].size());
		q.pop();
		rs=1;
		for(auto j:G[t]) {
			if(st[j]) continue;
			if(rs==cs[t]) rs++; 
			cs[j]=rs;
			ans[{t,j}]=rs;
			ans[{j,t}]=rs++;
			st[j]=1;
			q.push(j);
		}
	}
}
int Xiaobo()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++) {
		int a,b;
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
		bc.push_back({a,b});
	}
	bfs(1);
	cout<<mx<<'\n';
	for(auto item:bc) {
		cout<<ans[item]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 27380
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
A = LI()

# hyoten = [1] * (N-K+1)

# for i in range(N-K+1):
#     for q in range(K):
#         hyoten[i] *= A[i+q]


# for j in range(len(hyoten)-1):
#     if (hyoten[j+1]>hyoten[j]):
#         print('Yes')
#     else:
#         print('No')

for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 31620
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (n) => {
  // ...
  let current = undefined
  let max = 0
  let z = []
  n.map((r, i) => {
    if (current === undefined) {
      z[i] = 0
      current = r
      return
    }
    // let before = n[i - 1]
    if (r > current) {
      z[i] = 0
    } else {
      z[i] = z[i - 1] + 1
      max = Math.max(z[i], max)
    }
    current = r
  })
  // console.log(z)
  return max
}
const main = (input) => {
  const [h, r] = input.split("\n")
  return solve(r.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}


Measured memory_bytes: 29804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

struct POS {
	int x, y;
	int c;

	bool operator<(const POS& r)const {
		if(min(x, y) != min(r.x, r.y))return min(x,y) < min(r.x,r.y);
		return max(x, y) < max(r.x, r.y);
	}
};

bool sort_(const POS& l, const POS& r) {
	if (max(l.x, l.y) != max(r.x, r.y))return max(l.x, l.y) > max(r.x, r.y);
	return min(l.x, l.y) > min(r.x, r.y);
}

int main() {

	vector<POS>pos;

	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		pos.push_back(POS({ a, b, 0 }));
	}

	for (int i = 0; i < n; i++) {
		int c, d;
		cin >> c >> d;
		if (c == 0 || d == 0)continue;
		pos.push_back(POS({ c, d, 1 }));
	}
	sort(pos.begin(), pos.end());

	int ans = 0;
	vector<POS>red;
	for (int i = 0; i < pos.size(); i++) {
		int x, y;
		x = pos[i].x;
		y = pos[i].y;
		int c = pos[i].c;

		if (c == 0) {
			red.push_back(POS({ x,y,0 }));
		}
		else {
			sort(red.begin(), red.end(), sort_);
			for (int j = 0; j < red.size(); j++) {
				if (x > red[j].x && y > red[j].y) {
					ans++;

					red.erase(red.begin() + j);
					break;
				}
			}
		}
	}

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
int main() {
    int N;
    cin>>N;
    vi A(N);
    for (int i = 0; i < N; i++)cin>>A[i];
    vi B=A;
    sort(B.begin(),B.end());
    int first=B[N-1],second=B[N-2];
    for (int i = 0; i < N; i++){
        if(A[i]==first)cout<<second<<endl;
        else cout<<first<<endl;
    }
}

Measured memory_bytes: 4824
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)


bool g[10][10];
int perm[10];

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a][b] = true;
    g[b][a] = true;
  }
  
  REP(i, n)
    perm[i] = i;
  int res = 0;
  do {
    if(perm[0] != 0)
      continue;
    bool ok = true;
    REP(i, n-1) {
      if (g[perm[i]][perm[i+1]] == false) {
        ok = false;
        break;
      }
    }
    if (ok)
      ++res;
  } while (next_permutation(perm, perm + n));
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func DecimalDigitSum(x int) int {
	ret := 0
	for x > 0 {
		ret += x % 10
		x /= 10
	}
	return ret
}

func Harshad(x int) bool {
	return x%DecimalDigitSum(x) == 0
}

func main() {
	var n int
	fmt.Scanln(&n)
	if Harshad(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int l , r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r;i++) if(i%d==0) ans++;
		cout << ans;
}

Measured memory_bytes: 3644
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

H,W=get_i
a=array(H)
H.times do|i|
    a[i]=get_nsp
end
Dir_=[[1,0],[0,1]]
def bfs(map)
    visit=array(W,0,H)
    visit[0][0]=1
    queue=[]
    queue.push([0,0])
    until queue==[]
        cur=queue.shift
        visit[cur[1]][cur[0]]=1
        Dir_.each do|x,y|
            nx=cur[0]+x
            ny=cur[1]+y
            next unless nx.between?(0,W-1) and ny.between?(0,H-1) and map[ny][nx]=="#" and visit[ny][nx].zero?
            queue.push([nx,ny])
            break
        end
    end
    return visit
end
visit=bfs(a)
flag=true
H.times do|i|
    W.times do|j|
      if a[i][j]=="#" and visit[i][j]!=1
          flag=false
          break
      end
    end
end
puts yn_judge(flag,"Possible","Impossible")

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
const int maxn=3e5+10;
struct point {
    int x,y;
}p[maxn];
map<int,int>xcnt,ycnt;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int x,y,maxr=0,maxc=0;
    for(int i=1; i<=k; i++){
        cin>>x>>y;
        p[i]={x,y};
        xcnt[x]++,ycnt[y]++;
        maxr=max(maxr,xcnt[x]),maxc=max(maxc,ycnt[y]);
    }
    int num1=0,num2=0;
    for(auto tmp:xcnt)if(tmp.second==maxr)num1++;
    for(auto tmp:ycnt)if(tmp.second==maxc)num2++;
    int cnt=0;
    for(int i=1; i<=k; i++){
        x=p[i].x,y=p[i].y;
        if(xcnt[x]==maxr&&ycnt[y]==maxc)cnt++;
    }
    if(cnt==num1*num2)cout<< (maxc+maxr-1) <<endl;
    else cout<< (maxc+maxr) <<endl;
    return 0;
}


Measured memory_bytes: 34132
n = int(input())
a = []
b = []
for i in range(n):
  x,y = map(int, input().split())
  a.append(x+y)
  b.append(x-y)
a.sort()
b.sort()

ans = a[-1]-a[0]
c = b[-1]-b[0]
print (max(ans,c))


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

double dp[3000][3000]; // i回目までで表がj回でる確率
int main(){
    int n;
    cin >> n;
    double p[n];
    for(int i = 0; i < n; i++) cin >> p[i];
    dp[0][0] = 1.0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            // 表
            dp[i+1][j+1] += dp[i][j] * p[i];
            // 裏
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0.0;
    for(int i = n / 2 + 1; i <= n; i++) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 68864
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main(){
  int n,q;
  string s;
  cin>>n>>q>>s;
  int l[q],r[q];
  for(int i=0;i<q;i++){
    cin>>l[i]>>r[i];
  }
  int sum[n+10];
  sum[0]=0;
  for(int i=1;i<n;i++){
   sum[i]=sum[i-1];
   if(s.at(i)=='C'&&s.at(i-1)=='A'){
     sum[i]++;
   }
  }
  for(int i=0;i<q;i++){
    cout<<sum[r[i]-1]-sum[l[i]-1]<<endl;
  }
}

Measured memory_bytes: 2176
import sys

def solve():
    input = sys.stdin.readline
    R, C, K = map(int, input().split())
    item = [[0 for _ in range(C)] for r in range(R)]
    for _ in range(K):
        r, c, k = map(int, input().split())
        item[r-1][c-1] = k
    
    DP = [[[-1 for _ in range(C)] for r in range(R)] for i in range(4)]
    DP[0][0][0] = 0
    for r in range(R):
        for c in range(C):
            for i in range(4):
                if DP[i][r][c] > -1:
                    if r + 1 < R: 
                        DP[0][r+1][c] = max(DP[0][r+1][c], DP[i][r][c])
                    if c + 1 < C: 
                        DP[i][r][c+1] = max(DP[i][r][c+1], DP[i][r][c])
                    if i < 3 and item[r][c] > 0:
                        if r + 1 < R: DP[0][r+1][c] = max(DP[0][r+1][c], DP[i][r][c] + item[r][c])
                        if c + 1 < C: DP[i+1][r][c+1] = max(DP[i+1][r][c+1], DP[i][r][c] + item[r][c])

    ans = DP[3][R-1][C-1]
    for i in range(3): ans = max(ans, DP[i][R-1][C-1] + item[R-1][C-1])
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 462520
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;

int main(){
	int k, s;
	cin >> k >> s;

	int count = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <=k; j++) {
			int l = s - i - j;
				if (l >=0 && l<=k) {
					count++;
				}
		}
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
最大10000マス
1000の連結

5 4
.#.
#.#
.#.

4 1
.#.
###
.#.

4 3
##.
#.#
.#.

#######
#.#.#.#
#######
#######
.......
#.#.#.#
.......
#.#.#.#.
100*50
こんなかんじでいけるかも
100=1行2列に50個
いけるじゃん！
*/
int main(){
  ll A,B; cin>>A>>B;
  A--; B--;
  vector<vector<char>> Z(100,vector<char>(100,'.'));
  for(ll i=0; i<50; i++) for(ll j=0; j<100; j++) Z[i][j]='#';
  ll i=0,j=0;
  while(A>0){
    Z[i][j]='.';
    A--;
    j+=2;
    if(j==100){
      j=0;
      i+=2;
    }
  }
  i=99,j=0;
  while(B>0){
    Z[i][j]='#';
    B--;
    j+=2;
    if(j==100){
      j=0;
      i-=2;
    }
  }
  cout<<"100 100"<<endl;
  for(ll i=0; i<100; i++){
    for(ll j=0; j<100; j++)cout<<Z[i][j];
    cout<<endl;
  }
}

Measured memory_bytes: 256
H,W = map(int,raw_input().split())
M = [map(int,list(raw_input())) for i in range(H)]
for h in range(H):
	for w in range(W):
		if 0 < w  and 0 < h:
			M[h][w] += min(M[h-1][w],M[h][w-1])
		elif w == 0 and 0 < h:
			M[h][w] += M[h-1][w]
		elif 0 < w and h == 0:
			M[h][w] += M[h][w-1]
print M[H-1][W-1]

Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x[5];
    int index;
    for(int i=0;i<5;i++)
       {
           cin>>x[i];
           if(x[i]==0) index=i+1;
       }
    printf("%d\n",index);
    return 0;

}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<ll> a(N);
    ll tmp = 0;
    Rep(i,N){
        Scll(a[i]);
        a[i] -= i+1;
    }

    sort( a.begin(), a.end() );
    Rep(i,N){
        tmp += a[i] - a[0];
    }
    ll ans = tmp;
    Repe(i,N,1){
        tmp -= (a[i] - a[i-1]) * ( N-i*2 );
        ans = min( ans, tmp );
    }

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

    return 0;
}



Measured memory_bytes: 1792
"use strict";
const stringToIntDecimal = s => parseInt(s);

const readData = input => {
  const numberArray = input.split(" ").map(stringToIntDecimal);

  return {
    n: numberArray[0],
    k: numberArray[1]
  };
};

const calcRequiredChallengeCount = (point, k) => {
  let count = 0;

  while (point < k) {
    point <<= 1;
    count += 1;
  }

  return count;
};

const calcProbability = data => {
  let probability = 0;
  const n = data.n;
  const k = data.k;

  for (let i = 1; i <= n; i += 1) {
    const challengeCount = calcRequiredChallengeCount(i, k);
    probability += 1 / Math.pow(2, challengeCount);
  }

  return probability / n;
};

function Main(input) {
  let data = readData(input);
  console.log(calcProbability(data));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<stdio.h>
int partition(int *,int,int);
int main(){
	int n,x,i,k=-1;
	scanf("%d",&n);
	int A[n];
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	k=partition(A,0,n-1);
for(i=0;i<n;i++){
		if(i==n-1 && i!=k) printf("%d",A[i]);
		else if(i!=n-1 && i!=k) printf("%d ",A[i]);
		else if(i!=n-1 && i==k) printf("[%d] ",A[i]);
		else printf("[%d]",A[i]);
	}
printf("\n");
	return 0;
}

int partition(int *a,int p,int r){
	int x,i,j,k;
	x=a[r];
	i=p-1;
	for(j=p;j<r;j++){
		if(a[j]<=x){
			i=i+1;
			k=a[i];
			a[i]=a[j];
			a[j]=k;
		}
	}
	a[r]=a[i+1];
	a[i+1]=x;
	return i+1;
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll kaijo[200010];

void init() {
	kaijo[0] = 1;
	for (ll i = 1;i < 200010;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	//if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}

int main(void){
    init();
    ll n,m,k;
    cin>>n>>m>>k;
    ll sum1=0,sum2=0;
    for(ll d=1;d<=n-1;d++){
        sum1=(sum1+d*(n-d)*m*m%N)%N;
    }
    for(ll d=1;d<=m-1;d++){
        sum2=(sum2+d*(m-d)*n*n%N)%N;
    }
    cout<<(Comb(n*m-2,k-2)*((sum1+sum2+N)%N)%N+N)%N<<endl;
    return 0;
}

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

typedef struct node Node;

struct node{
  double val;
  Node *lft,*rht;
};

Node* Insert(Node*,double);
void PrintInOrder(Node*);
void PrintPreOrder(Node*);

int main(int argc,char* argv[]){
  int n;
  double x;
  string str;
  Node *root=NULL;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str;

    switch(str[0]){
    case 'i':
      cin>>x;
      root=Insert(root,x);
      break;
    case 'p':
      PrintInOrder(root); cout<<endl;
      PrintPreOrder(root); cout<<endl;
      break;
    }
  }

  return 0;
}

Node* Insert(Node *p,double x){
  if(p == NULL){
    Node *q = new Node;
    q->val=x;
    q->lft = q->rht = NULL;
    return q;
  }
  else if(x < p->val)
    p->lft = Insert(p->lft,x);
  else
    p->rht = Insert(p->rht,x);

  return p;
}

void PrintInOrder(Node *p){
  if(p != NULL){
    PrintInOrder(p->lft);

    cout<<" "<<p->val;

    PrintInOrder(p->rht);
  }
}

void PrintPreOrder(Node *p){
  if(p != NULL){
    cout<<" "<<p->val;

    PrintPreOrder(p->lft);
    PrintPreOrder(p->rht);
  }
}

Measured memory_bytes: 16920
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))

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; }
typedef long long ll;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  ll T=1, A=1;
  for(int i=0; i<N; i++) {
    ll t, a; std::cin >> t >> a;
    ll n = std::max( dup(A,a), dup(T,t) );
    A = n*a;
    T = n*t;
  }
  std::cout << T + A << std::endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int h;

void maxHeapify(vi &a,int i){
    int l=i*2;
    int r=l+1;
    int largest;
    if(l<=h&&a[l]>a[i])
        largest=l;
    else
        largest=i;
    if(r<=h&&a[r]>a[largest])
        largest=r;
    if(largest!=i){
        swap(a[i],a[largest]);
        maxHeapify(a,largest);
    }
}

void buildMaxHeap(vi &a){
    for(int i=h/2;i>=1;i--){
        maxHeapify(a,i);
    }
}

void run(){
    cin>>h;
    vi a(h+1);
    REP(i,1,h)cin>>a[i];
    buildMaxHeap(a);
    REP(i,1,h){
        cout<<" "<<a[i];
    }
    cout<<endl;
}


Measured memory_bytes: 6656
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

vector<int> enum_div(int n) {
   vector<int> ret;
   for (int i=1 ; i*i<=n ; ++i) {
      if (n%i == 0) {
         ret.push_back(i);
         if (i!=1 && i*i!=n) {
            ret.push_back(n/i);
         }
      }
   }
   return ret;
}

int main() {
   int N;
   cin >> N;
   int a[N];
   int flg[N];
   memset(flg, 0, sizeof(flg));
   vector<int> ansv;
   for (int i = 0; i < N; i++) cin >> a[i];
   for (int i = N; i > 0; i--) {
      vector<int> tmp = enum_div(i);
      if (flg[i - 1] % 2 != a[i - 1]) {
         ansv.push_back(i);
         for (auto& n : tmp) flg[n - 1] += 1;
      }
      tmp.clear();
   }
   cout << (int)ansv.size() << endl;
   for (auto& n : ansv) cout << n << " ";
   return 0;
}


Measured memory_bytes: 3064
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
ls = []
A_ = []
B_ = []
for i in range(N):
    A, B = map(int, raw_input().split())
    A_.append(A)
    B_.append(B)
    ls.append((A, 'A', i))
    ls.append((B, 'B', i))

ls.sort()

used = [[False] * N, [False] * N]

S = 0
for i in range(N):
    p = ls[i]
    S += p[0]
    if p[1] == 'A':
        used[0][p[2]] = True
    else:
        used[1][p[2]] = True

if True in used[0] and True in used[1]:
    pass
else:
    print S
    exit()

for i in range(N):
    if used[0][i] and used[1][i]:
        print S
        exit()

ans = INF
for i in range(N):
    T = S
    pos = N
    if ls[pos][2] == i:
        pos += 1
    if used[0][i]:
        T -= A_[i]
        T += ls[pos][0]
    else:
        T -= B_[i]
        T += ls[pos][0]
    ans = min(ans, T)

print ans

Measured memory_bytes: 79260
import sys
for i in range(sys.maxsize):
    c=0
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        for j in range(1,n+1):
            for k in range(j+1,n+1):
                for l in range(k+1,n+1):
                    if  j+k+l==x:
                        c+=1
    print(c)


Measured memory_bytes: 5600
try:
    a=""
    while True:
        S=input()
        if not S:
            break
        S=S.lower()
        a=a+S
except EOFError:
    pass
for i in range(97,97+26):
    b=a.count(chr(i))
    print(chr(i)+" : "+str(b))


          

Measured memory_bytes: 7428
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

string S;
int len;
long long ans = 0;

long long dfs(int p, long long a, long long b) {
  if (len <= p) {
    ans += (a + b);
    return 0;
  }


  dfs(p + 1, (S[p]-'0')+10*a, b);
  dfs(p + 1, S[p]-'0', a+b);
}

int main(int argc, char *argv[])
{
  cin >> S;
  len = S.size();
  dfs(1, S[0]-'0', 0);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import math
from collections import Counter

MOD=10**9+7
N,M=map(int, input().split())

factor=[]
for f in range(2, math.ceil(math.sqrt(M))):
	while M % f == 0:
		factor.append(f)
		M //= f
if M > 1:
	factor.append(M)

def F(n):
	if n == 1:
		return n
	return n * F(n-1)

def G(n, k):
	if k == 1:
		return n
	return n * G(n-1, k-1)

def H(n, k):
	return G(n+k-1, k) // F(k)

ans = 1
for c in Counter(factor).values():
	ans *= H(N, c)
	ans %= MOD

print(ans)


Measured memory_bytes: 38640