akhauriyash/Code-Regression huggingface dataset:
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 100500;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        ll x = 0;
        for (int j = i; j < s.size(); j++)
        {
            x = 10 * x + s[j] - '0';
            ans += x * (1 << max(i - 1, 0)) * (1 << max(0, ((int)s.size() - j - 2)));
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
package main

import (
  "fmt"
)

/**
in
2
2
2
100
 */
func main() {
  var a, b, c, target int
  fmt.Scan(&a, &b, &c, &target)
  cnt := 0
  for i:=0 ; i <= a ; i++ {
    for j:=0 ; j<=b ; j++ {
      for k:=0 ; k<=c ; k++ {
        if i*500 + j*100 + k*50 == target {
          cnt++
        }
      }
    }
  }
  fmt.Println(cnt)
}



Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int>P;
#define Z(a,b)v.push_back(make_pair(a,b))

struct C{bool operator()(P a,P b){return a.first*a.second<b.first*b.second;}};
int main(){
	int n,w,d,p,s;
	for(;scanf("%d%d%d",&n,&w,&d),w;puts("")){
		vector<P>v;
		Z(w,d);
		for(;n--;){
			scanf("%d%d",&p,&s);p--;
			s%=v[p].first+v[p].second;
			int x=v[p].first,y=v[p].second,state=0,_x=0,_y=0,x1,x2,y1,y2;
			for(;s--;)if(state==0){_x++;if(_x==x)state=1;}else _y++;
			if(state==0)x1=_x,x2=x-_x,y1=y2=y;
			else x1=x2=x,y1=_y,y2=y-_y;

			v.erase(v.begin()+p);
			if(x1*y1>x2*y2)
				Z(x2,y2),Z(x1,y1);
			else
				Z(x1,y1),Z(x2,y2);
		}

		for(sort(v.begin(),v.end(),C());v.size();){
			printf("%d",v[0].first*v[0].second);
			v.erase(v.begin());
			if(v.size())printf(" ");
		}
	}
}

Measured memory_bytes: 0
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 9 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    ivv(n);
    ivv(m);
    mii food;
    int temp = n;
    while(temp--){
        ivv(k);
        while(k--){
            ivv(t);
            food[t]++;
        }
    }
    int counter =0;
    for(auto itr:food){
        if(itr.second >=n){
            counter++;
        }
    }
    cout<<counter<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    string s;cin >> s;
    reverse(s.begin(),s.end());

    string s1="dream";reverse(s1.begin(),s1.end());
    string s2="dreamer";reverse(s2.begin(),s2.end());
    string s3="erase";reverse(s3.begin(),s3.end());
    string s4="eraser";reverse(s4.begin(),s4.end());

    int i=0;
    while(1){
        if(i==s.size()) break;
        else if(s.substr(i,s1.size())==s1) i += s1.size();
        else if(s.substr(i,s2.size())==s2) i += s2.size();
        else if(s.substr(i,s3.size())==s3) i += s3.size();
        else if(s.substr(i,s4.size())==s4) i += s4.size();
        else break;
    }
    YES(i==s.size())
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <cctype>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef string::const_iterator State;
class ParseError {};

void consume(State &begin, char expected);
int factor(State &begin);
int expression(State &begin);
int term(State &begin);
int number(State &begin);

void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'"
            << endl;
        cerr << "Rest string is '";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        throw ParseError();
    }
}

int factor(State &begin) {
    if (*begin == '(') {
        consume(begin, '(');
        int ret = expression(begin);
        consume(begin, ')');
        return ret;
    } else {
        return number(begin);
    }
}

// ?????????????????????????????????????????????????????????????????????
int expression(State &begin) {
    int ret = term(begin);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}

// ?????????????????????????????????????????????????????????????????????
int term(State &begin) {
    int ret = factor(begin);

    for (;;) {
        if (*begin == '*') {
            begin++;
            int a = factor(begin);
            ret *= a;
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

int main() {
    int N;
    cin >> N;
    cin.ignore();
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = expression(begin);
        consume(begin, '=');
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < (int)n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e8 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int M = 1003;
const int N = 1e6 + 10;



int main() {
    //freopen("a.in", "r", stdin);
    int n;
    cin >> n;
    set <int> s;
    fr(i, n) {
        int x;
        cin >> x;
        if (s.count(x))
            s.erase(x);
        else
            s.insert(x);
    }
    cout << s.size();
}


Measured memory_bytes: 4864
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n;
  long long int sum;
  cin>>n;
  vector<long long int> a(n),b(n);
  rep(i,n){
    cin>>a.at(i);
    b.at(a.at(i)-1)+=1;
  }
  rep(i,n){
    (b.at(i)==0?sum+=0:sum+=b.at(i)*(b.at(i)-1)/2);
  }
  for(int i:a){
    i-=1;
    long long int sumk=sum;
    sumk-=b.at(i)*(b.at(i)-1)/2;
    if(b.at(i)==0)
      cout<<sumk<<endl;
    else{
      sumk+=(b.at(i)-1)*(b.at(i)-2)/2;
      cout<<sumk<<endl;
    }
  }
}

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

int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for (int i=0;i<N;i++) {
    cin >> vec.at(i);
  }
  int A=0,B=0;
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i=0;i<N;i++) {
    if ((i+1)%2==1) {
      A+=vec.at(i);
    }
    else {
      B+=vec.at(i);
    }
  }
cout << A -B << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll Solve(){
    ll N,K; cin>>N>>K;
    if(N==K){
        ll ret=1;
        rep(i,N){
            ll x; cin>>x;
            if(x==0) return 0;
            if(x<0) x+=mod;
            MUL(ret,x);
        }
        return ret;
    }
    vec A,B; 
    ll Count=0;
    rep(i,N){
        ll x; cin>>x;
        if(x>0) A.pb(x);
        if(x<0) B.pb(-x);
        if(x==0) Count++;
    }
    if(N-Count<K) return 0;
    if(A.size()==0){
        sort(ALL(B));
        if(K%2){
            if(Count) return 0;
            ll ret=1;
            rep(i,K) MUL(ret,B[i]);
            return mod-ret;
        }
        reverse(ALL(B));
        ll ret=1;
        rep(i,K) MUL(ret,B[i]);
        return ret;
    }
    sort(ALL(A)); 
    sort(ALL(B)); 
    ll X=min((ll)A.size(),K);
    if(X%2!=K%2) X--;
    ll Y=K-X;
    if(Y>B.size()){
        if(A.size()+B.size()<N) return 0;
        ll ret=1;
        rep(i,B.size()) MUL(ret,B[i]);
        rep(i,A.size()) MUL(ret,A[i]);
        return mod-ret;
    }
    reverse(ALL(B));
    reverse(ALL(A));
    while(true){
        if(X<2) break;
        if(Y+1>=B.size()) break;
        if(B[Y]*B[Y+1]<=A[X-2]*A[X-1]) break;
        X-=2; Y+=2;
    }
    ll ret=1;
    rep(i,X) MUL(ret,A[i]);
    rep(i,Y) MUL(ret,B[i]);
    return ret;

}
int main(){
    cout<<Solve()<<endl;

}

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

struct Node {
    Node *ch[2];
    int num;
};

int number(char *&p) {
    int res = 0;
    while (isdigit(*p)) {
        res *= 10;
        res += *p - '0';
        ++p;
    }
    return res;
}

Node *tree(char *&p) {
    Node *res = new Node;
    for (int i = 0; i < 2; i++) {
        if (i) {
            ++p;
            res->num = number(p);
            ++p;
        }
        if (p[1] == ')') {
            ++p;
            res->ch[i] = nullptr;
            ++p;
        } else {
            ++p;
            res->ch[i] = tree(p);
            ++p;
        }
    }
    return res;
}

void print(Node *s, Node *t) {
    printf("(");
    for (int i = 0; i < 2; i++) {
        if (i) {
            printf(")[%d](", s->num + t->num);
        }
        if (s->ch[i] && t->ch[i]) {
            print(s->ch[i], t->ch[i]);
        }
    }
    printf(")");
}

int main() {
    char s[1010], t[1010];
    cin >> s >> t;
    char *ss = s, *tt = t;
    print(tree(ss), tree(tt));
    cout << '\n';
}

Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	ll n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	multiset<ll>s;//同じ値でも違うグループになるためmultiset
	s.insert(a[0]);
	for(int i=1;i<n;++i){
		auto itr=s.lower_bound(a[i]);
		if(itr==s.begin()){//どのグループにも属さないので新しく作る
			s.insert(a[i]);
		}
		else {
			itr--;
			s.erase(itr);//大きいものから更新した方が有利
			s.insert(a[i]);
		}
	}
	cout<<s.size()<<endl;
	return 0;
}




Measured memory_bytes: 5760
use std::vec::Vec;

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()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
   let mut h: usize = read();
   let mut c: usize = 0;
   if h == 1 {
      println!("{}", 1);
      return
   }

    while h > 0 {
      if h == 1 {
         h = 0;
         c += 1;
      } else {
         h = h / 2;
         c += 1;
      }
    }

    let mut ans: usize = 1;
    while c > 0 {
      ans *= 2;
      c -= 1;
    }
    ans -= 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
   ll n; cin>>n;
   ll sum=0;
   
   if(n%2==1){
      sum=n*(n-1)/2;
   }else{
     sum=n*(n-2)/2+n/2;
   }
   cout<<sum<<endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int dp[5005][5005];

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

    for (int i = n - 1; i >= 0; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if (s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i + 1][j + 1] + 1;
        }
    }

    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (i >= j) continue; // i < j;
            int now = min(dp[i][j], j - i);
            ans = max(ans, now);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 98048
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m;
pint p[2000], P[2000];

int main() {
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) cin >> p[i].first >> p[i].second;
        cin >> m;
        for (int i = 0; i < m; ++i) cin >> P[i].first >> P[i].second;
        sort(P, P+m);
        
        for (int i = 0; i < m; ++i) {
            int dx = P[i].first - p[0].first, dy = P[i].second - p[0].second;
            
            bool check = true;
            for (int j = 0; j < n; ++j) {
                pint np(p[j].first + dx, p[j].second + dy);
                if (!binary_search(P, P+m, np)) {
                    check = false; break;
                }
            }
            if (check) {
                cout << dx << " " << dy << endl;
                continue;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1196
import java.math.*

fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map{it.toInt()}
    
    val xs = readInputLine().split(" ").map{it.toInt()}.toIntArray()
    
    var l = 0
    var r = K - 1
    
    var ans = distance(xs, l, r)

    while (r < N - 1) {
        l++
        r++
        val nextDistance = distance(xs, l, r)
        if (nextDistance < ans) {
            ans = nextDistance
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun distance(xs: IntArray, l: Int, r: Int): Int {
    return Math.min(Math.abs(xs[l]) + Math.abs(xs[r] - xs[l]), Math.abs(xs[r]) + Math.abs(xs[l] - xs[r]))
}


Measured memory_bytes: 51604
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;

void dfs(int i, int n, vector<int> g[], int dp[], int vis[])
{
  vis[i] = 1;
  for (int x: g[i])
  {
    if (!vis[x])
      dfs(x, n, g, dp, vis);
    dp[i] = max(dp[i], 1 + dp[x]);
  }
}

int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  vector<int> g[100005];
  for (int i = 0; i < m; i++)
  {
    cin >> x >> y;
    g[x - 1].push_back(y - 1);
  }
  int dp[100005] = {0};
  int vis[100005] = {0};
  for (int i = 0; i < n; i++)
  {
    if (!vis[i])
      dfs(i, n, g, dp, vis);
  }
  cout << *max_element(dp, dp + n) ;
  return 0;
}


Measured memory_bytes: 9984
loop do
  n = gets.to_i
  break if n==0
  hash = Hash.new
  n.times do
    c,*ms = gets.split.map(&:to_i)
    sum = 0
    ms.each_with_index do |m,i|
      sum+= (i.even? ? 60 : 1) *m
    end
    hash[c] = sum
  end
  r = hash.keys.sort{|a,b| hash[a]-hash[b]}
  puts r[0]
  puts r[1]
  puts r[-2]
end

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

using namespace std;

int W, H, N;
int field[100][100];

void paint(int x, int y, int cmd){
	if(cmd == 1){
		for(int i = 0; i < H; ++i) for(int j = 0; j <= x; ++j) field[i][j] = 1;
	}else if(cmd == 2){
		for(int i = 0; i < H; ++i) for(int j = x + 1; j < W; ++j) field[i][j] = 1;
	}else if(cmd == 3){
		for(int i = 0; i <= y; ++i) for(int j = 0; j < W; ++j) field[i][j] = 1;
	}else{
		for(int i = y + 1; i < H; ++i) for(int j = 0; j < W; ++j) field[i][j] = 1;
	}
}

int count(){
	int res = 0;
	for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) if(field[i][j] == 0) res++;
	return res;
}

int main(){
	cin >> W >> H >> N;
	int x[N], y[N], a[N], ans = 0;
	for(int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> a[i];
	for(int i = 0; i < N; ++i){
		x[i]--; y[i]--;
		paint(x[i], y[i], a[i]);
	}
	ans = count();
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
        int x = 0;
        int y = 0;
        vector<pair<int, pair<int, int> > > room;
        for(;;){
            int dx, dy;
            cin >> dx >> dy;
            if(dx == 0 && dy == 0)
                break;
            x += dx;
            y += dy;
            room.push_back(make_pair(x*x + y*y, make_pair(x, y)));
        }

        pair<int, pair<int, int> > ret = *max_element(room.rbegin(), room.rend());
        cout << ret.second.first << ' ' << ret.second.second << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

map<char,int> M;

int main(){
  char S[107];cin >>  S;
  rep(i,strlen(S)){
    M[S[i]]++;
  }
  ll C=0;
  for(auto P : M){
    if(P.second%2==1){
      C++;
    }
  }
  cout << (C==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
w,h,n = map(int,raw_input().split(" "))

x_min,y_min,x_max,y_max = 0,0,w,h

for i in range(n):
    x,y,a = map(int,raw_input().split(" "))
    if a == 1:
        x_min = max(x_min,x)
    elif a == 2:
        x_max = min(x_max,x)
    elif a == 3:
        y_min = max(y_min,y)
    elif a == 4:
        y_max = min(y_max,y)

if x_min > x_max or y_min > y_max:
    print 0
else:
    print (x_max - x_min)*(y_max - y_min)

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

using namespace std;

int main(){
    string s;
    string strs[5] = {"dreamer", "eraser", "dream", "erase"};
    cin >> s;
    bool last=false;
    while(s.length()>0){
        bool ans = false;
        for(int i=0;i<4;i++){
            int ind=s.length() - strs[i].length();
            if(ind<0)continue;
            if(s.substr(ind, strs[i].length())==strs[i]){
                ans=true;
                s = s.substr(0,ind);
                break;
            }
        }
        if(!ans)break;
    }
    cout << (s.length()==0?"YES":"NO") << endl;
}

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

using namespace std;


int a[3][110];
int dp[3][110];
int dx[] = {1, 0};
int dy[] = {0, 1};
int res;
int n;
bool go(int x, int y){ return x >= 0 && x < 3 && y >= 0 && y < n; }
void dfs(int x, int y, int ret){
    if(x == 2 && y == n - 1){
        res = max(res, ret);
        return ;
    }
    for(int i = 0; i < 2; ++i){
        int nx = x + dx[i], ny = y + dy[i];
        if(go(nx, ny))dfs(nx, ny, ret + a[nx][ny]);
    }
}
int main(){
    ios::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    cin >> n;
    memset(a, 0, sizeof(a));
    memset(dp, 0, sizeof(dp));
    for (int k = 0; k < 2; ++k) {
        for (int i = 0; i < n; ++i){
            cin >> a[k][i];
            dp[k+1][i+1] = a[k][i];
        }

    }
    res = 0;
    dfs(0, 0, a[0][0]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <vector>
     
    int self_m(long long& a, long long b){
        a = std::max(a, b);
        return a;
    }
     
    int main() {
        int n, w, e_w, v;
        scanf("%d%d", &n, &w);
        std::vector<long long>dp(w+1, 0);
        
        for(int d =0; d<n; d++){
            //int e_w, v;
            scanf("%d%d", &e_w, &v);
            for(int al_w =w - e_w ; al_w>=0; al_w--){
                self_m(dp[e_w+al_w], dp[al_w] + v);
                
            }
        }
        
        std::cout<<*(std::max_element(std::begin(dp), std::end(dp)));
        
    }

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

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

using namespace std;

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}


int kaizyo[2010];
int MOD=1000000007;
int inv[2010];
int finv[2010];
long long nCr(int n, int r){
//   cout << (kaizyo[n] % MOD)/(kaizyo[r]*kaizyo[n-r] % MOD) << endl;
  return kaizyo[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}


signed main(){
  int N, K;
  cin>>N>>K;
  int red = N-K;
  int blue = K;

  int sum=1;
  kaizyo[0]=1;
  rep(i, 2009){
    inv[i]=1;
    finv[i]=1;
    kaizyo[i]=1;
  }
  int a;
  rep(i, 2004){
    a = i+2;
    kaizyo[a] = kaizyo[a-1]*(a) % MOD;
    inv[a] = MOD-inv[MOD%(a)] * (MOD / a) % MOD;
    finv[a] = finv[a-1] * inv[a] % MOD;
  }
  
  int chance;

  int result = 1;
  rep(i, K){
    if((N-K)<i){
      cout << 0 << endl;
      continue;
    }
    chance = nCr(red+1, i+1); //kaizyo[red+1]/(kaizyo[i+1]*kaizyo[red-i]);
    
    chance = chance*nCr(K-1, i) % MOD;

    cout << chance % MOD << endl;
  }
    

  return 0;
}


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

int main () {
 int N;
 cin >> N;
 for(int I=0; I<N; I++) {
  int gx, gy;
  cin >> gx >> gy;
  int tatemove[gx+1][gy+1];
  int yokomove[gx+1][gy+1];
  int T[gx+1][gy+1];
  for (int i=0; i<=gx; i++) {
   for (int j=0; j<=gy; j++) {
    tatemove[i][j] = 0;
    yokomove[i][j] = 0;
    T[i][j] = 0;
   }
  }
  int m;
  cin >> m;
  for (int i=0; i<m; i++) {
   int mx1, my1, mx2, my2;
   cin >> mx1 >> my1 >> mx2 >> my2;
   if (mx1 == mx2) { tatemove[mx1][(my1 > my2) ? my1 : my2] = 1; }
   if (my1 == my2) { yokomove[(mx1 > mx2) ? mx1 : mx2][my1] = 1; }
  }
  for (int i=0; i<=gx; i++) {
   for (int j=0; j<=gy; j++) {
    if (i == 0 && j == 0) { T[i][j] = 1; }
    else if (i == 0) { T[i][j] = (tatemove[i][j]) ? 0 : T[i][j-1]; }
    else if (j == 0) { T[i][j] = (yokomove[i][j]) ? 0 : T[i-1][j]; }
    else { T[i][j] = ((tatemove[i][j]) ? 0 : T[i][j-1]) + ((yokomove[i][j]) ? 0 : T[i-1][j]); }
   }
  }
  if (T[gx][gy] == 0) { cout << "Miserable Hokusai!" << endl; }
  else { cout << T[gx][gy] << endl; }
 }
}


Measured memory_bytes: 1160
s = input()
t = input()
ans = 0
A = []
for i in range(len(s)-len(t)+1):
    s_i = s[i:i+len(t)+1]
    count = 0
    for j in range(len(t)):
        if s_i[j] == t[j]:
            count += 1
    A.append(count)

ans = len(t) - max(A)
print(ans)

Measured memory_bytes: 8988
<?php
declare(strict_types=1);

//red blue
//3 4
//red

$h = STDIN;
list($a_str,$b_str) = explode(' ', trim(fgets($h)));
list($a,$b) = explode(' ', trim(fgets($h)));
$u = trim(fgets($h));

if ($u === $a_str) {
    echo $a - 1,' ',$b;
}else{
    echo $a,' ',$b - 1;
}


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

int N, M;
long long int T[101];
long long int P;
int x;

int main(){
    cin >> N;
    long long int sum = 0;
    long long int ans[101];
    for(int i = 1; i < N+1; i++){
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> P >> x;
        ans[i] = (sum - (T[P] - x));
    }
    for(int i = 0; i < M; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

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

typedef long long ll;

int main(){
	int N;
	cin>>N;
	pair<ll,ll>p[200010];
	for(int i=0;i<N;i++){
		ll a,b;
		cin>>a>>b;
		p[i].first=b;
		p[i].second=a;
	}
	sort(p,p+N);
	ll sum=0;
	for(int i=0;i<N;i++){
		sum+=p[i].second;
		if(sum>p[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3328
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;


int main()
{
	migmig ;
	string t , s ; 
	cin>>t>>s ; 
	cout<<s<<t ; 

}
//////
////////
///////////




Measured memory_bytes: 256
N, M = map(int, input().split())

a, b = [0] * N, [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

c, d = [0] * M, [0] * M
for i in range(M):
    c[i], d[i] = map(int, input().split())

for i in range(N):
    ans = min(range(M), key=lambda j: abs(a[i] - c[j]) + abs(b[i] - d[j]))
    print(ans + 1)


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

class Main {

    static int VALUE = 0;
    static int WEIGHT = 1;
    
    public static void main(String[] args) {
	final Scanner stdin = new Scanner(System.in);

	int c = 1;
	while ( true ) {

	    final int W = Integer.parseInt( stdin.nextLine() );
	    if ( W == 0 ) {
		break;
	    }
	    final int N = Integer.parseInt( stdin.nextLine() );
	    
	    int[][] tres = new int[N][2];
	    for ( int i = 0; i < N; i++ ) {
		String[] input = stdin.nextLine().split( "," );
		tres[i][VALUE] = Integer.parseInt( input[0] );
		tres[i][WEIGHT] = Integer.parseInt( input[1] );
	    }

	    int[][] dp = new int[N + 1][W + 1];
	    for ( int n = 1; n <= N; n++ ){
		System.arraycopy( dp[n - 1], 0, dp[n], 0, dp[n].length );
		for ( int w = 0; w <= W; w++ ) {
		    if ( tres[n - 1][WEIGHT] + w <= W ) {
			dp[n][w + tres[n - 1][WEIGHT]] = Math.max( dp[n][w + tres[n - 1][WEIGHT]],
							       dp[n - 1][w] + tres[n - 1][VALUE] );
		    }
		}
	    }

	    int maxValue = Integer.MIN_VALUE;
	    int maxValueWeight = Integer.MAX_VALUE;
	    for ( int w = 0; w <= W; w++ ){
		if ( maxValue < dp[N][w] ) {
		    maxValue = dp[N][w];
		    maxValueWeight = w;
		}
	    }

	    System.out.printf( "Case %d:\n", c );
	    System.out.println( maxValue );
	    System.out.println( maxValueWeight );
	    c++;
	}	
    }    
}

Measured memory_bytes: 31044
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
    ll q, a, b;

    cin >> q;
    rep(i, q){
        cin >> a >> b;
        if(a < b) swap(a, b);
        if(a == b){
            cout << 2*a-2 << endl;
        }else if(a+1 == b){
            cout << 2*a-2 << endl;
        }else{
            ll c = sqrt(a*b);
            if(c == sqrt(a*b)) c--;
            if(c*(c+1) >= a*b){
                cout << 2*c-2 << endl;
            }else{
                cout << 2*c-1 << endl;
            }
        }
    }
}

int main(){
    solve();
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
    vector<int> par, s;
    UnionFind(int n=2e5) { init(n); }
    void init(int n) {
        s.assign(n, 1); par.resize(n);
        iota(par.begin(), par.end(), 0);
    }
    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
        else par[y] = x, s[x] = s[x] + s[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    ll size(int x) { return s[find(x)]; }
};

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

    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<ll> a(m), b(m);
    REP(i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    vector<ll> ans(m);
    ans[m-1] = n*(n-1)/2;
    for(ll i=m-1; i>=1; --i) {
        if(!uf.same(a[i], b[i])) {
            ans[i-1] = ans[i] - uf.size(a[i]) * uf.size(b[i]);
            uf.unite(a[i], b[i]);
        } else {
            ans[i-1] = ans[i];
        }
    }

    for(auto i: ans) cout << i << endl;

    return 0;
}


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

int main(){
  vector<pair<int,int>> A(5);
  //A.at(0)=make_pair(0,0);
  for(int i=1;i<=2;i++){
    int x,y;cin>>x>>y;
    A.at(i)=make_pair(x,y);
  }
  for(int i=3;i<=4;i++){
    int X=A[i-2].second+A[i-1].first-A[i-1].second;
    int Y=A[i-1].first+A[i-1].second-A[i-2].first;
    A[i]=make_pair(X,Y);
  }
  for(int j=3;j<=4;j++) cout<<A[j].first<<" "<<A[j].second<<" ";
  cout<<"\n";
}
    
  

Measured memory_bytes: 3628
Module Module1

    Dim tmp As String()
    Dim A, B As Integer

    Sub Main()
        tmp = Split(Console.ReadLine)

        A = Int(tmp(0))
        B = Int(tmp(1))

        If A <= 8 And B <= 8 Then
            Console.WriteLine("Yay!")
        Else
            Console.WriteLine(":(")
        End If
    End Sub

End Module


Measured memory_bytes: 13664
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

#print(N,F,P)

ans = -(10**9+7)
for i in range(1, 2**10):
  tmp = 0
  for f, p in zip(F, P):
    tmp += p[bin(f&i).count('1')]
    #print(f,i,p[bin(f&i).count('1')])
  ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3060
# Algorithm and Data Structures 1
# Name: Ryuya Asada
# ID: s1260064


def InsertionSort(A: list):
    for i in range(1, len(A)):
        key = A[i]
        j = i - 1
        print(*A, sep=" ")
        while (j >= 0 and A[j] > key):
            A[j+1] = A[j]
            j -= 1
        A[j+1] = key


def main():
    length = int(input())
    A = [int(e) for e in input().split(" ")]

    InsertionSort(A)
    print(*A, sep=" ")


if __name__ == "__main__":
    main()




Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<(a-1)*(b-1);
    
    
    } 
    return 0;
}


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

using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long x;
  cin >> x;
  long long ans = (x/500)*1000;
  x %= 500;
  ans += (x/5)*5;
  cout<<ans<<'\n';
  return 0;
}


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

int main() {
	while (1) {
		int H, W;
		cin >> H >> W;

		if (H == 0 && W == 0) break;

		for (int i = 1; i <= H; i++) {
			if (i == 1) {
				for (int j = 1; j <= W; j++) {
					cout << "#";
				}
				cout << endl;
			}
			else if (i == H) {
				for (int j = 1; j <= W; j++) {
					cout << "#";
				}
			}
			else {
				for (int j = 1; j <= W; j++) {
					if (j == 1) cout << "#";
					else if (j == W) cout << "#";
					else cout << ".";
				}
				cout << endl;
			}
		}
		cout << endl << endl;
	}

	return 0;
}


Measured memory_bytes: 3048
n, m  = map(int,  input().split())
vertices = range(1,n+1)
adj =  {v: set() for  v  in vertices}
for _  in range(m):
    s, t  = map(int,  input().split())
    adj[s].add(t)
    adj[t].add(s)

ans = 0
reached = {v: False for v in vertices}
for v in vertices:
    if not reached[v]:
        i = 1
        reached[v] = True
        stack = [v]
        while stack:
            w = stack.pop()
            for u in  adj[w]:
                if not reached[u]:
                    reached[u] = True
                    stack.append(u)
                    i += 1
        ans = max(ans, i)
print(ans)

Measured memory_bytes: 112376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();
        long k = sc.NextLong();

        bool[,] map = new bool[h, w];

        for (int i = 0; i < h; i++)
        {
            string s = sc.Next();
            for (int j = 0; j < w; j++)
            {
                if (s[j] == '#')
                {
                    map[i, j] = true;
                }
            }
        }

        long answer = 0;

        for (int i = 0; i < Math.Pow(2, h); i++)
        {
            for (int j = 0; j < Math.Pow(2, w); j++)
            {
                bool[,] newMap = (bool[,])map.Clone();

                for (int l = 0; l < h; l++)
                {
                    for (int m = 0; m < w; m++)
                    {
                        if ((1 & (i >> l)) == 1)
                        {
                            newMap[l, m] = false;
                        }
                        if ((1 & (j >> m)) == 1)
                        {
                            newMap[l, m] = false;
                        }
                    }
                }

                long count = 0;
                for (int l = 0; l < h; l++)
                {
                    for (int m = 0; m < w; m++)
                    {
                        if (newMap[l, m])
                        {
                            count++;
                        }
                    }
                }
                if (count == k)
                {
                    answer++;
                }
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28300
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

string S;

int solve() {
    int N = S.size(); // N <= 80000

    int memo[80000][11];
    for (int j = 0; j < N; ++j) fill(memo[j], memo[j]+11, 0);
    memo[0][S[0]-'0'] = 1;

    int ans = 0;
    for (int j = 1; j < N; ++j) {
        int d = S[j] - '0';

        if (d != 0) memo[j][d] = 1;
        for (int k = 0; k < 11; ++k) {
            memo[j][(-k + d + 11) % 11] += memo[j-1][k];
        }

        ans += memo[j][0];
    }
    return ans;
}

int main() {
    while (true) {
        cin >> S;
        if (S == "0") return 0;
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 6660
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n; cin >> n;

	int c = 0;
	FOR_LE(i, 1, n) {
		if (              i < 10) c++;
		if (100   <= i && i < 1000) c++;
		if (10000 <= i && i < 100000) c++;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256