akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    vector<ll> p(n), q(n);
    rep(i,0,n) cin >> p[i];
    rep(i,0,n) cin >> q[i];

    vector<ll> v(n); 
    iota(v.begin(), v.end(),1);

    ll a, b, cnt(0);
    do {
        cnt++;
        if (p == v) a = cnt;
        if (q == v) b = cnt;
    } while (next_permutation(v.begin(), v.end()));    

    cout << abs(a-b) << endl; 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    string s;string a;
    cin >> s >> a;
    COUT("A" + a.substr(0,1) + "C");
    return 0;
}


Measured memory_bytes: 256
#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>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[110];
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	int ans=0;
	int mn=1000000000;
	for(int i=0;i<n;i++){
		ans+=a[i];
		mn=min(mn,max(ans,cnt-ans)-min(ans,cnt-ans));
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;


int main(){
  int a,b;

  while(true){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    if (a > b) cout << b << " " << a << endl;
    else cout << a << " " << b << endl;
  }
  return 0;
}



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

int main(void)
{
    string s;
    getline(cin, s);  // 1行読み込む
    for(int i = 0; i < s.size(); i++) {
        char c = s[i];
        if ('A' <= c && c <= 'Z') {
            //c = tolower(c);
            c = c + 32;
        }
        else if('a' <= c && c <= 'z') {
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 3136
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)
	//考え方 A^5 - B^5 = X
	/*
	この時, Xが10^9(もしくは-10^9)の時を考える
	Xが最大を向かえる時に,AもしくはBの可動範囲を考えたいので,
	A + B (A,B > 0)　よりも, A - B (A,B >0)の方が、Aが最大に行くのがわかる。
	この時 n^5 - (n-1)^5 ex: 3^5 - 2^5 = 211, n^5 - (n-2)^5 ex: 3^5 - 1^5 = 242
	より,n^5 - (n-1)^5 の形が一番小さい数になるので、
	n^5 - (n-1)^5<= 10^9　を満たす限り可能な限り,nを大きくすると,
	 */
	//for {
	//	i++
	//	if int(math.Pow(float64(i),5)) - int(math.Pow(float64(i-1),5)) < max {
	//		continue
 	//	} else {
 	//		fmt.Println(i)
 	//		break
	//	}
	//}
	// answer:120
	//-120 < n < 120　区間を考える
	// 計算量 240 * 240 = 48000  < 10^6 いける？
	a := 0
	b := 0
	for i:=-120; i<120; i++ {
		for j:=-120; j<120; j++ {
			if int(math.Pow(float64(i),5)) - int(math.Pow(float64(j),5)) == x {
				a = i
				b = j
			}
		}
	}
	fmt.Println(a,b)
}




Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

vector<int> e[200200];
int a[200200];
int par[200200];
int len[200200];
int ans[200200];

void dfs(int v, vector<int>&arr) {
    
    auto p = lower_bound(ALL(arr), a[v]);
    
    int pre = *p;
    *p = a[v];

    ans[v] = lower_bound(ALL(arr), INF) - arr.begin();
    
    for(auto&&u:e[v]) {
        if(par[u] == -1) {
            par[u] = v;
            dfs(u, arr);
        }
    }
    *p = pre;
    
}        

signed main() {

    int n;
    cin >> n;

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

    int x, y;

    for(int i = 0; i < n-1; i++) {
        cin >> x >> y;
        e[x].bash(y);
        e[y].bash(x);
    }

    memset(par, -1, sizeof(par));
    par[1] = 1;
    vector<int> arr(n+1, INF);
    dfs(1, arr);


    for(int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }

  
    return 0;
}



Measured memory_bytes: 28772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}
	
	public static int solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}

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

		int X = 0, Y = 0;
		for (int i = 0; i < N; i++) {
			if (V[i] >= C[i]) {
				X += V[i];
				Y += C[i];
			}
		}
		return X - Y;
	}
}

Measured memory_bytes: 23764
import math
n=input().split()
N=int(n[0])
K=int(n[1])
c = 0
for i in range(1,N+1):
    if i < K:
        if math.log2(K/i) % 1 == 0:
            a =int(math.log2(K/i))
            b = (1/2)**a
            c = b + c
        else:
            a =int(math.log2(K/i) + 1)
            b = (1/2)**a
            c = b + c
    if i >= K:
        c = c + 1
c = c/N
print(c)

Measured memory_bytes: 3188
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	var lists  [][]int
	for i :=0;i<n; i++ {
		li := make([]int, d)
		for j := 0; j <d; j++ {
			fmt.Scan(&li[j])
		}
		lists = append(lists, li)
	}
	cnt := 0
	for i:=0; i<n; i++ {
		for j:=i+1; j<n; j++ {
			total := 0
			for k := 0; k<d; k++ {
				total += ((lists[i][k] - lists[j][k])*(lists[i][k] - lists[j][k]))
			}
			p := math.Sqrt(float64(total))
			//below sentense is not own idea!!気づけよ！！
			if p == float64(int(p)) {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            Console.WriteLine(ss[0][ss[0].Length - 1] == ss[1][0] && ss[1][ss[1].Length - 1] == ss[2][0] ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <algorithm>
#include <complex>
#include<vector>
#include<map>

#define mod 1000000007

int main()
{
    int pattern[8]{1, 1}, h, w, k;
    long long amida[2][8]{};
    scanf("%d%d%d", &h, &w, &k);
    if (w == 1)
    {
        printf("%d\n", 1);
        return 0;
    }
    for (int i = 2; i < w; i++) pattern[i] = pattern[i - 1] + pattern[i - 2];
    amida[0][0] = 1;
    for (int i = 1; i <= h; i++)
    {
        bool odd = i & 1;
        amida[odd][0] = (amida[!odd][0] * pattern[w - 1] + amida[!odd][1] * pattern[w - 2]) % mod;
        amida[odd][w - 1] = (amida[!odd][w - 1] * pattern[w - 1] + amida[!odd][w - 2] * pattern[w - 2]) % mod;
        for (int j = 1; j < w - 1; j++)
        {
            amida[odd][j] = ((amida[!odd][j - 1] * pattern[j - 1] * pattern[w - j - 1]) % mod
             + (amida[!odd][j] * pattern[j] * pattern[w - j - 1]) % mod
             + (amida[!odd][j + 1] * pattern[j] * pattern[w - j - 2]) % mod
             ) % mod;
        }
    }
    printf("%lld\n", amida[h & 1][k - 1]);
    
    return 0;
}

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

enum node_type{
    ND_CONST,
    ND_IDENT,
    ND_NOT,
    ND_AND,
    ND_OR,
    ND_IF
};

struct node{
    node_type type;
    node *lhs, *rhs;
    int value;
};

char *code;
node *formula();

pair<node *, node *> equation(char *c){
    code = c;
    node *n1 = formula();
    assert(*(code++) == '=');
    node *n2 = formula();
    assert(*code == '\0');

    return {n1, n2};
}
node *formula(){
    node *n = new node();
    if(*code == 'T' || *code == 'F'){
        n->type = ND_CONST;
        n->value = (*(code++) == 'T');
        return n;
    }
    if('a' <= *code && *code <= 'k'){
        n->value = *(code++) - 'a';
        n->type = ND_IDENT;
        return n;
    }
    if(*code == '-'){
        ++code;
        n->type = ND_NOT;
        n->lhs = formula();
        return n;
    }
    if(*code == '('){
        ++code;
        n->lhs = formula();
        if(*code == '+'){
            ++code;
            n->type = ND_OR;
            n->rhs = formula();
        }else if(*code == '*'){
            ++code;
            n->type = ND_AND;
            n->rhs = formula();
        }else{
            assert(strncmp(code, "->", 2) == 0);
            code += 2;
            n->type = ND_IF;
            n->rhs = formula();
        }
        assert(*(code++) == ')');
        return n;
    }
    assert(false);
}
int value(node *n, int ptn){
    switch(n->type){
    case ND_CONST:
        return n->value;
    case ND_IDENT:
        return (ptn >> n->value) & 1;
    case ND_NOT:
        return value(n->lhs, ptn) ^ 1;
    case ND_AND:
        return value(n->lhs, ptn) & value(n->rhs, ptn);
    case ND_OR:
        return value(n->lhs, ptn) | value(n->rhs, ptn);
    default:
        return (value(n->lhs, ptn) ^ 1) | value(n->rhs, ptn);
    }
}
bool solve(char *code){
    auto eq = equation(code);
    for(int ptn=0;ptn<(1<<11);++ptn){
        if(value(eq.first, ptn) != value(eq.second, ptn)){
            return false;
        }
    }
    return true;
}

int main(){
    char code[1001];
    while(true){
        scanf("%s", code);
        if(*code == '#') break;
        printf("%s\n", solve(code) ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 3360
#include <stdio.h>

int main(void)
{
  int n = 0;
  int x = 0;
  int i, j, k;
  int result = 0;

  while(1){
    scanf("%d %d", &n, &x);
    
    if(n == 0 && x == 0)
      break;

    for(i = 1; i < n - 1; i++)
      for(j =1; j < n; j++)
	for(k = 1; i + j + k <= n; k++)
	  if(i + i + j + i + j + k == x)
	    result++;

    printf("%d\n", result);

    result = 0;
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;
    vector<string> grid(H);
    for (auto& g : grid) {
        cin >> g;
    }
    vector<vector<int>> dp(H, vector<int>(W, INF));
    queue<P> que;
    que.emplace(x1, y1);
    dp[x1][y1] = 0;
    vector<int> dh = {-1, 0, 1, 0};
    vector<int> dw = {0, -1, 0, 1};
    while (!que.empty()) {
        P now = que.front();
        que.pop();
        int h = now.first;
        int w = now.second;
        rep(i, 0, 4) {
            int nh = h;
            int nw = w;
            rep(j, 0, K) {
                nh += dh[i];
                nw += dw[i];
                if (nh < 0 || nh >= H || nw < 0 || nh >= W) {
                    break;
                }
                if (grid[nh][nw] == '@') {
                    break;
                }
                if (dp[nh][nw] <= dp[h][w]) {
                    break;
                }
                if (dp[nh][nw] == INF) {
                    dp[nh][nw] = dp[h][w] + 1;
                    que.emplace(nh, nw);
                }
            }
        }
    }
    if (dp[x2][y2] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[x2][y2] << endl;
    }
    return 0;
}

Measured memory_bytes: 12124
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  let [m, n] = lines[0].split(" ").map(Number);
  if (m < n) {
    [m, n] = [n, m];
  }
  while (n != 0) {
    const t = n;
    n = m % n;
    m = t;
  }
  console.log(m);
});



Measured memory_bytes: 16536
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    vv<int> dp = vvec(N + 1, 4, 0);

    for (int i = 0; i < N; ++i) {
        for (int l = 1; l <= 4; ++l) {
            if (i + l > N) break;

            for (int m = 1; m <= 4; ++m) {
                if (i < m || m != l || S.substr(i - m, m) != S.substr(i, m)) {
                    dp[i + l][l - 1] = max(dp[i + l][l - 1], dp[i][m - 1] + 1);
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; ++i) ans = max(ans, dp[N][i]);
    write(ans);
}

Measured memory_bytes: 11412
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <string.h>

#define Par(n)	((n) - 1 >> 1)
#define Rgt(n)	(2 * (n) + 2)
#define Lft(n)	(2 * (n) + 1)
#define Ele(n)	((n)+(SIZE>>1)-1)
typedef struct {int id, v;} Player;

#define SIZE (1 << 21)

Player st[SIZE];

int update(int x, int add)
{
	x = Ele(x);
	st[x].v += add;
	while (x){
		int p = Par(x);
		int r = Rgt(p);
		int l = Lft(p);

		if (st[r].v > st[l].v){
			st[p] = st[r];
		}
		else {
			st[p] = st[l];
		}
		x = p;
	}
	return (0);
}
int init(int n)
{
	int i;

	memset(st, 0, sizeof(st));
	for (i = 0; i < n; i++){
		st[Ele(i)].id = i;
	}
}

int main(void)
{
	int n, q;
	int i;

	scanf("%d %d", &n, &q);
	init(n);

	for (i = 0; i < q; i++){
		int uid, add;
		scanf("%d %d", &uid, &add);
		update(uid - 1, add);
		printf("%d %d\n", st->id + 1, st->v);	
	}
	return (0);
}

Measured memory_bytes: 16988
// AOJ 0509: Sheets
// 2018.1.28 bal4u

#include <stdio.h>
#include <string.h>

int s[2][10002];
int a[10002][20][2]; char hi[10002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, r, x1, y1, x2, y2, i, k1, k2, x, y, xmax, ymax, ans_s, ans_c;

	while(n = in()) {
		r = in() == 2;
		memset(s, 0, sizeof(s));
		memset(hi, 0, sizeof(hi));
		xmax = ymax = 0;
		for (i = 0; i < n; i++) {
			x1 = in()+1, y1 = in()+1, x2 = in()+1, y2 = in()+1;
			if (x2 > xmax) xmax = x2;
			if (y2 > ymax) ymax = y2;
			a[y1][hi[y1]][0] = x1, a[y1][hi[y1]++][1] = 1;
			a[y1][hi[y1]][0] = x2, a[y1][hi[y1]++][1] = -1;
			a[y2][hi[y2]][0] = x1, a[y2][hi[y2]++][1] = -1;
			a[y2][hi[y2]][0] = x2, a[y2][hi[y2]++][1] = 1;
        }

        ans_s = ans_c = 0;
        for (k1 = 1, k2 = 0, y = 0; y <= ymax; y++, k1 = k2, k2 = !k2) {
            memset(s[k2], 0, sizeof(s[k2]));
			for (i = 0; i < hi[y]; i++) s[k2][a[y][i][0]] += a[y][i][1];
			for (x = 0; x <= xmax; x++) {
				s[k2][x+1] += s[k2][x];
				s[k2][x] += s[k1][x];
			}
			for (x = 0; x <= xmax; x++) {
				if (s[k2][x]) ans_s++;
				if (r) {
					if ((s[k1][x] > 0) != (s[k2][x  ] > 0)) ans_c++;
					if ((s[k2][x] > 0) != (s[k2][x+1] > 0)) ans_c++;
				}
			}
		}
        printf("%d\n", ans_s);
		if (r) printf("%d\n", ans_c);
	}
	return 0;
}


Measured memory_bytes: 3348
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    if(a==b&&b!=c){
        cout<<"Yes";
        return 0;
    }
    if(b==c&&c!=a){
        cout<<"Yes";
        return 0;
    }
    if(c==a&&b!=a){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}

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

int main() {
	int N;
	long A, B;
	cin >> N >> A >> B;

	long mn = 0, mx = 0;
	long count = 0;

	if (N == 1) {
		if (A == B) {
			cout << "1" << endl;
		}
		else
		{
			cout << "0" << endl;
		}
	}
	else if ((N != 1) && (A <= B)) {
		for (int i = 0; i < N - 1; i++) {
			mn += A;
		}
		mn += B;
		for (int i = 0; i < N - 1; i++) {
			mx += B;
		}
		mx += A;

		count = mx - mn + 1;
		cout << count << endl;
	}
	else if ((N != 1)&&(A>B)){
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	hh := make([]int, n)
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
	}
	ans := make([]int, n)
	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		if hh[a] <= hh[b] {
			ans[a] = 1
		}
		if hh[b] <= hh[a] {
			ans[b] = 1
		}
	}
	var s int
	for i := 0; i < n; i++ {
		if ans[i] == 0 {
			s++
		}
	}
	fmt.Fprintln(writer, s)
}


Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
int main(){
int N; int64_t M;
  cin>>N>>M;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B={};
  for(int i=0;i<N;i++){
  int64_t k=A.at(i);
    for(int j=0; ;j++){
    int64_t l=k; k/=2;
      B.push_back(l-k);
      if(k==0)
        break;
    }
  }sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int64_t l=B.size();
  int64_t ans=0;
  for(int i=0;i<N;i++)
    ans+=A.at(i);
  int64_t sum=0;
  for(int i=0;i<min(M,l);i++)
    sum+=B.at(i);
  ans-=sum;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35812
#include<stdio.h>
int main(void){
char s[3];
  int i;
  int judgea=0,judgeb=0,judgec=0;
  scanf("%s",s);
  for(i=0;i<3;i++){
  if(s[i]=='a'){
  judgea=1;
  }
  }
   for(i=0;i<3;i++){
  if(s[i]=='b'){
  judgeb=1;
  }
  }
   for(i=0;i<3;i++){
  if(s[i]=='c'){
  judgec=1;
  }
  }
  if(judgea==1&&judgeb==1&&judgec==1){
  printf("Yes");
  }else{
  printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([usize]);
    v.sort();
    let longest = v[v.len() - 1];
    let mut other = 0;
    for i in 0..n - 1 {
        other += v[i];
    }
    if longest < other {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    cin>>n;
    for (int i = 0; i < n; ++i) {
        vector<int> lens;
        for (int j = 0; j < 3; ++j) {
            int tmp;
            cin>>tmp;
            lens.push_back(tmp);
        }
        sort(lens.begin(),lens.end(),greater<int>());
        if(pow(lens[0],2)==pow(lens[1],2)+pow(lens[2],2)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

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


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N, K;

    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    int MD = 50;
    ll dp[100][2];

    memset(dp, -1, sizeof(dp));
 
    dp[0][0]  = 0;
    for (int d = 0; d < MD; ++d) {
        ll mask = 1LL << (MD - d - 1);
        //debug(d)
        int n = 0;
        rep(i, N){
            if (A[i] & mask)++n;

        }

        ll c0 = mask * n;
        ll c1 = mask * (N-n);
        
        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(c0, c1));
        }
        if (dp[d][0] != -1) {
            if(K & mask){
                chmax(dp[d+1][1], dp[d][0] + c0);
            }
        }
        if (dp[d][0] != -1){
            if(K & mask){
                chmax(dp[d+1][0], dp[d][0] + c1);
            }
            else {
                chmax(dp[d+1][0], dp[d][0] + c0);
            }
        }
        //debug(dp[d+1][0])debug(dp[d+1][1])
    }
    cout << max(dp[MD][0], dp[MD][1]) << "\n";
    return 0;
}

Measured memory_bytes: 1024
def make_list(a):
    t = a-1
    s = a-3
    anslist = [t]
    while s > 0:
        anslist.append(s+t)
        t += s
        s -= 2
    if a % 2 == 1:
        anslist += anslist[::-1]
    else:
        anslist = anslist[:-1] + anslist[::-1]
    return anslist

mod = 10**9+7
h, w = [ int(v) for v in input().split() ]
h_list = [ int(v) for v in input().split() ]
w_list = [ int(v) for v in input().split() ]
h_list_2 = [(h_list[i+1] - h_list[i]) % mod for i in range(h-1)]
w_list_2 = [(w_list[i+1] - w_list[i]) % mod for i in range(w-1)]
h_list_3 = make_list(h)
w_list_3 = make_list(w)
h_total = sum([(h_list_3[i] * h_list_2[i]) % mod for i in range(h-1)]) % mod
w_total = sum([(w_list_3[i] * w_list_2[i]) % mod for i in range(w-1)]) % mod

print((h_total*w_total)%mod)

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){
    
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < 26; i++){
        char c = char(i) + 'a';
        string n = s + c;
        if(n == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
            cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BTAKOYAKIFESTIVAL2019 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> D(N);
        for(auto& d : D) in>>d;
        int ans = 0;
        REP(i, N) FOR(j, i+1, N){
            ans += D[i] * D[j];
        }
        out<<ans<<'\n';
    }
};


int main() {
	BTAKOYAKIFESTIVAL2019 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3568
MOD = 1000000007

N = parse(Int, readline())
s1 = readline()
s2 = readline()

curr = 0
prev = 0
ans = 1

i = 1
while i <= N
    curr = s1[i] == s2[i] ? 1 : 2
    if prev == 0
        if curr == 1
            global ans = 3
        else
            global ans = 6
        end
    else
        if (prev,curr) == (1,1)
            global ans *= 2
        elseif (prev,curr) == (1,2)
            global ans *= 2
        elseif (prev,curr) == (2,1)
            global ans *= 1
        elseif (prev,curr) == (2,2)
            global ans *= 3
        end
    end

    ans%=MOD

    global i += curr
    global prev = curr
end

println(ans)

Measured memory_bytes: 163184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
    int n; cin >> n;
    vector<string> S(n);
    rep(i,n){
        cin >> S[i];
    }
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    vector<vector<int>> T(26,vector<int>(55));
    rep(i,n){
        rep(j,26){
            int cnt = 0;
            rep(k,S[i].size()){
                if(S[i][k] == alphabet[j]) cnt++;
            }
            T[alphabet[j] - 'a'][cnt]++;
        }
    }

    string ans = "";
    rep(i,26){
        int num = 0;
        for(int j = 54; j >= 0; j--){
            num += T[i][j];
            if(num >= n){
                rep(k,j){
                    ans += i + 'a';
                }
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int c[10][10],min;
void get(int n,int cost){
  if(cost>=min)return;
  if(n==1){
    if(cost<min)min=cost;
    return;
  }
  for(int i=0;i<10;i++){
    if(i!=n)get(i,cost+c[n][i]);
  }
}

int main(void){
  int h,w;
  scanf("%d %d",&h,&w);
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      scanf("%d",&c[i][j]);
    }
  }
  int b[10];
  for(int i=0;i<10;i++){
    min=c[i][1];
    get(i,0);
    b[i]=min;
  }
  int r=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      scanf("%d",&a);
      if(a>=0)r+=b[a];
    }
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]
heapify(a)
for i in range(m):
    tmp = -heappop(a)
    heappush(a,-(tmp//2))
print(-sum(a))

Measured memory_bytes: 14688
#include<bits/stdc++.h>
#define task "MAXFRAME"

#define nguyen_dz the_best
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define Yes cout <<"Yes"<<endl;
#define No cout<<"No" <<endl;


using namespace std;
const ll  maxn= 4e6+100;

ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
    ll a, b;
     cin>>a>>b;
      cout <<a*b;


}



Measured memory_bytes: 3656
lines = []
colums = []

while True:
 H,W = map(int,input().split())
 if H == 0 and W == 0:
   break
 lines.append(H)
 colums.append(W)

for H,W in zip(lines,colums):
 for i in range(H):
   if i%2==0:
     for j in range(W):
       if j%2==0:
         print("#",end="")
       else:
         print(".",end="")
   else:
     for j in range(W):
       if j%2!=0:
         print("#",end="")
       else:
         print(".",end="")

   print("\n",end="")
 print("\n",end="")


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
main(){
  int A,B;
  cin>>A>>B;
  int K=0;
  if((A+B)%2==0){
    K=(A+B)/2;
    cout<<K<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int result=0;
  for (int i=0; i<N; i++) {
    int r,l;
    cin >> r >> l;
    result += l-r+1;
  }
cout << result << endl;
}

    


Measured memory_bytes: 3600
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int count = 0;

      for(int i = 1;i<=N;i++){
        if(i%2!=0){
          count++;
        }
      }
      System.out.println((double)count/N);

                   }
      }

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int M = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

string s;

int main() {
    ios::sync_with_stdio(false);
     cin>>s;
      if(s[2]==s[3] && s[4]==s[5]) printf("Yes\n");
      else printf("No\n");



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int H, W, i, ii;
	while (scanf("%d %d", &H, &W) == 2) {
		if (H == 0 && W == 0) break;
		i = ii = 1;
		while (i <= H) {
			while (ii <= W) {
				if (i % 2 == 1 && ii % 2 == 1) printf("#");
				if (i % 2 == 1 && ii % 2 == 0) printf(".");
				if (i % 2 == 0 && ii % 2 == 1) printf(".");
				if (i % 2 == 0 && ii % 2 == 0) printf("#");
				ii ++;
			}
			printf("\n");
			ii = 1;
			i ++;
		}
		printf("\n");
	}
	return 0;
}

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

int main() {

  int N, w, x, y, z;
  cin >> N;
  x = 0;
  y = N;
  
  while (y > 0) {
  	x += y % 10;
    y /= 10;
  }
  
  if (N % x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
#include<complex>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
#define MIN (1e-10)
typedef complex<double> P;
bool EQ(P a, P b){
	if (abs(a.real() - b.real()) < MIN&&abs(a.imag() - b.imag()) < MIN)return true;
	else return false;
}
double dot(P a, P b){
	return{ a.real()*b.real() + a.imag()*b.imag() };
}
double cross(P a, P b){
	return{ a.real()*b.imag() - a.imag()*b.real() };
}
P insec(P a1, P a2, P b1, P b2){
	P a, b;
	a = a2 - a1;
	b = b2 - b1;
	return a1 + (a*cross(b, b1 - a1) / cross(b, a));
}
void print(double x,int k){
	if (x < 0){
		printf("-");
		x = -x;
	}
	printf("%d.", (int)x);
	x = x - (double)(int)x;
	f(i, k){
		x = x * 10;
		printf("%d", (int)x);
		x = x - (double)(int)x;
	}
	return;
}

int main(void){
	P a, b, c;
	P d, e, f;
	double x, y;
	int n;
	scanf("%lf %lf", &x, &y);
	a = P(x, y);
	scanf("%lf %lf", &x, &y);
	b = P(x, y);
	f = (b - a)*P(0, 1);
	scanf("%d", &n);
	f(i, n){
		scanf("%lf %lf", &x, &y);
	c = P(x, y);
	d = c + f;
	e = insec(a, b, c, d);
	print(e.real(),10);
	printf(" ");
	print(e.imag(),10);
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()

using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vi hog(5);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,f;
  string s,ss,sss;
  cin>>a>>b>>c>>d>>e>>f;
  hog[a]++;hog[b]++;hog[c]++;hog[d]++;hog[e]++;hog[f]++;
  sort(ALL(hog),greater<ll>());
  if(hog[0]==2&&hog[1]==2&&hog[2]==1&&hog[3]==1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 1000000007

n = int(input())
s1 = input()
s2 = input()


def tiles(s1, s2):
    t = []
    c1p, c2p = None, None
    for c1, c2 in zip(s1, s2):
        if c1 == c2:
            t.append(1)
        elif c1 != c1p and c2 != c2p:
            t.append(2)
        c1p, c2p = c1, c2
    return t


def solve(s1, s2):
    ncolor = 1
    t = tiles(s1, s2)

    prev = None
    ncolor = 1
    for ti in t:
        if prev is None:
            if ti == 1:
                ncolor *= 3
            if ti == 2:
                ncolor *= 6
        if prev == 1:
            if ti == 1:
                ncolor *= 2
            if ti == 2:
                ncolor *= 2
        if prev == 2:
            if ti == 1:
                ncolor *= 1
            if ti == 2:
                ncolor *= 3
        ncolor %= MOD
        prev = ti

    return ncolor


answer = solve(s1, s2)
print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, M, K; cin >> N >> M >> K;
    string ans = "No";

    REP(i, N + 1){
        REP(j, M + 1){
            if(i * M + j * N - 2 * i * j == K) ans = "Yes";
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef struct {
	string str;
	int num;
	int point;
} rest;
int main() {
	int n;
	cin >> n;
	vector<rest> vec(n);
	REP(i, n) {
		vec[i].num = i;
		cin >> vec[i].str >> vec[i].point;
	}
	sort(vec.begin(), vec.end(), [](rest &a,rest &b) {return a.str < b.str; });
	string old_str=vec[0].str;
	int old_pos=0;
	REP(i, n) {
		if (old_str != vec[i].str) {
			old_str = vec[i].str;
			sort(vec.begin() + old_pos, vec.begin() + i, [](rest & a, rest & b) {return a.point > b.point; });
			old_pos = i;
		}
	}
	if (old_str == vec[vec.size() - 1].str) {
		sort(vec.begin() + old_pos, vec.end(), [](rest& a, rest& b) {return a.point > b.point; });
	}
	REP(i, n) {
		cout << vec[i].num+1 << endl;
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int64_t ans = 0;
    int64_t b_cnt = 0;
    rep(i, s.size())
    {
        if (s[i] == 'W')
        {
            ans += b_cnt;
        }
        else
        {
            b_cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

signed main(){
    int n;
    cin >> n;
    if(n == 1){ 
        cout << "Hello World\n";
    }   
    else{
        int a,b;
        cin >> a >> b;
        cout << a + b << '\n';
    }   
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//lower_bound like o_set.find_by_order(val) strictly less then val
//upper_bound like o_set.order_of_key(MAX)– o_set.order_of_key(val)
//if u need multiset elements then use second parameter as time and think 
//typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int MAX=2e5+5;
const ll MM=1e16;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}

void solve()
{
    ll n,m,i,j,k;
    cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;
}

int main()
{
  boost;
  ll t=1;
// cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int N=4e3+10;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,p,bin[N],fl=1,ans=0;
bitset<N> a,b,c;

int main() {
	cin>>n>>a;
	for(int i=1;i<=n;i++) {
		cin>>c;
		while(c.any()) {
			for(int i=4000;;i--) if(c[i]) { p=i;break; }
			for(int i=4000;i>=p;i--) if(b[i]) b^=c<<(i-p);
			swap(b,c);
		}
	}
	bin[0]=1;
	for(int i=1;i<N;i++) bin[i]=2ll*bin[i-1]%mod;
	for(int i=4000;;i--) if(b[i]) { p=i;break; }
	c.reset();
	for(int i=4000;i>=p;i--) {
		if(a[i]) ans=(ans+bin[i-p])%mod;
		if(c[i]!=a[i]) c^=b<<(i-p);
	}
	for(int i=p-1;~i;i--)
		if(c[i]<a[i]) break;
		else if(c[i]>a[i]) { fl=0;break; }
	cout<<(ans+fl)%mod;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

    int ans = INF;
    for (int i = 0; i <= n; i++) {
        int cnt = 0;
        int t = i;
        while(t>0){
            cnt += t %6;
            t /= 6;
        }
        t = n-i;
        while(t>0){
            cnt += t%9;
            t /= 9;
        }
        chmin(ans, cnt);
    }
    
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            char[] S_c = S.ToCharArray();
            char[] T_c = T.ToCharArray();

            int ans = 0;
            for (int i = 0; i < S_c.Length; i++)
            {
                if (S_c[i] != T_c[i])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


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

int main()
{
  string s,ans;
  cin>>s;
  int i,j;
  char tmp;
  for(i=0;i<4;i++){
    for(j=i+1;j<4;j++){
      if(s[i]>s[j]){
        tmp=s[i];s[i]=s[j];s[j]=tmp;
      }
    }
  }
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
    ans="Yes";
  }
  else{
    ans="No";
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define MOD 1000000007

using namespace std;

int X, Y;

uint64_t mod_power(uint64_t x, uint64_t y) {
  uint64_t result = 1;

  while (y > 0) {
    if (y & 1) {
      result = (result * x) % MOD;
    }

    y = y >> 1;
    x = (x * x) % MOD;
  }

  return result;
}

uint64_t mod_inverse(uint64_t x) {
  return mod_power(x, MOD - 2);
}

uint64_t comb(int n, int r) {
  if (r == 0) {
    return 1;
  }

  vector<uint64_t> f(n + 1, 0);
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i] = (i * f[i - 1]) % MOD;
  }

  return (f[n] * mod_inverse(f[r]) % MOD * mod_inverse(f[n - r]) % MOD) % MOD;
}

int solve() {
  if ((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0 || 2 * X - Y < 0 || 2 * Y - X < 0) {
    return 0;
  }

  int a = (2 * X - Y) / 3;
  int b = (2 * Y - X) / 3;

  return comb(a + b, a);
}

int main() {
  cin >> X >> Y;

  cout << solve() << endl;

  return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>
int main()
{
    int N,n;
    scanf("%d",&N);
    if(N%1000==0){
        printf("0\n");
    }
    else {
        n=(N/1000)+1;
        n=1000*n-N;
        printf("%d\n",n);
    }
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    vector<string> V(H);
    rep(i,0,H)cin >> V[i];
    rep(i,0,H){
        int cnt = 0;
        rep(j,0,W)if(V[i][j] == '#')cnt++;
        if(cnt == 0)rep(j,0,W)V[i][j] = '-';
    }
    rep(j,0,W){
        int cnt = 0;
        rep(i,0,H)if(V[i][j] == '#')cnt++;
        if(cnt == 0)rep(i,0,H)V[i][j] = '-';
    }
    rep(i,0,H){
        int cnt = 0;
        rep(j,0,W){
            if(V[i][j] == '-' || V[i][j] == '\n')continue;
            cnt++;
            cout << V[i][j];
        }
        if(cnt)cout << endl;
    }
    
}

Measured memory_bytes: 256