akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(26));
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        for (auto c : s) {
            a[i][c - '0' - 49]++;
        }
    }
    vector<int> ans = a[0];
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < n; j++) {
            ans[i] = min(ans[i], a[j][i]);
        }
        for (int k = 0; k < ans[i]; k++) {
            char c = i + 49 + '0';
            cout << c;
        }
    }
}


Measured memory_bytes: 3588
#include<iostream>
#include<queue>
#include<utility>

using namespace std;

const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
char mp[100][100];
int step[100][100];
bool vis[100][100];
int n,m;

bool check(int x,int y) {
    if(x < 0 || y < 0|| x >= n || y >= m || vis[x][y] || mp[x][y] == '#') return false;
    return true;
}

int BFS() {
    queue<pair<int ,int> > q;
    q.push(make_pair(0,0));
    step[0][0] = 1;
    vis[0][0] = true;
    while (!q.empty()) {
        pair<int ,int> t = q.front();
        q.pop();
        for(int i = 0;i < 4;i++) {
            int tox = t.first + Move[i][0];
            int toy = t.second + Move[i][1];
            if(tox == n - 1 && toy == m - 1)   return step[t.first][t.second] + 1;
            if(check(tox,toy)) {
                vis[tox][toy] = true;
                step[tox][toy] = step[t.first][t.second] + 1;
                q.push(make_pair(tox,toy));
            }
        }
    }
    return -1;
}


int main(){
    cin>>n>>m;
    int cnt = 0;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++) {
            cin>>mp[i][j];
            if(mp[i][j] == '#') cnt++;
        }
    int res = BFS();
    if(res == -1) {
        cout<<"-1"<<endl;
    } else {
    	
        cout<< n*m - res - cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Dice:	
	def __init__( self, nums ):
		self.face = nums
	
	def rolltoTop( self, dicenum ):	
		num = 0
		for i,val in enumerate( self.face ):
			if dicenum == val:
				num = i
				break
		if num == 1:
			self.roll( "N" )
		elif num == 2:
			self.roll( "W" )
		elif num == 3:
			self.roll( "E" )
		elif num == 4:
			self.roll( "S" )
		elif num == 5:
			self.roll( "NN" )
	
	def roll( self, actions ):
		for act in actions:
			t = 0
			if act == "E":
				t =   self.face[0]
				self.face[0] =   self.face[3]
				self.face[3] =   self.face[5]
				self.face[5] =   self.face[2]
				self.face[2] = t
			elif  act == "N":
				t =   self.face[0]
				self.face[0] =   self.face[1]
				self.face[1] =   self.face[5]
				self.face[5] =   self.face[4]
				self.face[4] = t
			elif  act == "S":
				t =  self.face[ 0]
				self.face[0] =  self.face[4]
				self.face[4] =  self.face[5]
				self.face[5] =  self.face[1]
				self.face[1] = t	
			elif  act == "W":
				t =  self.face[0]
				self.face[0] =  self.face[2]
				self.face[2] =  self.face[5]
				self.face[5] =  self.face[3]
				self.face[3] = t	
			elif  act == "M":
				t =  self.face[1]
				self.face[1] =  self.face[2]
				self.face[2] =  self.face[4]
				self.face[4] =  self.face[3]
				self.face[3] = t

diceface = [ int( val ) for val in raw_input( ).split( " " ) ]
dice = Dice( diceface )
q = int( raw_input( ) )
for i in range( q ):
	topnum, frontnum = [ int( val ) for val in raw_input( ).split( " " ) ]
	dice.rolltoTop( topnum )
	while dice.face[1] != frontnum:
		dice.roll( "M" )
		
	print( dice.face[2] )

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

int main() {
    int X, Y;
    while (cin >> X >> Y, (X || Y)) {
        vector<vector<int>> sketch(Y, vector<int>(X, 0));
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                cin >> sketch[i][j];
            }
        }
        int dp[15][15] = {};
        int pattern = 0;
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                if (i == 0 && sketch[i][j] == 0) {
                    dp[i][j] = 1;
                }
                if (sketch[i][j] == 0) {
                    if (Y <= i+1) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (0 <= j-1 && sketch[i+1][j-1] == 0) {
                        dp[i+1][j-1] += dp[i][j];
                    }
                    if (sketch[i+1][j] == 0 || sketch[i+1][j] == 2) {
                        dp[i+1][j] += dp[i][j];
                    }
                    if (j+1 < X && sketch[i+1][j+1] == 0) {
                        dp[i+1][j+1] += dp[i][j];
                    }
                } else if (sketch[i][j] == 2) {
                    if (Y <= i+2) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (sketch[i+2][j] == 0 || sketch[i+2][j] == 2) {
                        dp[i+2][j] += dp[i][j];
                    }
                }
            }
        }
        cout << pattern << endl;
    }
    return 0;
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -fsanitize=signed-integer-overflow -fno-sanitize-recover=all -o template template.cpp

signed main()
{
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	bool ans = 1;


	if(b-a > k)ans = 0;
	else if(c-a > k)ans = 0;
	else if(d-a > k)ans = 0;
	else if(e-a > k)ans = 0;
	else if(c-b > k)ans = 0;
	else if(d-b > k)ans = 0;
	else if(e-b > k)ans = 0;
	else if(d-c > k)ans = 0;
	else if(e-c > k)ans = 0;
	else if(e-d > k)ans = 0;

	if(ans ==  0)cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int a, b; cin >> a >> b;
    int cnt = 0;
    for (int i=a;i<=b;i++) {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());
        if (s==t) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;

int sq;
ll dp[105][65005];
ll pre[105][65005];
ll cnt[65005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    sq = (int)sqrt(n);
    
    f1(sq){
        cnt[i] = 1;
    }
    //cout << "HERE" << endl;
    int lst = sq;
    for (int i = 1;i <= sq;i++) {
        int cur = n / (sq - i + 1);
        cnt[i + sq] = cur - lst;
        //cout << i + sq << endl;
        lst = cur;
    }
    //cout << "HERE"<<endl;
    f1(sq) {
        dp[0][i] = 1;
        dp[0][i+sq] = cnt[i+sq];
    }
    f1(sq * 2) {
        pre[0][i] = pre[0][i-1] + dp[0][i];
        pre[0][i] %= mod;
        //cout << dp[0][i] << endl;
    }
    //cout << "HERE"<<endl;
    f1(k-1) {
        fr (j,1,sq*2+1) {
            //cout << sq * 2 + 1 - j <<' '<<cnt[j] << endl;
            dp[i][j] = pre[i-1][sq*2+1-j] * cnt[j] % mod;
        }
        fr (j,1,sq*2+1) {
            pre[i][j] = pre[i][j-1] + dp[i][j];
            pre[i][j] %= mod;
        }
    }
    cout << pre[k-1][sq*2] << '\n';
}

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

long long int mini[2003]={0};

int main(){
    long long int n, x;
    cin >> n >> x;
    vector<long long int> v;
    long long int ans = 0;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
        ans += a;
    }

    for(int i=0;i<n;++i)mini[i] = v[i];

    for(long long int i=1;i<n;++i){
        long long int sum = x * i;
        for(int j=0;j<n;++j){
            int idx = j - i;
            if(idx < 0)idx += n;
            mini[j] = min(mini[j], v[idx]);
            sum += mini[j];
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
Hlist = input().split()
nlist = []
for t in Hlist:
    nlist.append(int(t))
k = nlist[0]
maxlist = [nlist[0]]
p = 1
for t in range(1,len(nlist)):
    if nlist[t] >= max(maxlist):
        p+=1
        maxlist.append(nlist[t])
    else:
        maxlist.append(nlist[t])
print(p)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll a, b;

void solve() {
	cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
use strict;
use warnings;

sub main {
    my ($N,$M) = split(/ /,<STDIN>);
    chomp($M);
    my @xyz;
    for (1..$N) {
        chomp(my $l=<STDIN>);
        push(@xyz, [split(/ /, $l)]);
    }
    print solve($N,$M,\@xyz);
}

main() unless caller;

sub solve {
    my ($N,$M,$xyz) = @_;
    my @arr;
    for my $l(@$xyz){
        my $tmp = 0;
        for my $i(@$l){
            $tmp += $i;
        }
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    my $max = 0;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp -= $l->[0];
        $tmp += $l->[1];
        $tmp += $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp += $l->[0];
        $tmp -= $l->[1];
        $tmp += $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp += $l->[0];
        $tmp += $l->[1];
        $tmp -= $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp -= $l->[0];
        $tmp -= $l->[1];
        $tmp += $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp -= $l->[0];
        $tmp += $l->[1];
        $tmp -= $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp += $l->[0];
        $tmp -= $l->[1];
        $tmp -= $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);


    @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp -= $l->[0];
        $tmp -= $l->[1];
        $tmp -= $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);

    return $max;
}

sub _max {
    my ($arr, $M, $max) = @_;
    my $x = 0;
    my $y = 0;
    my $z = 0;
    for my $i(0..$M-1){
         $x += $arr->[$i]->[1]->[0];
         $y += $arr->[$i]->[1]->[1];
         $z += $arr->[$i]->[1]->[2];
    }
    my $tmp = abs($x) + abs($y) + abs($z);
    $max = $max > $tmp ? $max : $tmp;
    return $max;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


pi getPair(string s){
  int x=0, y=1;
  if (s == "AC"){
    x = 0; y = 2;
  }
  if (s == "BC"){
    x = 1; y = 2;
  }
  return pi{x, y};
}

int main() {
  int n;
  cin >> n;
  vi abc(3);
  rep(i, 3) cin >> abc[i];

  vector<string> s(n);
  rep(i, n){
    cin >> s[i];
  }
  s.push_back("AB");

  vector<string> mp = {"A", "B", "C"};
  vector<string> ans;
  rep(i, n){
    pi si = getPair(s[i]);
    if (abc[si.first] == 0 and abc[si.second] == 0){
      cout << "No" << endl;
      return 0;
    }

    if (abc[si.first] == 0){
      abc[si.first]++;
      abc[si.second]--;
      ans.push_back(mp[si.first]);
      continue;
    }

    if (abc[si.second] == 0){
      abc[si.first]--;
      abc[si.second]++;
      ans.push_back(mp[si.second]);
      continue;
    }

    pi sin = getPair(s[i+1]);
    if (si.first == sin.first or si.first == sin.second){
        abc[si.first]++;
        abc[si.second]--;
        ans.push_back(mp[si.first]);
    }else{
        abc[si.first]--;
        abc[si.second]++;
        ans.push_back(mp[si.second]);
    }
  }

  cout << "Yes" << endl;
  rep(i, n){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 13644
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n, m; cin >> n >> m;
    priority_queue<int> pque;
    REP(i, n) {
        int a; cin >> a;
        pque.push(a);
    }
    REP(i, m) {
        int top = pque.top();
        pque.pop();
        top /= 2;
        pque.push(top);
    }
    ll sum = 0;
    while (!pque.empty()) {
        int tmp = pque.top();
        pque.pop();
        sum += tmp;
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
#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>;

bool flag[100001];//その数を見たかどうか/falseなら素数


int main() {
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    rep(i,Q) cin >> l[i] >> r[i];
    
    vector<int> prime_v(100000);

    for (int i = 2; i <= 100000; ++i) {
        if(!flag[i]) {
            for (int j = i * 2; j <= 100000; j += i) flag[j] = true;
        }
    }
    for (int i = 3; i <= 100000; i += 2) if (!flag[i] && !flag[(i+1)/2]) ++prime_v[i];//今回は2が含まれない
    for (int i = 3; i <= 100000; i += 2) prime_v[i] += prime_v[i-2];

    rep(i,Q) {
        if (l[i] == 1) cout << prime_v[r[i]] << endl;
        else cout << prime_v[r[i]] - prime_v[l[i]-2] << endl;
    }
}



Measured memory_bytes: 4484
s = input()
t = input()

table = [[0] * (len(t)+1) for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
  for j in range(1, len(t)+1):
    if(s[i-1]==t[j-1]):
      table[i][j] = table[i-1][j-1]+1
    else:
      table[i][j] = max(table[i-1][j], table[i][j-1])

y = len(s)
x = len(t)

moji = ""

while(True):
  while(y > 0 and table[y-1][x] == table[y][x]):
    y -= 1
  
  while(x > 0 and table[y][x-1] == table[y][x]):
    x -= 1
  if(x > 0 and y > 0):
    moji = s[y-1] + moji
    x -= 1
    y -= 1
  else:
    break

print(moji)
  

Measured memory_bytes: 144632
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000;

int n, a[N], b[N];

bool check() {
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i]) {
			return false;
		}
	}
	return true;
}

int main() {

	scanf("%d", &n);

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

	sort(b, b + n);

	if (check()) {
		puts("YES");
		exit(0);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			swap(a[i], a[j]);
			if (check()) {
				puts("YES");
				exit(0);
			}
			swap(a[i], a[j]);
		}
	}

	puts("NO");

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  REP(i,0,N) cin >> A[i];
  REP(i,0,N) cin >> B[i];
  REP(i,0,N) cin >> C[i];
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));

  ll ans = 0;
  REP(i,0,N) {
    // B[i]より小さいAの要素数
    int x = lower_bound(ALL(A), B[i]) - A.begin();
    // B[i]より大きいCの要素数
    int y = C.end() - upper_bound(ALL(C), B[i]);

    ans += (ll)x*y;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A, B, K = map(int, input().split())
nums = []
for i in range(min(A, B), 0, -1):
    if A % i == B % i == 0:
        nums.append(i)
print(nums[K - 1])



Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    vi board = {a, b, c};
    sort(board.begin(), board.end());
    for(int i = 0; i < k; i++) {
        board[2] *= 2;
        sort(board.begin(), board.end());
    }
    rep(i,3) sum += board[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

//xとy/最大公倍数返す
int gcd(int x, int y){
  int a;
  if(y<x){
    a=x;
    x=y;
    y=a;
  }
  
  while(1){
    a=y%x;
    y=x;
    x=a;
    if(a==0)break;
  }
  return y;
}


int main(){
  int x,y;
 
  scanf("%d%d",&x,&y);//INPUT

  printf("%d\n",gcd(x,y));//OUTPUT

  return 0;
}



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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=k;i<n;i++){
    if(a[i]>a[i-k]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int N;
  cin >> N;
  Vll T(N), A(N);
  INPUT(T); INPUT(A);
  ll max_h = MAX(T);
  if (max_h != MAX(A))
  {
    cout << 0 << endl;
    return 0;
  }
  Vll H(N, 0);
  REP(i, N) H[i] = min(T[i], A[i]);
  VB fixed(N, false);
  fixed[0] = true;
  fixed[N-1] = true;
  REP2(i, 1, N)
  {
    if (T[i] > T[i-1])
    {
      if (T[i] > A[i])
      {
        cout << 0 << endl;
        return 0;
      }
      fixed[i] = true;
    }
    if (T[i] == max_h) break;
  }
  REPR(i, N-1)
  {
    if (A[i] > A[i+1])
    {
      if (A[i] > T[i])
      {
        cout << 0 << endl;
        return 0;
      }
      fixed[i] = true;
    }
    if (A[i] == max_h) break;
  }
  ll ans = 1;
  REP(i, N)
  {
    if (!fixed[i])
    {
      ans *= H[i];
      ans %= MOD;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int gcd(int a, int b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}

int lcm(int a, int b)
{
	return a / gcd(a, b)*b;
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>t(n);
	rep(i, n) {
		cin >> t[i];
	}
	int ret = t[0];
	rep1(i, n) {
		ret = lcm(ret, t[i]);
	}
	print(ret);
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){int list[32768];int i,j,c;for(i=2;i<32770;i++)list[i-2]=i;for(j=2;j*j<32771;j++)if(list[j-2]!=0)for(i=1;j-2+list[j-2]*i<32769;i++)list[j-2+list[j-2]*i]=0;while(1){cin>>i,c=0;if(i==0)break;for(j=2;j<=(i/2);j++)if((list[j-2]!=0)&&(list[i-j-2]!=0))c++;cout<<c<<"\n";}}

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

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

typedef long long ll;
typedef pair<int, int> P;

int main(int argc, char const *argv[]){
  ll r0,w0,c,r;
  while(cin>>r0>>w0>>c>>r, r0) {
    ll x=0;
    while(1){
      if(r0+x*r-c*w0>=0){
        cout<<x<<endl;
        break;
      }
      x++;
    }
  }
  return 0;
}

Measured memory_bytes: 3060
x, y = map(int, input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python3
def main():
    N = int(input())

    ans = 0
    for n in range(1, N + 1, 2):
        cnt = 0
        for divisor in range(1, N + 1):
            cnt += 0 if n % divisor else 1
        ans += 1 if cnt == 8 else 0
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int n;

int main()
{
  while(cin >> n) printf("3C%02d\n", (n % 39 ? n % 39 : 39));

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){
  int n,b,f,r,v,i,j,k;
  cin >> n;
  int a[4][3][10];
  for (i=0;i<4;i++) {
    for (j=0;j<3;j++) {
      for (k=0;k<10;k++) {
        a[i][j][k]=0;
      }
    }
  }

  for (i=0;i<n;i++) {
    cin >> b >> f >> r >> v;
    a[b-1][f-1][r-1]+=v;
  }

  for (i=0;i<4;i++) {
    for (j=0;j<3;j++) {
      for (k=0;k<10;k++) {
        cout << " " << a[i][j][k];
      }
      cout << endl;
    }
    if (i<3) cout << "####################" << endl;
  }

  return 0;
}



Measured memory_bytes: 3092
from math import ceil
a,b = map(int,input().split())

ah=(a+1)//0.08
al=ceil(a/0.08)
bh=(b+1)//0.1
bl=ceil(b/0.1)

if ah < al or bh < bl:
    ans = -1
else:
    if (al <= bh and ah >= bl) or (al >= bh and ah <= bl):
        ans = max(al,bl)
    else:
        ans = -1
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{ 
  int a, p;
  cin >> a >> p;
  a = a * 3;
  cout << (a + p) / 2 << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

vector<ll> fact,inv;

ll f(ll a,ll b, ll p){  // a^b mod pを求める
	if (b == 0)return 1;
	else if (b % 2 == 0){
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n){
	fact.resize(n+1,1);
	inv.resize(n+1,1);
	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
		fact[i] = fact[i-1] * i % mod;
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
		inv[i] = f(fact[i],mod-2,mod) % mod;
}

ll comb(ll n,ll k){  //n_C_k
	if (n < k) return 0;
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


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

	ll ans=0;
	rep(i,min(n,k)+1){
		ans += comb(n,i) * comb(n-1,i) % mod;
		ans %= mod;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
from collections import defaultdict as dd

h,w,n=map(int,input().split())
d=dd(int)
c={i:0 for i in range(10)}

for _ in range(n):
    a,b=map(int,input().split())
    for i in range(3):
        for j in range(3):
            if a-i>0 and b-j>0 and a-i<=h-2 and b-j<=w-2:
                d[(a-i,b-j)]+=1

d=dict(d)
v=0
for i in d.values():
    c[i]+=1
    v+=1
c[0]=(h-2)*(w-2)-v

for i in range(10):
    print(c[i])

Measured memory_bytes: 181592
#include<stdio.h>
#define MAX 500001
#define NIL -1
  
 struct Node{
            int key;
            int left,right,parent;
            };
  
 struct Node T[MAX];
 int root;
 int ix=0;
  
 void insert(int k){
  
            int y=NIL;
            int x=root;
            int z=ix++;
  
  
            T[z].key=k;
            T[z].left=NIL;
            T[z].right=NIL;
  
             
            while(x != NIL){//探す処理
                     y=x;
                     if(T[z].key<T[x].key){x=T[x].left;}
                     else {x=T[x].right;}
                     }
  
            T[z].parent=y;
            if(y==NIL)root=z;//セットする処理
            else {
                  if(T[z].key<T[y].key)T[y].left=z;
                  else T[y].right=z;
                  }
            }
  
  
  
 int find(int root,int k){
            while(T[root].key!=k && root!=NIL){
                      if(k<T[root].key){root=T[root].left;}
                      else {root=T[root].right;}
                      }
            return root;
            }
  
  
 int inorder(int u){
             if(u==NIL)return;
             inorder(T[u].left);
             printf(" %d",T[u].key);
             inorder(T[u].right);
             }
  
 int preorder(int u){
             if(u==NIL)return;
             printf(" %d",T[u].key);
             preorder(T[u].left);
             preorder(T[u].right);
             }
  
 int main(){
         int n,i,k,ans;
         char m[10];
         root=NIL;
         ix=0;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].key=NIL;}
         for(i=0;i<n;i++){
                  scanf("%s",&m);
                  if(m[0]=='i'){
                              scanf("%d",&k);
                              insert(k);
                              }
                  else if(m[0]=='f'){
                              scanf("%d",&k);
                              ans=find(root,k);
                              if(ans!=NIL)printf("yes\n");
                              else printf("no\n");
                              }
                  else if(m[0]=='p'){
                              inorder(root);
                              printf("\n");
                              preorder(root);
                              printf("\n");
                              }
                  }
         return 0;
         }


Measured memory_bytes: 9556
using System;
using System.Linq;

class names
{

    static void Main()
    {
        long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = s[0];
        long d = s[1];
        long ans = 0;
        long f = 0;
        for(long k = 0; k < n; k++)
        {
            s = Console.ReadLine().Split().Select(long.Parse).ToArray();
            f = s[1] * s[1] + s[0] * s[0];
            if (f <= d*d)
            {

                ans++;

            }




        }

        Console.WriteLine(ans);






    }





}

Measured memory_bytes: 41256
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
int mod = 1e9+7;
void add_self(int &a,int b) {
	a+=b;
	if(a>=mod) a-=mod;
}
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n,k;
cin>>n>>k;
int ans=0;
FOR(i,k,n+2){
	 add_self(ans,((n-i+1)*i+1)%mod);
	// cout<<((n-i+1)*i+1)<<endl;
}
cout<<ans; 
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
typedef long long LL; 
const int MAX_N = 1e5 + 5; 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; } 
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 
int N, sz[MAX_N];
LL D[MAX_N]; 
struct node { LL D; int id; } a[MAX_N]; 
bool operator < (const node &l, const node &r) { return l.D < r.D; } 
int dis[MAX_N]; 
void dfs(int x, int fa) { 
	for (int i = fir[x]; ~i; i = e[i].next) {
		int v = e[i].to; if (v == fa) continue; 
		dis[v] = dis[x] + 1, dfs(v, x); 
	} 
} 
int main () { 
	clearGraph(); 
	scanf("%d", &N); 
	for (int i = 1; i <= N; i++) scanf("%lld", D + i), sz[i] = 1, a[i] = (node){D[i], i}; 
	sort(&a[1], &a[N + 1]); 
	for (int i = N; i > 1; i--) { 
		int x = a[i].id, u = 0; 
		LL ds = 2 * sz[x] - N + a[i].D; 
		u = lower_bound(&a[1], &a[N + 1], (node){ds, 0})->id; 
		if (D[u] != ds) return puts("-1") & 0; 
		sz[u] += sz[x]; 
		Add_Edge(u, x), Add_Edge(x, u); 
	} 
	dfs(1, 0);
	LL ds = 0; 
	for (int i = 1; i <= N; i++) ds += dis[i]; 
	if (ds != D[1]) return puts("-1") & 0; 
	for (int i = 0; i < e_cnt; i += 2) printf("%d %d\n", e[i].to, e[i ^ 1].to); 
    return 0; 
} 

Measured memory_bytes: 15028
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int intA = scan.nextInt();
		int intB = scan.nextInt();
		if(intA < intB){
			System.out.println("a < b");
		}else if(intA > intB){
			System.out.println("a > b");
		}else if(intA == intB){
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17160
numbers = []
n = int(raw_input())
s = raw_input()
count = 0

numbers = s.split(" ")
for i in range(int(n)):
	numbers[i] = int(numbers[i])

flag = 1
while flag:
	flag = 0
	for j in range(n - 1, 0, -1):
		if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1
print ' '.join([str(a) for a in numbers])
print count

Measured memory_bytes: 6360
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const long long Maxn=1e2;
typedef long long ll;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int A=min(a,b);
	int B=min(c,d);
	int sum=A+B;
	printf("%d",sum);
}

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

std::vector<std::string> solve(int a)
{
  std::vector<std::string> result;

  if (a == 1) {
    result.push_back("a");
    return result;
  }

  auto v = solve(a - 1);
  for (const auto& s : v) {
    std::vector<int> used(10);
    char max = 'a';
    for (auto c : s) {
      max = std::max(max, c);
    }
    for (char c = 'a'; c <= max + 1; ++c) {
      result.push_back(s + c);
    }
  }

  return result;
}

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

  std::cout << std::setprecision(20);

  for (const auto& s : solve(n)) {
    std::cout << s << std::endl;
  }
}


Measured memory_bytes: 9164
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i64>();
    let n2 = 1 << n;
    a.sort();
    let mut s = vec![];
    s.push(a[a.len() - 1]);
    let idx = a.len() - 1;
    a[idx] = -1;
    for i in 0..n {
        let mut p = s.clone();
        p.sort();
        let mut ai = (1 << n) - 1;
        while p.len() > 0 {
            if a[ai] == -1 {
                if ai == 0 {
                    break;
                }
                ai -= 1;
                continue;
            }
            if a[ai] < *p.last().unwrap() {
                s.push(a[ai]);
                p.pop();
                a[ai] = -1;
            }
            if ai == 0 {
                break;
            }
            ai -= 1;
        }
        if p.len() > 0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;

typedef long long ll;
int main(){
    ll n,k;
    ll t = 0;
    cin >>n >>k;
    if(k==0) cout<<(n*n)<<endl;
    else{
        for(ll b = 1; b <= n;b++){
            if(b-1<k) t += ((n/b)*b);
            else t += ((n/b)*k);
            if(n%b<k) t+=(n%b);
            else t += (k-1);
        }
    cout << (n*n-t) <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int id = sc.nextInt();
		Node root = new Node(++id, 0, sc.next());
		for (int i = 1; i < n; i++) {
			int targetId = sc.nextInt();
			Node parent = root.findNode(targetId);
			parent.children.add(new Node(++id, parent.depth + 1, sc.next()));
		}
		root.printContents();
		sc.close();
	}

}

class Node {
	int id, depth;
	String contents;
	List<Node> children;

	Node(int i, int d, String c) {
		id = i;
		depth = d;
		contents = c;
		children = new ArrayList<Node>();
	}

	public Node findNode(int id) {
		if (id == this.id)
			return this;
		for (Node child : children) {
			Node target = child.findNode(id);
			if (target != null)
				return target;
		}
		return null;
	}

	public void printContents() {
		for (int i = 0; i < depth; i++)
			System.out.print('.');
		System.out.println(contents);
		for (Node child : children)
			child.printContents();
	}
}

Measured memory_bytes: 58416
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

int qq;
ull n=0,t[R],s=0;
int main()
{
	
	cin >> n;
	for(int i=0;i<n;++i)
	{
		cin >> t[i];
		s=s^t[i];
	}
	for(int i=0;i<n;++i)
	{
		t[i]^=s;
		if(i<n-1) cout<<t[i]<<" ";
		else cout<<t[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 5184
N,K = map(int,input().split())
R,S,P = map(int,input().split())
sco = {"r":P,"s":R,"p":S}
T = input()
B = [-1]*N
ans = 0
for i in range(N):
    if i<K:
        ans+=sco[T[i]]
    elif T[i]!=T[i-K]:
        ans+=sco[T[i]]
    elif B[i-K]==-1:
        B[i]=0
    else:
        ans+=sco[T[i]]
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  cin >> n;
  vv(ll) a(n,v(ll)(n));
  rep(i,n)rep(j,n) cin >> a[i][j];

  v(ll) dp(1<<n);
  dp[0] = 1;
  rep(s,1<<n) {
    rep(j,n) {
      int i = pcnt(s);
      if (bit(s,j) == 1 && a[i-1][j] == 1) {
        dp[s] = (dp[s] + dp[s^(1<<j)])%mod;
      }
    }
  }

  ll ans = dp[(1<<n)-1];
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = 2e6 + 5;
const int mod = 1e9 + 7;

vector < ll > fact (N);

ll pwr (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv (ll a) {
  return pwr (a, mod - 2);
}

ll nCr (int n, int r) {
  return ((((fact[n] * inv (fact[r])) % mod) * inv (fact[n - r])) % mod);
}

ll f (int i, int j) {
  return nCr (i + j, j);
}

ll g (int i, int j) {
  return (f (i + 1, j + 1) - 1 + mod) % mod;
}

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

  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  ll ans = (g (r2, c2) - g (r2, c1 - 1) - g (r1 - 1, c2) + g (r1 - 1, c1 - 1) + 2 * mod) % mod;

  cout << ans << '\n';
}


Measured memory_bytes: 18652