akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

void main_sub(void) {
    int a, b, k;
    cin >> a >> b >> k;
    if (a > k) {
        cout << a - k << " " << b << endl;
    } else {
        cout << 0 << " " << max((i64)0, b - (k - a)) << endl;
    }
    return;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, M = map(int, input().split())
    d = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)

    for i in range(1, N + 1):
        print(len(d[i]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
/// b.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int a[1 << 20];
    static int b[1 << 20];
    static char s[1 << 10][1 << 10];
    for (int i = 1;i <= n;++i)
        fi>>(s[i] + 1);
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= n;++j)
            a[i] += s[i][j] == '#',b[j] += s[i][j] == '#';
    int cnt = 0;
    for (int i = 1;i <= n;++i)
        cnt += b[i] != n;
    if (accumulate(a + 1,a + 1 + n,0) == 0)
        return 0 * fail;
    int ans = n + n;
    for (int i = 1;i <= n;++i)
        smin(ans,cnt + (n - a[i]) + (!b[i]));
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;

int n, T, E;
ll x[N], dp[N];

int main() {
  scanf("%d %d %d", &n, &E, &T);
  for (int i = 1; i <= n; i++) scanf("%lld", &x[i]);
  x[n + 1] = E;
  ll mv = 1ll * n * T + E;
  for (int i = 1, j = 1; i <= n; i++) {
    dp[i] = dp[i - 1] + x[i] - x[i - 1] + T;
    for (; 2 * (x[i] - x[j]) >= T; j++)
      mv = min(mv, dp[j - 1] - x[j - 1] - 2 * x[j]);
      dp[i] = min(dp[i], mv + x[i] * 3);
    if (j < i) {
      dp[i] = min(dp[i], dp[j - 1] + x[i] - x[j - 1] + T);
    }
  }
  printf("%lld\n", dp[n] + E - x[n]);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;

bool comp(int a, int b) {
	
	return abs(a)>abs(b);
}
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.out");
	//ifstream cin ("fileName.in");
	
	int N,K;
	cin>>N>>K;
	vl pos, neg;
	
	for(int i=0; i<N; ++i) {
		ll n;
		cin>>n;
		if(n>=0) pos.pb(n);
		else neg.pb(n);
	}
	
	ll ans=1;
	
	if(K==N) {
		for(auto x: pos) ans=(ans*(x%MOD))%MOD;
		for(auto x: neg) ans=(ans*(x%MOD))%MOD;
		if(ans<0) ans+=MOD;
		cout<<ans<<"\n";
		return 0;
	}
	
	if(neg.size()==N && K%2==1) {
		sort(neg.rbegin(), neg.rend());
		for(int i=0; i<K; ++i) ans=(ans*(neg[i]%MOD))%MOD;
		ans+=MOD;
		cout<<ans<<"\n";
		return 0;
	}
	
	sort(pos.begin(), pos.end());
	sort(neg.rbegin(), neg.rend());
	
	int minus=neg.size()-1, plus=pos.size()-1;
	
	while(K) {
		ll a=-1, b=-1;
		if(K>=2 && minus>=1) a=neg[minus]*neg[minus-1];
		if(plus>=1)	b=pos[plus]*pos[plus-1];
		
		if(a>b && K!=1) {
			K-=2;
			minus-=2;
			ans=(ans*(a%MOD))%MOD;
		}
		
		else {
			--K;
			ans=(ans*(pos[plus]%MOD))%MOD;
			--plus;
		}
	}
	
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 5448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, eps = 1e-7;



int main()
{
    fastInp;

    ll x;
    cin >> x;

    for (ll i = 1; i <= SIZE; i++) {
        if ((i * 360) % x == 0) {
            cout << (i * 360) / x;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3664
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else {
		if (b <= a&&c <= a)
			cout << b*c << endl;
		else if (b <= c&&a <= c)
			cout << a*b << endl;
		else cout << a*c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

struct block{
    int w, s, v;
};

bool compare(block a, block b){
    return a.w + a.s < b.w + b.s;
}

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

    int n;
    cin >> n;
    vector<block> vb(n);
    rep(i, n){
        int w, s, v;
        cin >> w >> s >> v;
        vb[i] = {w, s, v};
    }
    sort(ALL(vb), compare);

    vector<vector<int>> dp(n + 1, vector<int>(20001));
    rep(i, n){
        rep(j, 20000){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j > vb[i].s){
                continue;
            }
            if(j + vb[i].w > 20000){
                continue;
            }
            dp[i+1][j+vb[i].w] = max(dp[i+1][j+vb[i].w], dp[i][j] + vb[i].v);
        }
    }

    int ans = 0;
    rep(i, 20001){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 160640
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
int n;
int dp[100005][2];
vector<int> hi;
ll calc(int idx, bool jmp) {
	if (idx >= n)
		return 1e9;
	int &ret = dp[idx][jmp];
	if (ret != -1)
		return ret;
	ret = abs(hi[idx] - hi[idx - (1 + jmp)]);
	if (idx == n - 1)
		return ret;
	ret += min(calc(idx + 1, false), calc(idx + 2, true));
	return ret;
}
int main() {
	//freopen("src.txt", "r", stdin);
	memset(dp, -1, sizeof dp);
	cin >> n;
	hi.resize(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &hi[i]);
	cout << min(calc(1, false), calc(2, true)) << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

typedef long long LL;

LL D;

LL power[20];

map<int, int> mp[2];
LL base[20];
LL dfs(int i, int n, LL num){
    if(i == n){
        if(num == 0){
            return 1;
        }else{
            return 0;
        }
    }
    LL ret = 0;
    int id = (i == 0);
    bool find = false;
    int mx = 0;
    for(int j = -9;j <= 9;j++){
        if(mp[id][j] == 0)
            continue;
        if(j * base[i] <= num){
            find = true;
            mx = j;
        } 
    } 
    if(find){
        LL num1 = num - mx * base[i];
        if(num1 == 0){
            return mp[id][mx] * dfs(i + 1, n, num1);
        }
        ret += mp[id][mx] * dfs(i + 1, n, num1);
    }
    find = false;
    mx = 0;
    for(int j = 9;j >= -9;j--){
        if(mp[id][j] == 0){
            continue;
        }
        if(j * base[i] > num){
            find = true;
            mx = j;
        }
    }
    if(find){
        LL num1 = num - mx * base[i];
        ret += mp[id][mx] * dfs(i + 1, n, num1);
    }
    return ret;
}

int main(){
    power[0] = 1;
    for(int i = 1;i <= 18;i++){
        power[i] = power[i - 1] * 10;
    } 
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            mp[0][i - j]++;
        }
    }
    for(int i = 0;i < 10;i++){
        for(int j = 1;j < 10;j++){
            mp[1][i - j]++;
        }
    }
    //cout << mp[1][7] << endl;
    cin >> D;
    LL ans = 0;
    for(int digit = 2;digit <= 18;digit++){
        int n = digit / 2;
        for(int i = 0;i < n;i++){
            base[i] = power[digit - 1 - i] - power[i];
        }
        LL tmp = dfs(0, n, D);
        if(digit & 1){
            tmp = tmp * 10;
        }
        ans = ans + tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MP make_pair
#define PB push_back
typedef long long ll;
const ll oo = 1e13;
const ll N = 1e5;
int main() {_
int n;cin >> n;
int a,b;
if(n==1)
    cout << "Hello World" << endl ;
else {
    cin >> a >> b;
    cout << a+b << endl;
}
}


Measured memory_bytes: 892
h, w = map(int, input().split())
s = [input() + '#' for _ in range(h)]
s.append('#' * w)

yoko = [[0] * w for _ in range(h)]
for i in range(h):
  start = -1
  for j in range(w + 1):
    if s[i][j] == '#':
      if start != -1:
        for k in range(start, j):
          yoko[i][k] = j - start
        start = -1
    else:
      if start == -1:
        start = j

tate = [[0] * w for _ in range(h)]
for i in range(w):
  start = -1
  for j in range(h + 1):
    if s[j][i] == '#':
      if start != -1:
        for k in range(start, j):
          tate[k][i] = j - start
        start = -1
    else:
      if start == -1:
        start = j

result = 0
for i in range(h):
  for j in range(w):
    t = yoko[i][j] + tate[i][j] - 1
    if t > result:
      result = t

print(result)


Measured memory_bytes: 125656
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    int n = Integer.parseInt(br.readLine());
    Node[] nodes = new Node[n];
    for (int i=0; i<n; i++) {
      nodes[i] = new Node(i);
    }
    for (int i=0; i<n-1; i++) {
      String[] s = br.readLine().split(" ");
      int a = Integer.parseInt(s[0])-1;
      int b = Integer.parseInt(s[1])-1;
      nodes[a].adj.add(nodes[b]);
      nodes[b].adj.add(nodes[a]);
    }
    if (solve(nodes[0],-1)!=0) {
      System.out.println("Alice");
    } else {
      System.out.println("Bob");
    }


  }
  static int solve(Node a, int from) {
    if (a.adj.size()==1 && a.i!=0) {
      return 0;
    }
    int ans = 0;
    for (Node n:a.adj) {
      if (n.i!=from) {
        ans ^= 1+solve(n,a.i);
      }
    }
    //System.out.println("Answer for "+a.i+": "+ans);
    return ans;
  }
}
class Node {
  int i;
  ArrayList<Node> adj;
  public Node(int ii) {
    i = ii;
    adj = new ArrayList<Node>();
  }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

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


void Main() {
	int N; cin >> N;
	vint parent(N);
	vint rev(N, 0);
	for (int i = 1; i < N; i++) { cin >> parent[i]; parent[i]--; }
	for (int i = N-1; i > 0; i--) rev[parent[i]]++;
	for (auto &v : rev) {
		cout << v << el;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4784
s=input().split("T")
X,Y=map(int,input().split())
x=list(map(len,s[::2]))
y=list(map(len,s[1::2]))
l=[x[0]]
s=set()
for i in x[1:]:
    s.clear()
    for j in l:
        s.add(j+i)
        s.add(j-i)
    l=list(s)
if(not X in l):
    print("No")
    quit()
l=[0]
for i in y:
    s.clear()
    for j in l:
        s.add(j+i)
        s.add(j-i)
    l=list(s)
if(not Y in l):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3528
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import deque
 
H, W, K = map(int,readline().split())
x1, y1, x2, y2 = map(int,readline().split())
x1 -= 1; y1 -= 1; x2 -= 1; y2 -= 1
C = read().split()

dist = [[-1]*W for i in range(H)]
dist[x1][y1] = 0
d = deque([[x1, y1]])
dxy= [[1, 0], [0, 1], [-1, 0], [0, -1]]
while d:
  x, y = d.popleft()
  if (x, y) == (x2, y2):
    print(dist[x][y])
    quit()
  for dx, dy in dxy:
    xx = x; yy = y
    for i in range(K):
      xx += dx; yy += dy
      if 0<=xx<H and 0<=yy<W and C[xx][yy]!='@':
        if 0 <= dist[xx][yy] <= dist[x][y]:
          break
        if dist[xx][yy] == -1:
           d.append([xx, yy])
        dist[xx][yy] = dist[x][y] + 1
      else:
        break

print(-1)

Measured memory_bytes: 118444
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;

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

    bool flag = true;
    ll ans = 100;
    int num = 0;
    while (ans < X){
        ans += ans / 100;
        num++;
    }

    cout << num << endl;
}

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


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

    string IN;
    long long num[5] = {};

    for (int i=0; i<N; i++) {
        cin >> IN;
        if (IN[0] == 'M') num[0]++;
        if (IN[0] == 'A') num[1]++;
        if (IN[0] == 'R') num[2]++;
        if (IN[0] == 'C') num[3]++;
        if (IN[0] == 'H') num[4]++;
    }

    long long ans = 0;

    ans += num[0] * num[1] * num[2];
    ans += num[0] * num[1] * num[3];
    ans += num[0] * num[1] * num[4];
    ans += num[0] * num[2] * num[3];
    ans += num[0] * num[2] * num[4];
    ans += num[0] * num[3] * num[4];
    ans += num[1] * num[2] * num[3];
    ans += num[1] * num[2] * num[4];
    ans += num[1] * num[3] * num[4];
    ans += num[2] * num[3] * num[4];

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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 MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    VI L(M), R(M);
    VI ANS(N+2,0);
    int cnt = 0;
    REP(i, M) {
        cin >> L[i] >> R[i];
        ANS[L[i]]++;
        ANS[R[i] + 1]--;
    }
    REP(i, N + 1) {
        ANS[i+1] += ANS[i];
        if (ANS[i + 1] == M) {
            cnt++;
        }
    }
    cout << cnt << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> cnt_e(n);
	char ew;
	int cnt=0;

	for(int i=0; i<n; i++){
		cin >> ew;
		if(ew=='E'){
			cnt++;
		}
		cnt_e.at(i)=cnt;
	//	cout << cnt_e.at(i) << endl;
	}	

	int ans=n;
	int tmp;
	for(int i=0; i<n; i++){
		if(i==0){
			tmp = cnt_e.at(n-1)-cnt_e.at(0);
		}else{
			tmp = cnt_e.at(n-1)-cnt_e.at(i) + (i-cnt_e.at(i-1));
		}
		
		if(tmp<ans){
			ans = tmp;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
n = gets.to_i
elem = []
n.times do
  elem << gets.chomp
end
res = []
i = 0
elem.group_by(&:itself).values.each do |v|
  if v.size > i
    res = []
    res << v[0]
    i = v.size
  elsif v.size == i
    res << v[0]
  end
end
puts res.sort.join("\n")

Measured memory_bytes: 53096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  int ans=d[n/2]-d[n/2-1];
  cout<<ans<<endl;
}

Measured memory_bytes: 3788
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

li = []
nums = []
for s in S:
    if s not in li:
        li.append(s)
        nums.append(1)
    else:
        nums[li.index(s)] += 1
for t in T:
    if t in li:
        nums[li.index(t)] -= 1
mx = max(nums)
ans = max(0, mx)
print(ans)

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


int main() {
  int64_t N;
  cin >> N;
  string arufabetto;
  arufabetto = "abcdefghijklmnopqrstuvwxyz";
  string namae;
  while(N > 26){
    for(int i = 1; i < 26; i++){
  		if(N % 26 == i){
    	 namae.push_back(arufabetto.at(i-1));
    	}
    }
    if(N % 26 == 0){
     namae.push_back('z');
     N = (N - 26) /26;
     continue;
    }
    N = (N - (N % 26) )/26;
  }
  for(int i = 1; i < 26; i++){
  		if(N % 26 == i){
    	 namae.push_back(arufabetto.at(i-1));
    	}
    }
  if(N % 26 == 0){
   namae.push_back('z');
  }
  reverse(begin(namae),end(namae));
  cout << namae << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
 
    lli n;cin>>n;
    lli a[5];
    loop(i,0,5)cin>>a[i];
    lli mini=a[0];loop(i,0,5)mini=min(mini,a[i]);
    if(n<=mini){cout<<5;return 0;}
    lli t=0;
    if(n%mini==0)t=n/mini-1;
    else t=n/mini;
    cout<<5+t;


 	return 0;
 }

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
sheet=[min(i%n,i//n,n-i%n-1,n-i//n-1) for i in range(n**2)]
space=[1]*(n**2)
ans=0
for x in p:
  x-=1
  ans+=sheet[x]
  space[x]=0
  todo=[x]
  while todo:
    v=todo.pop()
    x,y=divmod(v,n)
    for dx,dy in ((0,1),(0,-1),(1,0),(-1,0)):
      if 0<=x+dx<n and 0<=y+dy<n:
        nv=(x+dx)*n+(y+dy)
        if sheet[nv]>sheet[v]+space[v]:
          sheet[nv]=sheet[v]+space[v]
          todo.append(nv)
print(ans)



Measured memory_bytes: 128056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int p[N];
    rep(i, N) cin >> p[i];
    sort(p, p+N);
    int sum = 0;
    rep(i, N-1) sum += p[i];
    sum += p[N-1]/2;
    cout << sum << endl;
}

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,r) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  ll x, y;
  FOR(h, 1, 3501) {
	FOR(w, 1, 3501) {
	  x = 4 * h*w - h * n - w * n;
	  y = n * h * w;
	  if (x <= 0) continue;
	  if (y % x == 0) {
		cout << h << " " << w << " " << y / x << endl;
		return 0;
	  }
	}
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	if (n % 1000)cout << 1000 - n % 1000 << endl;
	else cout << 0 << endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a,b,c,d;
int main(){
cin>>a>>b>>c>>d;
if(d>=abs(a-c)||d>=abs(a-b)&&d>=abs(b-c))
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;
}

Measured memory_bytes: 504
s=require('fs').readFileSync('/dev/stdin','utf8').split('\n');
[n,h,w]=s[0].split(' ')
for(i=1,r=0;i<=n;i++){
	[a,b]=s[i].split(' ').map(n=>n|0)
	a>=h&&b>=w&&r++
}
console.log(r)


Measured memory_bytes: 7740
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
hand = ""
point = 0
for i in range(n):
    if i<k:
        if t[i] == "r":
            hand += "p"
        elif t[i] == "s":
            hand += "r"
        else:
            hand += "s"
    else:
        if t[i] == t[i-k] and hand[i-k] == "a":
            if t[i] == "r":
                hand += "p"
            elif t[i] == "s":
                hand += "r"
            else:
                hand += "s"
        elif t[i] == t[i-k] and hand[i-k] != "a":
            hand += "a"
        else:
            if t[i] == "r":
                hand += "p"
            elif t[i] == "s":
                hand += "r"
            else:
                hand += "s"

for i in range(n):
    if hand[i] == "p":
        point += p
    elif hand[i] == "r":
        point += r
    elif hand[i] == "s":
        point += s
    else:
        point += 0
print(point)

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

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int mod = n%10 ;
        if(mod==2 || mod==4||mod==5||mod==7||mod==9){
            System.out.println("hon");
        }else if(mod==0 || mod==1||mod==6||mod==8){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }

        private int readByte(){
            if(hasNextByte())return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c){
            return 33<=c && c<=126;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            return hasNextByte();
        }

        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b<='9'){
                    n*=10;
                    n+=b-'0';
                }else if(b==-1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 32392
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
 
using namespace std;
 
struct Node{
  int key;
  Node *right,*left,*parent;
};
 
Node *root,*NIL;
 
void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
   
  z = (Node*)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
   
  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}
 
Node * find(Node *u,int i){
  while(u != NIL && i != u->key){
    if(i < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}
 
void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
int main(){
  int n,x;
  string com;
   
  scanf("%d",&n);
   
  for(int i=0;i<n;++i){
    cin>>com;
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com == "find"){
      scanf("%d",&x);
      Node *nd = find(root,x);
      if(nd != NIL)printf("yes\n");
      else printf("no\n");
    }
  }
   
  return 0;
}


Measured memory_bytes: 22096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

int main()
{
  int n;cin >> n;
  string s;cin >> s;
  auto f = [&](int a,int b){ return a+b;};
  int id = 0;
  vector<SegTree<decltype(f),int>> seg(10,SegTree<decltype(f),int>(f,id));
  rep(i,10) seg[i].init(n);
  rep(i,n){
    int c = s[i]-'0';
    seg[c].update(i,1);
  }
  map<int,int> mp;
  rep1(i,n-2){
    int c = s[i]-'0';
    rep(j,10){
      if(seg[j].query(0,i,0,0,seg[j].size)>0){
	rep(k,10){
	  if(seg[k].query(i+1,n,0,0,seg[j].size)>0){
	    mp[100*j+10*c+k]++;
	  }
	}
      }
    }
  }
  int res=0;
  for(auto m:mp) res++;
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll A,B;
  cin >> A >> B;
  cout << max(A+B,max(A*B,A-B)) << endl;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string p;
    cin>>p;
    if(p==s)
    {
        cout<<a-1<<" "<<b<<endl;
    }
    if(p==t)
    {
        cout<<a<<" "<<b-1<<endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Point{
public:
	int x;
	int y;
	Point(int _x,int _y) : x(_x), y(_y) {}
};

bool isHere[5001][5001];

int main(){
	int n;	
	while(~scanf("%d",&n)){
		if(n==0) break;

		
		memset(isHere,0,sizeof(isHere));

		vector<Point> pos;
		for(int i=0;i<n;i++){
			int x,y;
			scanf("%d %d",&x,&y);
			isHere[y][x] = true;
			pos.push_back(Point(x,y));
		}

		int res = 0;
		for(int p1=0;p1<pos.size();p1++){
			for(int p2=p1+1;p2<pos.size();p2++){
				int dx = pos[p2].x - pos[p1].x;
				int dy = pos[p2].y - pos[p1].y;
				
				dx = dx < 0 ? -dx : dx;
				dy = dy < 0 ? -dy : dy;

				int p3x = pos[p2].x + dy;
				int p3y = pos[p2].y + dx;

				int p4x = pos[p1].x + dy;
				int p4y = pos[p1].y + dx;

				if(p3x > 5000 || p3y > 5000
					|| p4x > 5000 || p4y > 5000) continue;

				if(isHere[p3y][p3x] 
					&& isHere[p4y][p4x]){
					res = max(res,dx*dx+dy*dy);
				}
			}
		}

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

Measured memory_bytes: 25676
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,k,ans;
    cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else{
        ans = a;
        k -= a;
        if(k <= b) cout << ans << endl;
        else{
            k -= b;
            ans -= k;
            cout << ans << endl;
        }
    }
}


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

int main()
{

        string s;
        cin >> s;

        if (s == "SUN") {
                cout << 7 << endl;
        }
        else if ( s== "MON") {
                cout << 6 << endl;
        }
        else if (s == "TUE") {
                cout << 5 << endl;
        }
        else if (s == "WED") {
                cout << 4 << endl;
        }
        else if (s == "THU") {
                cout << 3 << endl;
        }
        else if (s == "FRI") {
                cout << 2 << endl;
        }
        else if (s == "SAT") {
                cout << 1 << endl;
        }









}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input().strip())

sp_list=[]
for i in range(N):
    s,p = input().rstrip().split()
    sp_list.append( [i+1,s,int(p)] )
#-----

sp_list.sort( key=lambda x:(x[1],-x[2]) )

for i,s,p in sp_list:
    print(i)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int B[N];
int n , q;

int bit[N + 1];

void update(int id, int val)
{
	for (int i = id; i <= N; i += i & (-i) ) bit[i] += val;
}
 
int get(int id)
{
	int sum = 0;
	for ( int i = id; i > 0; i -= i & (-i) ) sum += bit[i];
	return sum;
}


void solve()
{
	cin >> n >> q;

	loop(i,1,n+1)cin >> A[i];

	mset(B,-1);

	vector<pair<int,pii> > vec;

	vector<int> ans(q);

	loop(i,0,q)
	{
		int l ,r;
		cin >> l >> r;
		vec.pb({r,{l,i}});
	}

	S(vec);

	int j = 0;

	loop(i,1,n+1)
	{
		if(B[A[i]] != -1)update(B[A[i]],-1);
		B[A[i]] = i;
		update(i,1);

		while(j < q && vec[j].ff == i)
		{
			ans[vec[j].ss.ss] = get(vec[j].ff) - get(vec[j].ss.ff - 1); 
			j++;
		}
	}

	loop(i,0,q)cout << ans[i] << endl;

}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

using namespace std;
int main(){
    // cin.tie(0);
    char c[4];
    for(int i=0;i<4;++i){
        cin >> c[i];
    }

    int upper = 10*(c[0]-'0') + (c[1]-'0');
    int lower = 10*(c[2]-'0') + (c[3]-'0');

    if(lower>=1 && lower<=12){
        if(upper>=1 && upper<=12){
            cout << "AMBIGUOUS" << "\n";
        } else {
            cout << "YYMM" << "\n";
        }
    } else {
        if(upper>=1 && upper<=12){
            cout << "MMYY" << "\n";
        } else {
            cout << "NA" << "\n";
        }
    }
    
    return 0;
}

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

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

    long long n;
    cin>>n;
    for(long long i=1;i<=3500;i++){
        for(long long j=1;j<=3500;j++){
            long long num1=n*i*j,num2=4*i*j-n*i-n*j;
            if(num2==0 || num1/num2<0)continue;
            if((num1%num2==0)){
                cout<<i<<" "<<j<<" "<<num1/num2<<endl;
                return 0;
            }
        }
    }

}

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

using namespace std;
const int maxn = 4;
typedef long long ll;
const int INF = 1e9+7;

list<int>sta[maxn];
void action()
{
    //cout<<sqrt(880)<<endl;
    int n;
    scanf("%d",&n);
    while(n--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);


        ll cnt = a*b;
        if(a<b)swap(a,b);

        if(a==b)
        {
            cout<<a+a-2<<endl;
            continue;

        }
        /*else if(a == b+1)
        {
            cout<<2*(b-1)<<endl;
            continue;
        }*/

        ll sq = sqrt(cnt);
        ll sq1 = sq-1;
        ll sq2 = sq-1;

        if(sq*sq==cnt)
            sq1--;

        ll cnt22 = ceil(sqrt(cnt));
        if(cnt22 * sq <cnt )
            sq1++;
        printf("%lld\n",sq1+sq2);

    }

}
int main()
{

    action();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 1000009
#define LL long long
#define INF 0x3f3f3f3f
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
int pre[N];
int unionsearch(int root){
	return (pre[root] == root)?pre[root]:pre[root] = unionsearch(pre[root]);
}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n, m, at, bt;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		pre[i] = i;
	}
	for(int i = 1; i <= m; i++){
		cin >> at >> bt;
		pre[unionsearch(at)] = unionsearch(bt);
	}
	//for(int i = 1; i <= n; i++){
		//cout << "debug1: " << i << " pre: " << pre[i] << endl;
	//}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(pre[i] == i) ans++;
	}
	cout << ans - 1;
	return 0;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    int n;
    cin>>n;
    vector<pair<pair<string,int>,int>> sp(n);
    fr(i,n){
        cin>>sp[i].ft.ft>>sp[i].ft.sd;
        sp[i].ft.sd*=-1;
        sp[i].sd=i+1;
    }
    sort(sp.begin(),sp.end());
    fr(i,n) cout<<sp[i].sd<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>



using namespace std;


using namespace std;

int main() {
    int A, B, C;
    cin>>A>>B>>C;

    cout<< C/A*B<<endl;



}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    REP(i, N) cin >> H[i];
    int A, B;
    vector<bool> good(N, true);
    REP(i, M) {
        cin >> A >> B;
        --A;
        --B;
        if (H[A] < H[B]) {
            good[A] = false;;
        } else if (H[A] > H[B]) {
            good[B] = false;
        } else {
            good[A] = false;
            good[B] = false;
        }
    }
    cout << std::count(good.begin(), good.end(), true) << endl;
}


Measured memory_bytes: 3712