akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int bfs(const string &start) {
	const string goal = "1112131415161700212223242526270031323334353637004142434445464700";

	unordered_map<string, int> dist;
	queue<string> que;
	dist[start] = 0;
	que.emplace(start);

	while(!que.empty()) {
		const string current = que.front();
		que.pop();

		if(current == goal) return dist[current];
		const int next_dist = dist[current] + 1;

		for(int i = 2; i < 64; i += 2) {
			if(current[i] == '0') {
				string tmp = current.substr(i - 2, 2);
				++tmp[1];

				int pos = -1;
				for(int j = 2; j < 64; j += 2) {
					if(current[j] == tmp[0] && current[j + 1] == tmp[1]) {
						pos = j;
						break;
					}
				}

				if(pos == -1) continue;

				string next(current);
				next[i] = tmp[0];
				next[i + 1] = tmp[1];
				next[pos] = '0';
				next[pos + 1] = '0';

				if(!dist.count(next)) {
					dist[next] = next_dist;
					que.emplace(next);
				}
			}
		}
	}
	return -1;
}

void solve() {
	string start = "";
	for(int i = 0; i < 4; ++i) {
		string tmp = string(1, '1' + i) + "1";
		for(int j = 0; j < 7; ++j) {
			int card;
			cin >> card;
			if(card % 10 == 1) {
				tmp += "00";
			}
			else {
				tmp += to_string(card);
			}
		}
		start += tmp;
	}

	cout << bfs(start) << endl;
}

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

	int t;
	cin >> t;
	while(t--) solve();
}

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

using i64 = int64_t;

vector<string> solve(int n, char cc, string s){
    vector<string> res;
    for(char c='a';c<=(char)(cc+1);++c){
        string tmp = s;
        tmp.push_back(c);
        if(tmp.size() == n){
            res.push_back(tmp);
        }else{
            auto v = solve(n, max(c, cc), tmp);
            for(auto e: v){
                res.push_back(e);
            }
        }
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "a" << endl;
        return 0;
    }
    vector<string> ans = solve(n, 'a', "a");
    sort(ans.begin(), ans.end());
    for(auto s: ans){
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 9448
#include <stdio.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;

int main(void) {
	vector<long int> r;
	int n=0,m=0;
	while (scanf("%d %d",&n,&m) != EOF)
	{
		int a=0,b=0,re=0;
		if (n>m){
			a=n;b=m;
		} else {
			a=m;b=n;
		}
		while (a%b != 0)
		{
			re=a%b;
			a=b;
			b=re;
		}
		r.push_back(b);
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
using namespace std;
 
double EPS = 1e-10;
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
  point operator + (point p){return point(add(x,p.x), add(y,p.y));}
  point operator - (point p){return point(add(x,-p.x), add(y,-p.y));}
};
 
double dot(point a, point b){return a.x*b.x+a.y*b.y;}
double cross(point a, point b){return a.x*b.y-a.y*b.x;}
 
int is_point_on_line(point a, point b, point c) {
  return cross(b-a,c-a)==0.0 && dot(b-a,c-a)>-EPS && dot(a-b,c-b)>-EPS;
}
 
int is_intersected_ls(point a1, point a2, point b1, point b2) {
  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return (cross(a2-a1, b1-a1)*cross(a2-a1, b2-a1)<EPS ) &&
           (cross(b2-b1, a1-b1)*cross(b2-b1, a2-b1)<EPS );
  }
}
 
int contain(point p, vector<point> ps){
  point a=p,b(1000000,p.y);
 
  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<ps.size();i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;
 
  int cnt=0,cnt1=0;
  for(int i=0;i<ps.size();i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;
   
  for(int i=0;i<ps.size();i++)
    if(is_intersected_ls(ps[i],next(ps,i),a,b))cnt++;
  
  return (cnt-cnt1)%2;
}
 
 
int main(void){
  
  point in[4],p;
 
  while(true){
    vector<point>ps(3);
 
    for(int i=0;i<3;i++)
      if(!(cin >> ps[i].x >> ps[i].y))return 0;
 
    cin >> p.x >> p.y;
     
    if(contain(p,ps))cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		/*int Joken[] = new int[2];
		int joken = 0;
		while(joken < 2) {
			Joken[joken] = scan.nextInt();
		}*/
		String NL = scan.nextLine();
		String NandL[] = NL.split(" ");
		int L = Integer.parseInt(NandL[0]);
		int N = Integer.parseInt(NandL[1]);
		
		//System.out.println(N + " " + L);

		int line = 0;
		String out[] = new String[L];
		while(line < L) {
			String s = scan.nextLine();
			if(s.length() < N || s.length() > N)
				return;
			out[line] = s;
			line++;
		}

		Arrays.sort(out);

		int j = 0;
		while(j < out.length){
			System.out.print(out[j]);
			j++;
		}
		System.out.println("");

	}

}

Measured memory_bytes: 22100
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    ll n, k; cin >> n >> k;
    vector<ll>a(n);
    ll sm = 0;
    ll mx = 0;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll l = 0, r = 1e18;
    while (l < r - 1) {
        ll m = (l + r) / 2;
        ll kek = 0;
        for (ll i = 0; i < n; i++) {
            ll x = 2 * a[i];
            ll c = 2 * m + 1;
            ll kk = a[i] / m - (a[i]%m == 0);
            kek += kk;
        }
        if (kek <= k) {
            r = m;
        } else l = m;
    }
    cout << r << endl;
    return 0;
}

/*

*/

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

int main(){
  int a,b,c,i = 0;
  cin >> a >> b >> c;
  for ( int x = a; x <= b; x++ ){
    if ( c % x != 0 ) continue;
    i++;	    
    }
  cout << i << endl;

  return 0;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

// ??°??????????????????
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(void)
{
    ll m, n;
    cin >> m >> n;

    cout << mod_pow(m, n, 1000000007) << endl;

    return 0;
}

Measured memory_bytes: 1156
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 3;
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				System.out.println(0);
				return;
			}
		}
		Arrays.sort(a);
		System.out.println(a[0] * a[1]);
	}
}


Measured memory_bytes: 9556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] nums = new int[n];
		for(int arrayIndex = 0; arrayIndex < n; arrayIndex++) {
			nums[arrayIndex] = sc.nextInt();
		}
		printArray(nums);
		for(int i = 1; i <= n - 1; i++) {
			int v = nums[i];
			int j = i - 1;
			while(j >= 0 && nums[j] > v) {
				nums[j + 1] = nums[j];
				j--;
			}
			nums[j + 1] = v;
			printArray(nums);
		}
	}
	public static void printArray(int[] array) {
		int arrayLength = array.length;
		for(int index = 0; index < arrayLength - 1; index++) {
			System.out.print(array[index] + " ");
		}
		System.out.println(array[arrayLength - 1]);
	}
}

Measured memory_bytes: 34736
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
/*standard declarations*/
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef vector<ll> vll;
typedef vector<pair<ll,ll> > vllp; 
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a;i>=b;i--)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
#define pb push_back
 
/*comparators*/
struct cmp {
	bool operator() (const pair<ll,pair<ll, ll>> &a, const pair<ll,pair<ll, ll>> &b) const {
		if(a.ft!=b.ft){
            return a.ft<b.ft;
        }
        else{
            if(a.sd.ft!=b.sd.ft){
                return a.sd.ft<b.sd.ft;
            }
            else{
                return a.sd.sd<b.sd.sd;
            }
        }
	}
};
/*templates here*/
template <typename T>
void show(T *a, int size)
{
    int i;
    cout << endl
         << "The array is ";
    fr(i, 0, size)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
 
template <typename T>
void show_vector(vector<T> v)
{
    cout << endl
         << "The vector is ";
    int i;
    fr(i, 0, v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}
/*global variables here*/
ll TESTTEST;
#define mxn 2000001
#define PI 3.14159265	
#define mod 1000000007	
ll dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
ll n,k;
/*global functions here*/


/*main function here*/							
void solve(){
    ll n;
    cin>>n;
    ll a[n+1];
    fr(i,0,n){
        cin>>a[i+1];
    }
    ll ans[n+1];
    if(n==1){
        cout<<0<<"\n";
        return;
    }
    if(n==2){
        cout<<abs(a[2]-a[1])<<"\n";
        return;
    }
    ans[1]=0;
    ans[2]=abs(a[2]-a[1]);
    fr(i,2,n){
        ans[i+1]=min(ans[i]+abs(a[i+1]-a[i]),ans[i-1]+abs(a[i+1]-a[i-1]));
    }
    cout<<ans[n]<<"\n";
    return;
}
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll zzz=1;
	//cin>>zzz;
	for(TESTTEST=1;TESTTEST<(zzz+1);TESTTEST++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 5156
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)

Measured memory_bytes: 116568
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;
void dfs_visit(int u){
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for(v = 0;v < n;v++){
        if(M[u][v] == 0) continue;
        if(color[v] == WHITE){
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs(){
    int u;
    for(u = 0;u < n;u++) color[u] = WHITE;
    tt = 0;
    for(u = 0;u < n;u++){
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(u = 0;u < n;u++){
        printf("%d %d %d\n",u + 1,d[u],f[u]);
    }
}

int main(){
    int u,v,k,i,j;
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++) M[i][j] = 0;
    }
    for(i = 0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j = 0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e3 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, k, s;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> s;
    if (s == 1e9){
        ForE(i, 1, k) cout << s << ' ';
        ForE(i, k + 1, n) cout << 2 << ' ';
        return 0;
    }
    ForE(i, 1, k) cout << s << ' ';
    ForE(i, k + 1, n) cout << s + 1 << ' ';
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int res = 0;
		PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
		
		for (int i = 0; i < 2*n; i++) {
			pq.offer(sc.nextInt());
		}
		while (!pq.isEmpty()) {
			int kushi1 = pq.poll();
			int kushi2 = pq.poll();
			res += (Math.min(kushi1, kushi2));
		}
		
      	System.out.println(res);
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
  std::vector<int> abc(3);
  std::cin >> abc[0] >> abc[1] >> abc[2];
  std::sort(abc.begin(), abc.end());
  int ans = abc[2] - abc[1];
  if ((abc[2] - abc[0] - ans) % 2 == 0)
    ans +=(abc[2] - abc[0] - ans) / 2;
  else
    ans +=(abc[2] - abc[0] - ans) / 2 + 2;
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
n=int(input())

if n>=400 and n<600:
    print(8)

elif n>=600 and n<800:
    print(7)

elif n>=800 and n<1000:
    print(6)

elif n>=1000 and n<1200:
    print(5)

elif n>=1200 and n<1400:
    print(4)

elif n>=1400 and n<1600:
    print(3)

elif n>=1600 and n<1800:
    print(2)

else:
    print(1)

Measured memory_bytes: 9188
n = int(input())
l = list(map(int,input().split()))
a = sorted(l)

total = 0
for i in range(n-2):
    for j in range(i+1,n):
        for k in  range(j+1,n):
            if a[i]!=a[j] and a[j]!= a[k] and a[i]+a[j]>a[k]:
                total +=1
print(total)

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;

  int result = 0;
  char tmp = s[0];
  for (int i = 1; i < s.size(); ++i) {
    if (tmp != s[i]) {
      result++;
      tmp = s[i];
    }
  }
  cout << result << endl;

  return 0;
}


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

long long n,fp[100005],r=1,br;
vector<long long> d;

void sito()
{
    fp[1]=1;
    for(long long i=2;i<100005;i+=2)
        fp[i]=2;
    for(long long i=3;i<100005;i+=2)
    {
        if(fp[i]==0)
        {
            fp[i]=i;
            for(long long j=2*i;j<100005;j+=i)
                fp[j]=i;
        }
    }
}

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

    cin>>n;
    sito();
    for(long long i=2;i<=n;i++)
        if(fp[i]==i)
        {
            long long j=i;
            //cout<<j<<endl;
            while(j<=n)
            {
                br+=n/j;
                j*=i;
            }
            r*=br+1;
            r%=1000000007;
            br=0;
        }

    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vector<char> alp;
    for(char c='A';c<='Z';c++) alp.push_back(c);
    REP(i,S.size()){
        int idx = S[i] - 'A';
        idx += N;
        idx %= 26;
        cout << alp[idx];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
typedef long long ll;
typedef unsigned long long ull;
const int INF= 0x3f3f3f3f;

int main() {
	string s,a;
	a="ABC";
	int n;
	cin>>n;
	cin>>s;
	n=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		{
			n++;
			i=i+1;
		}
	}
	cout<<n;
	
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		String T = stdIn.next();
		int ans = 0;
		for(int i = 0; i < S.length(); i++){
			if(S.charAt(i) == T.charAt(i)){
				ans++;
			}
		}
		System.out.println(ans);
		stdIn.close();
	}
}

Measured memory_bytes: 35552
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

var tab = []string{"dream", "dreamer", "erase", "eraser"}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	i := len(s)
	ok := true
	for i > 0 && ok {
		ok = false
		for _, t := range tab {
			if i >= len(t) && s[i-len(t):i] == t {
				i -= len(t)
				ok = true
				break
			}
		}
	}
	if ok {
		con.Println("YES")
	} else {
		con.Println("NO")
	}
	return nil
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++){
    if(s[i] == s[i+1]){
      cout << "Bad\n";
      return 0;
    }
  }
  cout << "Good\n";
  return 0;
}

Measured memory_bytes: 256
N = int(input())
lis = []

if N % 2 == 0:

    S = N+1

    for i in range(N):

        for j in range(i):

            if (i+1) + (j+1) == S:
                continue

            else:
                lis.append([i+1,j+1])

else:

    S = N

    for i in range(N-1):

        for j in range(i):

            if (i+1) + (j+1) == S:
                continue

            else:
                lis.append([i+1,j+1])

    for i in range(N-1):
        lis.append([i+1,N])

print (len(lis))

for i in lis:

    print (i[0],i[1])

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

int main(){
	char s[1000],u[1000];
	scanf("%s %s",&s,&u);
  //cin >> s >> u;
	ll ns,nu;
	cin >> ns >> nu;
	char str[1000];
  	scanf("%s",&str);
	//cin >> str;
  ll st = strcmp(str,s);
	if( st== 0){
      cout << ns-1 <<" "<< nu <<endl;
    }
	else{
      cout << ns<<" "<< nu-1 <<endl;
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.range(0, n).map(i -> scanner.nextInt() - 1).sum());
		}
	}
}


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

int     main()
{
    int x;  cin >> x;
    //int tab = {500,  5};
    int res = 0;
    //for (i; i < 2; i++)
    while (x >= 500)
    {   
        res += 1000;
        x -= 500;
    }   
    while (x >= 5)
    {   
        res += 5;
        x -= 5;
    }   
    cout << res << endl;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int ans = m * 1900 + (n - m) * 100;
  while (m--) {
    ans *= 2;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int ans = max({A,B,C});
    while(K>0){
        ans *= 2;
        K--;
    }
    
    ans = ans + A+B+C-max({A,B,C});
    
    cout << ans << endl;
        return 0;
    }
    


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let (n, m) = i::u2();
    let a = i::uv(n);
    let bc = i::uv2(m);
    let mut count = HashMap::new();
    let mut key = HashSet::new();
    for k in a {
        key.insert(k);
        *count.entry(k).or_insert(0) += 1;
    }
    for (b, c) in bc {
        key.insert(c);
        *count.entry(c).or_insert(0) += b;
    }
    let mut key: Vec<usize> = key.iter().cloned().collect();
    key.sort();
    key.reverse();

    let mut c = 0;
    let mut ans = 0;
    for k in &key {
        if c + count[k] <= n {
            ans += count[k] * *k;
            c += count[k];
            continue;
        }
        ans += (n - c) * *k;
        break;
    }
    //dbg!(count, key);
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 21840
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll dp[N][5] ;
int flag[N] ;
vector <int> e[N] ;
int n ;
ll ans ;

void dfs(int k, int fat) {
	if (siz(e[k]) == 1 && e[k][0] == fat) { // leaves
		dp[k][0] = dp[k][1] = 1 ;
		return ;
	}
	ll x = 1, y = 1 ;
	for (int i = 0; i < siz(e[k]); i++) {
		int to = e[k][i] ; if (to == fat) continue ;
		dfs(to, k) ;
		x = (x * (dp[to][0] + dp[to][1]) % MOD) % MOD ;
		y = y * dp[to][0] % MOD;
	}
	dp[k][0] = x, dp[k][1] = y ;
}


signed main(){
	scanf("%d", &n) ;
	for (int i = 1, x, y; i < n; i++) {
		scanf("%d%d", &x, &y) ;
		e[x].pb(y) ; e[y].pb(x) ;
		flag[y] = 1 ;
	}
	int root = 0 ;
	for (int i = 1; i <= n; i++) if (!flag[i]) {
		root = i ;
		break ;
	}
	dfs(root, -1) ;
	ans = (dp[root][0] + dp[root][1]) % MOD ;
	printf("%lld\n", ans) ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 15360
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int N,M;
	scan(N);scan(M);
	UnionFind uf(N);
	rep(i,M){
		int a,b;
		scan(a);scan(b);
		a--;b--;
		uf.unite(a,b);
	}
	int size1=uf.size(0),size2=uf.size(1);
	ll hen;
	if(size1<size2){
		hen=(ll)size1*(size1-1)/2+(ll)(N-size1)*(N-size1-1)/2;
	}
	else{
		hen=(ll)size2*(size2-1)/2+(ll)(N-size2)*(N-size2-1)/2;
	}
	prin(hen-M);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    vector< pair<int,int> > v;
    int i,x,y;
    scanf("%d%d",&n,&q);
    for(i=1; i<=q; i++)
    {
        scanf("%d%d",&x,&y);
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end());
    stack< pair<int,int> > s;
    for(i=0; i<q; i++)
    {
        if(s.empty())
        {
            s.push(v[i]);
           // printf("%d %d\n",v[i].first,v[i].second);
        }
        else {
            pair<int,int> cur = s.top();
            
            if(cur.second > v[i].first)
            {
               // printf("should pop\n");
                int ma = max(cur.first,v[i].first),mi =  min(cur.second,v[i].second);
                if(mi > ma){
                s.pop();
                s.push(make_pair(ma,mi));
                }
            }
            else s.push(v[i]);
        }
       // printf("%d %d\n",s.top().first,s.top().second);
      //  printf("%d\n",s.size());
    }
    printf("%d\n",s.size());
}

Measured memory_bytes: 1400
import math
 
N = int(input())
A = list(map(int, input().split()))
ans = 0

dct = {}
for i in A:
  if not i in dct:
    dct[i]=0
  dct[i] += 1

anst=0
for (i,cnt) in dct.items():
  if cnt >= 2:
    anst += cnt * (cnt-1)/2

for i in A:
  print(int(anst-dct[i]+1))

Measured memory_bytes: 26140
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
//typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX1 = 2000 + 47;
const int MAX = MAX1 * MAX1 + 47;

LL F[MAX];
LL FR[MAX];
LL dp[MAX1][MAX1];

LL bp(LL a, LL n)
{
	LL res = 1;
	while (n)
	{
		if (n & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		n >>= 1;
	}

	return res;
}

LL c(int n, int k)
{
	if (n < k) return 0;
	LL res = (F[n] * FR[n - k]) % MOD;
	res = (res * FR[k]) % MOD;
	return res;
}

void ADD(LL& key, LL val)
{
	key = key + val;
	if (key >= MOD) key -= MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	F[0] = 1;
	FR[0] = bp(1, MOD - 2);
	FOR(i, 1, MAX)
	{
		F[i] = (F[i - 1] * i) % MOD;
		FR[i] = bp(F[i], MOD - 2);
	}

	int n, k;
	cin >> n >> k;
	if (k == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	dp[0][0] = 1;
	FOR(i, 0, n + 1)
	{
		FOR(j, 0, n + 1)
		{
			if (i + 1 <= n)
			{
				ADD(dp[i + 1][j], dp[i][j]);
			}

			if (i - j > 0)
			{
				int left = n * k - i - j * (k - 1);
				LL w = (c(left - 1, k - 2) * (n - j)) % MOD;
				//cout << i << " " << j << ": " << w << endl;
				ADD(dp[i][j + 1], (dp[i][j] * w) % MOD);
			}

		}
	}

	//FOR(i, 0, n + 1)
	//{
	//	FOR(j, 0, n + 1) cout << dp[i][j] << " ";
	//	cout << endl;
	//}

	cout << dp[n][n] << endl;
}

Measured memory_bytes: 97664
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, m, q, a[55], b[55], c[55], d[55], arr[20], maxi;

void permutasi(ll idx, ll len){
	if(len >  n){
		ll sum = 0;
		for(ll i = 1; i <= q; i++){
			if(arr[b[i]] - arr[a[i]] == c[i]){
				sum += d[i];
			}
		}
		maxi = max(maxi, sum);
		return;
	}
	for(ll i = idx; i <= m; i++){
		arr[len] = i;
		permutasi(i, len + 1);
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	
	cin >> n >> m >> q;
	for(ll i = 1; i <= q; i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	permutasi(1, 1);
	cout << maxi << '\n';
}



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

int main(){
    int N;
    cin >> N;
    vector<tuple<string, int, int>> v;
    string S;
    int P;
    
    for(ll i = 0; i < N; i++){
        cin >> S >> P;
        v.emplace_back(S, -P, i+1);
    }

    sort(v.begin(), v.end());
    
    for(int i = 0; i < N; i++){
        cout << get<2>(v[i]) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> P;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    int N,M;cin>>N>>M;
    vector<int> A(M),B(M),C(M);
    vector<vector<ll> > d(N,vector<ll>(N,INF));
    for(int i=0;i<N;++i) d[i][i]=0;
    for(int i=0;i<M;++i){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;B[i]--;
        d[A[i]][B[i]]=d[B[i]][A[i]]=C[i];
    }
    for(int k=0;k<N;++k){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                if(d[i][k]==INF||d[k][j]==INF) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    for(int k=0;k<M;++k){
        bool ok=true;
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                if(i==j) continue;
                if(d[i][A[k]]+C[k]+d[B[k]][j]==d[i][j]){
                    ok=false;
                }
            }
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
int main()
{
    int a;
    std::cin >> a;
    int n[100];
    for (int i = 0; i < a; i++)
        std::cin >> n[i];

    for (int i = 0; i < a; i++)
    {
        int v = n[i];
        int j = i - 1;
        while (j >= 0 && n[j] > v)
            n[j + 1] = n[j--];
        n[j+1] = v;
        for (int i = 0; i < a; i++)
            std::cout << n[i] << (i<a - 1 ? " " : "\n");
    }
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define LL long long
using namespace std;

LL S,x,y;

LL sqrt(LL a){
	LL l=1,r=1e9,ans;
	while(l<=r){
		LL mid=l+r>>1;
		LL p=mid*mid;
		if(p==S)return mid;
		if(p<S)ans=mid,l=mid+1;
		else r=mid-1;
	}
	return ans+1;
}
int main(){
	scanf("%lld",&S);
	x=sqrt(S);
	y=x*x-S;
	printf("0 0 %lld %lld %lld %lld",x,1,y,x);
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<LL, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;



struct edge{
  //int from; //始点
  int to; //終点
  LL weight;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;
//graph[始点][エッジのインデックス]

vector<LL> dist; //ノードまでの最小コスト
vector<int> prever; //最小木の親ノード

void dijkstra(int n, LL s){
    dist = vector<LL>(n,LINF);
    prever = vector<int>(n,-1);
    dist[s] = 0;

    //P(終点までの最小コスト, 終点)
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P((LL)0,s));

    while(!que.empty()){
        P p = que.top();
        //dist[p.second]はこの時点で確定
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0; i<graph[v].size(); i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.weight){
                dist[e.to] = dist[v] + e.weight;
                prever[e.to] = v;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

int main(){
  int n;
  cin >> n;
  graph = AdjList(n);
  for(int i=0;i<n-1;i++){
      int from, to;
      LL weight;
      cin >> from >> to >> weight;
      --from;
      --to;
      graph[from].push_back((edge){to,weight});
      graph[to].push_back((edge){from,weight});
  }
  dijkstra(n,0);

  REP(i, n){
    if(dist[i]%2==0) cout<<0<<endl;
    else cout<<1<<endl;
  }

  return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll K,A,B;
  cin>>K>>A>>B;
  if(A%K==0||B%K==0)cout<<"OK"<<endl;
  else if(A/K!=B/K)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

/// g++ code.cpp//
// ./a.out //

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

#define chmax(a, b) (a) = ((a) < (b)) ? (b) : (a)
#define YMAX 1000000007
#define mend '\n'

typedef long long ll;

using namespace std;

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

  int len = S.size();
  if(S[len - 1] != 's') {
    cout << S << 's' << mend;
  } else {
    cout << S << "es" << mend;
  }
}


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

int main() {
	int n;
	cin >> n;
	vector<int>x, x_;
	int s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		x.push_back(s);
	}
	x_ = x;
	sort(x.begin(), x.end());
	for (int i = 0; i < n; i++) {
		if (x_[i] <= x[n / 2 - 1]) {
			cout << x[n / 2] << endl;
		}
		else {
			cout << x[n / 2 - 1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N;
    cin >> N;
    vector<P> vec(N);
    for(int i = 0;i < N;i++) {
        int A, B;
        cin >> A >> B;
        vec.at(i) = P(A, B);
    }
    sort(vec.begin(), vec.end());
    map<P, int> ma;
    for(int i = 0;i < N - 1;i++) {
        for(int j = i + 1;j < N;j++) {
            int A = vec[j].first - vec[i].first;
            int B = vec[j].second - vec[i].second;
            ma[P(A, B)]++;
        }
    }
    int ret = 0;
    for(auto x:ma) {
        ret = max(ret, x.second);
    }
    cout << N - ret << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using ll = long long;
vector<int> adj[101010];
int n,m,ans;
bool check[101010];
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1,x,y; i<=m; i++){
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1; i<=n; i++){
        if(!check[i]){
            ans++;
            queue<int> q;
            q.push(i);
            check[i] = 1;
            while(q.size()){
                int here = q.front();
                q.pop();
                for(int i : adj[here]){
                    if(!check[i]){
                        check[i] = 1;
                        q.push(i);
                    }
                }
            }
        }
    }
    cout<<ans-1<<'\n';
}


Measured memory_bytes: 8936
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[111111][3];
ll cnt[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans=1;
  for(int i=0;i<n;i++){
    cnt[A[i]]++;
    if(A[i] == 0){
      ans*=(4-cnt[A[i]]);
    }else{
      ans*=(cnt[A[i]-1]-cnt[A[i]]+1);
    }
    
    ans%=MOD;
  }
  cout<<(ans)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 1792