akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, res = 0; cin >> n;
    V<int> a(n), dp(n + 1, 0);
    REP(i, n){
        cin >> a[i];
        dp[a[i]+1] = dp[a[i]] + 1;
        chmax(res, dp[a[i]+1]);
    }
    cout <<  n - res << '\n';
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 100005, M = 102, mod = 998244353, mxLog = 20;
int n, w;
int W[M], V[M];
long long memo[M][N];
long long solve(int i, int cur_w) {
    if (i == n)
        return 0;
    long long &ret = memo[i][cur_w];
    if (~ret)
        return ret;
    ret = solve(i + 1, cur_w);
    if (cur_w + W[i] <= w) {
        ret = max(ret, solve(i + 1, cur_w + W[i]) + V[i]);
    }
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(7), cout << fixed;

    cin >> n >> w;
    for (int i = 0; i < n; ++i) {
        cin >> W[i] >> V[i];
    }
    memset(memo, -1, sizeof memo);
    cout << solve(0, 0) << '\n';


    return 0;
}

Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	int sum=0;
	rep(i,n){
	    int in;
	    cin>>in;
	    sum+=in;
	}
	cout<<sum-n*(n+1)/2<<endl;
}



Measured memory_bytes: 3212
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);


int main()
{
    IOS();
    ll r,c,k;
    cin>>r>>c>>k;
    bool b=0;
    REP(i,r+1)REP(j,c+1)if(i*c+j*r-2*i*j==k)b=1;
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def dist(v1, v2):
    return abs(v1[0] - v2[0]) + abs(v1[1] - v2[1])


N, M = (int(e) for e in input().split())

students = []
for i in range(N):
    students.append([int(e) for e in input().split()])

checkpoints = []
for i in range(M):
    checkpoints.append([int(e) for e in input().split()])

for i in students:
    min_dist = 1e9
    to = None
    for j, cp in enumerate(checkpoints):
        d = dist(i, cp)
        if min_dist > d:
            to = j+1
            min_dist = d
    print(to)

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

int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                if (500 * i + 100 * j + 50 * k == X)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

data class Room(val ridge: Int, val floor: Int, val number: Int)

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val roomMap = mutableMapOf<Room, Int>()
    (1..n).forEach {
        roomMap.merge(
            Room(scanner.nextInt(), scanner.nextInt(), scanner.nextInt()),
            scanner.nextInt(),
            Int::plus
        )
    }
    (1..4).forEach { ridge ->
        (1..3).forEach { floor ->
            (1..10).forEach { number ->
                print(" " + roomMap.getOrDefault(Room(ridge, floor, number), 0))
            }
            println()
        }
        if (ridge != 4) {
            println("####################")
        }
    }
}


Measured memory_bytes: 30520
def primes(max)
  nums = Array.new(max + 1, 1)
  nums[0] = nums[1] = 0

  (2..Math.sqrt(max)).each do |sieve|
    if nums[sieve] == 1
      (2 * sieve).step(max, sieve).each do |num|
        nums[num] = 0
      end
    end
  end

  nums
end

max = 1_000_000

primes = primes(max)

nums = (2..max).select { |num| primes[num] == 1 }

while line = gets
  n = line.chomp.to_i
  break if n == 0

  answer = 0

  for i in nums
    j = n - i
    break if i > j
    answer += 1 if primes[j] == 1
  end

  puts answer
end

Measured memory_bytes: 17152
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int n, m;
int a[100][100], b[50][50][4];

string conv(int n)
{
  stringstream ss;
  ss << n;

  return ss.str();
}

string solve()
{
  bool f;

  for(int i = 0; i < n-m+1; ++i)
    for(int j = 0; j < n-m+1; ++j){
      for(int k = 0; k < 4; ++k){
	f = true;
	for(int s = 0; f && s < m; ++s)
	  for(int t = 0; f && t < m; ++t){
	    if(a[i+s][j+t] == b[s][t][k] || b[s][t][k] == -1) continue;
	    f = false;
	  }
	
	if(f)
	  for(int s = 0; s < m; ++s)
	    for(int t = 0; t < m; ++t)
	      if(b[s][t][k] != -1) return (conv(j+t+1)+" "+conv(i+s+1));
      }
    }

  return "NA";
}

int main()
{
  while(cin>>n>>m && n+m){
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j) cin >> a[i][j];

    for(int i = 0; i < m; ++i)
      for(int j = 0; j < m; ++j) cin >> b[i][j][0];

    for(int k = 0; k < 3; ++k)
      for(int i = 0; i < m; ++i)
	for(int j = 0; j < m; ++j)
	  b[m-1-j][i][k+1] = b[i][j][k];
    
    cout << solve() << endl;
  }
  
  return 0;
}

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

int H, W;
int INF = 1<<21;
vector<string> S;

int bfs(int x, int y) {
    int dx[4] = { 0, 0, 1, -1 }, dy[4] = { 1, -1, 0, 0 };

    int d[H][W];
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            d[i][j] = INF;
        }
    }

    queue<pair<int, int>> Q;
    Q.push({x, y});
    d[x][y] = 0;

    while(!Q.empty()) {
        pair<int, int> p = Q.front(); Q.pop();
        for(int i=0;i<4;i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0<=nx&&nx<H&&0<=ny&&ny<W) {
                if(S[nx][ny]=='.'&&d[nx][ny]==INF) {
                    d[nx][ny]=d[p.first][p.second] + 1;
                    Q.push({nx, ny});
                }
                
            }
        }
    }

    int MAX = 0;
    for (int i=0;i<H;i++) {
		for (int j=0;j<W;j++) {
			if (d[i][j] != INF) MAX = max(MAX, d[i][j]);
		}
	}
    return MAX;
}

int main(void) {
    cin >> H >> W;

    S.resize(H);
    for(int i=0;i<H;i++) {
        cin >> S.at(i);
    }

    int ans = 0;
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            if(S[i][j]=='.') ans = max(ans, bfs(i, j));
        }
    }
    
    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int i;
	int count;
	int number[200] = { 0 };
	int old_number[200]={ 0 };
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &number[i]);
		old_number[i] = number[i];
	}
	for (count = 0;; count++)
	{
		for (i = 0; i < n; i++)
		{
			number[i] /= 2;
			if (2 * number[i] != old_number[i])
			{
				goto label;
			}
			old_number[i] = number[i];
		}
	}
label:
	printf("%d", count);
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

struct c {
	char suit;
	char value;
};

void swap(c *a, c *b)
{
	c *v;
	v = a;
	a = b;
	b = v;
}

void bubblesort(c a[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (a[j].value < a[j - 1].value)
				swap(a[j], a[j - 1]);
		}
	}
}

void selectionsort(c a[], int N)
{
	int mini;
	int j;
	for (int i = 0; i < N; i++)
	{
		mini = i;
		for (j = i; j < N; j++)
		{
			if (a[j].value < a[mini].value)
				mini = j;
		}
		swap(a[i], a[mini]);
	}
}

/*void judge(c a[], c b[], int N)  // 比较两个数字一样的字符串的字母顺序是否和输入顺序一样
{
	for (int i = 0; i < N; i++)
	{
		if (a[i].value == a[i + 1].value)   // a 是已经排好序的  b 是输入顺序
		{
			for (int j = 0; j < N; j++)
			{
				if (b[j].value == a[i].value)
				{
					if (b[j].suit == a[i].suit)
					{
						cout << "Stable" << endl;
						break;
					}
					else
					{
						cout << "Not stable" << endl;
						break;
					}
				}
			}
			break;
		}
	}
}*/

bool isstable(c a[], c b[], int N) // a 是冒泡排序结果， b 是选择排序结果
{
	for (int i = 0; i < N; i++)
	{
		if (a[i].suit != b[i].suit)
			return false;
	}
	return true;
}

void print(c a[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i > 0) cout << " ";
		cout << a[i].suit << a[i].value ;  // 如果在输入结果后加空格，则输出结果后会多一个空格，presentation check
	}
	cout << endl;
}

int main()
{
	c a[36];
	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a[i].suit >> a[i].value; 
		// scanf_s("%c%d", &a[i].suit, &a[i].value);  为什么这句输入异常
	}
	cin.get();

	c b[36], c[36];
	
	for (int i = 0; i < N; i++)
	{
		b[i] = a[i];
		c[i] = a[i];
	}

	bubblesort(b, N);
	print(b, N);
	cout << "Stable" << endl;
	//judge(b, a, N);

	selectionsort(c, N);
	print(c, N);
	//judge(c, a, N);
	
	if (isstable(b, c, N))
	{
		cout << "Stable" << endl;
	}
	else cout << "Not stable" << endl;

	cin.get();
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef long long LL;
LL fun(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n & 1)
            res=(res*x);
        x=(x*x);
        n >>= 1;
    }
    return res;
}
ll a[200]={0,2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67 ,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167 ,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227 ,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347 ,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401 ,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461 ,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523 ,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599 ,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653 ,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727 ,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797 ,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859 ,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937 ,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997 ,1001};
int main()
{
    ll n;
    ll mod=1e9+7;
    ll ans=1;
    cin>>n;
    ll b[1010];
    int pos=0;
    while(1)
    {
        if(a[pos]<=n)
        {
           pos++;
        }
        else
        {
            break;
        }
    }
    //cout<<<<endl;
    for(int i=1; i<=pos-1; i++)
    {
        ll sum=0;
        for(int j=1; j<=n; j++)
        {
            if(fun(a[i],j)<=n)
            {
                sum+=(n/fun(a[i],j));
            }
            else
            {
                break;
            }
        }
        ans=ans*(sum+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

ans = [""] * M
for i in range(N):
    G[i] = sorted(G[i])
    j = 1
    for y, k in G[i]:
        ans[k] = "0" * (6 - len(str(i + 1))) + str(i + 1) + "0" * (6 - len(str(j))) + str(j)
        j += 1

for k in ans:
    print(k)

Measured memory_bytes: 35992
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = sc.nextInt();
        int h = z/60/60;
        int m = (z/60)%60;
        int s = z%60;
        System.out.printf("%s:%s:%s\n",h,m,s);
    }
}


Measured memory_bytes: 26316
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<climits>
#include<cmath>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define endl "\n"
typedef long long ll;
int mod=(int)1e9+7;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	if(n==0)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3640
N = int(input())


def divisor(M):
    div = set()
    for i in range(1, int(N ** 0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    while M % X == 0:
        M //= X
    return M % X == 1


B = divisor(N - 1)
ans = len(B) - 1

A = divisor(N)
A -= {1}
for a in A:
    if simu(N, a):
        ans += 1

print(ans)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 0 || b == 0 || (a < 0 && b >=0) || (a >= 0 && b <0)) {
        cout << "Zero" << endl;
        return 0;
    }

    if ( a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else if (((-1) * (a - b)) % 2 == 1) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);

  int a, b, k;
  cin >> a >> b >> k;

  for (int i = a; i <= b; ++i) {
    if (i < a + k || i > b - k) {
      cout << i << '\n';
    }
  }

  return 0;
}


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

int N, C, K;
vector<int> T;

void agc011a() {
  sort(T.begin(), T.end());
  ll res = 1, cnt = 0, t = T[0];
  for (int i = 0; i < N; i++) {
    if (cnt < C && T[i] <= t + K) {
      cnt++;
    }
    else {
      res++;
      cnt = 1;
      t = T[i];
    }
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> C >> K;
  T.resize(N);

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

struct Unionfind {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // constructor
  Unionfind(int n = 1) { stree(n + 1); }
  // make and initialization
  void stree(int n = 1) {
    par.assign(n, -1);
    treerank.assign(n, 0);
  }
  // search root
  int root(int x) {
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[y];
    par[y] -= size(x);
    par[x] = y;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

long long n;
vector<pair<long long, long long>> v;
long long memo[100005][2] = {0};
set<int> s[100005][2];
Unionfind uf;

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].fi >> v[i].se;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  uf = Unionfind(n + 1);
  for(int i = 0; i <= 100000; ++i)
    for(int j = 0; j < 2; ++j) memo[i][j] = -1;
  for(int i = 0; i < n; ++i) {
    if(memo[v[i].fi][0] == -1)
      memo[v[i].fi][0] = i;
    else
      uf.uni(i, memo[v[i].fi][0]);
    if(memo[v[i].se][1] == -1)
      memo[v[i].se][1] = i;
    else
      uf.uni(i, memo[v[i].se][1]);
  }
  for(int i = 0; i < n; ++i) {
    s[uf.root(i)][0].insert(v[i].fi);
    s[uf.root(i)][1].insert(v[i].se);
  }
  for(int i = 0; i < n; ++i)
    if(uf.root(i) == i)
      ans += s[i][0].size() * s[i][1].size();

  return ans - n;
}

Measured memory_bytes: 18176
#include<iostream>
using namespace std;
int main(){
    int x,y,i;
    while(cin >> x >> y){
        if(x == 0 && y == 0){
            break;
        }
        if(x>y){
            cout << y << " " << x << endl;
        }else {
            cout << x << " " << y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n;
    cin >> n;
    vi v(n);
    cin >> v;
    int g = v[0];
    rep(i,1,n)
        g = gcd(g, v[i]);
    vvi v2(1000001);
    rep(i,2,1000001)
    {
        if(v2[i].size())
            continue;
        for(int j = i; j <= 1000001; j += i)
            v2[j].push_back(i);
    }
    bool ok = 1;
    vi cnt(1000001);
    rep(i,0,n)
    {
        int f = v[i];
        for(int y : v2[v[i]])
        {
            if(cnt[y])
            {
                ok = 0;
                break;
            }
            cnt[y] = 1;
            while(f % y == 0)
                f /= y;
        }
        if(!ok)
            break;
        if(f != 1)
        {
            if(cnt[f])
            {
                ok = 0;
                break;
            }
            cnt[f] = 1;
        }
    }
    if(ok)
        ret("pairwise coprime");
    if(g == 1)
        ret("setwise coprime")
    ret("not coprime");
}


Measured memory_bytes: 66524
#include <bits/stdc++.h>
using namespace std;
#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()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vi dist, node, parent, depth;
vector<unordered_map<int, P>> color;

void dfs(const vector<Graph> &edge, int v, int p, int di, int de) {
  bool branch = edge[v].size() > 2 || p == -1 || color[v].size() > 250;
  if (branch) di = 0;
  de += branch;

  for (auto nv : edge[v]) {
    if (nv[0] == p) continue;

    dist[nv[0]] = di + nv[2];
    node[nv[0]] = branch ? nv[0] : node[v];
    parent[nv[0]] = branch ? v : parent[v];
    depth[nv[0]] = de;

    if (!branch) color[nv[0]] = color[v];
    ++color[nv[0]][nv[1]].first;
    color[nv[0]][nv[1]].second += nv[2];

    dfs(edge, nv[0], v, dist[nv[0]], de);
  }
}

int calc(const int &x, const int &y, int u, int v) {
  int du = dist[u], dv = dist[v];
  if (color[u].count(x)) du += color[u][x].first * y - color[u][x].second;
  if (color[v].count(x)) dv += color[v][x].first * y - color[v][x].second;

  if (node[u] == node[v]) {
    return abs(du - dv);
  }

  if (depth[u] == depth[v]) {
    return du + dv + calc(x, y, parent[u], parent[v]);
  }

  if (depth[u] > depth[v]) {
    dv = 0;
    u = parent[u];
  }
  else {
    du = 0;
    v = parent[v];
  }
  return du + dv + calc(x, y, u, v);
}

int main() {
  int N, Q; cin >> N >> Q;
  vector<Graph> edge(N);
  rep(i,N-1) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b;
    edge[a].push_back({b, c, d});
    edge[b].push_back({a, c, d});
  }

  dist.resize(N);
  node.resize(N);
  parent.resize(N);
  depth.resize(N);
  color.resize(N);

  dist[0] = 0;
  node[0] = 0;
  parent[0] = -1;
  depth[0] = 0;

  dfs(edge, 0, -1, 0, 0);

  rep(i,Q) {
    int x, y, u, v;
    cin >> x >> y >> u >> v;
    --u; --v;

    cout << calc(x, y, u, v) << endl;
  }
  return 0;
}


Measured memory_bytes: 579200
import heapq

N, M = map(int, input().split())

AB = []

for i in range(N):
    A, B = map(int, input().split())
    AB.append([A, B])

AB.sort(reverse=True)

q = []
cnt = 0
for i in range(1, M+1):
    while len(AB) > 0 and AB[-1][0] <= i:
        tmp = AB.pop()
        heapq.heappush(q, -tmp[1])
    if len(q) > 0:
        max_val = -heapq.heappop(q)
        cnt += max_val

print(cnt)
        

Measured memory_bytes: 20236
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
int N,M,i;
int Cn=0,Pn=0;
  scanf("%d %d",&N,&M);
  int *p=(int*)malloc(sizeof(int)*M);
  int *af=(int*)malloc(sizeof(int)*N);
  int *wn=(int*)malloc(sizeof(int)*N);
  char S[100000][3];
  char AC[3]="AC";
  for(i=0;i<N;i++){
  	  	af[i]=0,wn[i]=0;
  }
  for (i=0;i<M;i++){
	scanf("%d %s",&p[i],&S[i]);
    p[i]--;
  }
  for(i=0;i<M;i++){
  	if(af[p[i]]==0){
		if(strcmp(S[i],AC)!=0)wn[p[i]]++;
    	else{
          	Cn++;
        	af[p[i]]=1;
        }
    }
  }
  for(i=0;i<N;i++)if(af[i]==1)Pn+=wn[i];
  printf("%d %d\n",Cn,Pn);
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
/**
vector<int>ar(3);
for(auto&e:ar){
    scanf("%d",&e);
        }
sort(ar.begin(),ar.end())
int sum=accumulate(ar.begin(),ar.end(),0);
**/
int sum(const vector<vector<int>>& p, int t, int l, int b, int r) {
  return p[b][r] - p[b][l - 1] - p[t - 1][r] + p[t - 1][l - 1];
}
 
int frame(const vector<vector<int>>& p, int t, int l, int b, int r) {
  int result = sum(p, t, l, b, r);
  if(b - t > 1 && r - l > 1) result -= sum(p, t + 1, l + 1, b - 1, r - 1);
  return result;
}
 
int main() {
  int N;
  cin >> N;
  vector<vector<int>> p(N, vector<int>(N));
  for(auto& i: p) for(auto& j: i) cin >> j;
  for(auto& i: p) i.insert(begin(i), 0);
  p.insert(begin(p), vector<int>(N + 1, 0));
 
  for(int i = 1; i <= N; ++i) for(int j = 2; j <= N; ++j) p[i][j] += p[i][j - 1];
  for(int i = 2; i <= N; ++i) for(int j = 1; j <= N; ++j) p[i][j] += p[i - 1][j];
 
  int answer = -1000;
  for(int top = 1; top <= N; ++top) for(int bottom = top; bottom <= N; ++bottom) {
    int left = 1;
    for(int right = 1; right <= N; ++right) {
      int tlbr = frame(p, top, left, bottom, right);
      answer = max(answer, tlbr);
      int r = frame(p, top, right, bottom, right);
      int tlb = tlbr - r + frame(p, top, right, top, right) + frame(p, bottom, right, bottom, right);
      if(top == bottom) tlb -= frame(p, bottom, right, bottom, right);
      if(r > tlb) left = right;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 3668
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int dp[100010];

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

    dp[0] =0;
    for (int n = 1; n <= 100000; n++) {
        dp[n] = 1e9;
        int power = 1;
        while (power <= n) {
            dp[n] = min(dp[n], dp[n-power]+1);
            power *= 6;
        }
        power = 1;
        while (power <= n) {
            dp[n] = min(dp[n], dp[n-power]+1);
            power *= 9;
        }
    }

    cout << dp[N] << endl;

    return 0;
}


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

int main(){
  int N, K;
  int num = 1;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    if(num + K > 2*num)
      num *= 2;
    else num += K;
  }
  
  cout << num << endl;
}

Measured memory_bytes: 3628
//package Beginner120;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int k = s.nextInt();
        int gcd = gcd(a, b);
        ArrayList<Integer> div = div(gcd);
//        int count = 0;
        System.out.println(div.get(div.size() - k));
    }

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

    private static ArrayList<Integer> div (int num) {
        ArrayList<Integer> ans = new ArrayList<>();
        for (int i = 1; i <= Math.sqrt(num); i++) {
            if(num % i == 0) {
                if(i == num/i) {
                    ans.add(i);
                } else {
                    ans.add(i);
                    ans.add(num/i);
                }
            }
        }
        Collections.sort(ans);
        return ans;
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
int d = 1e9 + 7;
int fact(int N){
    if(N == 0) return 1;
    long long int temp = fact(N - 1);
    temp = temp * N;
    return (int)(temp % d);
}
int main(){
    int N, M;
    cin >> N >> M;
    if(fabs(M - N) > 1.000000001) cout << 0 << endl;
    else{
        long long int res = fact(N);
        res *= fact(M);
        if(M != N) {
            cout << (int)(res % d) << endl;
        }
        else cout << (int)((res << 1) % d) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    int N;
    cin >> N;
    vector<tuple<string,int,int>> a;
    for(int i=1; i<=N; i++){
        string S;
        int P;
        cin >> S >> P;
        P=-P;
        a.emplace_back(S,P,i);
    }
    sort(a.begin(),a.end());
    rep(i,N){
        cout << get<2>(a.at(i)) << endl;
    }

 
}

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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 5005;

typedef pair<int,int>   ii;

int b[N][205];
ll  a[N];
ll  tr[N << 1];
ll  lz[N << 1];

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

    int n;  cin >> n;
    int m;  cin >> m;

    auto app = [&](int i,ll  v) {
        tr[i] += v;
        lz[i] += v;
    };
    auto upd = [&](int l,int r,ll  v)   {
        l += n;
        r += n + 1;

        int L = l;
        int R = r - 1;

        for(; l < r ; l >>= 1, r >>= 1) {
            if (l & 1)  app(l++,v);
            if (r & 1)  app(--r,v);
        }
        for(; L > 1 ; L >>= 1)  tr[L >> 1] = max(tr[L],tr[L ^ 1]) + lz[L >> 1];
        for(; R > 1 ; R >>= 1)  tr[R >> 1] = max(tr[R],tr[R ^ 1]) + lz[R >> 1];
    };

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

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < m ; ++j)
        cin >> b[i][j];

    stack<int>  st[m];

    ll  ans = 0;

    for(int i = 0 ; i < n ; ++i)    {
        upd(i,i,a[i]);

        for(int j = 0 ; j < m ; ++j)    {
            upd(i,i,b[i][j]);

            while (st[j].size() && b[st[j].top()][j] < b[i][j]) {
                int r = st[j].top();    st[j].pop();
                int l = st[j].size() ?  st[j].top() + 1 : 0;

                upd(l,r,b[i][j] - b[r][j]);
            }
            st[j].push(i);
        }
        if (ans < tr[1] - a[i])
            ans = tr[1] - a[i];
    }
    cout << ans << endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    ll mn = 0, mx = 0;
    REP(i, K) {
        mn += i;
        mx += N - i;
    }
    for (ll n = K; n <= N + 1; ++n) {
        ans += mx - mn + 1;
        ans %= MOD;
        mx += N - n;
        mn += n;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3528
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int K = in.nextInt();
        if (K % 7 == 0)
            K /= 7;
        if (K == 1) {
            out.println(1);
        } else {
            int ans = 1;
            int rem = 1;
            int add = 1;
            while (rem != 0 && ans < K) {
                ans++;
                add *= 10;
                add %= K;
                rem += add;
                rem %= K;
            }
            if (rem != 0) {
                out.println(-1);
            } else {
                out.println(ans);
            }
        }

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



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

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

    bool is_appeared[26] = {};
    for (int i = 0; i < S.size(); i++)
    {
        is_appeared[S[i] - 'a'] = true;
    }

    string ans = "None";
    for (int i = 0; i < 26; i++)
    {
        if (!is_appeared[i])
        {
            ans = "a";
            ans[0] += i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60
int main(){
    long long N;
    cin >> N;
    vector<long long>B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }

    long long ans=0;
    ans+=B[0];
    for(long long i=1;i<N-1;i++){
        ans+=min(B[i-1],B[i]);
    }
    ans+=B[N-2];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define MAX_N 101


int main(){
        int H,W;
        char ch;
        while(1){
                std::cin>>H>>W;
                if(H==0 && W==0) break;
                for(int i=0;i<H;i++){
                        for(int j=0;j<W;j++){
                                if(i==0 || i==H-1) ch='#';
                                else if(j==0 || j==W-1) ch='#';
                                else ch='.';
                                 std::cout<<ch;
                        }
                        std::cout<<std::endl;
                }
                std::cout<<std::endl;
        }
        return 0;
}

Measured memory_bytes: 3068
#無限ループと標準入力とカウンタ変数のリセット
while True:
    kai = 0
    num = int(input())
    
    #入力値が0だったら終わる
    if num == 0:break

    #標準入力をし、平均値を求める
    line = list(map(int,input().split()))
    heikin = sum(line) / num
    
    #平均値以下の個数を調べ個数を出力
    for i in range(num):
        if line[i] <= heikin:kai += 1
    print(kai)


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

B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    sm = C
    for j in range(M):
        sm += A[i][j] * B[j]

    if sm > 0:
        ans += 1

print(ans)

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

int main(){
  long long n,l[100];
  cin>>n;
  l[0]=2,l[1]=1;
  
  for(int i=2;i<=n;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  map<string,ll> cnt;
  string s;
  while(n--){
    cin >> s;
    sort(begin(s),end(s));
    ++cnt[s];
  }
  ll ans = 0;
  for(auto& p : cnt){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 11264
N = int(input())
s = [''.join(sorted(list(input()))) for _ in range(N)]
s.sort()
tmp = s[0]
t = 0
ans = 0
for x in s[1:]:
    if x == tmp:
        t += 1
    else:
        ans += t * (t + 1) // 2
        t = 0
        tmp = x
ans += t * (t + 1) // 2
print(ans)


Measured memory_bytes: 10988
#include <algorithm>
#include <iostream>
#include <vector>

const int mod = 1e9 + 7;

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

    std::vector<long long> dp(n + 1);

    dp[0] = 2;
    dp[1] = 1;

    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }

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


Measured memory_bytes: 256
def make_divs(n):
    divs = []
    
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divs.append(i)
            
            if i!=n//i:
                divs.append(n//i)
                
    divs.sort(reverse=True)
    
    return divs

N, M = map(int, input().split())
divs = make_divs(M)

for d in divs:
    if M//d>=N:
        print(d)
        exit()

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

int main() {
	long long		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> n;
	
	vector<int> a(n);
	
	for(i=0;i<n;i++) {
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	str = "YES";
	for(i=0;i<n-1;i++) {
		if (a[i] == a[i+1]) {
			str = "NO";
		}
	}
	
	cout << str << endl;


}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

double n, p;
vector<double> prob={0};

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cout << setprecision(9)<<fixed;
  cin >> n;
  rep(i, 1, n){
  	cin >> p;
  	prob.pb(p);
  }
  vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
  dp[0][0]=1;
  rep(i, 1, n){
  	rep(j, 0, n){
  		if(j==0) dp[i][j]=dp[i-1][j]*(1-prob[i]);
  		else dp[i][j]=(1-prob[i])*dp[i-1][j]+prob[i]*dp[i-1][j-1];
  		// cout << "dp["<<i<<"]["<<j<<"] "<<dp[i][j]<<endl;
  	}
  }

  double ans=0;
  rep(i, n/2+1, n){
  	ans+=dp[n][i];
  }
  cout << ans;
}

Measured memory_bytes: 73824
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll m1,m2,d1,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  
  if( m1<m2 ) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

}


Measured memory_bytes: 23636
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int main(){
	map<string, vector<int> > dic;
	string voc;
	int page;
	while (cin >> voc >> page) {
		dic[voc].push_back(page);
	}
	map<string, vector<int> >::iterator it = dic.begin();
	while(it!=dic.end()) {
		cout << (*it).first<<endl;
		sort((*it).second.begin(), (*it).second.end());
		for (int i = 0;i < (*it).second.size();i++) {
			if (i == (*it).second.size() - 1) {
				cout << (*it).second[i];
			}
			else cout << (*it).second[i] << " ";
		}
		cout << endl;
		it++;
	}
	
}

int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        Dictionary<string, string> pairTable = new Dictionary<string, string>()
        {
            {"A", "T" },
            {"T", "A" },
            {"C", "G" },
            {"G", "C" },
        };
        var b = Console.ReadLine();
        Console.WriteLine(pairTable[b]);

    }
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int d[2005];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());


    int n, x, y;
    cin >> n >> x >> y;
    FOR(i,1,n){
        FOR(j,i+1,n){
            d[min(abs(j-i), min(abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)))]++;
        }
    }
    FOR(i,1,n-1){
        cout << d[i] << endl;
    }

    
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	char arrMap[55][55] = { 0 };
	int iWidth, iLength,nCount=0;
	register int i, j,k,l;
	cin >> iWidth >> iLength;
	for (i = 1; i <= iWidth; ++i){
		for (j = 1; j <= iLength; ++j){
			cin >> arrMap[i][j];
		}
	}
	for (i = 1; i <= iWidth; ++i){
		for (j = 1; j <= iLength; ++j){
			if (arrMap[i][j] == '.'){
				for (k = i - 1; k <= i + 1; ++k){
					for (l = j - 1; l <= j + 1; ++l){
						if (arrMap[k][l] == '#'){
							++nCount;
						}
					}
				}
				arrMap[i][j] = nCount+'0';
				nCount = 0;
			}
			cout << arrMap[i][j];
		}
		cout << endl;
	}
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256