akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL a[N];
LL before[N],last[N];
int main() {
    int n;
    scanf("%d",&n);

    LL maxSum=0,minSum=0;
    priority_queue<LL> minSumQ;
    priority_queue<LL, vector<LL>, greater<LL> > maxSumQ;
    for(int i=1;i<=3*n;i++){
        scanf("%d",&a[i]);
        if(i<=n){
            maxSum+=a[i];
            maxSumQ.push(a[i]);
        }
        else if(i>2*n){
            minSum+=a[i];
            minSumQ.push(a[i]);
        }
    }

    before[n]=maxSum;
    for(int i=n+1;i<=2*n;i++) {
        LL temp=maxSumQ.top();
        if(temp<a[i]){
            maxSum+=a[i]-temp;
            maxSumQ.pop();
            maxSumQ.push(a[i]);
        }
        before[i]=maxSum;
    }

    last[2*n]=minSum;
//    last[2*n+1]=minSum;
    for(int i=2*n-1;i>=n;i--){
        LL temp=minSumQ.top();
        if(temp>a[i+1]){
            minSum+=a[i+1]-temp;
            minSumQ.pop();
            minSumQ.push(a[i+1]);
        }
        last[i]=minSum;
    }

    LL res=before[n]-last[n];
    for(int i=n+1;i<=2*n;i++)
        res=max(res,before[i]-last[i]);
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 8820
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,a,b;
  cin>>n>>a>>b;
  Int s=1<<n;
  Int y=b^a;
  if(!__builtin_parity(y)){    
    cout<<"NO"<<endl;
    return 0;
  }  
  vector<Int> v;
  for(Int i=0;i<n;i++)
    if((~y>>i)&1) v.emplace_back(1<<i);  
  for(Int i=0;i<n;i++)
    if((y>>i)&1) v.emplace_back(1<<i);

  vector<Int> ans(s,0);
  for(Int i=1;i<s;i++) ans[i]=v[__builtin_ctz(i)];

  Int c=0;
  for(Int i=0;i<n;i++)
    if((y>>i)&1) c++;

  Int d=n-3;
  while(c>2){
    assert(ans[1<<d]==ans[3<<d]);
    Int i=ans[1<<d],j=ans[2<<d];
    ans[1<<d]=j;
    ans[2<<d]=i;
    ans[3<<d]=j;
    c-=2;
    d-=2;
  }
  
  cout<<"YES"<<endl;
  Int res=0;
  for(Int i=0;i<s;i++){
    if(i) cout<<" ";
    res^=ans[i];
    cout<<(res^a);
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		while (true) {

			int outer = 0;

			int[] num = new int[6];
			for (int i=0; i<6; i++) {
				num[i] = in.nextInt();
				outer += num[i];
			}

			if (outer == 0) break;

			int[] p = new int[3];
			for (int i=0; i<3; i++) {
				p[i] = num[i] + num[i+3];
			}

			int ans = 0;

			for (int i=0; i<3; i++) {
				int tmp = i;
				for (int j=0; j<3; j++) {
					if (p[j] - i < 0) {
						tmp = -1;
						break;
					} else {
						tmp += (p[j] - i)/3;
					}
				}
				ans = Math.max(ans, tmp);
			}

			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 68484
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestA().doIt();
	}
	class TestA{
		void doIt() {
			int N = Integer.parseInt(sc.next());
			int X = Integer.parseInt(sc.next());
			int T = Integer.parseInt(sc.next());
			int ans = (N / X) * T;
			if(N % X > 0)ans = ans + T;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 35644
#include <iostream>
#include <string>
using namespace std;
int main(){

string A,B,C;

    cin>>A>>B>>C;

    if (A.back()==B[0]&&B.back()==C[0])
    {
        cout<<"YES"<<endl;
    }
else
    cout<<"NO"<<endl;

    return 0;
}


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

int main() {
  char N[3];
  scanf("%s" ,&N) ;

  if ( N[0] == N[1] && N[1] == N[2]|| N[1] == N[2] && N[2] == N[3] ) {
    puts("Yes" );
  }
  
  else puts("No") ;
}


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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  string S;
  cin >> S;
  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int Cpos = 0;
  for (int i = 2; i <= (int)S.size() - 2; i++) {
    if (S[i] == 'C') {
      if (Cpos != 0) {
	cout << "WA" << endl;
	return 0;
      }
      Cpos = i;
    }
  }

  if (Cpos == 0) {
    cout << "WA" << endl;
    return 0;
  }
  
  bool isValid = true;
  for (int i = 1; i < (int)S.size(); ++i) {
    if (i == Cpos) continue;
    if ((int)S[i] < (int)'a') {
      isValid = false;
    }
  }

  if (isValid) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
  return 0;
}


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

int main() {
	int x = 0; //number
	string s;//+or-
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			x++;
		}
		else {
			x--;
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 256
import sys
A,B = map(int,input().split())

if not (-1000 <= A <= 1000 and -1000 <= B <= 1000):
    sys.exit()

result = -1000
if A + B > result:
    result = A + B
if A - B > result:
    result = A - B
if A * B > result:
    result = A * B

print(result)

Measured memory_bytes: 9152
#include <iostream>
#define INF 1000000001
using namespace std;

int S[110];
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=N;i++) cin>>S[i];

	int mi=INF,res=0;
	for(int i=1;i<=N;i++){
		res+=S[i];
		if(S[i]%10) mi=min(mi,S[i]);
	}
	if(res%10) cout<<res<<endl;
	else if(mi!=INF) cout<<res-mi<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    cout<<n*n<<"\n";

    return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	cinf(a,n);
	ll min = a[0];
	ll max = a[0];
	arep(1,i,n){
		if(max<a[i])
			max=a[i];
		else if(min>a[i])
			min=a[i];
	}
	cout << max-min << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int Calc(int a,int b,char op){
	switch(op){
		case '+':
			return a + b;
			break;
		case '-':
			return a - b;
			break;
		case '*':
			return a * b;
			break;
		case '/':
			return a / b;
			break;
		default:
			break;
	}
}
int main(void){
	int a,b;
	char op;

	while(1){
		scanf("%d %s %d", &a, &op, &b);

		if(op == '?'){
			break;
		}

		if(a >= 0 && a <= 20000 && b >= 0 && b <= 20000){
			printf("%d\n", Calc( a, b, op));
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};
int main()
{
    int N;
    long long K;
    cin >> N;
    cin >> K;
    
    vector<int> data(N);
    for(int i=0;i<N;i++)
    {
        cin >> data[i];
        data[i]--;
    }
    
    vector<int> ans(N,-1);
    
    vector<int> used(N,-1);
    
    int count = 0;
    int temp = 0;
    while(used[temp] == -1)
    {
        used[temp] = count;
        ans[count] = temp;
        temp = data[temp];
        count ++;
        
    }
    int start = used[temp];
    int loop = count - start;
    
    if(K < start)
    {
        cout << ans[K]+1 << endl;
    }
    else
    {
        K -= start;
        K %= loop;
        K += start;
        cout << ans[K]+1 << endl;
    }
    return 0;
}

/*
int main()
{
    int M,N,X;
    cin >> M >> N >> X;
    vector<vector<int>> data(M,vector<int>(N));
    vector<int> cost(M);
    
    for(int i=0;i<M;i++)
    {
        cin >> cost[i];
        for(int j=0;j<N;j++)
        {
            cin >> data[i][j];
        }
    }
    
    int ans = INT_MAX;
    
    for(int bit = 0;bit < (1<<M);bit++)
    {
        int money = 0;
        vector<int> temp(N,0);
        for(int i=0;i<M;i++)
        {
            if((1<<i) & bit)
            {
                money += cost[i];
                for(int j=0;j<N;j++)
                {
                    temp[j] += data[i][j];
                }
            }
            
        }
        bool ok = true;
        for(int j=0;j<N;j++)
        {
            if(temp[j]< X)
            {
                ok  =false;
                break;
            }
        }
        if(ok)
        {
            ans = min(ans,money);
        }
    }
    
    if(ans == INT_MAX) ans = -1;
    cout << ans << endl;
    return 0;
}

*/
/*
int main()
{
    int N;
    cin >> N;
    
 
 int ans;
 cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 5636
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var M = Number(lines[0].split(" ")[1]);
    var X = Number(lines[0].split(" ")[2]);
    var Y = Number(lines[0].split(" ")[3]);

    var x = lines[1].split(" ").map(i => Number(i));
    var y = lines[2].split(" ").map(i => Number(i));

    x.sort((a, b) => b - a)
    y.sort((a, b) => a - b)

    var Z = y[0];
    if (x[0] < Z && X < Z && Z <= Y) { console.log("No War") }
    else { console.log("War") }

});

Measured memory_bytes: 7756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  int hi=5000;
  int mi=-5000;
  
  rep(i,n){
    cin>>p[i];
    hi=min(hi,p[i]);
    mi=max(mi,p[i]);
  }
  
  cout << mi-hi << endl;
  
}

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

  int main(void){
    // Your code here!
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    
    if (N > K){
        cout << X * K + (N - K) * Y << endl;
    }
    else{
        cout << N * X << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>  // sort, unique
#include <string>
#include <vector>

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1

using namespace std;

void printVector(vector<int> &vec) {
    cout << "size: " << vec.size() << endl;
    for (int i = 0; i < (int)vec.size(); ++i) {
        cout << vec[i] << ", ";
    }
    cout << endl << endl;
}

int main() {
    // input
    int N, M;
    // N
    cin >> N;
    vector<string> vec_N(N);
    REP(i, N) cin >> vec_N.at(i);
    // M
    cin >> M;
    vector<string> vec_M(M);
    REP(i, M) cin >> vec_M.at(i);

    int ans = 0;
    REP(i, N) {
        int sum = 0;
        string tmp = vec_N[i];
        REP(j, N) {
            if (tmp == vec_N[j]) {
                sum++;
            }
        }

        REP(k, M) {
            if (tmp == vec_M[k]) {
                sum--;
            }
        }

        // ans と比較
        if (ans < sum) {
            ans = sum;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  long long a[n],b[m],c[m];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  pair<long long, long long> p[m];
  for(int i=0;i<m;i++){
    cin >> b[i] >> c[i];
    p[i]=make_pair(c[i],b[i]);
  }
  sort(p,p+m);
  reverse(p,p+m);
  long long j=0,cnt=0;
  for(int i=0;i<n;i++){
    if(j==m){
      break;
    }
    if(p[j].first>a[i]){
      if(cnt<p[j].second){
        a[i]=p[j].first;
        cnt++;
      }else{
        i--;
        j++;
        cnt=0;
      }
    }else{
      break;
    }
  }
  for(int i=0;i<n;i++){
    ans+=a[i];
  }cout << ans << endl;
  return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  string s;
  cin >> s;
  REP(i, 3) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
list1=[]
ans=[]
for i in range(m):
    a,b=input().split()
    list1.append(a)
    list1.append(b)
for i in range(n):
    ans.append(list1.count(str(i+1)))
for i in range(n):
    print(ans[i])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
  int dp[n][3];
  memset(dp,0,sizeof(dp));
  for(int i=0;i<3;i++){
      dp[0][i]=a[0][i];
  }
  for(int i=1;i<n;i++){
      for(int j=0;j<3;j++){
          if(j==0)
          dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+a[i][j];
          else if(j==1)
          dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+a[i][j];
          else if(j==2)
          dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+a[i][j];
      }
  } 
//   for(int i=0;i<n;i++){
//       for(int j=0;j<n;j++){
//           cout<<dp[i][j]<<" ";
//       }
//       cout<<endl;
//   }
  int m=INT_MIN;
  for(int i=0;i<3;i++){
      m=max(dp[n-1][i],m);
  }
   cout<<m<<endl;
}
   
   
   
   
   
   
   

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=1,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    n = s1.size(); m = s2.size(); d = s3.size();
    if(s1[n-1]==s2[0] and s2[m-1]==s3[0]) cout << "YES";
    else cout << "NO";
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e6+10;
const ll inf = 1e9;


ll ans = 0;

int main(){
	fastio;
	ll tc,n,u,v,k;
	cin>>n;
	f(i,1,n){
		cin>>u>>v;
		if(u>v) swap(u,v);
		ans += u * (n - v +1 ) ;
	}
	ll to = 0;
	f(i,1,n+1){
		to += i*(n+1-i);
	}
	cout<< to- ans<<endl;
}

Measured memory_bytes: 3644
n,P=map(int,input().split())
if n==1:
	print(P)
	exit()
if n>39:
  print(1)
  exit()
ans=1
if n==2:
	for i in range(2,10**6+1):
		while P%(i**2)==0:
			ans*=i
			P/=(i**n)
	
if n==3:
	for i in range(2,10**4+1):
		while P%(i**3)==0:
			ans*=i
			P/=(i**n)
	
if n==4:
	for i in range(2,10**3+1):
		while P%(i**4)==0:
			ans*=i
			P/=(i**n)
	  
if n==5:
	for i in range(2,int(10**2.4)+1):
		while P%(i**5)==0:
			ans*=i
			P/=(i**n)
else:
	for i in range(2,101):
		while P%(i**n)==0:
			ans*=i
			P/=(i**n)
print(ans)

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

using namespace std;

typedef long long ll;

#define mod 1000000007

int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll cnt[n]={0};
  for(int i=0;i<n;i++){
    cin>>a[i];
    cnt[a[i]]++;
  }
  
  ll ans=1;
  //2^n/2
  for(int i=0;i<n/2;i++){
    ans=(ans*2)%mod;
  }
  
  bool isValid=true;
  if(n%2==1){
    if(cnt[0]!=1){
      isValid=false;
    }
    for(int i=2;i<n&&isValid;i=i+2){
      if(cnt[i]!=2){
        isValid=false;
      }
    }
  }else{
    for(int i=1;i<n&&isValid;i=i+2){
      if(cnt[i]!=2){
        isValid=false;
      }
    }
  }
  if(isValid){
  	cout<<ans<<endl;
  }else{
    cout<<"0"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 5168
a, b, c, k = map(int, input().split(' '))

cnt_a = 0
cnt_b = 0
cnt_c = 0

if (a > 0) & (a > k):
    cnt_a = k
    k = 0
else:
    cnt_a = a
    k = k - cnt_a

if (b > 0) & (b > k):
    cnt_b = k
    k = 0
else:
    cnt_b = b
    k = k - cnt_b

if c > 0:
    cnt_c = k

result = cnt_a * 1 + cnt_b * 0 + cnt_c * (-1)
print(result)


Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    int tak = c / b, aok = a / d;
    
    if(c % b == 0) {
        tak -= 1;
    }
    if(a % d == 0) {
        aok -= 1;
    }
    
    if(tak <= aok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int num = k - q;
  vector<int> a(q);
  for(int i = 0; i < q; i++)
    cin >> a.at(i);
  vector<int> ans(n);
  for(int i = 0; i < n; i++)
    ans.at(i) = 0;
  for(int i = 0; i < q; i++) {
    ans.at(a.at(i) - 1)++;
  }
  for(int i = 0; i < n; i++) {
    if(ans.at(i) + num <= 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1408
N, A = map(int, input().split())

ans = N

for i in range(1, 50):
    ok = 10 ** 20
    ng = 0

    while ok - ng > 1:
        mid = (ok + ng) // 2
        prod = 1
        for j in range(i):
            prod *= (mid + j) // i
        if prod >= N:
            ok = mid
        else:
            ng = mid

    ans = min(ans, A * (i - 1) + ok)

print(ans)


Measured memory_bytes: 41836
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int d=max(a,b);
    int e=max(d,c);
    int f=min(a,b);
    int g=min(f,c);
    cout<<e-g<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int iabs(int x) {
  return x>=0 ? x : -x;
}

int main() {
  int N;
  int px = 0, py = 0, pt = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int x, y, t;
    scanf("%d%d%d", &t, &x, &y);
    if (iabs(x - px) + iabs(y - py) > t - pt) {
      puts("No"); return 0;
    } else if (((x + y + px + py) & 1) != ((t + pt) & 1)) {
      puts("No"); return 0;
    }
    pt = t;
    px = x;
    py = y;
  }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 128
absN = int(input())
M = [[0 for _ in range(absN)] for _ in range(absN)]

for _ in range(absN):
    cmd = list(map(int, input().split(" ")))
    for i in range(cmd[1]):
        M[cmd[0]-1][cmd[i+2]-1] = 1

for x in M:
    x =map(str, x)
    print(" ".join(x))


Measured memory_bytes: 5680
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000000],n;
int main ()
{
  cin>>n;
  for(int i = 0 ;i<n;i++)
     cin>>a[i];
  int q,k,sum = 0;
  cin>>q;
  for(int i = 0;i<q;i++)
     {
       cin>>k;
       if(*lower_bound(a,a+n,k)  == k)  sum++;
     }
     cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
long long dp[101][100005];
int main()
{
    int n,w;
    cin>>n>>w;
    int i,j;
    long long ww[n+1],v[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>ww[i]>>v[i];
    }
    for(j=ww[1];j<=w;j++)
    {
        dp[1][j]=v[1];
    }
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            dp[i][j]=dp[i-1][j];
            if((j-ww[i])>=0)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-ww[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][w]<<endl;

}


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

int main(){
	int num;
	int mostNum = 1;
	int mostTimes = 0;
	int counter;
	cin >> num;
	for(int i = num; i >= 1; i--){
		counter = 0;
		int number = i;
		while(number>1 && number % 2 == 0){
			number = number / 2;
			counter++;
		}
		if(counter > mostTimes){
			mostTimes = counter;
			mostNum = i;
		}
	} 
	cout << mostNum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MEM 100005

int main(void) {
    int N, Q;
    long long arr[MEM];
    
    scanf("%d %d", &N, &Q);
    for (int i = 0; i < N; i++) scanf("%lld", arr+i);
    for (int query = 0; query < Q; query++) {
        long long
            q,
            res = 0,
            sum = 0;
        int right = 0;
        scanf("%lld", &q);

        for (int left = 0; left < N; left++) {
            while (right < N && sum + arr[right] <= q) {
                sum += arr[right];
                right++;
            }
            res += right - left;
            if (right == left) {
                right++;
            } else {
                sum -= arr[left];
            }
        }

        printf("%lld\n", res);
    }

    return 0;
}


Measured memory_bytes: 2632
#include<iostream>
using namespace std;
  
int main(){
    int n, b, f, r, v;
    int buildings[4][3][10];
  
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                buildings[i][j][k] = 0;
            }
        }
    }
  
      
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        buildings[b-1][f-1][r-1] += v;
    }
  
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << " " << buildings[i][j][k];
            }
            cout << endl;
        }
        if(i!=3){
            cout << "####################" << endl;
        }
    }
  
    return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, D;
  ll ans = 0;
  cin >> N >> D;
  vvl X = VVL(N, D, 0);
  REP(i, N) REP(j, D) cin >> X[i][j];
  REP(i, N - 1) FOR(j, i + 1, N) {
    long double a = 0;
    REP(d, D) a += POW(X[i][d] - X[j][d], 2);
    if (SQRT(a) == (ll)SQRT(a))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  int N , M; cin >> N >> M;
  vector<P1> a(M); rep(i,M) cin >> a[i].fi >> a[i].sc.fi; rep(i,M) a[i].sc.sc = i;
  SORT(a);

  vector<int> num(M);
  int cnt = 1;
  num[0] = cnt;
  rep(i,M - 1){
    if(a[i].fi == a[i + 1].fi) num[i + 1] = ++cnt;
    else{
      cnt = 1;
      num[i + 1] = cnt;
    }
  }

  vector<P1> b(M);
  rep(i,M){
    b[i].fi = a[i].sc.sc;
    b[i].sc.fi = a[i].fi;
    b[i].sc.sc = num[i];
  }
  SORT(b);

  rep(i,M){
    printf("%06d", b[i].sc.fi);
    printf("%06d", b[i].sc.sc);
    cout << endl;
  }
}


Measured memory_bytes: 4224
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

int N,A,B;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> A >> B;
	
	cout << (abs(A-B-1)%2==0 ? "Borys\n" : "Alice\n");
	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	int n, k;
	solve(int n, int k):n(n),k(k){}
	vi operator()(vi a)
	{
		for(int i=0;i<k;i++)
		{
			vi r(n+1);
			for(int i=0;i<n;i++)
			{
				int s=max(i-a[i], 0);
				int e=min(i+a[i]+1, n);
				r[s]++;
				r[e]--;
			}

			int c=0;
			int n_cnt=0;
			for(int i=0;i<n;i++)
			{
				c+=r[i];
				a[i]=c;
				if(c==n) n_cnt++;
			}
			if(n_cnt==n)
			{
//				cout << "i=" << i << endl;
				break;
			}
		}
		return a;
	}
};

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

	for(;;)
	{
		int n, k;
		cin >> n >> k;
		if(cin.fail()) break;

		vi a(n);
		for(int i=0;i<n;i++) cin >> a[i];

		auto ans=solve(n, k)(a);
		cout << ans[0];
		for(int i=1;i<n;i++) cout << " " << ans[i];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 5780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int[] a=fs.readArray(5);
		for (int i=0; i<5; i++) {
			if (a[i]==0) System.out.println(i+1);
		}
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32548
use std::io;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();

    let n: i32 = iter.next().unwrap().parse::<i32>().unwrap();
    let mut h: i32 = iter.next().unwrap().parse::<i32>().unwrap();

    let mut a_s: Vec<i32> = Vec::new();
    let mut b_s: Vec<i32> = Vec::new();

    for _ in 0..n {
        let mut buf: String = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        a_s.push(iter.next().unwrap().parse::<i32>().unwrap());
        b_s.push(iter.next().unwrap().parse::<i32>().unwrap());
    }
    a_s.sort_by(|a, b| b.cmp(a));
    b_s.sort_by(|a, b| b.cmp(a));
    let a_max = a_s[0];
    let mut cnt: i32 = 0;
    let mut idx: usize = 0;
    while h > 0 {
        if idx < b_s.len() && b_s[idx] > a_max {
            h -= b_s[idx];
            idx += 1;
        } else {
            cnt += h / a_max + if h % a_max == 0 {0} else {1};
            break;
        }
        cnt += 1;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
import sys
from itertools import product

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    return "Heisei" if ii(str) <= "2019/04/30" else "TBD"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 12248
# -*- coding: utf-8 -*-
# B - Strings with the Same Length
import sys
import os

def getGCD(A, B):
  a, b = A, B
  if B > A:
    a, b = B, A
  r = a%b
  while r != 0:
    a = b
    b = r
    r = a%b
  return b

def problem148C(A, B):
  gcd = getGCD(A, B)
  print(int(A*B/gcd))

if __name__ == "__main__":
  A, B = list(map(int, input().split()))
  problem148C(A, B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAX=110;

int N,T,L,B,Lose,Back;
int P[MAX];
double dp[MAX][MAX];

void solve(){
    for (int i=0;i<=T;++i)
        for (int j=0;j<=N;++j)
            dp[i][j]=0;
    dp[0][0]=1;
    for (int i=0;i<T;++i){
        for (int j=0;j<=N;++j){
            if (j==N){dp[i+1][j]+=dp[i][j]; continue;}
            for (int k=1;k<=6;++k){
                int nxt=(j+k<=N?j+k:2*N-j-k);
                if (P[nxt]==0) dp[i+1][nxt]+=dp[i][j]/6;
                if (P[nxt]==1&&i+2<=T) dp[i+2][nxt]+=dp[i][j]/6;
                if (P[nxt]==2) dp[i+1][0]+=dp[i][j]/6;
            }
        }
    }
    cout << dp[T][N] << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    while(cin >> N >> T >> L >> B,N){
        for (int i=0;i<=N;++i) P[i]=0;
        for (int i=0;i<L;++i){
            cin >> Lose; P[Lose]=1;
        }
        for (int i=0;i<B;++i){
            cin >> Back; P[Back]=2;
        }
        solve();
    }
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll ans = 0;

  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#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 999999999


int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  printf("%d %d %d\n",a[0],a[1],a[2]);
}



Measured memory_bytes: 3248
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
ll mod=1e9+7;
int main()
{
	ll n,m,i,j,k,kk,aa,bb,t,s,p,a,b,c,d;
     cin>>a>>b>>c>>d;
     aa=c/b;
     if(c%b)
     aa++;
     bb=a/d;
     if(a%d)
     bb++;
//     cout<<aa<<' '<<bb<<endl;
     if(aa>bb)
     printf("No\n");
     else
     printf("Yes\n");
}

Measured memory_bytes: 3632
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

vi gen_d_prim(int n){
	vi D(n+1, 0);
	rpd(i, 2, n+1, 1)
		if(!D[i]) rpd(j, i, n+1, i) D[j] = i;
	return D;
}

bool is_pairwise(vi &A){
	vi D = gen_d_prim(1000000);
	set<int> past;
	for(auto a:A){
		set<int> now;
		while(a != 1){
			// # 素数 D[a]: 今回は未済 & 過去は済
			if(!now.count(D[a]) && past.count(D[a])) return false;
			now.insert(D[a]);
			past.insert(D[a]);
			a /= D[a];
		}
	}
	return true;
}

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

	int N; cin>>N;
	int g = 0;
	vi A(N); rpd(i, 0, N, 1){ cin>>A[i]; g = gcd(g, A[i]); }
	int t = 0;
	if(g > 1) t = 2;
	else t = !is_pairwise(A);
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


Measured memory_bytes: 11096
N=int(input())
A=["a"]
if N==1:
    print("a")
    exit()
else:
    S="abcdefghijklmn"
    slist=list(S) 
    for i in range(2,N+1):
        temp=[[] for _ in range(N)]
        for j in range(i-1):
            for w in A[j]:
                for u in slist[:j+1]:
                    temp[j].append(w+u)
                temp[j+1].append(w+slist[j+1])
        A=temp
    B=[]    
    for j in range(N):
        for t in A[j]:
            B.append(t)
    B.sort()
    for i in range(len(B)):
        print(B[i])

Measured memory_bytes: 14064
#include "bits/stdc++.h"
using namespace std; 
#define LIM 100003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";



int n, m, vis[LIM],ans[LIM];
vector< pair< int , int > >graph[LIM] ;
void dfs(int start, int par) {
	int siz = graph[start].size() ;
	for( int i=0; i<siz; i++) {
		int ele = graph[start][i].first ;
		if(ele == par)
			continue ;
		int wt = graph[start][i].second ;
		ans[ele] = ans[start] + wt ;
		dfs(ele, start) ;
	}
}
int main() {
	int i, j, t;
	sc(n) ;
	m = n-1 ;
	while(m--) {
		int st, en, wt;
		sc3(st, en, wt);
		if(wt & 1)
			wt = 1 ;
		else
			wt = 0; 
		graph[st].pb(mp(en, wt)) ;
		graph[en].pb(mp(st, wt)) ; 	
	}	
	dfs(1, 0) ;
	for(i=1; i<=n; i++) {
		if(ans[i] & 1) {
			cout << 1 << " ";
		}
		else
			cout << 0 << " ";
	}
	cout << endl ;
	return 0;
}




Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int N = S.size();
    bool ans = true;
    
    for (int i = 1; i <= (N-3)/4+1; i++){
        if (S.at(i-1) != S.at((N+1)/2-i-1)){
            ans = false;
            break;
        }
    }
    if (ans){
    for (int i = 1; i <= N/2 + 1; i++){
        if (S.at(i-1) != S.at(N-i)){
            ans = false;
            break;
        }
    }
    }
    
    if (ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
int n,m;
int a[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
    if(i*j==n) {
                puts("Yes");
                return 0;
    }
    puts("No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=1e6+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int n,c,h[mxN],dp[mxN];

struct pt{
    int x,y;
    pt operator+(pt p){return {x+p.x,y+p.y};}
    pt operator-(pt p){return {x-p.x,y-p.y};}
}seg[4*mxN];
int dot(pt a,pt b){return a.x*b.x+a.y*b.y;}
int cross(pt a,pt b){return a.x*b.y-a.y-b.x;}
int f(pt a,int b){pt temp={b,1};return dot(a,temp);}

void upd(pt nw,int i=0,int j=mxN,int no=1){
    //cout<<i<<" "<<j<<" "<<no<<"\n";
    int m=(i+j)/2;
    bool lef=f(nw,i)<f(seg[no],i);
    bool mid=f(nw,m)<f(seg[no],m);
    if(mid)swap(nw,seg[no]);
    if(j-i==1)return;
    else if(lef!=mid)upd(nw,i,m,2*no);
    else upd(nw,m,j,2*no+1);
}
int query(int x,int i=0,int j=mxN,int no=1){
    //cout<<i<<" "<<j<<" "<<no<<"\n";
    int m=(i+j)/2;
    if(j-i==1)return f(seg[no],x);
    else if(x<m)return min(f(seg[no],x),query(x,i,m,2*no));
    return min(f(seg[no],x),query(x,m,j,2*no+1));
}
int32_t main(){

    cin>>n>>c;
    for(int i=0;i<n;i++)cin>>h[i];
    //hi^2 + hj^2 -2hihj + c + dp[i]
    upd({-2*h[0],dp[0]+h[0]*h[0]});
    for(int i=1;i<n;i++){
        int tmp=query(h[i]);
        dp[i]=tmp+c+h[i]*h[i];
        upd({-2*h[i],dp[i]+h[i]*h[i]});
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 14892
#include<stdio.h>
#include<string.h>
int main(){
  char c[201],n;
  int len,m,h,a,b,d,e;
  while(1){
    scanf("%s",c);
    if(strcmp(c,"-")==0)break;
    len=strlen(c);
    scanf("%d",&m);
    for(d=0;d<m;d++){
      scanf("%d",&h);
      for(a=0;a<h;a++){
    n=c[0];
    for(b=1;b<=len-1;b++){
      c[b-1]=c[b];
    }
    c[len-1]=n;
      }
    }
    printf("%s\n",c);
  }
  return 0;
}

Measured memory_bytes: 584
import itertools   # accumulate, compress, permutations(nPr), combinations(nCr)
# import bisect      # bisect_left(insert位置), bisect_right(slice用)
import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

n = int(input())
p = list(input().split())
q = list(input().split())
nlis = sorted(p)

cntp = 0
cntq = 0

for idx, i in enumerate(itertools.permutations(nlis,n)):
    if list(i)==p:
        cntp = idx
    if list(i)==q:
        cntq = idx

print(abs(cntp-cntq))

Measured memory_bytes: 8964