akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<set<ll>> ng(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        ng[a].insert(b);
        ng[b].insert(a);
        uf.merge(a, b);
    }
    rep(i, k) {
        ll c, d;
        cin >> c >> d;
        c--; d--;
        ng[c].insert(d);
        ng[d].insert(c);
    }
    rep(i, n) {
        ll ans = uf.size(i) - 1;
        for(auto x : ng[i]) {
            if (uf.is_same(i, x)) {
                ans--;
            }
        }
        printf("%lld%s", ans, (i == (n - 1)) ? "\n" : " ");
    }
    return 0;
}


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

namespace AtCoder
{
    public class Code20171216A
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();

            var ret = Math.Ceiling(s1.Split().Average(a => int.Parse(a))) ;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11220
N = int(input())
a_list = list(map(int, input().split()))
c = 0
for i in range(N-1):
    minj = i
    for j in range(i+1, N):
        if a_list[j] < a_list[minj]:
            minj = j
    if a_list[i] != a_list[minj]:
        a_list[i], a_list[minj] = a_list[minj], a_list[i]
        c += 1
print(' '.join(map(str, a_list)))
print(c)



Measured memory_bytes: 5600
<?php 
  fscanf(STDIN,"%s",$s);
  fscanf(STDIN,"%s",$t);
 
$s_l = str_split($s);
$t_l = str_split($t);

sort($s_l);
rsort($t_l);
$s_mo = '';
$t_mo = '';

for($i=0;$i<strlen($s);$i++) $s_mo .= $s_l[$i];
for($i=0;$i<strlen($t);$i++) $t_mo .= $t_l[$i];

//echo $s_mo."\n";
//echo $t_mo."\n";

if($s_mo < $t_mo){
  echo "Yes\n";
}else{
  echo "No\n";
}


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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par;

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    par[root(a)]=root(b);
}

vector<bool> prime(200001);

void sieve(li n)
{
    fill(prime.B,prime.E,true);

    for(li i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(li j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}

    
int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    sieve(200000);

    li n;

    cin>>n;

    while(!prime[n])
    {
        n++;
    }

    cout<<n;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char C;
	for(C=getchar();!isdigit(C);C=getchar()); 
	for(;isdigit(C);C=getchar())x=x*10+C-'0'; 
}

bool small(ll a,ll b){
	ll A=0,B=0,x;
	for(x=a;x;x/=10)A+=x%10;
	for(x=b;x;x/=10)B+=x%10;
	return a*B<b*A||(a*B==b*A&&a<b);
}

ll a[100],m,z;
void split(ll x){
	for(m=0;x;x/=10)a[++m]=x%10;
}
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	ll k,w=1;
	for(cin>>k;k;k--){
		Pr("w=%lld\n",w); 
		split(w); 
		for(ll i=1,t=w,z=1;i<=m;++i,z=z*10){
			t+=(9-a[i])*z;
			Pr("t=%lld\n",t); 
			if(small(t,w))w=t;
		}
		printf("%lld\n",w);
		w=w+1;
	}
	return 0;
}

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

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(auto it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll a,b,n,i;
    string s;
    cin>>n;

    if(n%1000==0)
     cout<<0<<endl;
    else
    {
         a = n/1000 + 1;
         cout<<a*1000-n;
    }


     return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < H.length; ++i) {
            H[i] = sc.nextInt();
        }

        System.out.println(solve(H));

        sc.close();
    }

    static int solve(int[] H) {
        return (int) IntStream.range(0, H.length).filter(i -> IntStream.range(0, i).allMatch(j -> H[j] <= H[i]))
                .count();
    }
}

Measured memory_bytes: 36284
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) throws Exception{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int tmp,x,y;
		
		while(true){
			
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);
			
			if(x == 0 && y == 0){
				break;
			}else if (x > y){
				tmp = x;
				x = y;
				y = tmp;
			}
			System.out.println(x + " " + y);
		}
	}

}

Measured memory_bytes: 27172
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int me,a,book;
  cin>>me>>a>>book;
  if (me >= book) {
    cout << 0 << endl;
  } else if (me+a >= book) {
    cout << book-me << endl;
  } else {
    cout << "NA" << endl;
  }
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a, b;
	cin >> a >> b;

	if (a > b)
	{
		swap(a, b);
	}

	for(int i = 0; i < b; ++i)
	{
		cout << a;
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


ll A, B, C;

void solve() {
    int powab = 0;
    ll ab = A + B;
    while (ab % 2 == 0) {
        ab /= 2;
        powab++;
    }
    ll bc = B + C;
    int powbc = 0;
    while (bc % 2 == 0) {
        bc /= 2;
        powbc++;
    }
    ll ca = C + A;
    int powca = 0;
    while (ca % 2 == 0) {
        ca /= 2;
        powca++;
    }
    if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) cout << 0 << endl;
    else if (A == B && B == C) cout << -1 << endl;
    else cout << min(powca, min(powab, powbc)) << endl;
}

int main() {
    cin >> A >> B >> C;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int lli;
lli inf = 1e18;

int main(){
	int n;
	cin >> n;
	vector<int> p(n),q(n);
	for(int i=0; i<n; i++) cin >> p[i];
	for(int i=0; i<n; i++) cin >> q[i];
	vector<int> a(n);
	for(int i=0; i<n; i++) a[i] = i+1;
	int cnt=0;
	int pi=-1, qi=-1;
	do{
		if(a == p) pi = cnt;
		if(a == q) qi = cnt;
		cnt++;
	}while(next_permutation(a.begin(), a.end()));
	cout << abs(pi-qi) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
con = [[] for _ in range(n)]
for i in range(n):
  a = int(input())
  for _ in range(a):
    x, y = map(int, input().split())
    con[i].append((x-1, y))

maxi = 0
for m in range(2**n):
  num = 0
  flg = False
  for i in range(n):
    if ((m >> i) & 1):
      num += 1
      for x, y in con[i]:
        if (((m >> x) ^ y) & 1):
          flg = True
          break
      if flg:
        break
  if not flg:
    maxi = max(num, maxi)
print(maxi)

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

int main (){
    string a;
    cin>>a;
    if((a[0]==a[1]&&a[2]==a[3]&&a[1]!=a[2])||(a[0]==a[2]&&a[1]==a[3]&&a[1]!=a[2])||
       (a[0]==a[3]&&a[2]==a[1]&&a[1]!=a[0])||(a[1]==a[2]&&a[0]==a[3]&&a[0]!=a[1])||
       (a[1]==a[3]&&a[2]==a[0]&&a[0]!=a[1]))puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
//20
#include<iostream>
#include<cctype>

using namespace std;

char d[8][7];
int p[8];

void rot(char *d,int p){
  int pa[][4]={{0,1,5,4},{0,2,5,3},{1,2,4,3}};
  int *pp=pa[p];
  char t=d[pp[0]];
  d[pp[0]]=d[pp[1]];
  d[pp[1]]=d[pp[2]];
  d[pp[2]]=d[pp[3]];
  d[pp[3]]=t;
}

bool dfs(int u,int r){
  if(r==8){
    return true;
  }else{
    for(int i=0;i<8;i++){
      if(!(u>>i&1)){
	for(int j=0;j<6;j++){
	  rot(d[i],j%2);
	  for(int k=0;k<4;k++){
	    rot(d[i],2);
	    p[r]=i;
	    bool f=true;
	    for(int l=0;l<6;l++){
	      int dx[]={0,0,1,-1,0,0};
	      int dy[]={1,0,0,0,0,-1};
	      int dz[]={0,-1,0,0,1,0};
	      int x=r%2+dx[l];
	      int y=r/2%2+dy[l];
	      int z=r/4+dz[l];
	      int o=z*4+y*2+x;
	      if(((x|y|z)&2)==0&&o<r){
		char cf=d[i][l],pf=d[p[o]][5-l];
		f&=(tolower(cf)==tolower(pf))&&(isupper(cf)^isupper(pf));
	      }
	    }
	    if(f){
	      if(dfs(u|1<<i,r+1)){
		return true;
	      }
	    }
	  }
	}
      }
    }
    return false;
  }
}

int main(){
  for(;;){
    for(int i=0;i<8;i++){
      cin>>d[i];
    }
    if(d[0][0]=='0')break;
    cout<<(dfs(0,0)?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1132
N = int(input())
L = input().split()
max = 0
total = 0
for i in range(N):
    if max < int(L[i]):
        max = int(L[i])
    else:
        pass
for i in range(N):
    total += int(L[i])
total = total - max

if max < total:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
M = int(input())
dc = [list(map(int, input().split())) for _ in range(M)]
 
d = [dc[i][0] for i in range(M)]
c = [dc[i][1] for i in range(M)]
 
ans = sum(c) - 1
s = 0
 
for i in range(M):
    s += c[i] * d[i]
    if s % 9 != 0:
        ans += s // 9
        s = s % 9
    else:
        ans += s//9 - 1 
        s = 9
print(ans)

Measured memory_bytes: 48696
import java.util.Scanner;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int cnt = 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) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
package main

import (
	"fmt"
)

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)
	kindsCount := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		kindsCount[i] = sameCharCount(s[:i+1], s[i+1:])
	}
	fmt.Println(max(kindsCount))
}

func sameCharCount(str1 string, str2 string) int {
	m1 := map[uint8]bool{}
	m2 := map[uint8]bool{}
	for i := range str1 {
		m1[str1[i]] = true
	}
	for i := range str2 {
		m2[str2[i]] = true
	}
	var count int
	for k := range m2 {
		if _, ok := m1[k]; ok {
			count++
		}
	}
	return count
}

func max(a []int) int {
	max := a[0]
	for _, i := range a {
		if i > max {
			max = i
		}
	}
	return max
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define pb push_back

int main(){
	vector<int> flight;
	for(int x= 0; x<3; x++){
		int y;
		cin >> y;
		flight.pb(y);
	}
	sort(flight.begin(), flight.end());
	cout << flight[0]+flight[1];
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    ll N = 3*n;
    vl a(N); rep(i,N) cin >> a[i];
    ll sl = 0, sr = 0;
    multiset<ll> l,m,r;
    rep(i,n){
        l.insert(a[i]);
        sl += a[i];
    }
    REP(i,n,N){
        r.insert(a[i]);
    }
    rep(i,n){
        auto itr = r.begin();
        sr += *itr;
        m.insert(*itr);
        r.erase(itr);
    }
    ll ans = sl - sr;
    REP(i,n,2*n){
        auto itr = l.begin();
        if(*itr < a[i]){
            sl -= *itr;
            l.erase(itr);
            l.insert(a[i]);
            sl += a[i];
        }
        if(m.find(a[i]) != m.end()){
            sr -= a[i];
            m.erase(m.find(a[i]));
            auto itr2 = r.begin();
            m.insert(*itr2);
            sr += *itr2;
            r.erase(itr2);
        }else{
            r.erase(r.find(a[i]));
        }
        chmax(ans, sl - sr);
    }
    cout << ans << "\n";
}

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

int main(){
	int A,B;
	cin>>A>>B;
	if(A%3==0||B%3==0||(A+B)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
return 0;
}

Measured memory_bytes: 256
N, D = [int(_) for _ in input().split()]
X = [[int(_) for _ in input().split()] for i in range(N)]

import math

result = 0

for i in range(N):
    for j in range(i + 1, N):
        d = sum((X[i][k] - X[j][k])**2 for k in range(D))
        r = math.ceil(math.sqrt(d))
        if r * r == d:
            result += 1

print(result)



Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
 
using namespace std;
 
string in, s;
int ct = 0;
 
char ToLower(char cX) { return tolower(cX); }
 
int main(){
    cin >> in;
    transform(in.begin(), in.end(), in.begin(), ToLower);
    while (true){
        cin >> s;
        if (s == "END_OF_TEXT") break;
        transform(s.begin(), s.end(), s.begin(), ToLower);
        if (s == in) ct++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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; }

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n,m,x,ans=0,ans2=0;
    cin >> n >> m >> x;
    bool flag[n+1];
    for (ll i=0;i<=n;i++)flag[i]=false;
    ll a[m];
    for (ll i=0;i<m;i++)cin >> a[i];
    for (ll i=0;i<m;i++)flag[a[i]]=true;
    for (ll i=0;i<x;i++){
        if (flag[i]){
            ans++;
        }
    }
    for (ll i=n;i>x;i--){
        if (flag[i]){
            ans2++;
        }
    }
    cout << min(ans,ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
int n; 
struct nod{
	string a;
	int num;
	int val;
}f[111];
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
bool cmp(nod aa,nod bb)
{
	if(aa.a<bb.a) return true;
	else if(aa.a==bb.a&&aa.val>=bb.val) return true;
	else return false;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		cin>>f[i].a>>f[i].val;
		f[i].num=i;
	}
	sort(f+1,f+n+1,cmp);
	for(int i=1;i<=n;i++)
	printf("%d\n",f[i].num);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n];
	ll res[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	res[0][0]=0,res[0][1]=0,res[1][0]=abs(arr[1]-arr[0]),res[1][1]=res[1][0];
	for(int i=2;i<n;i++)
	{
		res[i][0]=min(res[i-1][0],res[i-1][1])+abs(arr[i]-arr[i-1]);
		res[i][1]=min(res[i-2][0],res[i-2][1])+abs(arr[i]-arr[i-2]);
	}
	cout<<min(res[n-1][0],res[n-1][1])<<endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double pi = 3.141592653589;
		double r;
		Scanner scan = new Scanner(System.in);
		r = scan.nextDouble();

		System.out.printf("%6f %6f",(pi*r*r),(2*pi*r));

	}

}

Measured memory_bytes: 28324
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    string s,t;
    cin>>s>>t;
    int n = s.size();
    vector< vector<int> > v(26);
    rep(i,0,n){
        v[s[i]-'a'].push_back(i);
    }
    int flag=1;
    char def;
    int tempi;
    set<char> vst;
    rep(i,0,26){
        if(v[i].size()>0){
            // error(i);
            def = t[v[i][0]];
            if(vst.find(def)!=vst.end()){flag=0;break;}
            else{vst.insert(def);}
            //error(v[i].size())
            rep(j,1,v[i].size()) if(t[v[i][j]]!=def){flag=0;break;}
        }

    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3092
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
using namespace std;
int A[10], B[10], C[10];

bool dfs(int p, int p1, int p2){
	if(p == 10) return 1;
	if(p1 == 0 || (p1 > 0 && A[p] > B[p1 - 1])){
		B[p1] = A[p];
		if(dfs(p + 1, p1 + 1, p2)) return 1;
	}
	if(p2 == 0 || (p2 > 0 && A[p] > C[p2 - 1])){
		C[p2] = A[p];
		if(dfs(p + 1, p1, p2 + 1)) return 1;
	}
	return 0;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		for(int i = 0; i < 10; i++) scanf("%d", A + i);
		printf(dfs(0, 0, 0) ? "YES\n" : "NO\n");
	}
	return 0;
}


Measured memory_bytes: 3160
#!/usr/bin/ruby

def solve(n, m, foods_list)
  liked = [0] * m
  foods_list.each do |foods|
    foods.each do |food|
      liked[food - 1] += 1
    end
  end
  liked.select {|liked_cnt| liked_cnt == n}.size
end

def each_case(sin)
  n, m = sin.gets.chomp.split(" ").map(&:to_i)
  foods_list = []
  while ln = sin.gets
    _, *foods = ln.chomp.split(" ").map(&:to_i)
    foods_list.push foods
  end
  yield n, m, foods_list
end

each_case(STDIN) do |n, m, foods_list|
  puts solve(n, m, foods_list).to_s
end




Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#define MOD 1000000007

typedef long long ll;
using namespace std;

int i;
struct UnionFind
{
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;
    
    UnionFind(int n) : par(n), sizes(n, 1) {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        for(i=0;i<n;i++) par[i] = i;
    }
    
    // データxが属する木の根を得る
    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
    }
    
    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y) {
        // データの根ノードを得る
        x = find(x);
        y = find(y);
        
        // 既に同じ木に属しているならマージしない
        if (x == y) return;
        
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y]) swap(x, y);
        
        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }
    
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    
    // データxが含まれる木の大きさを返す
    int size(int x) {
        return sizes[find(x)];
    }
};

int main(void) {
    int n,m;
    cin >> n >> m;
    int a[100050]={};
    int ans=0;
    struct UnionFind u(n);

    for(i=0;i<m;i++){
        int x,y,z;
        cin >> x >> y >> z;
        u.unite(x-1,y-1);
    }
    for(i=0;i<n;i++){
        a[u.find(i)]=1;
        //cout<< u.find(i)<<endl;
    }
    for(i=0;i<n;i++){
        ans+=a[i];
    }
    cout << ans << endl;
    
    return 0;
}


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

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

	int s_len = s.length();
	if (s_len <= k) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3132
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <queue> //C++
using namespace std; //C++



int main(void) {
	
	int x, n, i,j;
	int count = 0;
	int p[101];
	cin >> x >> n;
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (i = 0; i < n; i++) {
		if (p[i] == x) {
			count++;
			break;
		}
	}
	if (count == 0) {
		cout << x;
		return 0;
	}
	
	int mai=x, pul=x;

	for (;;) {
		count = 0;
		mai--;
		pul++;
		for (i = 0; i < n; i++) {
			if (p[i] == mai) {
				count++;
				break;
			}
		}
		if (count == 0) {
			cout << mai;
			return 0;
		}
		count = 0;
		for (i = 0; i < n; i++) {
			if (p[i] == pul) {
				count++;
				break;
			}
		}
		if (count == 0) {
			cout << pul;
			return 0;
		}
	}



}


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


using namespace std;

typedef long long ll;

queue <int> q;

int main() {
    int n,m;
    cin>>n>>m;
    vector <int> g[n+1];
    int p[n+1]={0};
    int a,b;
    for(int i=1;i<=m;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);}
    bool v[n+1]={0};
    v[1]=true;
    q.push(1);
    while(!q.empty()){
        int s=q.front();
        q.pop();
        for(int i=0;i<g[s].size();i++){
            if(!v[g[s][i]]){
                v[g[s][i]]=true;
                q.push(g[s][i]);
                p[g[s][i]]=s; }}}
    bool yesorno=true;
    for(int i=2;i<=n;i++){
        if(p[i]==0) yesorno=false;}
    if(!yesorno) cout<<"No";
    else{
        cout<<"Yes"<<"\n";
        for(int i=2;i<=n;i++){
            cout<<p[i]<<"\n";}}



















    return 0;
}


Measured memory_bytes: 10608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a,b,k;
  cin >> a >> b >> k;

  for (long i = a; i <= b; i++) {
    if (i-a < k or b-i < k) cout << i << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin >> a >> b >> c >>d;
if(a==b==c==d||a==b&&c==d||a==c&&b==d||a==d&&b==c){
cout <<"yes"<<endl;
}
else cout <<"no"<<endl;
}


Measured memory_bytes: 3096
//普通に0/1ナップザックを解いて、その表を使って答える。
//dp表を大きな値で初期化すると、k * dp[n][i]がオーバーフローすることがあるので、計算の仕方または初期化の大きさに注意
#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int c, n, m;
int s[10000], p[10000];
int dp[20001];
int INF = 1e+18;

signed main() {
	int i, j;
	
	cin >> c >> n >> m;
	rep(i, n) cin >> s[i] >> p[i];
	rep(i, c + 1) dp[i] = -INF;
	
	dp[0] = 0;
	rep(i, n) {
		for (j = c; j >= 0; j--) dp[j + s[i]] = max(dp[j + s[i]], dp[j] + p[i]);
	}
	
	for (i = 1; i <= m; i++) {
		int ans = 0;
		for (j = 0; i * j <= c; j++) {
			ans = max(ans, dp[j]);
		}
		cout << ans * i << endl;
	}
	return 0;
}


Measured memory_bytes: 3412
'use strict';
        (function(stdin) {
          var inputs  = stdin.toString();
          var cols = inputs.split('\n')[0].split(' ').map(Number);
          var a = cols[0];
          var b = cols[1];
          var c = cols[2];
          if(a < b && b < c){
            console.log('Yes');
          }else{
            console.log('No');
        }
      }(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		int num = scanner.nextInt();
		scanner.close();
		char[] alphabet = str.toCharArray();
		for (int i = 0; i < alphabet.length; i++) {
			int tem = alphabet[i];
			int temDif = 123 - tem;
			if (temDif <= num && temDif != 26) {
				alphabet[i] = 'a';
				num = num - temDif;
			}
		}
		if (num > 0) {
			int tem = alphabet[alphabet.length - 1];
			tem = (tem + num -97) % 26 + 97; 
			alphabet[alphabet.length - 1] = (char) tem;
		}
		str = new String(alphabet);
		System.out.println(str);
	}
}


Measured memory_bytes: 13956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    char retu[200001];
    scanf("%s",retu);
    int i=0;
    int max=0;
    while(retu[i]!=0){
        if(retu[i]=='A'){
            long j=strlen(retu);
            while(retu[j-1]!='Z'){
                j--;
            }
            if(max<(j-i)){
                max=(int)j-i;
            }else{
                ;
            }
        }else{
            ;
        }
        if((strlen(retu)-i)<=max){
            break;
        }
        i++;
        
    }
    printf("%d",max);
}


Measured memory_bytes: 1920
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e3+10;

int main()//所有的循环已改正 
{
	int x,t;
	cin>>x>>t;
	if(x<=t){
		cout<<"0"<<endl;
	} 
	else cout<<x-t<<endl;
	return 0;
}	 


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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll a,b;
    cin>>a>>b;
    if(a<=b)cout<<a;
    else cout<<a-1;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

# 累積和
a_acm = list(accumulate(a[::-1]))

ans = 0
mod = 10 ** 9 + 7
for i in range(n-1):
    ans += a[i] * a_acm[n-2-i]
    ans %= mod
print(ans)


Measured memory_bytes: 31276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    
 ll n,i,x,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
{
 x=log10(i)+1;
        
       if(x%2==1) sum++;
        
   //cout<<x<<endl;
}
    cout<<sum;
 


}

Measured memory_bytes: 640
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	int min_diff = 1e9;

	REP(i, N) {
		cin >> h[i];
	}

	sort(h.begin(), h.end());

	REP(i, N - K + 1) {
		min_diff = min(min_diff, h[i + K - 1] - h[i]);
	}

	cout << min_diff << endl;

	return 0;
}

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

int N;
int P[21];
int main(){
    cin >> N;
    for(int i=1;i<=N;i++) cin >> P[i];
    int ans = 0;
    for(int i=2;i<N;i++){
        if(P[i-1]<P[i] && P[i]<P[i+1]) ans++;
        else if(P[i+1]<P[i] && P[i]<P[i-1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using LL = long long;
LL N,T;
LL t,x;
int main() {
	std::cin >> N >> T;
	for (int i = 0; i < N; i++) {
		LL a;
		std::cin>> a;
		x += std::min(T, a - t);
		t = a;
	}
	std::cout << x+T << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	char c;
	scanf("%c",&c);
	if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 256
import math

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

min_idx = A.index(min(A))

count = N
start = max(0,min_idx-K+1)
end = min(start+K, N)
for i in range(start, end):
    tmp = math.ceil(i/(K-1)) + max(0, math.ceil((N-(i+K))/(K-1)))
    if count > tmp+1:
        count = tmp+1

print(count)

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

int main(){
  double N;
  cin >> N;
  
  priority_queue<double> V;
  for (int i = 0; i < N; i++){
    int v;
    cin >> v;
    v *= -1;
    V.push(v);
  }
  
  for (int i = 0; i < N - 1; i++){
    double guzai1, guzai2;
    guzai1 = V.top();
    V.pop();
    guzai2 = V.top();
    V.pop();
    
    V.push((guzai1 + guzai2) / 2);
  }
  
  double ans = V.top() * -1;
  cout << ans << endl;
}

Measured memory_bytes: 3764
N,Z,W = map(int,input().split())
A = list(map(int,input().split()))

memoX = {}
memoY = {}
memo = 0

def X(n,z,w):
    score = 0
    if n == 0:
        if not (0,z,w) in memoX:
            memoX[(0,z,w)] = abs(z-w)
        return abs(z-w)
    else:
        if (n,w) in memoX:
            global memo
            memo += 1
            return memoX[(n,w)]
        else:
            for i in range(n):
                tmp = Y(i,A[N-1-i],w)
                if score < tmp:
                    score = tmp
            memoX[(n,w)] = score
            return score

def Y(n,z,w):
    score = float("inf")
    if n == 0:
        if not (0,z,w) in memoY:
            memoY[(0,z,w)] = abs(z-w)
        return abs(z-w)
    else:
        if (n,z) in memoY:
            global memo
            memo += 1
            return memoY[(n,z)]
        else:
            for i in range(n):
                tmp = X(i,z,A[N-1-i])
                if score > tmp:
                    score = tmp
            memoY[(n,z)] = score
            return score
    
ans = X(N,Z,W)
#print(memo)
#print(len(memoX))

print(ans) 

Measured memory_bytes: 47452
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)]

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in graph[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    flag=True
    for _i in range(n):
        if d[_i]==None:
            flag=False
    return flag

cnt=0
for i in range(m):
    graph = [[] for _ in range(n)]
    for j in range(m):
        if i!=j:
            graph[ab[j][0]-1].append(ab[j][1]-1)
            graph[ab[j][1]-1].append(ab[j][0]-1)
    if not bfs(0):
        cnt+=1
print(cnt)


Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
void solve(){
    for(int j =0;j<5;j++){
        int x;
        cin>>x;
        if(x==0){
            cout<<j+1<<'\n';
            return;
        }
    }
}
int main()
{
    
    
    solve();
    return 0;
}


Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	N, K = map(int, input().split(" "))

	ans = 0
	ans2 = 0
	for i in range(1, N+1):
		if i % K == 0:
			#print(i)
			ans += 1
		elif K % 2 == 0 and i % K == K/2:
			#print(i)
			ans2 += 1
	
	print(ans*ans*ans + ans2*ans2*ans2)

	
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,f=0;
    scanf("%d ",&n);
    char str[n+1];
    gets(str);
    if(n%2!=0)
        printf("No\n");
    else
    {
        for(i=0,j=n/2; i<n/2; i++,j++)
        {
            if(str[i]!=str[j])
            {
                f=1;
                break;
            }
        }

        if(f==1)
            printf("No");
        else
            printf("Yes");

    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

namespace myspace{
	
	class vector{
	public:
		void push_back(int);
		int size();
		int &operator[](int);
		vector();
		~vector();
	private:
		int s;
		int* box;
	};
	
	vector::vector()
	{
		box = NULL;
		s = 0;
	}
	
	vector::~vector()
	{
		if(box)delete[] box;
	}
	
	int &vector::operator[](int i)
	{
		return box[i];
	}
	
	int vector::size()
	{
		return s;
	}
	
	void vector::push_back(int input)
	{
		int* box2 = box;
		box = new int[s+1];
		for(int i=0; i<s; i++)box[i] = box2[i];
			
		box[s] = input;
		s++;
	}
}//??????????????????myspac

using namespace myspace;
using namespace std;

void Output(vector &A)
{
    int i;
    for(i=0;i<A.size()-1;i++){
        cout << A[i] << " ";
    }
    cout << A[i] << endl;
}
 
void InsertionSort(vector &A,int n)
{
    for(int i=0;i<n;i++)
    {
        int v = A[i];
        int j = i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        Output(A);
    }
}
 
int main()
{   
    int n;
    cin >> n;
     
    vector A;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
    InsertionSort(A, n);
     
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
 
#define int  long long
const int MOD = 1e9 + 7;
const int INF = 1e18;

void solve(){
   int a, b;
   cin >> a >> b;
   int g = __gcd(a, b);
   map<int, int> m;
   while (g % 2 == 0){
	   m[2]++;
	   g /= 2;  
	 }
   for (int i = 3; i * i <= g; i += 2){
	   while (g % i == 0){
		    g /= i;
		    m[i]++;
		  }
	 }
   if (g > 2) m[g]++;
   int ret = (int)m.size();
   cout << ret + 1 << endl;
}

int32_t main(){
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr);
     solve();	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=1;
string s;
bool flag;
void Main(){    
    cin>>s;
    n=s.size();
    ans=n;
    For(i,1,n){
        if(s.at(i)!=s.at(i-1)){
            ans=min(ans,max(i,n-i));
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 512
N = int(input())
a = [int(input()) for _ in range(N)]
a.sort()

if N % 2 == 0:
    res = 2 * (sum(a[N // 2:]) - sum(a[:N // 2]))
    res += a[N // 2 - 1] - a[N // 2]
    print(res)
else:
    res = 2 * (sum(a[N // 2 + 1:]) - sum(a[:N // 2]))
    print(res - min(a[N // 2 + 1] - a[N // 2], a[N // 2] - a[N // 2 - 1]))


Measured memory_bytes: 13336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int S, W;
cin >> S >> W;

if(S > W){
cout << "safe";
}else{
cout << "unsafe";
}

return 0;

}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

char ans;

LL x;

inline void query(LL n){
  cout << "? " << n << endl;
  cin >> ans;
  // printf("? %d\n",n);
  // scanf("%c",&ans);
  // if((n<=x&&to_string(n)<=to_string(x))||(n>x&&to_string(n)>to_string(x))) ans='Y';
  // else ans='N';
  return;
}

int main(){
  // cin >> x;
  LL c=1;
  LL ketasu=-1;
  for(LL i=1;i<=11;i++,c*=10){
    query(c);
    if(ans=='N'){
      ketasu=i-1;
      break;
    }
  }
  // cout << ketasu << endl;
  LL l,r;
  LL kakutei=0;
  if(ketasu>1){
    for(LL i=1;i<ketasu;i++){
      l=0;r=10;
      while(r-l>1){
        query(kakutei*10+(l+r)/2);
        if(ans=='Y') l=(l+r)/2;
        else r=(l+r)/2;
      }
      kakutei=kakutei*10+l;
    }
    // cout << kakutei << endl;
    for(LL i=0;i<10;i++){
      query(kakutei*100+i*10);
      if(ans=='Y'){
        cout << "! " << kakutei*10+i << endl;
        return 0;
      }
    }
    return 0;
  }else if(ketasu==1){
    for(LL i=1;i<10;i++){
      query(i*10);
      if(ans=='Y'){
        cout << "! " << kakutei*10+i << endl;
        return 0;
      }
    }
  }else{
    c=1;
    for(LL i=1;i<=11;i++,c*=10){
      query(2*c);
      if(ans=='Y'){
        cout << "! " << c << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 684
N = int(input())
ans = 0

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(9 + N - 99)
elif N < 10000:
    print(909)
elif N < 100000:
    print(909 + N - 9999)
else:
    print(90909)



Measured memory_bytes: 2568
t=list(input())

if t[0]=="A" and not t[1]=="C" and not t[-1]=="C":
    rs=1
else:
    rs=0

if t[1].isupper()==True or t[-1].isupper()==True:
    rs -=1

del t[:2]
del t[-1]

if not t.count("C")==1:
    rs -=1

if rs==1:
    t.remove("C")

for i in t:
    if i.isupper()==True:
        rs -=1

if rs==1:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//~ #define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int mod = 998244353; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

const int fMax = 1800 * 1000;
int64_t f[fMax], rf[fMax];

int64_t extGcd(int64_t a, int64_t b, int64_t &x, int64_t &y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int64_t x1, y1;
	int64_t g = extGcd(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return g;
}

inline int64_t inverse(int64_t a, int64_t m = mod) {
	int64_t x, y;
	int64_t g = extGcd(a, m, x, y);
	assert(g == 1);
	return (x % m + m) % m;
}

inline int64_t C(int64_t n, int64_t k) {
	if (k < 0 || k > n) {
		return 0;
	}
	return f[n] * rf[k] % mod * rf[n-k] % mod;
}

inline int64_t cntLim(int64_t n, int64_t sum, int64_t limit) {
	int64_t res = 0;
	for (int i = 0; i <= n; ++i) {
		res += int64_t((i&1) ? mod-1 : 1) * C(n, i) % mod * C(n+sum-1, n-1);
		res %= mod;
		sum -= limit+1;
		if (sum < 0) {
			return res;
		}
	}
	return res;
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	
	f[0] = 1;
	for (int i = 1; i < fMax; ++i) {
		f[i] = f[i-1] * i % mod;
	}
	for (int i = 0; i < fMax; ++i) {
		rf[i] = inverse(f[i]);
	}
	
	int n, m; cin >> n >> m;
	int64_t res = 0;
	
	// step I: don't have 2*m
	res += [&]() -> int64_t {
		int64_t res = 0;
		for (int i = 0; i <= n && i <= m; ++i) {
			if ((3*m-i) & 1) {
				continue;
			}
			res += C(n, i) * cntLim(n, (3*m-i) / 2, m-1) % mod;
			res %= mod;
		}
		return res;
	}();
	
	// step II: have 2*m
	res += [&]() -> int64_t {
		int64_t res = 0;
		for (int i = 0; i < n && i <= m; ++i) {
			if ((m-i) & 1) {
				continue;
			}
			res += C(n-1, i) * cntLim(n-1, (m-i) / 2, m-1) % mod;
			res %= mod;
		}
		res *= n;
		res %= mod;
		return res;
	}();
	
	res %= mod;
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 28416
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    string a;
    cin>>n;
    cin>>a;
    for(i=0;i<n;i++)
    {
        if((a[i]=='A')&&(a[i+1]=='B')&&(a[i+2]=='C'))
        {
            c++;
        }

    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main() {
  int n, q; cin >> n >> q;
  string S; cin >> S;
  vll a(n), s(n+1);
  for (int i = 1; i < n; i++)
    if (S[i] == 'C' && S[i-1] == 'A') a[i]++;
  rep(i, n) s[i+1] = s[i] + a[i];
  rep(i, q) {
  int l, r;
  cin >> l >> r;
  cout << s[r] - s[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 2688