akhauriyash/Code-Regression huggingface dataset:
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

const int nax = 1005;
vector<string> s(nax);
int x, y, a, b;
int n, m;
int vis[nax][nax], dp[nax][nax];

void count(int p, int q){
	priority_queue<pair<int,pii>, vector<pair<int,pii>>, greater<pair<int,pii>>> pq;
	pq.push({0, {p, q}});
	while(!pq.empty()){
		pair<int,pii> arr = pq.top();
		pq.pop();
		if(arr.y.x == x && arr.y.y==y){
			cout << arr.x << endl;
			exit(0);
		}
		if(vis[arr.y.x][arr.y.y])continue;
		vis[arr.y.x][arr.y.y]=1;
		for(int i=max(0ll, arr.y.x-2); i<=min(n-1, arr.y.x+2); i++){
			for(int j=max(0ll, arr.y.y-2); j<=min(m-1, arr.y.y+2); j++){
				if(s[i][j]!='.')continue;
				if(abs(i-arr.y.x)+abs(j-arr.y.y)==1){
					pq.push({arr.x, {i, j}});
				}
				else{
					pq.push({arr.x+1, {i, j}});
				}
			}
		}
	}
}

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	cin >> n >> m;
	cin >> x >> y >> a >> b;
	a--, b--, x--, y--;
	for(int i=0; i<nax; i++){
		for(int j=0; j<nax; j++){
			dp[i][j]=INT_MAX;
		}
	}
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	dp[a][b]=0;
	count(a, b);
	cout << -1 << endl;
 
	return 0;
}  

Measured memory_bytes: 23300
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double ans = 0;
    int water = 0, sugar = 0;
    vector<int> params(4);
    rrep (a, 0, 30) {
        rrep (b, 0, 30) {
            rrep (c, 0, 100) {
                rrep (d, 0, 100) {
                    int w_weight = 100*A*a + 100*B*b;
                    int s_weight = C*c + D*d;

                    if (F < w_weight + s_weight) continue;
                    if (s_weight > E*w_weight/100) continue;

                    if (w_weight+s_weight == 0) continue;

                    if (ans < (double)100*s_weight/(w_weight+s_weight)) {
                        ans = (double)100*s_weight/(w_weight+s_weight);
                        water = w_weight;
                        sugar = s_weight;
                    }
                }
            }
        }
    }

    if (ans == 0) water = 100*A;

    cout << water+sugar << " " << sugar << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		if(a < b) System.out.println("a < b");
		else if(a > b) System.out.println("a > b");
		else System.out.println("a == b");
	}
}

Measured memory_bytes: 26072
class Main{
    public static void main(String[] args){
        java.util.Scanner in = new java.util.Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int area = a * b;
        int length = 2 * (a+b);
        System.out.println(String.format(
            "%d %d", area, length));
    }
}

Measured memory_bytes: 17328
import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)
for i in range(m):
    mx=heapq.heappop(a)
    heapq.heappush(a, (-1)*(-mx//2))

print(-sum(a))

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

using namespace std;

#define MAX 1000
typedef pair<int, int> pii;

int W, H, N;
int X1[MAX], Y1[MAX], X2[MAX], Y2[MAX];
bool fld[MAX*6][MAX*6];

int compress(int *x1, int *x2, int w)
{
    vector<int> xs;
    for (int i = 0; i < N; i++) {
        for (int d = -1; d <= 1; d++) {
            int tx1 = x1[i] + d, tx2 = x2[i] + d;
            if (0 <= tx1 && tx1 < w) xs.push_back(tx1);
            if (0 <= tx2 && tx2 < w) xs.push_back(tx2);
        }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    
    for (int i = 0; i < N; i++) {
        x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    return xs.size();
}

int solve()
{        
    W = compress(X1, X2, W);
    H = compress(Y1, Y2, H);

    memset(fld, 0, sizeof(fld));
    for (int i = 0; i < N; i++) {
        for (int y = Y1[i]; y < Y2[i]; y++) {
            for (int x = X1[i]; x < X2[i]; x++) {
                fld[y][x] = 1;
            }
        }
    }

    const int dx[] = {-1, 0, 1, 0};
    const int dy[] = {0, -1, 0, 1};
    int res = 0;
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (fld[y][x]) continue;
            res++; fld[y][x] = 1;
            queue<pii> Q; Q.push(pii(x, y));
            while (!Q.empty()) {
                pii p = Q.front(); Q.pop();
                for (int i = 0; i < 4; i++) {
                    int nx = p.first + dx[i];
                    int ny = p.second + dy[i];
                    if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                        !fld[ny][nx]) {
                        fld[ny][nx] = 1;
                        Q.push(pii(nx, ny));
                    }
                }
            }            
        }
    }
    return res;
}

int main()
{
    while (cin >> W >> H >> N, W) {
        for (int i = 0; i < N; i++) {
            cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        }
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 36416
#include <iostream>
#include <cassert>
#include <vector>
using namespace std;

int curPos = 0;
string str;
int info[128] = {};
vector< vector<int> > g;
int number[128] = {};
int mx = 0;
void parse(int pos){
	//cout << curPos << " " << str[curPos] << endl;
	mx = max(pos,mx);
	if( str[curPos] >= '0' && str[curPos] <= '9'){
		number[pos] = info[ str[curPos] - '0' - 1];
		curPos++;
		return;
	}
	
	assert(str[curPos] == '(');
	curPos++;
	g[pos].push_back(pos*2+1);
	parse(pos*2+1);
	
	assert(str[curPos] == ' ');
	curPos++; // space 
	
	
	g[pos].push_back(pos*2+2);
	parse(pos*2+2);
	assert(str[curPos] == ')');
	curPos++;
	return;
}

int calc(int a,int b,int t){
	if( t == 0 ) return a & b;
	if( t == 1 ) return a | b;
	return a^b;
}

int tmp[30] = {};

vector<int> all(int pos){
	if( number[pos] >= 0 ){
		vector<int> c(16);
		c[number[pos]] = 1;
		//cout << pos << " : ";
		//for(int i = 0 ; i < 16 ; i++) cout << c[i] << " "; cout << endl;
		return c;
	}else{
		vector<int> a,b,c(16);
		a = all(pos*2+1);
		b = all(pos*2+2);
		for(int k = 0 ; k < 3 ; k++){
			for(int i = 0 ; i < 16 ; i++){
				for(int j = 0 ; j < 16 ; j++){
					c[calc(i,j,k)] += a[i] * b[j];
				}
			}
		}
		//cout << pos << " : ";
		//for(int i = 0 ; i < 16 ; i++) cout << c[i] << " "; cout << endl;
		return c;
	}
}

int main(){
	int n;
	while(1){
			while( getline(cin,str) && (str == "" || str == "END") ){ if(str == "END") return 0; }
		for(int i = 0 ; i < 128 ; i++) number[i] = -1;
		cin >> n;
		g.clear();
		g.resize(128);
		for(int i = 0 ; i < n ; i++){
			int inf = 0 , a;
			for(int j = 0 ; j < 4 ; j++){
				cin >> a;
				inf |= (a<<j);
			}
			info[i] = inf;
		}
		str += "~";
		curPos = 0;
		mx = 0;
		parse(0);
		assert(str[curPos] == '~');
		/*for(int i = 0 ; i <= mx ; i++){
			cout << i << "(" << number[i] << ")" << " : ";
			for(int j =0 ; j < g[i].size() ; j++) cout << g[i][j] << " ";
			cout << endl;
		}*/
		vector<int> answer = all(0);
		cout << answer[15] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	void merge(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}
};

typedef tuple<ll, int, int> tup;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vll x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	vector<tup> v;
	vector<pll> p(n);
	rep(i, n) p[i] = pll(x[i], i);
	sort(p.begin(), p.end());
	rep(i, n-1) v.push_back(tup(p[i+1].first - p[i].first, p[i].second, p[i+1].second));
	rep(i, n) p[i] = pll(y[i], i);
	sort(p.begin(), p.end());
	rep(i, n-1) v.push_back(tup(p[i+1].first - p[i].first, p[i].second, p[i+1].second));
	sort(v.begin(), v.end());

	UnionFind uf(n);
	ll ans = 0;
	rep(i, v.size()) {
		ll d; int a, b;
		tie(d, a, b) = v[i];
		if(uf.issame(a, b)) continue;
		ans += d;
		uf.merge(a, b);
	}
	cout << ans << endl;
}


Measured memory_bytes: 9584
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int h, w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>>a[i][j];
        }
    }
    vector <int> y;
    vector <int> x;
    vector <int> yp;
    vector <int> xp;
    int count=0;
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w-1; j++)
        {
            if(a[i][j]%2==1)
            {
                a[i][j]--;
                a[i][j+1]++;
                y.push_back(i);
                x.push_back(j);
                yp.push_back(i);
                xp.push_back(j+1);
                count++;
            }
        }
    }
    for(int i=0; i<h-1; i++)
    {
        if(a[i][w-1]%2==1)
        {
            a[i][w-1]--;
            a[i+1][w-1]++;
            y.push_back(i);
            x.push_back(w-1);
            yp.push_back(i+1);
            xp.push_back(w-1);
            count++;
        }
    }
    cout<<count<<endl;
    for(int i=0; i<count; i++)
    {
        cout<<y[i]+1<<" "<<x[i]+1<<" "<<yp[i]+1<<" "<<xp[i]+1<<endl;
    }
    
	return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[200];

int main(){
	cin >> n;
	int c = INF;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		int cnt = 0;
		while(a[i] % 2 == 0){
			a[i] /= 2;
			cnt++;
		}
		c = min(c, cnt);
	}
	
	cout << c << endl;
	
	return 0;
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int a, b;
	cin >> a >> b;
	if (a < b) {
		rep(i, b) cout << a << flush;
	}
	else rep(i, a) cout << b << flush;

	cout << endl;
	return 0;
}


Measured memory_bytes: 3580
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readIntegerList()
    val allXor = aList.reduce { acc, i -> acc xor i }
    aList.map { it xor allXor }
        .joinToString(" ")
        .let(out::println)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 79416
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
#define N 100

int main(){
        int i=0, key[N], count=0;
        string keymoji;

        cin >> i;
        while(i != 0){
                for(int j=0; j<i; j++){
                        cin >> keymoji;
                        if(keymoji.size() == 2){
                                key[j] = (keymoji[0]-'0')*10+keymoji[1]-'0';
                        }else{
                                key[j] = (keymoji[0]-'0');
                        }
                }
                //for(int j=0; j<i; j++){
                //      key[j] = keymoji[j*2]-'0';
                //}
                string eki;
                cin >> eki;
                for(int j=0; j<eki.size(); j++){
                        if(eki[j] <= 'Z'){
                                eki[j] -= key[j%i];
                                if(eki[j] < 'A'){
                                        eki[j] = 'z'+1-('A'-eki[j]);
                                        if(eki[j] < 'a'){
                                                eki[j] = 'Z'+1-('a'-eki[j]);
                                        }
                                }
                        }else{
                                if(eki[j]-key[j%i] < 'a'){
                                        eki[j] -= key[j%i]+('a'-'Z'-1);
                                        if(eki[j] < 'A'){
                                                eki[j] += 'z'-'A'+1;
                                        }
                                }else{
                                        eki[j] -= key[j%i];
                                }
                        }
                }
                cout << eki << endl;
                cin >> i;
        }
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
using namespace std;
main()
{ 
    unordered_map<string,int> mp;
    int n;cin>>n;
    string s;
    long long res=0;
    for(int i=1;i<=n;i++)
    {
        char in[12];cin>>in;
        sort(in,in+10);
        s=string(in);
        res+=mp[s];
        mp[s]++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 10660
a, b, c, d, e, f = gets.split.map(&:to_i)
a *= 100
b *= 100
waters = []
0.upto(30) do |a_count|
  0.upto(30) do |b_count|
    amount = a * a_count + b * b_count
    if amount <= f
      waters << amount
    else
      break
    end
  end
end
waters.uniq!

answers = [a, 0, 0.0]

waters.each do |water|
  max_sugar = water / 100 * e
  0.upto(3000) do |c_count|
    c_sugar = c * c_count
    break if water + c_sugar > f
    break if c_sugar > max_sugar
    d_sugar_max_op1 = max_sugar - c_sugar
    d_sugar_max_op2 = f - (water + c_sugar)
    d_sugar_max = [d_sugar_max_op1, d_sugar_max_op2].min
    d_count = d_sugar_max / d
    d_sugar = [d * d_count, 0].max
    sugar_total = c_sugar + d_sugar
    sugar_percentage = (sugar_total * 100.0) / (water + sugar_total)
    if answers[2] < sugar_percentage
      answers[0] = water + sugar_total
      answers[1] = sugar_total
      answers[2] = sugar_percentage
    end
  end
end

puts "#{answers[0]} #{answers[1]}"


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#define N 100000

typedef struct q{
  char name[10];
  int time;
}queue;

queue Q[N];
int head,tail,n;

void enqueue(queue x){
  Q[tail] = x;
  tail = (tail+1)%N; 
}

queue dequeue(){
  queue x = Q[head];
  head = (head+1)%N;
  return x;
}

int min(int a,int b){return a < b ? a : b;}

int main(){
  queue x;
  int q,i;
  int pass = 0,c;

  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s %d",Q[i].name,&Q[i].time);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    x=dequeue();
    c=min(q,x.time);
    x.time-=c;
    pass+=c;
    if(x.time>0)enqueue(x);
    else printf("%s %d\n",x.name,pass);
  }

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> d;
  d.reserve(N);
  for (int i = 0; i < N; i++) {
    int D;
    cin >> D;
    d.emplace_back(D);
  }
  
  sort(d.begin(), d.end());
  int med_0 = d[int(N / 2) - 1];
  int med_1 = d[int(N / 2)];
  
  if (med_0 == med_1) {
    cout << 0 << endl;
  } else {
    cout << med_1 - med_0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#define BIG 1000000000
#define BIGNUM 1000000
#define SIZE 1000
using namespace std;

int cnt = 0;

void insertionSort(int *A, int n, int g) {
	for (int i = g; i < n; i++) {
		int t = A[i];
		int j;
		for (j = i - g; j >= 0 && A[j] > t;cnt++,j-=g)
			A[j + g] = A[j];
		A[j + g] = t;
	}
}

void shellSort(int *A, int n) {
	cnt = 0;
	stack<int> s;
	s.push(1);
	while (3*s.top()+1 < n) {
		s.push(3 * s.top() + 1);
	}

	int m = s.size();
	printf("%d\n", m);

	for (int i = 0; i < m; i++) {
		insertionSort(A, n, s.top());
		if (i > 0) printf(" ");
		printf("%d", s.top());
		s.pop();
	}
	printf("\n%d\n",cnt);
}

int main() {
	int inputN;
	int A[1000000];

	scanf("%d", &inputN);
	for (int i = 0; i < inputN; i++) {
		scanf("%d", &A[i]);
	}
	shellSort(A, inputN);
	for (int i = 0; i < inputN; i++) {
		if (i > 0) printf("\n");
		printf("%d", A[i]);
	}
	return 0;
}

Measured memory_bytes: 7076
import math
n, h = map(int, input().split())
max_swing = 0
throw = []
for _ in range(n):
    a, b = map(int, input().split())
    max_swing = max(max_swing, a)
    throw.append(b)

throw.sort(reverse=True)

min_cnt = int(math.ceil(h / max_swing))
throw_cnt = 0
for t in throw:
    h -= t
    throw_cnt += 1
    if h <= 0:
        min_cnt = min(throw_cnt, min_cnt)
        break
    cnt = throw_cnt + int(math.ceil(h / max_swing))
    min_cnt = min(cnt, min_cnt)

print(min_cnt)


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

int main(){
	int x,y;
	while(1){
		cin >> x>>y;
		if ( x == 0 && y==0) break;
		
		if(x<y){
		}else{
			swap(x,y);
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#","# => r#" "#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: String,
    }

    s.replace(",", " ")
}

Measured memory_bytes: 4352
import sys
from collections import Counter

n,*S = sys.stdin.read().split()
n = int(n)

def main():
    t = [''.join(sorted(t)) for t in S]
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v*(v-1)
    print(cnt//2)
main()


Measured memory_bytes: 28296
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
int main(void) {
   int n;
   int cnt = 0;
   long long sum = 0;
   long long int ans = 0;
   scanf("%d", &n);
   int min_abs = 1000000000;
   int *L = (int *)malloc(n * sizeof(int));
   for (int i = 0; i < n; i++) {
      scanf("%d", &L[i]);
      sum += ABS(L[i]);
      if (L[i] < 0) {
         cnt ++;
      }
   }
   for (int i = 0; i < n; i++) {
      min_abs = MIN(min_abs, ABS(L[i]));
   }  
   if (cnt % 2 == 0) {
      ans = sum;
   } else {
      ans = sum - 2*min_abs; 
   }
   printf("%lld\n",ans);

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int a, b;
    cin >> a >> b;
    if (a <= 5) cout << 0 << endl;
    else if (a <= 12) cout << b/2 << endl;
    else cout << b << endl;
    
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int k;
	string a;
	cin >> k >> a;

	if (k >= a.size()) {
		cout << a << endl;
	}

	if (k < a.size()) {
		rep(i, 0, k) {
			cout << a.at(i);
		}
		cout << "..." << endl;
	}


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)--;
  }
  vector<int> c(n);
  for(int i=0;i<n;i++)
    cin>>c.at(i);
  int64_t m;
  for(int i=0;i<n;i++){
    vector<int64_t> s;
    s.push_back(c.at(p.at(i)));
    int x=p.at(i);
    int64_t b=0;
    for(int j=0;x!=i;j++){
      s.push_back(s.at(j)+c.at(p.at(x)));
      b=max(b,abs(s.at(j)+c.at(p.at(x))));
      x=p.at(x);
    }
    int l=s.size();
    int64_t msl=-b;
    int64_t msg=-b;
    for(int j=0;j<k%l;j++)
      msl=max(msl,s.at(j));
    for(int j=k%l;j<l;j++)
      msg=max(msg,s.at(j));
    int64_t ms;
    if(k<l)
      ms=msl;
    else if(s.at(l-1)<0)
      ms=max(msl,msg);
    else
      ms=max(msl+s.at(l-1)*(k/l),msg+s.at(l-1)*(k/l-1));
    m=(i==0?ms:max(m,ms));
  }
  cout<<m<<endl;
}

Measured memory_bytes: 3768
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String a = inp.next();
        String b = a.substring(5, 7);
        int n = Integer.parseInt(b);
        if (n > 4) System.out.println("TBD");
        else System.out.println("Heisei");
        inp.close();
    }
}


Measured memory_bytes: 21844
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int64

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,K)=readInts() |> pair

printfn "%d" (min (N%K) (K-(N%K)))

Measured memory_bytes: 14044
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>L;
    vec bit(20,0);
    ll e = 0;
    rep(i,20){
        bit[i] = (L>>i) & 1;
        e += bit[i];
    }
    for(int i = 19; i >= 0; --i){
        if(bit[i] == 1) {
            N = i;
            break;
        }
    }

    e += N * 2 - 1;
    cout<<N+1<<' '<<e<<endl;
    rep(i,N){
        cout<<i+1<<' '<<i+2<<' '<<0<<endl;
        cout<<i+1<<' '<<i+2<<' '<<(1LL<<i)<<endl;
    }
    ll w = L;
    rep(i,N){
        if(bit[i] == 1){
            w -= (1LL<<i);
            cout<<i+1<<' '<<N+1<<' '<<w<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll t(0);
  t.pb(0);
  rep(i,n){
    ll a;
    cin>>a;
    t.pb(a);
  }
  t.pb(0);
  ll ans=0;
  for(int i=1;i<n+2;i++){
    ans+=abs(t[i]-t[i-1]);
  }
 
  for(int i=1;i<n+1;i++){
    ll aa=ans;
    aa-=abs(t[i]-t[i-1])+abs(t[i+1]-t[i]);
    aa+=abs(t[i+1]-t[i-1]);
    COUT(aa);
  }
}
    


Measured memory_bytes: 2164
import sys
x = int(input())

# b<=0

for i in range(0,int(x**(1/4))+1):
    for j in range(0,int(x**(1/4))+1):
        if i**5 - j**5 == x:
            print(i,j)
            sys.exit()


# b>0

for i in range(0,int(x**(1/4)+1)):
    for j in range(-int(x**(1/4))-2,0):
        if i**5 - j**5 == x:
            print(i,j)
            sys.exit()




Measured memory_bytes: 9228
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	vector<string> str_abc;

	REP(i,3){
		string str;
		cin>>str;
		str_abc.push_back(str);
	}

	int player = 0;	
	int indexes[3] = {0,0,0};


	while( str_abc[player].size() > indexes[player]  ){

		auto s = str_abc[player][indexes[player]];

		indexes[player]++;
		if(s =='a'){
			player = 0;
		}
		else if(s =='b')
		{
			player = 1;
		}else
		{
			player = 2;
		}

		// if(player == 0){
		// 	cout<<"A"<<endl;
		// }
		// else if(player == 1){
		// 	cout<<"B"<<endl;
		// }
		// else{
		// 	cout<<"C"<<endl;
		// }
	}
	

	if(player == 0){
		cout<<"A"<<endl;
	}
	else if(player == 1){
		cout<<"B"<<endl;
	}
	else{
		cout<<"C"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int sum = 0;
    
    for(int i = 1 ; i <= n ; i++){
      sum = sum + i;
    }
    System.out.println(sum);
  }
}

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

using namespace std;

template<class INT>
INT mod_pow(INT n, INT k, INT p){
    if (k == 0)
        return 1;
    if (k % 2 == 0){
        INT res = mod_pow(n, k / 2, p);
        return res * res % p;
    }
    return mod_pow(n, k - 1, p) * n % p;
}

template<class INT>
vector<INT> fact(INT n, INT p=INT(1e9 + 7)){
    vector<INT> f(n + 1);
    f[0] = 1;
    for (INT i = 0; i < n; i++)
        f[i + 1] = (i + 1) * f[i] % p;
    return f;
}

template<class INT>
vector<INT> invfact(INT n, const vector<INT> &f, INT p=INT(1e9 + 7)){
    vector<INT> inv(n + 1);
    inv[n] = mod_pow<INT>(f[n], p - 2, p);
    for (INT i = n; i > 0; i--)
        inv[i - 1] = inv[i] * i % p;
    return inv;
}

template<class INT>
INT comb(INT a, INT b, const vector<INT> &f, const vector<INT> &invf, INT p=(INT)(1e9 + 7)){
    if (a < b)
        return 0;
    if (a < 0 or b < 0)
        return 0;
    return f[a] * invf[b] % p * invf[a - b] % p;
}

int main(){
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    sort(A.begin(), A.end());
    const int64_t p = 1e9 + 7;

    auto f = fact<int64_t>(n, p);
    auto invf = invfact<int64_t>(n, f, p);
    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        auto coef = (comb<int64_t>(i, k - 1, f, invf, p) - comb<int64_t>(n - i - 1, k - 1, f, invf, p) + p) % p;
        ans += A[i] * coef % p;
        ans = (ans + p) % p;
    }

    cout << ans % p << endl;
}

Measured memory_bytes: 2560
import math
import fractions
import sys
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))



def funct(n):
	i=1
	res=0
	while True:
		ans=2*5**i
		
		if n//ans==0:
			break
		res+=(n//ans)
		i+=1
	return res


N=input1()
a=0
if N%2==1:
	a=0
else:
	a=funct(N)

print(a)






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

namespace AOJHelloWorld1
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int s = S % 60;
            int m = S / 60 % 60;
            int h = S / 60 / 60;
            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}



Measured memory_bytes: 17928
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int map[3][100000];
bool flag[100000];
int get(vector<int>v)
{
	int r = 0;
	for (int i = 0; i < v.size(); i++)if (v[i] < 0)r ^= 1, v[i] = -v[i];
	for (int i = 0; i < v.size(); i++)v[i] = (v[i] - 1) / 2;
	fill(flag, flag + 100000, false);
	for (int i = 0; i < v.size(); i++)
	{
		if (!flag[i])
		{
			int now = i;
			int c = 0;
			for (;;)
			{
				if (flag[now])break;
				flag[now] = true;
				c++;
				now = v[now];
			}
			if (c % 2 == 0)r ^= 2;
		}
	}
	return r;
}
void no()
{
	printf("No\n");
	exit(0);
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < 3; i++)for (int j = 0; j < num; j++)scanf("%d", &map[i][j]);
	vector<int>vec;
	vector<int>v1, v2;
	for (int i = 0; i < num; i++)
	{
		if (map[0][i] + 1 == map[1][i] && map[1][i] + 1 == map[2][i] && map[2][i] % 3 == 0)vec.push_back(map[2][i] / 3);
		else if (map[2][i] + 1 == map[1][i] && map[1][i] + 1 == map[0][i] && map[0][i] % 3 == 0)vec.push_back(-map[0][i] / 3);
		else no();
	}
	for (int i = 0; i < num; i++)
	{
		if (i % 2 == 0)
		{
			if (vec[i] % 2 == 0)no();
			else v1.push_back(vec[i]);
		}
		else
		{
			if (vec[i] % 2 == 0)v2.push_back(vec[i]);
			else no();
		}
	}
	int s = get(v1), t = get(v2);
	if (((s & 1) == 0) == ((t & 2) == 0) && ((s & 2) == 0) == ((t & 1) == 0))printf("Yes\n");
	else no();
}

Measured memory_bytes: 2680
import collections
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if n == 1:
    print(0)
else:
    ans = 0
    c = factorization(n)
    for arr in c:
        m = arr[1]
        i = 1
        for _ in range(m):
            if i > m:
                break
            ans += 1
            m -= i
            i += 1
    print(ans)

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int a,b,c,t=0,h=0;
	char k;
	while(cin>>a){
		//if(a==0)break;
		cin>>k>>b>>k>>c;
		if(a*a+b*b==c*c && a!=b) t++;
		else if(a==b) h++;
	}
	cout<<t<<endl<<h<<endl;
}

Measured memory_bytes: 1160
"""
3 つの箱 A,B,C があります。それぞれの箱には、整数が 1 つ入っています。
現在、箱 A,B,C に入っている整数はそれぞれ X,Y,Z

です。
これらの箱に対して以下の操作を順に行った後の、それぞれの箱に入っている整数を求めてください。

    箱 A

と箱 B
の中身を入れ替える
箱 A
と箱 C の中身を入れ替える
"""
x,y,z=input().split()
print(z,x,y)

Measured memory_bytes: 2940
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,w,n;cin>>h>>w>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    bool abc=0;
    int x=0;int k=a[x];
    for(int i=0;i<h;i++){
        if(abc==0){
            for(int j=0;j<w;j++){
                if(k){
                    cout<<x+1<<" ";
                    k--;
                }
                else{
                    x++;
                    k=a[x];
                    k--;
                    cout<<x+1<<" ";
                }
               
            }
             cout<<endl;
            abc=1;
        }
        else{
            vector<int>output;
            for(int j=w-1;j>=0;j--){
                if(k){
                     k--;
                    output.pb(x+1);
                 }
                 else{
                     x++;
                     k=a[x];
                     k--;
                     output.pb(x+1);
                 }
            }
            reverse(all(output));
            for(int j=0;j<output.size();j++)
                cout<<output[j]<<" ";
            cout<<endl;
            abc=0;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(aa,bb,cc) for(int aa=(bb);aa<=(int)(cc);++aa)
using namespace std;
const int maxn=1e5+10;
int n,m,flag;
int be[maxn],ne[maxn<<1],to[maxn<<1],e;
int st[maxn],cnt[2];
bool vis[maxn];

inline void add_edge(int x,int y){
	to[++e]=y,ne[e]=be[x],be[x]=e;
	to[++e]=x,ne[e]=be[y],be[y]=e;
}

template<class T>void read(T &x){
	x=0;char c=getchar();bool symbol=0;
	while(!isdigit(c)) symbol|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x=symbol?-x:x;
}

void dfs(int node,int fa,int res){
	st[node]=res;++cnt[res];vis[node]=1;
	for(int i=be[node];i;i=ne[i]){
		int u=to[i];
		if(u==fa) continue;
		if(vis[u]){
			if(st[node]==st[u]) flag=1;
		}
		else dfs(u,node,res^1);
	}
}

int main(){
	int x,y;
	read(n),read(m);
	For(i,1,m) read(x),read(y),add_edge(x,y);
	dfs(1,0,0);
	if(flag) printf("%lld\n",1ll*n*(n-1)/2-m);
	else printf("%lld\n",1ll*cnt[0]*cnt[1]-m);
	return 0;
}

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

typedef long long int ll;

using namespace std;

ll lcm(ll x, ll y) {
    ll a = x;
    ll b = y;
    int temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return a / x * b;
}

ll notMultiple(ll x, ll y, ll z) {
    return x - x / y - x / z + x / lcm(y, z);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << notMultiple(b, c, d) - notMultiple(a - 1, c, d) << endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


int N;

ll fact(ll x)
{
    if(x == 0) return 1;
    else return ((x % MOD) * fact(x-1) % MOD) % MOD;
}

void solve()
{
    cin >> N;
    cout << fact(N) % MOD << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#define maxn 3008
#define Max(a,b) a>b?a:b
#define Min(a,b) a<b?a:b
#define X first
#define Y second
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
using namespace std;
#pragma warning(disable:4996)//取消安全警告
#pragma comment(linker, "/STACK:102400000,102400000")//手动扩栈
//ios::sync_with_stdio(false);
//**********不要使用int***********************
ll ans, cans, rans, fans, lans,sum;
int main() {
	ll  x, y;
	cin >> x >> y;
	int a = 0;
	//if (x == 1)x++;
	while (x<= y) {
		if (x > INF / 2+1)break;
		x *= 2; a++;
	}
	cout << a<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	string s[55]={},ans="";
	int a[30]={};
	cin>>n;
	FOR(i,0,n)cin>>s[i];
	FORQ(k,0,'z'-'a'){
		a[k]=mod;
	}
	FOR(i,0,n){
		int b[30]={};
		FOR(j,0,s[i].length()){
			b[s[i][j]-'a']++;
		}
		FORQ(k,0,'z'-'a'){
			a[k]=min(a[k],b[k]);
		}
	}
	FORQ(k,0,'z'-'a'){
		if(a[k]>0){
			char cc='a'+k;
			FOR(t,0,a[k]){
				ans+=cc;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#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<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
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;
int main(){
	int N,P[9],Q[9];
	scan(N);
	int pa=1,qa=1;
	vint A(N);
	rep(i,N){
		A[i]=i;
	}
	rep(i,N){
		scan(P[i]);
		P[i]--;
	}
	rep(i,N){
		scan(Q[i]);
		Q[i]--;
	}
	while(1){
		int flag=1;
		rep(i,N){
			if(A[i]!=P[i]){
				flag=0;
			}
		}
		if(flag){
			break;
		}
		pa++;
		next_permutation(ALL(A));
	}
	rep(i,N){
		A[i]=i;
	}
	while(1){
		int flag=1;
		rep(i,N){
			if(A[i]!=Q[i]){
				flag=0;
			}
		}
		if(flag){
			break;
		}
		qa++;
		next_permutation(ALL(A));
	}
	prin(abs(pa-qa));
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    String st = "";
    for(int i = 0 ; i < n ; ++i){
      st += s.charAt(i);
      st += t.charAt(i);
    }
   
    System.out.println(st);
    
  }
}

Measured memory_bytes: 39272
import sys
import bisect
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        left=bisect.bisect_left(l,l[i]+l[j])
        # right=bisect.bisect_right(l,(l[i]+l[j]+1)//2)
        # print(left)
        # print(right)
        # print()
        cnt=left-(j+1)
        if left<=j+1:
            # print(99)
            continue
        # if right<j+2:
        #     cnt-=j+2-right
        if cnt>=0:
            ans+=cnt
        
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	string str;
	cin >> str;
	map<char, ll> mp;
	for (size_t i = 0; i < str.size(); i++)
	{
		mp[str[i]]++;
	}
	ll ans = 1;
	for (char i = 'a'; i < 'z' + 1; i++)
	{
		ans *= mp[i] + 1;
		ans %= mod;
	}
	cout << (ans  + mod - 1) % mod << endl;
	return 0;
}

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

// 素因数分解
map<ll, int> prime_factorization(ll n) {
	map<ll, int> res;
	for(ll i = 2; i * i <= n; i++){
		if(n % i) continue;
		res[i] = 0;
		while(n % i == 0){
			n /= i;
			res[i]++;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main() {
	
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	
	vector<map<ll, int>> f(n);
	rep(i, n) f[i] = prime_factorization(a[i]);
	
	// 各素因数の最大値を取得
	map<int, int> mx;
	rep(i, n){
		for(auto t: f[i]){
			int tei = t.first;
			int zyo = t.second;
			if(mx[tei] < zyo) mx[tei] = zyo;
		}
	}
	// lcm
	mint x = 1;
	for(auto t: mx) {
		int tei = t.first;
		int zyo = t.second;
		x *= pow(tei, zyo);
	}
	
	mint ans = 0;
	rep(i, n){
		ans += x / a[i];
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 3968