akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<fstream>
#include<vector>
#include<string>
#include<iostream>
#include<math.h>



using namespace std;

int main(void){

    int A, B, K;
    int A_divided, B_divided;
    int A_modified, B_modified;

    vector<int> vnumbers;

    int counter = 0;
    int i;


    cin >> A >> B >> K;

    for(i = 1; i <= A && i <= B; i++){

        A_divided = A / i;
        B_divided = B / i;

        
        A_modified = A_divided * i;
        B_modified = B_divided * i;





        if(A == A_modified && B == B_modified ){
            counter++;
            vnumbers.push_back(i);
        }
    }


    cout << vnumbers.at(counter - K) << endl;

    return 0;
}

Measured memory_bytes: 256
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

MOD = 10**9 + 7
P = 97
def solve(N, S):
    A = [0]
    rawA = []
    #powers = []
    ha = 0
    #pwr = 1
    for c in S:
        x = ord(c) - ord('a') + 2
        rawA.append(x)
        #ha += x * pwr
        #ha %= MOD
        #powers.append(pwr)
        ha += x
        A.append(ha)
        #pwr *= P
        #pwr %= MOD
    #powers.append(pwr)

    def gethash(i, j):
        ha = A[j] - A[i]
        #ha *= pow(powers[i-1], MOD-2, MOD)
        ha %= MOD
        #print 'gh', i,j, ';', ha
        return ha

    # A
    #print 'g1',gethash(2, 2+5)
    #print 'g2', gethash(8, 8+5)
    
    def doublematch(L):
        if L == 0: return True
        for i in xrange(N - L + 1):
            for j in xrange(i + L, N - L + 1):
                if gethash(i, i+L) == gethash(j, j+L) and rawA[i:i+L] == rawA[j:j+L]:
                    return True

    #print map(doublematch, range(len(A)))
    lo, hi = 0, len(A) / 2
    while lo < hi:
        mi = (lo + hi + 1) / 2
        if doublematch(mi):
            lo = mi
        else:
            hi = mi - 1
    return lo

print solve(rri(), rr())


Measured memory_bytes: 61992
def good_contest(num):
  return len(set(str(num))) == 1


def find_good_contest(next_contest):
  while not good_contest(next_contest):
    next_contest += 1
  return next_contest


def main():
  print(find_good_contest(int(input())))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int MAXN = 500010;

int n, st[MAXN], col[MAXN], top;
void add() {
	if (st[top] > 1 && st[top - 1] != st[top] - 1) {
		st[top + 1] = st[top];
		col[top + 1] = col[top];
		--st[top]; ++top;
	}
	++col[top];
}
int A[MAXN];
bool judge(int cnt) {
	int lst = 0;
	memset(st, 0, top + 1 << 2);
	memset(col, 0, top + 1 << 2);
	top = 0;
	for (int i = 1, t; i <= n; ++i) {
		t = A[i];
		if (lst < t) {
			if (!top || col[top] != 0) st[++top] = t, col[top] = 0;
			else st[top] = t;
		} else {
			int k = -1;
			while (st[top] > t) k = col[top], --top;
			if (st[top] != t) st[++top] = t, col[top] = k;
			if (cnt > 1) {
				add();
				while (top && col[top] >= cnt) {
					int at = st[top]; --top;
					if (st[top] + 1 != at)
						st[++top] = at - 1;
					add();
				}
			} else top = 0, col[0] = 1;
			if (col[0]) return false;
			if (st[top] != t) st[++top] = t, col[top] = 0;
		}
		lst = t;
	}
	return true;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i];
	int l = 1, r = n, ans = 0;
	while (l <= r) {
		int mid = l + r >> 1;
		if (judge(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin>>n>>m;
    Vec a(n);
    priority_queue<int, vector<ll>, function<bool(ll, ll)>> q([](ll a, ll b)->int {
        return a<b;
    });
    rep(i, n) {
        cin>>a[i];
        q.push(a[i]);
    }

    while (m--) {
        ll now=q.top();
        q.pop();
        q.push(now/2);
    }

    ll ans=0;
    while (!q.empty()) {
       // dbg(q.top());
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int):
    n = N%10
    if (n==0) or (n==1) or (n==6) or (n==8):
        print('pon')
    elif (n==3):
        print('bon')
    else:
        print('hon')
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27112
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = false;

int main(void) {
    string s;
    cin >> s;
    int beg, end;
    beg = end = -1;
    for (int pos = 0;; ++pos) {
        if (s[pos] == 'A') {
            beg = pos;
            break;
        }
    }
    for (int pos = s.size()-1;; --pos) {
        if (s[pos] == 'Z') {
            end = pos;
            break;
        }
    }

    cout << (end - beg + 1) << endl;

    return 0;
}


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

using namespace std;

int main() {
	double a[2], b[2];
	double d;
	cin >> a[0] >> a[1] >> b[0] >> b[1];
	d = sqrt(pow(b[0]-a[0],2) + pow(b[1]-a[1],2));
	printf("%.8f\n",d);
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
//#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int vtoi(vi v){
	int ret = 0, p = 1;
	for(int i = 0; i < v.size(); i++){
		ret += v[i] * p;
		p *= 8;
	}
	return ret;
}

vi itov(int n){
	vi ret(8, 0);
	int idx= 0;
	while(n > 0){
		ret[idx] = n % 8;
		n /= 8;
		idx++;
	}
	return ret;
}

vector<int> get_nexts(vi v){
	vi ret;
	for(int i = 0; i < v.size(); i++){
		if(v[i]!=0) continue;
		if(i % 4 != 0){
			swap(v[i], v[i-1]);
			ret.pb(vtoi(v));
			swap(v[i], v[i-1]);
		}
		if(i % 4 != 3){
			swap(v[i], v[i+1]);
			ret.pb(vtoi(v));
			swap(v[i], v[i+1]);
		}
		if(i /4 == 0){
			swap(v[i], v[i+4]);
			ret.pb(vtoi(v));
			swap(v[i], v[i+4]);
		}
		else{
			swap(v[i], v[i-4]);
			ret.pb(vtoi(v));
			swap(v[i], v[i-4]);
		}
		return ret;
	}
	return ret;
}

map<int, int> mp;

void print(vi v){
	for(int i = 0; i < v.size(); i++){
		cout<<" "<<v[i];
	}
	cout<<endl;
}

int main(){
	vi a(8);
	rep(i, 8) a[i] = i;
	queue<pii> q;
	q.push(pii(0, vtoi(a)));
	mp[vtoi(a)] = 0;
	pii p;
	int c, t;
	vi nexts;
	while(!q.empty()){
		p = q.front(); q.pop();
		a = itov(p.se);
		c = p.fi;
		nexts = get_nexts(a);
		for(int i = 0; i < nexts.size(); i++){
			t = nexts[i];
			if(mp.find(t) != mp.end()) continue;
			mp[t] = c + 1;
			q.push(pii(c + 1, t));
			//print(itov(t));
		}
	}
	//cout<<mp.size()<<endl;
	vi d(8);
	while(cin>>d[0]){
		rep(i, 7) cin>>d[i+1];
		cout<<mp[vtoi(d)]<<endl;
	}
}

Measured memory_bytes: 2168
//diverta22019_c.cpp
//Sat Jun 15 20:50:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	sort(a,a+n,greater<int>());

	P ans[n-1];
	int pcount = 0;
	priority_queue<int> plus;
	priority_queue<int> minus;
	int maxnum = a[0];
	int minnum = a[n-1];
	for (int i=1;i<n-1;i++){
		if (a[i]>0){
			ans[pcount].first = minnum;
			ans[pcount].second = a[i];
			pcount++;
			minnum = minnum-a[i];
		}else if (a[i]<0){
			ans[pcount].first = maxnum;
			ans[pcount].second = a[i];
			pcount++;
			maxnum = maxnum-a[i];
		}else {
			ans[pcount].first = maxnum;
			ans[pcount].second = a[i];
			pcount++;
		}
	}

	ans[pcount].first = maxnum;
	ans[pcount].second = minnum;
	int lastans = maxnum-minnum;

	cout << lastans << endl;

	for (int i=0;i<n-1;i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3072
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		String[][] square = new String[H+2][W+2];
		for(int i =1;i<=H;i++){
			String s = sc.nextLine();
			for(int j =1;j<=W;j++){
				square[i][j] =s.substring(j-1,j);

			}
		}
		int flg = 0;
		for(int i =1;i<=H;i++){
			for(int j =1;j<=W;j++){
				if(square[i][j].equals("#")){
					int a=1,b=1,c=1,d=1;
					if(square[i-1][j]!=null){
						if(square[i-1][j].equals("#")){
							a =0;
						}
					}
					if(square[i+1][j]!=null){
						if(square[i+1][j].equals("#")){
							b =0;
						}
					}
					if(square[i][j-1]!=null){
						if(square[i][j-1].equals("#")){
							c =0;
						}
					}
					if(square[i][j+1]!=null){
						if(square[i][j+1].equals("#")){
							d =0;
						}
					}
					if(a==0||b==0||c==0||d==0){

					}else{
						flg =1;
					}
				}

			}
		}
		if(flg==1){
			System.out.println("No");
		}else if(flg==0){
			System.out.println("Yes");
		}
	}

}


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

#define MAX 100

int N;
long long T[MAX];

long long gcd( long long u, long long v )
{
	long long r;
	while ( v != 0 ) {
		r = u % v;
		u = v;
		v = r;
	}
	return u;
}

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

	sort( T, T + N );
	long long ans = T[N - 1];
	for( int i = 0; i < N - 1; i++ ) {
		if( ans % T[i] == 0 ) {
		}
		else {
			ans *= T[i] / gcd( ans, T[i] );
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int H,W;
    H = s.nextInt();
    W = s.nextInt();
    String[] str = new String[H];
    for(int i = 0; i < H; i++){
      //for(int j = 1; i < W++){
        str[i] = s.next();
      //}
    }
    for(int i = 0; i < H; i++){
      //for(int j = 1; i < W++){
        System.out.println(str[i]);
        System.out.println(str[i]);
      //}
    }
  }
}

Measured memory_bytes: 24340
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<<endl;
int a[N];
int main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	cin >> n;
	for(int i = 1;i <= n;i++) {
		cin >> a[i];

	}
	sort(a+1,a+n+1);
	int it = lower_bound(a+1,a+n+1,a[n]/2) - a;
	if(it == n) {
		it--;
	}
	m = a[n];
	int r1 = a[it];
	int r2 = a[it-1];
	// cout << r1 << " " << r2 << endl;
	int r = it;
	if(abs(r1 - (m-r1)) > abs(r2 - (m-r2))) {
		r = it-1;
	}
	cout << a[n] << " " << a[r] << endl;

}

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

int main() {
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int A,B,K;
  cin>>A>>B>>K;

  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2!=0){
        A-=1;
      }
      B+=A/2;
      A/=2;
    }else{
      if(B%2!=0){
        B-=1;
      }
      A+=B/2;
      B/=2;
    }
    //cout<<A<<' '<<B<<endl;
  }
  cout<<A<<' '<<B<<endl;
}


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

const int N = 100005; 

using namespace std; 

vector< int > e[N]; 

int n, m; 
bool oddCircle; 
int col[N], cnt[2];

queue<int> q;  

void bfs(int s) {

	for(int i=1; i<=n; ++i) col[i] = -1; 
	q.push(s); col[s] = 0;

	while(!q.empty()) {
		int u = q.front();
		++cnt[col[u]]; 
		int eSize = e[u].size();
		for(int k=0; k<eSize; ++k) {
			int v = e[u][k];
			if(col[v] == -1) col[v] = col[u]^1, q.push(v); 
			else if(col[v] == col[u]) { oddCircle = 1; return ; }
		}
		q.pop(); 
	}

}

int main() {

	int u, v; 

	scanf("%d%d", &n, &m); 
	for(int i=1; i<=m; ++i) {
		scanf("%d%d", &u, &v); 
		e[u].push_back(v); 
		e[v].push_back(u); 
	}

	bfs(1); 

	if(oddCircle) printf("%lld\n", 1ll*n*(n-1)/2 - m); 
	else printf("%lld\n", 1ll*cnt[0]*cnt[1] - m); 

	return 0; 

}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<vector>
#include<set>
using namespace std;
#define MAXN 200010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define eps 1e-8
ll fac[MAXN],ine[MAXN];
int n,m,x,y;
ll ans;
ll C(int n,int m){
	return fac[n]*ine[m]%MOD*ine[n-m]%MOD;
}
int main(){
	int i;
	cin>>n>>m>>x>>y;
	fac[0]=ine[0]=ine[1]=1;
	for(i=1;i<MAXN;i++){
		fac[i]=fac[i-1]*i%MOD;
	}
	for(i=2;i<MAXN;i++){
		ine[i]=(MOD-MOD/i)*ine[MOD%i]%MOD;
	}
	for(i=2;i<MAXN;i++){
		(ine[i]*=ine[i-1])%=MOD;
		
	}
	for(i=y+1;i<=m;i++){
		(ans+=C(n-x+i-2,i-1)*C(x+m-i-1,x-1))%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

/*

*/


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

int main() {
    
    string  n; cin >> n;
    string ans = "No";
    if (n[0] == n[1] && n[1] == n[2]) ans = "Yes";
    if (n[1] == n[2] && n[2] == n[3]) ans = "Yes";
    cout << ans << endl;
    return 0;
}

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

void code()
{
    ll k;
    cin>>k;
    ll ans=0;
    for(ll i=1;i<=k;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            for(ll h=1;h<=k;h++)
            {
                ll temp=__gcd(i,j);
                ans+=__gcd(temp,h);
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <utility>

using namespace std;

int main(){
    int N,M,A[123];
    
    scanf("%d %d",&N,&M);
    
    for(int i=0;i<N;i++) scanf("%d",&A[i]);
    
    for(int k=1;k<=M;k++){
        for(int i=0;i<N-1;i++){
            if(A[i]%k>A[i+1]%k)swap(A[i],A[i+1]);
        }
    }
    
    for(int i=0;i<N;i++) printf("%d\n",A[i]);
    
    return 0;
    
}

Measured memory_bytes: 2712
#include<stdio.h>
#include<string.h>
int main()
{
	char s[202];
	scanf("%s", s);
	long long int k;
	scanf("%lld", &k);
	int i, n = strlen(s);
	if (s[0] != s[n - 1])
	{
		long long int count = 0;
		for (i = 1; i < n - 1; i++)
		{
			if (s[i - 1] == s[i] && s[i] == s[i + 1])
			{
				count++;
				s[i] = 'P';
			}
		}
		for (i = 1; i < n; i++)
		{
			if (s[i] == s[i - 1])
			{
				count++;
				s[i] = 'P';
			}
		}
		printf("%lld\n", k * count);
	}
	else
	{
		for (i = 0; i < n; i++)
			s[i + n] = s[i];
		n *= 2;
		char ss[203];
		for (i = 0; i < n; i++)
			ss[i] = s[i];
		long long int count = 0;
		long long int ans;
		for (i = 1; i < n - 1; i++)
		{
			if (s[i - 1] == s[i] && s[i] == s[i + 1])
			{
				count++;
				s[i] = 'P';
			}
		}
		for (i = 1; i < n; i++)
		{
			if (s[i] == s[i - 1])
			{
				count++;
				s[i] = 'P';
			}
		}
		if (count % 2 == 0)
			ans = k * count / 2;
		else if (s[n - 1] == 'P')
			ans = k / 2 * count + k % 2 * count / 2;
		else
			ans = k * (count + 1) / 2 - 1;
		count = 1;
		ss[0] = 'P';
		for (i = 1; i < n - 1; i++)
		{
			if (ss[i - 1] == ss[i] && ss[i] == ss[i + 1])
			{
				count++;
				ss[i] = 'P';
			}
		}
		for (i = 1; i < n; i++)
		{
			if (ss[i] == ss[i - 1])
			{
				count++;
				ss[i] = 'P';
			}
		}
		if (count % 2 == 0)
		{
			if (ans > k * count / 2)
				ans = k * count / 2;
		}
		else
		{
			if (ans > k / 2 * count + k % 2 * count / 2)
				ans = k / 2 * count + k % 2 * count / 2;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

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

MOD = 998244353
ctr = Counter(X)

if X[0] == 0 and ctr[0] == 1:
    ans = 1
    for i in range(1, max(X) + 1):
        ans *= pow(ctr[i - 1], ctr[i], MOD)
        ans %= MOD
    print(ans)
else:
    print(0)


Measured memory_bytes: 98160
#include<stdio.h>

void main(){
  int N,keta;
  scanf("%d",&N);
  keta=N%10;
  switch(keta){
    case 3:
      printf("bon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon");
      break;
    default:
      printf("hon");
      break;
  } 		
}

Measured memory_bytes: 1736
n, k = map(int, input().split())
v = list(map(int, input().split()))
vv = [0] * (n + 1)
for i in range(n):
    vv[i + 1] = vv[i] + v[i]
sumv = vv[n]
ans = 0
for l in range(n):
    for r in range(l - 1, n):
        c = r - l + 1
        if n - c > k:
            continue
        x = []
        value = sumv - (vv[r + 1] - vv[l])
        for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
        x.sort()
        for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
        ans = max(value, ans)
print(ans)

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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  string answer;
  
  if(k > 1) answer += s.substr(0,k-1);
  if(s.substr(k-1,1) == "A"){
    answer += "a";
  } else if(s.substr(k-1,1) == "B"){
    answer += "b";
  } else if(s.substr(k-1,1) == "C"){
    answer += "c";
  }
  if(k < s.length()) answer += s.substr(k,s.length()-k);
  
  cout << answer << endl;
  return 0;
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define Q 1000000007

int main(void){
  unsigned long n,k,ans;
  cin >> n >> k;
  ans = 1;
  for (int i=0; i<n; i++){
    ans *= k-i;
    ans %= Q;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n, m;
	cin >> n >> m;
	int tot = 0;
	vi v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i], tot += v[i];
	int m1 = 4 * m, x = (tot + m1 - 1) / m1, cnt = 0;
	for(int i = 0; i < n; i++)
		cnt += v[i] >= x;
	if(cnt >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;			
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int cnt = 0;
    for(int i = 1; i < n-1; i++){
        if((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool valid(int A, int B, const string& S)
{
  for (int i = 0; i < S.size(); ++i) { 
    if (i == A) {
      if (S[i] != '-') return false;
    } else {
      if (S[i] < '0' or S[i] > '9') return false;                                   }
  }
  return true;
}                                                                                
int main()
{
  int A, B;                                                                       cin >> A >> B;
  string S;                                                                       cin >> S; 
  cout << (valid(A, B, S) ? "Yes" : "No") << endl;
  return 0;
}                          

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    string S;
    cin >> S;
    if(S.find("AC")==string::npos)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}   

Measured memory_bytes: 256
s = input()
if(s[0]==s[1])and(s[1]==s[2])and(s[2]==s[3]):
    print("No")
elif(s[0]==s[1])and(s[2]==s[3]):
    print("Yes")
elif(s[1]==s[2])and(s[0]==s[3]):
    print("Yes")
elif(s[1]==s[3])and(s[0]==s[2]):
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3064
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	int i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n;
		int arr[200005]{};
		rep(i,0,n-1){
			cin>>j;
			arr[j]++;
		}
		rep(i,1,n+1){
			cout<<arr[i]<<"\n";
		}


	}
	
	return 0;
}

Measured memory_bytes: 4376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXM 1000
#define INF 1000000000
LL a,b,ans;
int main()
{
	scanf("%lld%lld",&a,&b);
	LL G=__gcd(a,b);
	for(LL i=2;i*i<=G;i++)
	if(G%i==0){
		while(G%i==0)G/=i;
		ans++;
	}
	if(G!=1)ans++;
	printf("%lld",ans+1);
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#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 ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yay!" : ":(") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(a, b);
  OK(a <= 8 && b <= 8);

  return 0;
}



Measured memory_bytes: 256
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
  	
  	int n, a, b;
  	cin >> n >> a >> b;
  	cout << min(n * a, b) << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define MOD 998244353
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

int N, M, tot = 0, def[100005][3];
ll cnt = 0, f[100005][2];
map<PII, int> s;

inline void setdef(int x, int y, int v){
	int &defv = def[x][y - x + 1];
	if(defv != -1 && defv != v) puts("0"), exit(0);
	defv = v;
}

int main(){
	getint(N), getint(M), memset(def, 0xff, sizeof(def));
	for(register int i = 1; i <= M; i++){
		int x, y, v; getint(x), getint(y), getint(v);
		if(abs(x - y) < 2) setdef(x, y, v);
		else if(s.find(make_pair(y, x)) != s.end()){
			if(abs(x - y) == 2) setdef(x + y >> 1, x + y >> 1, s[make_pair(y, x)] ^ v);
			else if(s[make_pair(y, x)] ^ v) return puts("0"), 0;
			cnt++, tot++;
		}
		else s[make_pair(x, y)] = v, tot++;
	}
	cnt = (N - 1) * (N - 2LL) / 2 - cnt - (tot - cnt * 2);
	f[1][0] = f[1][1] = 1;
	if(def[1][1] != -1) f[1][def[1][1] ^ 1] = 0;
	for(register int i = 2; i <= N; i++){
		const int u = def[i - 1][2], l = def[i][0];
		if(u != -1 && l != -1){
			f[i][0] = f[i - 1][u ^ l];
			f[i][1] = f[i - 1][u ^ l ^ 1];
		}
		else{
			const ll c = (u == -1) + (l == -1);
			f[i][0] = f[i][1] = (f[i - 1][0] + f[i - 1][1]) * c % MOD;
		}
		if(def[i][1] != -1) f[i][def[i][1] ^ 1] = 0;
	}
	return printf("%lld\n", (f[N][0] + f[N][1]) * fastpow(2, cnt) % MOD), 0;
}

Measured memory_bytes: 6144
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   string a;
   cin>>a;
   string tesa,tesb;
   tesa="";
   tesb="";
   int count=0;
   rep(i,a.size()){
      if(i%2==0){
         tesa+="1";
         tesb+="0";
      }
      else{
         tesa+="0";
         tesb+="1";
      }
   }
   if(a.at(0)=='1'){
      rep(i,a.size()){
         if(a.at(i)!=tesa.at(i)){
            count++;
         }
      }
   }
   else{
      rep(i,a.size()){
         if(a.at(i)!=tesb.at(i)){
            count++;
         }
      }
   }
   cout<<count<<endl;
}



Measured memory_bytes: 768
import sys

def main():
    lines = sys.stdin.readlines()



    for line in lines:
        if len(line) == 0:
            continue
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        # print elems
        last_width_index = int(elems[1]) - 1
        last_height_index = int(elems[0]) - 1
        #print(last_height_index)

        if elems[0] == "0" or elems[1] == "0":
            continue
        for height_ind in range(int(elems[0])):
            width_str = ""
            for width_ind in range(int(elems[1])):
                if height_ind != 0 and height_ind != last_height_index and width_ind != 0 and width_ind != last_width_index:
                    width_str = width_str + "."
                else:
                    width_str = width_str + "#"

            print width_str
        print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 6444
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
const ll mn=1e5+4;
ll p[mn];
const ll klim=32;
ll f[2][klim][mn];
ll solve(ll a, ll go, ll rev) {
	ll origa=a;
	for (ll k=0;k<klim;k++) {
		if (go&(1LL<<k)) {
			a=f[rev][k][a];
		}
	}
	return a;
}
int main() {
	ios_base::sync_with_stdio(false);
	ll n; scanf("%lld",&n);
	for (ll i=0;i<n;i++) scanf("%lld",&p[i]);
	ll L,Q; scanf("%lld %lld",&L,&Q);
	for (ll rev=0;rev<2;rev++) {
		for (ll x=0;x<n;x++) {
			ll px=p[x];
			ll imin=x,imax=n;
			while(imin<imax) {
				ll imid=(imin+imax)/2;
				if (p[imid]<=L+px) imin=imid+1;
				else imax=imid;
			}
			imin--;
			f[rev][0][x]=imin;
			//printf("rev:%lld x:%lld imin:%lld\n",rev,x,imin);
		}
		for (ll k=1;k<klim;k++) {
			for (ll x=0;x<n;x++) f[rev][k][x]=f[rev][k-1][f[rev][k-1][x]];
		}
		reverse(p,p+n);
		for (ll i=0;i<n;i++) p[i]=-p[i];
	}
	for (ll i=0;i<Q;i++) {
		ll a,b; scanf("%lld %lld",&a,&b);
		a--;b--;
		ll rev=0;
		if (a>b) {
			rev=1;
			a=n-1-a;
			b=n-1-b;
		}
		ll imin=0,imax=n+1;
		while(imin<imax) {
			ll imid=(imin+imax)/2;
			if (solve(a,imid,rev)<b) imin=imid+1;
			else imax=imid;
		}
		ll got=solve(a,imin,rev);
		if (got>=b) printf("%lld\n",imin);
		else printf("-1\n");
	}
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

    ll sum = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll mi = ((i - 1) * i / 2) % MOD;
        ll mx = ((n - i + 1 + n) * i / 2) % MOD;
        sum = (sum + (mx - mi + 1) % MOD) % MOD;
    }
    if (sum < 0)
        sum += MOD;

    cout << sum << endl;
}


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

int main() {
  int a,b,k; cin >>a >>b >>k;
  int cnt;
  int ans;
  for (int i=min(a,b); i>0; i--){
    if (a%i==0 && b%i==0){
      cnt++;
      if (cnt==k) ans = i;
    }
  }
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-i-1)
B.sort()
if N%2==0:
  b=(B[N//2]+B[N//2-1])//2
else:
  b=B[N//2]
sad=0
for j in range(N):
  sad=sad+abs(B[j]-b)
print(sad)

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

main() {
  int n; cin >> n;
  vll s(n, 0);
  rep(i, n) {
    int a;
    cin >> a;
    if (i == 0) {
      s[i] = a;
    } else {
      s[i] = s[i - 1] + a;
    }
  }

  vll ans(2, 0);
  rep(i, 2) {
    ll tmp = 0;
    rep(j, n) {
      ll sum = s[j] + tmp;
      if ((i + j) % 2) {
        if (sum <= 0) {
          tmp += 1 - sum;
          ans[i] += abs(1 - sum);
        }
      } else {
        if (sum >= 0) {
          tmp += -1 - sum;
          ans[i] += abs(-1 - sum);
        }
      }
    }
  }
  cout << min(ans[0], ans[1]) << endl;
}

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

cnt = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        cnt[A[i]] += 1
        if cnt[A[i]] > 2:
            print(0)
            exit()
        if cnt[A[i]] == 1:
            ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            cnt[A[i]] += 1
            if cnt[A[i]] > 2:
                print(0)
                exit()
            if cnt[A[i]] == 1:
                ans = (ans * 2) % (10 ** 9 + 7)
        if A[i] == 0:
            cnt[0] += 1
            if cnt[0] > 1:
                print(0)
                exit()
    print(ans)

Measured memory_bytes: 14324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = a[0];
            int K = a[1];
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;
            int x = A.Distinct().Count();

            if (x <= K)
            {
                Console.WriteLine(ans);
                return;
            }
            else
            {
                int[] num = new int[N + 1];
                for (int i = 0; i <= N; i++)
                {
                    num[i] = int.MaxValue;
                }
                for (int i = 0; i < N; i++)
                {
                    if (num[A[i]] == int.MaxValue) num[A[i]] = 1;
                    else num[A[i]]++;
                }

                Array.Sort(num);
                for(int i = 0; i < x - K; i++)
                {
                    ans += num[i];
                }

                Console.WriteLine(ans);
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 37828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		System.out.println(Math.min(a*n, b));
	}

}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int a, b;
	a = n / 100;
	b = n % 100;
	
	if(a < 1 or a > 12)
		if(b < 1 or b > 12)
			cout << "NA";
		else
			cout << "YYMM";
	else
		if(b < 1 or b > 12)
			cout << "MMYY";
		else
			cout << "AMBIGUOUS";
}


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

using lint = long long;

lint n, a[100004], b[100004], h[100004];
lint ans[100004];

map<int, int> mp;

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

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

    lint s = 0;    
    mp[0] = n;
    for (int i=0, k=0; i<n; i++) {
        if (a[i] > k) {
            mp[a[i]] = i;
            k = a[i]; s = 0;
        }
        auto it = mp.lower_bound(a[i]); it--;
        int x = it -> second, y = next(it) -> second;

        ans[y] += a[i] - a[x];
        b[x]++;
    }

    for (auto i=mp.begin(); next(i) != mp.end(); i++) {
        h[next(i)->second] = next(i)->first - i->first;
    }

    s = 0;
    for (int i=n-1; ~i; i--) if (b[i]) {
        s += b[i];
        ans[i] += h[i] * s;
    }

    for (int i=0; i<n; i++) cout << ans[i] << '\n';
}

Measured memory_bytes: 8832
d = dict()
d["a"] = raw_input()
d["b"] = raw_input()
d["c"] = raw_input()

turn = "a"
while True:
    if len(d[turn]) == 0:
        print turn.upper()
        break
    t = d[turn][0]
    d[turn] = d[turn][1:]
    turn = t


Measured memory_bytes: 2696
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace A {
	class main {
		public main() { }
		public static int Main() {
			new main().run();
            return 0;
        }
		void run() {
			Scanner cin = new Scanner();
			bool ck=false;
			while(true) {
				int a = cin.nextInt();
				int b = cin.nextInt();
				if(a==0 && b==0) break;
				while(a%4!=0) a++;
				bool ck2=true;
				if(ck) Console.WriteLine();
				ck=true;
				for(int i=a; i<=b; i+=4) {
					if((i%4==0 && i%100!=0) || i%400==0) {
						Console.WriteLine(i);
						ck2=false;
					}
				}
				if(ck2) Console.WriteLine("NA");
			}
		}
	}

	class Scanner {
		string[] s;
		int i;
		
		char[] cs = new char[] { ' ' };
		
		public Scanner() {
			s = new string[0];
			i = 0;
		}
		public string next() {
			if (i < s.Length) return s[i++];
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return s[i++];
		}
		public int nextInt() {
			return int.Parse(next());
		}
		public long nextLong() {
			return long.Parse(next());
		}
		public double nextDouble() {
			return double.Parse(next());
		}
	}
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define ll long long
#define pr pair<ll,ll>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<pr > Q;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		Q.push_back({ a,i });
	}
	sort(Q.begin(), Q.end());
	for (pr p : Q) {
		cout << p.second+1<<' ';
	}
	return 0;
}

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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 != M2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool **ice;
int answer;
int compus[4][2]{ {0,1},{1,0},{0,-1},{-1,0} };
void road(int, int, int);
int main() {
	int x, y;
	while (cin >> x >> y&&x){ 
		ice = new bool*[x + 2];
		ice[0] = new bool[y + 2]{ 0 };
		ice[x + 1] = new bool[y + 2]{ 0 };
		for (int i = 1; i <= x; ++i) {
			ice[i] = new bool[y + 2]{0};
			for (int j = 1; j <= y; ++j) {
				cin >> ice[i][j];
			}
		}
		answer = 1;
		for (int i = 1; i <= x; ++i) {
			for (int j = 1; j <= y; ++j) {
				road(i, j, 0);
			}
		}
		cout << answer << endl;
		for (int i = 0; i < y + 2; ++i) {
			delete[] ice[i];
		}
	}
	return 0;
}

void road(int x, int y, int sum) {
	if (ice[x][y]==0) {
		if (answer < sum) {
			answer = sum;
		}
		return;
	}
	++sum;
	for (int i = 0; i < 4; ++i) {
		ice[x][y] = 0;
		road(x + compus[i][0], y + compus[i][1], sum);
		ice[x][y] = 1;
	}
}

Measured memory_bytes: 3080