akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 1 << 17;

struct LazySegTree {
	int n;
	struct S {
		int flag;
		int len;
		int sum;
		int l, r;
		S() : flag(0), len(1), sum(0), l(0), r(0) {}
	};
	S node[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
	}

	void propagate(int k) {
		S& t = node[k];
		if(!t.flag) return;
		if(2 * k + 1 < 2 * n - 1) {
			S& l = node[2 * k + 1];
			S& r = node[2 * k + 2];
			l.flag = r.flag = 1;
			int x = t.l;
			l.l = l.r = r.l = r.r = x;
			l.sum = r.sum = x;
		}
		t.flag = 0;
	}

	S merge(S l, S r) {
		S ret;
		ret.len = l.len * 2;
		ret.sum = l.sum + r.sum;
		if(l.r && r.l) ret.sum--;
		ret.l = l.l;
		ret.r = r.r;
		return ret;
	}

	void query(int a, int b, int x) { query(a, b, x, n, 0, 0, n); }

	void query(int a, int b, int x, int len, int k, int l, int r) {
		if(r <= a || b <= l) return;
		propagate(k);
		if(a <= l && r <= b) {
			node[k].flag = 1;
			node[k].l = node[k].r = x;
			node[k].sum = x;
			propagate(k);
			return;
		}
		query(a, b, x, len / 2, k * 2 + 1, l, (l + r) / 2);
		query(a, b, x, len / 2, k * 2 + 2, (l + r) / 2, r);
		node[k] = merge(node[2 * k + 1], node[2 * k + 2]);
	}
};

int n;
int b[100000];

LazySegTree st;

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

	cin >> n;
	st.init(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; i++) {
		b[i] = s[i] - '0';
	}

	for(int i = 0; i < n; i++) {
		int idx = i + st.n - 1;
		auto& node = st.node[idx];
		node.l = node.r = node.sum = b[i];
	}
	for(int i = st.n - 2; i >= 0; i--) {
		st.node[i] = st.merge(st.node[2 * i + 1], st.node[2 * i + 2]);
	}

	int q;
	cin >> q;
	for(int t = 0; t < q; t++) {
		int l, r, x;
		cin >> l >> r >> x;
		l--;
		st.query(l, r, x);
		auto node = st.node[0];
		cout << node.sum << endl;
	}
}

Measured memory_bytes: 8764
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
li read(){
	li x = 0,y = 0,c = gc;
	while(!isdigit(c)) y = c,c = gc;
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'),c = gc;
	return y == '-' ? -x : x;
}
void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li s1 = 19260817,s2 = 23333333,s3 = 998244853,srd;
li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
int n,m,a[200010];
void file(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
//const int mo = 998244353;
//const int mo = 1000000007;
int st[1000010][2],ft;
bool chk(int q){
	ft = 0;
	for(int i = 2;i <= n;++i) if(a[i] <= a[i - 1]){
		while(ft && st[ft][0] > a[i]) --ft;
		if(!ft || st[ft][0] != a[i]) st[++ft][0] = a[i],st[ft][1] = 1;
		else{
			++st[ft][1];
			int tp = a[i];
			while(st[ft][1] == q){
				--tp;--ft;
				if(!tp) return 0;
				else if(!ft || st[ft][0] != tp){
					st[++ft][0] = tp;st[ft][1] = 1;break;
				}
				else ++st[ft][1];
			}
		}
	}
	return 1;
}
int main(){
	srand(time(0));rd();
	//file();
	int i,j;
	n = read();for(i = 1;i <= n;++i) a[i] = read();
	bool fg = 1;
	for(i = 2;i <= n;++i) if(a[i] <= a[i - 1]){
		fg = 0;break;
	}
	if(fg){
		pc('1');return 0;
	}
	int l = 2,r = n,as = n,mid;
	while(l <= r){
		mid = l + r >> 1;
		if(chk(mid)){
			as = mid;r = mid - 1;
		}
		else l = mid + 1;
	}
	print(as);
	return 0;
}


Measured memory_bytes: 2816
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y = list(map(int, readline().split()))
    if x == 1 and y == 1:
        print(300000 * 2 + 400000)
    else:
        t = 0
        if x == 1:
            t += 300000
        elif x == 2:
            t += 200000
        elif x == 3:
            t += 100000
            
        if y == 1:
            t += 300000
        elif y == 2:
            t += 200000
        elif y == 3:
            t += 100000
        print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
int N, M;
int a[1010], b[1010], c[1010];
int dis[110][110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
  }
  fill_n((int*)dis, 110 * 110, INF);
  for (int i = 0; i < N; i++) {
    dis[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int ans = 0;
  for (int e = 0; e < M; e++) {
    int use = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (dis[i][a[e]] + dis[b[e]][j] + c[e] == dis[i][j]) {
          use = 1;
        }
      }
    }
    ans += !use;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
in1 = list(map(int, input().split()))
N = in1[0]
M = in1[1]

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

A.sort()

req = 0

for a in A:
    if M <= a[1]:
        req += a[0]*M
        break

    req += a[0]*a[1]
    M -= a[1]

print(req)


Measured memory_bytes: 27760
import sys
sys.setrecursionlimit(1000)

n = int(input())
mod = 1000000007
memo = {}
def doit(n, a, b, c):
    if n == 0:
        return 1
    key = (n, a, b, c)
    if not key in memo:
        ret = (doit(n - 1, b, c, 'A') + doit(n - 1, b, c, 'T')) % mod
        if (b != 'A' or c != 'C'):
            ret = (ret + doit(n - 1, b, c, 'G')) % mod
        if (b != 'A' or c != 'G') and (b != 'G' or c != 'A') and (a != 'A' or c != 'G')  and (a != 'A' or b != 'G'):
            ret = (ret + doit(n - 1, b, c, 'C')) % mod
        memo[key] = ret
    return memo[key]
print(doit(n, '', '', ''))

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200005, mod = 1000000007, S = N - 3, T = N - 2, inf = 1 << 29;
int n, m, q, sz = 1, pos[N], que[N], hd, tl, a[N], b[N], c[N], d[N], dis[N], ans, sum, ns;
struct Edge { int y, nex, z; } g[N * 10];
void Init(int x, int y, int z) { g[++ sz] = (Edge) { y, pos[x], z }, pos[x] = sz; }
void Add(int x, int y, int z) { Init(x, y, z), Init(y, x, 0); } // cout<<x<<" "<<y<<" "<<z<<endl; }
bool Bfs() {
	memset(dis, 0, sizeof(dis)), dis[S] = 1;
	que[hd = tl = 1] = S;
	while (hd <= tl) {
		int x = que[hd ++];
		RepE(i, x) {
			int y = g[i].y;
			if (!dis[y] && g[i].z) dis[y] = dis[x] + 1, que[++ tl] = y;
		}
	}
	return dis[T];
}
int Dfs(int x, int mx) {
	if (x == T) return mx;
	int ret = 0;
	RepE(i, x) {
		int y = g[i].y, k;
		if (mx && dis[y] == dis[x] + 1 && g[i].z && (k = Dfs(y, min(mx, g[i].z)))) {
			ret += k, g[i].z -= k, g[i ^ 1].z += k, mx -= k;
		}
	}
	if (mx) dis[x] = 0;
	return ret;
}
void Dinic() {
	int ret = 0;
	while (Bfs()) {
		while (ret = Dfs(S, inf)) sum += ret;
	}
}
int main()
{
	scanf ("%d", &n);
	Rep(i, 1, n) scanf ("%d", &a[i]), a[i] ++;
	Rep(i, 1, n) scanf ("%d", &b[i]), b[i] ++;
	Rep(i, 1, n) if (!c[i]) {
		int k = 0;
		ns ++;
		for (int j = i;; j = a[j]) {
			k ++;
			c[j] = ns;
			if (a[j] == i) break ;
		}
		if (k > 1) Add(S, ns, k);
	}
	// ns = n;
	Rep(i, 1, n) if (!d[i]) {
		int k = 0;
		ns ++;
		for (int j = i;; j = b[j]) {
			k ++;
			d[j] = ns;
			if (b[j] == i) break ;
		}
		if (k > 1) Add(ns, T, k);
	}
	ans = 2 * n;
	Rep(i, 1, n) {
		if (a[i] == i || b[i] == i) {
			if (b[i] == a[i]) ans -= 2;
			else ans --;
			continue ;
		}
		if (a[i] == b[i]) Add(c[i], d[i], 2);
		else Add(c[i], d[i], 1);
	}
	Dinic();
	// cout << sum<<endl;
	printf("%d\n", ans - sum);

	return 0;
}

Measured memory_bytes: 14592
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

i, j = 0, 0
c = 0
num = 0
while i < n and c + A[i] <= k:
    c = c + A[i]
    num += 1
    i += 1
while j < m and B[j] + c <= k:
    c = c + B[j]
    num += 1
    j += 1
for a in range(i-1, -1, -1):
    c -= A[a]
    while j < m and c + B[j] <= k:
        c = c + B[j]
        j += 1
        num = max(num, a+j)
print (num)


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

int main(){
  int n, maxv = 1-1000000000, minv;
  int R[200000];

  cin >> n >> R[0];
  minv = R[0];
  for ( int j = 1; j < n; j++ ){
    cin >> R[j];
    if ( R[j]-minv > maxv ) maxv = R[j]-minv;
    if ( R[j] < minv ) minv = R[j];
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 3892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		for(int i = 0; i < n + 1; i++) {
			board[i] = sc.next().toCharArray();
		}
		int sum = 0; //print
		for(int i = 1; i <= n; i++) {//?????????????????£????????????
			out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
				if(board[i][j] == board[0][0]) {
					for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
						if(board[i][k] == board[0][1]) {
							int interval = k - j;//1???????????¨2??????????????????
							int cnt = 2;//?????????????????¢?´¢???????????????
							for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
								if(board[i][m] == board[0][cnt]) {
									cnt = cnt + 1;
									if(cnt == board[0].length) {
										sum = sum + 1;
										break out;
									}
								} else {
									break;
								}
							}
						}
					}
				}
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 27940
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

struct node{
	long long cans,yuan;
}a[1000005];

bool cmp(node x,node y){
	return x.yuan<y.yuan;
}

int main()
{
	int n,m;
	long long sum=0,cnt=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].yuan,&a[i].cans);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		sum+=a[i].cans*a[i].yuan;
		cnt+=a[i].cans;
		if(cnt>m)
		{
			sum-=(cnt-m)*a[i].yuan;
			break;
		}
	}
	printf("%lld",sum);
}

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

using namespace std;

struct Point
{
    double x,y;
    Point(){ x = y = 0.0; }
    Point(double _x, double _y) : x(_x), y(_y){}

    Point operator+ (Point p)
    {
        return Point(p.x + x, p.y + y);
    }

    Point operator- (Point p)
    {
        return Point(x - p.x, y - p.y);
    }

    double operator* (Point p)
    {
        return p.x * x + p.y * y;
    }

    Point operator* (double t)
    {
        return Point(x*t, y*t);
    }

};

Point projection(Point p1, Point p2, Point o)
{
    Point a = (p2 - p1);
    Point b = (o - p1);
    return p1 + a * ( (a * b) / (a * a) );
}

int main()
{
    cout.precision(10);
    cout << fixed;
    int q;
    Point p1, p2, o, ans;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    cin >> q;
    while(q--)
    {
        cin >> o.x >> o.y;
        ans = projection(p1, p2, o);
        cout << ans.x << " " << ans.y << '\n';
    }

    return 0;
}

Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;



signed main(){
    int n, m;
    cin >> n >> m;

    auto mpow = [](auto x, i64 y){
        auto z = x;
        decltype(x) val = y & 1 ? x : decltype(x)(1);
        while(z *= z, y >>= 1)
            if(y & 1)
                val *= z;
        return val;
    };

    vector<mint> div(1e5);
    for(int i = 0; i < 1e5; ++i){
        div[i] = mpow(mint(i), MOD - 2);
    }


    vector<vector<mint>> dp(n + 1, vector<mint>(n + 1, 0));
    dp[1][1] = 1;
    for(int i = 0; i < m; ++i){
        decltype(dp) nex(n + 1, vector<mint>(n + 1, 0));
        for(int j = 0; j <= n; ++j){
            for(int k = 0; k <= n; ++k){
                nex[min(j + 1, n)][k] += dp[j][k] * (n - j);
                nex[j][j] += dp[j][k] * k;
                nex[j][k] += dp[j][k] * (j - k);
            }
        }
        dp = move(nex);
    }
    cout << dp.back().back() << endl;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 == 1) {
    cout << "No" << endl;
  } else {
    if (S.substr(0, N / 2) == S.substr((N / 2), N)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N,0);
    long long sum_=0;
    for(int i=0; i<N; i++){
        long long a;
        cin >> a;
        A[i]=a;
        sum_+=a;
    }
    sort(A.begin(),A.end());

    for(int i=0; i+1<N; i+=2){
        long long tmp=sum_-2*A[i]-2*A[i+1];
        if(tmp>sum_){
            sum_=tmp;
        }else{
            break;
        }
    }
    cout << sum_ << endl;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 3e3+10;

double dp[N][N];
double p[N];

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

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

dp[0][0]=1;

for(int i=1;i<=n;i++) {
    dp[i][0]=(1-p[i])*dp[i-1][0];
    for(int k=1;k<=i;k++) {
        dp[i][k]=p[i]*dp[i-1][k-1] + (1-p[i])*dp[i-1][k];
    }
}

double ans=0;
for(int i=n/2+1;i<=n;i++) {
    ans = ans + dp[n][i];
}
cout<<setprecision(12)<<ans<<endl;

return 0;
}

Measured memory_bytes: 49896
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
using namespace std;

long long n;
vector<long long> arr(2000005);

long long gcd(long long a, long long b){
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}

long long lcm(long long a, long long b){
    return (a*b)/gcd(a,b);
}

int main(){
    int k;
    string str;
    cin >> k;
    cin >> str;
    if(str.size() <= k) cout << str << endl;
    else{
        string res = "";
        for(int i = 0; i < k; i++) res += str[i];
        res += "...";
        cout << res << endl;
    }
}

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

using namespace std;
typedef long long ll;

#define Rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define RepD(i,n) for(ll i=n-1;i>=0;i--)
#define For(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define ForD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
 string A;
 cin>>A;
  if(A=="ABC")cout<<"ARC";
  else if(A=="ARC") {
    cout<<"ABC";
  }

}

Measured memory_bytes: 3624
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
getInt = readInt <$> BS.getLine
-- readIntList = map readInt . BS.words
-- getIntList = readIntList <$> BS.getLine
-- getIntMatrix = map readIntList . BS.lines <$> BS.getContents
main = do
    arg <- getInt
    print (solve arg)


solve :: Integer -> Integer
solve arg = (24 - arg) + 24

Measured memory_bytes: 380
import heapq
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
q=[]
for i in range(N):
    heapq.heappush(q,-A[i])
for i in range(M):
    K=-heapq.heappop(q)
    L=K//2
    heapq.heappush(q,-L)
ans=0
for i in range(N):
    ans-=heapq.heappop(q)
print(ans)


Measured memory_bytes: 66968
x = int(input())

# 商品の合計がi個の場合の可能なxの範囲
# i=1   100-105
# i=2   200-210
# i=3   300-315
# i=4   400-420
# i=5   500-525
# i=6   600-630
# i=7   700-735
# i=8   800-840
# i=9   900-945
# ...
# i=19 1900-1995
# i=20以降は常に1

i = x // 100

if 100*i <= x <= 105*i:
  print(1)
else:
  print(0)

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int main(){
    int n;
    cin >> n;
    cout << n/2 + n%2 << endl;
    return 0;
}



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

using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
  long long int n; 
  cin>>n;
  long long int num=n;
  long long int ans=0;
  for(int i=0; i<n-1; i++){
    num--;
    const auto &pf = prime_factorize(num);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    ans+=res;
  }
  cout << ans << endl;

}


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

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc132/tasks/abc132_c

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

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

    sort(a+1, a+N+1);


    cout << a[(N/2)+1]-a[N/2] << endl;
}

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

int main(){
  int N,s=0,d=0;
  cin >>N;
  int a[100100];
  for(int i=0;i<N;i++){
    cin >>a[i];
  }
  for(int i=1;i<N;i++){
    if(a[i-1]>=a[i]){
      d++;
      if(d>s){
        s=d;
      }
    }
    if(a[i-1]<a[i]){
      d=0;
    }
  }

  cout <<s<<endl;

}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define inf 1e18
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define rep1(i,a,n) for(ll i=a;i<=(long long)n;++i)
#define rep2(i,n,a) for(ll i=n;i>(long long)a;--i)
#define rep3(i,n,a) for(ll i=n;i>=(long long)a;--i)
#define repi(i,a,n) for(int i=a;i<=(int)n;++i)
#define repl(i,a,n) for(int i=a;i<(int)n;++i)
#define PI 3.141592653589793238510
#define en '\n'
#define MAX 100005
#define less_time ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug cout<<"HERE"<<en;
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vi vc<int>
#define mii unordered_map<int,int>
#define pql priority_queue<int>
#define pqs priority_queue<int,vi,greater<int>>
#define vll vector<long long>
#define pll pair<long long,long long>
#define pl pair<int,int>
#define eb emplace_back
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace std::chrono;
vc<ll>adj[MAX];
bool vis[MAX];
vc<ll>dp(MAX,0);
void dfs(ll u)
{
  vis[u]=true;
  for(auto v:adj[u])
  {
    if(!vis[v])
     dfs(v);
    dp[u]=max(dp[u],1+dp[v]);
  }
}
int main(){
    less_time;
    memset(vis,false,sizeof vis);
    ll n,m;
    cin>>n>>m;
    ll u,v;
    repi(i,1,m)
    {
      cin>>u>>v;
      adj[u].pb(v);
    }
    repi(i,1,n)
    {
      if(!vis[i])
      dfs(i);
    }
    cout<<*max_element(all(dp));
return 0;
}


Measured memory_bytes: 7936
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main() {
    int n;
    long long int a[200005], b;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        a[i] -= i + 1;
    }

    sort(a, a+n);

    if (n % 2 == 1) b = a[(n - 1) /2];
    else b = (long long int)((a[n/2] + a[n/2 - 1]) / 2);

    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += abs(a[i] - b);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cmath>
#include <stdio.h>

using namespace std;

struct vec3d{
	double x, y, z;
	vec3d(){}
	vec3d(double a, double b, double c){
		x = a, y = b, z = c;
	}
	vec3d operator-(vec3d ope){
		return vec3d(x - ope.x, y - ope.y, z - ope.z);
	}
	double dot(vec3d ope){
		return x*ope.x + y*ope.y + z*ope.z;
	}
	double cross(vec3d ope){
		vec3d p = vec3d(y*ope.z - z*ope.y, z*ope.x - x*ope.z, x*ope.y - y*ope.x);
		double d = p.dot(p);
		if(d == 0) return 0;
		return sqrt(d);
	}
};

struct balloon{
	vec3d p;
	double r;
};

struct light{
	vec3d p;
	double b;
};

int N, M, R;
balloon B[2005];
light L[20];
vec3d E;

bool used[2005];
double bright[20];
vector<int> obst[20];

double distPP(vec3d p, vec3d q)
{
	return sqrt((p-q).dot(p-q));
}

double distLP(vec3d p, vec3d q, vec3d v)
{
	if((v-p).dot(q-p) <= 0) return distPP(p, v);
	if((v-q).dot(p-q) <= 0) return distPP(q, v);
	
	return fabs((v-p).cross(q-p) / distPP(p, q));
}

int main(void)
{
	while(1){
		cin >> N >> M >> R;
		if( N == 0 && M == 0 && R == 0) break;
		
		for(int i = 0; i < N; i++){
			cin >> B[i].p.x >> B[i].p.y >> B[i].p.z >> B[i].r;
		}
		for(int i = 0; i < M; i++){
			cin >> L[i].p.x >> L[i].p.y>> L[i].p.z >> L[i].b;
		}
		cin >> E.x >> E.y >> E.z;
		
		for(int i = 0; i < M; i++) obst[i].clear();
		
		for(int i = 0; i < M; i++){
			double d = distPP(E, L[i].p);
			bright[i] = L[i].b / (d*d);
			for(int j = 0; j < N; j++){
				if(distLP(E, L[i].p, B[j].p) < B[j].r){
					if(distPP(E, B[j].p) >= B[j].r || distPP(L[i].p, B[j].p) >= B[j].r) obst[i].push_back(j);
				}
			}
		}
		
		int n = 1 << M, cnt;
		double sum;
		double ans = 0.0;
		
		for(int s = 0; s < n; s++){
			sum = 0.0;
			for(int j = 0; j < N; j++) used[j] = false;
			for(int j = 0; j < M; j++){
				if(s & (1<<j)){
					sum += bright[j];
					for(int k = 0; k < obst[j].size(); k++) used[obst[j][k]] = true;
				}
			}
			cnt = 0;
			for(int j = 0; j < N; j++) if(used[j]) cnt++;
			if(cnt <= R) ans = max(ans, sum);
		}
		
		printf("%.8f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3368
fn main() {
    let stdin = std::io::stdin();
    let mut buf1 = String::new();
    let mut buf2 = String::new();

    stdin.read_line(&mut buf1).unwrap();
    let mut it1 = buf1.trim().split_whitespace();
    stdin.read_line(&mut buf2).unwrap();
    let mut a_vec: Vec<isize> = buf2.trim().split_whitespace()
        .map(|e| e.parse::<isize>().unwrap()).collect();

    let N: usize = it1.next().unwrap().parse().unwrap();
    let x: isize = it1.next().unwrap().parse().unwrap();

    let a0_over_x = a_vec[0] - x;
    let mut cnt = if a0_over_x > 0 { a_vec[0] = x; a0_over_x } else { 0 };
    
    for i in 0..N-1 {
        let over_x = a_vec[i] + a_vec[i+1] - x;
        if over_x > 0 {
            cnt += over_x;
            if i != N-2 {
                a_vec[i+1] -= over_x;
            }
        }
    }

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


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> last(26,-1), m(26);
  for (int i = 0; i != n; ++i) {
    auto ic = s[i] - 'a';
    m[ic] = max(m[ic], i - last[ic]);
    last[ic] = i;    
  }
  for (int i = 0; i != 26; ++i) m[i] = max(m[i], n - last[i]);
  cout << *min_element(begin(m),end(m)) - 1 << endl;
}



Measured memory_bytes: 3600
#include<stdio.h>
#define N 100
 
int main(void){
  int n,i,j,k,minj,tmp,count=0,data[N];
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&data[i]);
 
  for(i=0;i<n-1;i++){
    minj=i;
     for(j=i;j<n;j++)if(data[j]<data[minj]) minj=j;
 
     tmp=data[i];
     data[i]=data[minj];
     data[minj]=tmp;
     if(i!=minj) count++;
  }
 
  for(i=0;i<n;i++){
    printf("%d",data[i]);
    if(i!=n-1) printf(" ");
  }
 
  printf("\n%d\n",count);
  return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    bool ans = 1;
    if(s.size() == t.size() - 1){
        for(int i = 0;i < s.size();i++){
            if(t.at(i) != s.at(i)){
                ans = 0;
            }
        }
    }
    else
    {
        ans = 0;
    }

    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double EPS = 1e-6 ; 
signed main(){
    fastio
    int a , b ; 
    cin >> a >> b ; 
    for(int i = 1; i < 1e6; i++){
        if ( (i * 8) / 100 == a && (i * 10) / 100 == b  ){
            cout << i << endl;
            return 0 ; 
        }
    }
    cout << -1 << endl;
    return 0; 
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def find(S, val):
    left = 0
    right = len(S) - 1
    while left < right:
        mid = (left+right) // 2
        if S[mid] == val:
            return True
        elif S[mid] < val:
            left = mid+1
        else:
            right = mid-1
    return S[left] == val


def solv(S, T):
    count = 0
    for val in T:
        a = find(S, val)
        count += a
    return count


if __name__ == "__main__":

    _ = input()
    S = list(map(int, input().split()))
    _ = input()
    T = map(int, input().split())

    ans = solv(S, T)

    print(ans)



Measured memory_bytes: 16712
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
string arr[1111];
int dp[1111][1111],n,m;
int main(void){
	for(int e=0;e<1111;e++) for(int p=0;p<1111;p++) dp[e][p] = 1e9;
	scanf("%d%d",&n,&m);
	int x1,y1,x2,y2;
	scanf("%d%d%d%d",&y1,&x1,&y2,&x2);
	x1--;
	y1--;
	x2--;
	y2--;
	for(int e=0;e<n;e++) cin >> arr[e];
	deque<pi> q;
	q.push_front(mk(y1,x1));
	dp[y1][x1] = 0;
	while(!q.empty()){
		int y = q.front().x;
		int x = q.front().y;
		q.pop_front();
		for(int e=0;e<4;e++){
			int nexty = y + dy[e];
			int nextx = x + dx[e];
			if(isrange(nexty,nextx,n,m)&&arr[nexty][nextx]!='#'){
				if(dp[nexty][nextx]>dp[y][x]){
					dp[nexty][nextx] = dp[y][x];
					q.push_front(mk(nexty,nextx));
				}
			}
		}
		for(int e=y-2;e<=y+2;e++){
			for(int p=x-2;p<=x+2;p++){
				if(isrange(e,p,n,m)&&arr[e][p]!='#'){
					if(dp[e][p]>dp[y][x]+1){
						dp[e][p] = dp[y][x] + 1;
						q.push_back(mk(e,p));
					}
				}
			}
		}
	}
	if(dp[y2][x2]==1e9) printf("-1");
	else printf("%d",dp[y2][x2]);
	return 0;
}


Measured memory_bytes: 10556
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <functional>

using namespace std;

int main(){

	int K, T, a[101], i, r;
	int max = 0;

	cin >> K >> T;
	
	for(i = 0; i < T; i++){
		cin >> a[i];
	}

	for(i = 0; i < T; i++){
		if(max < a[i]) max = a[i];
	}

	if(T == 1)
		r = K - 1;
	else if(K - max < max - 1)
		r = max - 1 - (K - max);
	else
		r = 0;

	cout << r << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  if (x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long lli;
 
int main() {
  lli a, b, c;
  int re, hi;
  re = hi = 0;
  while(scanf("%lld,%lld,%lld", &a, &b, &c) != EOF) {
    if(a*a+b*b == c*c) ++re;
    if(a == b) ++hi;
  }
  cout << re << endl;
  cout << hi << endl;
  return 0;
}

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

int sumsum(int a) {
	int b = 0;
	while (a > 0) {
		b += a % 10;
		a /= 10;
	}

	return b;
}

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

	if(n%sumsum(n)==0)	cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;



int main(){

	int n,ans[3];
	cin >> n;
	ans[0] = n / 100;
	n %= 100;
	ans[1] = n / 10;
	n %= 10;
	ans[2] = n;
	rep(i, 3) {
		if (ans[i] == 1) ans[i] = 9;
		else if (ans[i] == 9) ans[i] = 1;
	}

	n = 100 * ans[0] + 10 * ans[1] + ans[2];

	cout << n << endl;

	return 0;
}


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



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


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> count(M,0);
    rep(i,N){
        ll K;
        cin >> K;
        rep(j,K){
            ll temp;
            cin >> temp;
            count[temp-1]++;
        }
    }

    ll ans=0;
    rep(i,M){
        if(count[i] == N){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
class Challenge
	def go
		loop do
			@array = Array.new(21).map! { Array.new(21,0) }
			number = gets.to_i
			break if number == 0
			set(number)
			move
			puts (@array.select { |x| x.include?(1) == true }.size == 0)? "Yes" : "No"
		end
	end

	def set(number)
		number.times do 
			line = gets.split.map(&:to_i)
			@array[line[0]][line[1]] = 1
		end
	end

	def move
		x=10
		y=10
		gets.to_i.times do
			line = gets.split
			line[1].to_i.times do
				case line[0]
					when "N"; y+=1
					when "E"; x+=1
					when "S"; y-=1
					when "W"; x-=1
				end
				@array[x][y] = 0;
			end
		end
	end
end
Challenge::new.go()

Measured memory_bytes: 6132
#include<cstdio>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b && b < c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2624
#include<iostream>
using namespace std;
int w[1000]={0};
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    w[a]++;
    w[b]++;
    w[c]++;
    if(w[5]==2&&w[7]==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
w=[1 if s[0]=='W' else 0]+[0]*(n-1)
e=[0]*(n-1)+[1 if s[n-1]=='E' else 0]
for i in range(n-1):
    if s[i+1]=='W':
        w[i+1]=w[i]+1
    else:
        w[i+1]=w[i]
    if s[n-2-i]=='E':
        e[n-2-i]=e[n-1-i]+1
    else:
        e[n-2-i]=e[n-1-i]
r=n
for i in range(n):
    r=min(r,w[i]+e[i]-1)
print(r)

Measured memory_bytes: 19936
N,M=map(int,input().split())
X=list(map(int,input().split()))

X.sort()
diff=[]
for i in range(M-1):
    diff.append(X[i+1]-X[i])
diff.sort()
to=M-N
if to<=0:
    ans=0
else:
    ans=sum(diff[:to])
print(ans)

Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#include <iomanip>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	int a = 0, b = 0, sc = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'g') {
			if (a < b) {
				a++;
				sc += 1;
			}
			else {
				b++;
			}
		}
		else {
			if (a < b) {
				a++;
			}
			else {
				b++;
				sc -= 1;
			}
		}
	}
	cout << sc;
}
				


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

using namespace std;

int main(){
    string T;

    cin >> T;

    for(int i = 0; i<T.size(); i++){
        if(i==0 && T[i]=='?'){
            T[i] = 'D';
        }
        if(i==T.size() && T[i]=='?'){
            T[i] = 'D';
        }
        if(T[i] == '?'){
            if(T[i-1] == 'D' && T[i+1] == 'D'){
                T[i] = 'P';
            }else{
                T[i] = 'D';
            }
        }
    }

    cout << T << endl;

    return 0;
}

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

int main(){
  int dn[26] = {0};
  string s;
  cin >> s;
  for (int i=0;i<s.size();i++){
    dn[s[i]-'a']++; 
  } 
  int ind = find(dn, dn+26, 0) - dn;
  
  if (ind < 26) cout << (char)('a' + ind) << endl;
  else cout << "None" << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

lli i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
bool func(pair< pair<string,int>,int> p1,pair< pair<string,int>,int> p2 )
{
	if(p1.fi.fi!=p2.fi.fi) return p1.fi.fi<p2.fi.fi;
	else return p1.fi.se>p2.fi.se;
 }
void solve()
{
	int n; cin>>n;
	vector < pair< pair< string,int> , int > > v;
	rep(i,1,n)
	{
		string s; int p; cin>>s>>p;
		v.pb({{s,p},i});
	}
	sort(all(v),func);
	rep(i,0,sz(v)-1)
	 cout<<v[i].se<<"\n";
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> ans1(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(ans1[i]=0;a[i]%2==0;ans1[i]++){
            a[i]/=2;
        }
    }
    int ans=ans1[0];
    for(int i=1;i<n;i++){
        if(ans1[i]<ans)ans=ans1[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int late = Integer.parseInt(sc.nextLine());
		int kyuu = 8;
		for (int i = 599; i < 2000; i = i + 200) {
			if (late <= i) {
				System.out.println(kyuu);
				break;
			}
			kyuu--;
		}
	}

}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;


int32_t main(){

    long double d, t , s ,x  ; cin >> d >> t >> s;
    x = d / s;
    // cout << d << ' ' << t << ' ' << s << ' ' << x << endl;
    if(x <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3664
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;



int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r;
    }   else {
        cout << r + 100 * (10 - n);
    }
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#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;
typedef long long ll;
// 区間加算、区間合計クエリ
template <typename F,typename T>
struct DST{
  T identity;
  F merge;
  int size;
  vector<T> dat,delay;
  
  DST(F f,T id):merge(f),identity(id){}

  void eval(int k,int l,int r){
    if(delay[k] != 0){
      dat[k] += delay[k];
      if(k<size-1){
	delay[2*k+1] += delay[k]/2;
	delay[2*k+2] += delay[k]/2;	
      }
      delay[k]=0;
    }
  }

  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
    delay.resize(size*2-1,0);    
  }

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

  void update(int a,int b,T x,int k,int l,int r){
    eval(k,l,r);

    if(r<=a||b<=l) return ;
    if(a<=l&&r<=b){
      delay[k] += (r-l)*x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    eval(k,l,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 all_eval(){
    rep(i,2*size-1){
      eval(i,0,0);
    }
  }

  T get(int k){ return dat[size-1+k];}
  
  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;
    }
    index = 0;
    num = 1;
    while(index<size){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  

  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<ll> c(q),s(q),t(q),x(q);
  rep(i,q){
    cin >> c[i];
    if(c[i]==0) cin >> s[i] >> t[i] >> x[i];
    else cin >> s[i] >> t[i];
  }

  auto f = [&](ll a,ll b){ return a+b;};
  ll id = 0;
  DST<decltype(f),ll> dst(f,id);
  dst.init(n);
  rep(i,q){
    if(c[i]==0) dst.update(s[i],t[i]+1,x[i],0,0,dst.size);
    else cout << dst.query(s[i],t[i]+1,0,0,dst.size) << "\n";
  }
  
  return 0;
}



Measured memory_bytes: 9984
#include <iostream>
using namespace std;
int main(){
	char s[10];
	for (int i = 0; i <= 5; i++)
		cin >> s[i];
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
p = nfa()

dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0
for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * p[i]
        dp[i + 1][j] += dp[i][j] * (1.0 - p[i])

ans = sum([dp[n][j] for j in range(n // 2 + 1, n + 1)])
print(ans)

Measured memory_bytes: 253960
#define lop(i, n) for (int i = n-1; i >= 0; i--)
#define loop(i, x) for (int i = 0; i < x; i++)
#define loopf(i, x, n) for (int i = x; i < n; i++)
#define loopr(i, x, n) for (int i = x - 1; i >= n; i--)
#define ain(arr, n) for (int i = 0; i < n; i++) cin>>arr[i]
#define aout(arr, n) for (int i = 0; i < n; i++) cout<<arr[i]<<" "
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef complex<int> ci;

int main()
{
	ios_base::sync_with_stdio(false);
	int n,y;
	cin>>n>>y;
	y/=1000;
	int a,b,c;
	bool found = false;
	loop(i, n+1)
	{
		if (found)break;
		loop(j, n+1)
		{
			int z = n - i - j;
			if (z < 0)
				break;
			if (i*1 + j*5 + z*10 == y)
			{
				found = true;
				a = i, b = j, c = z;
				break;
			}
		}
	}
	if (found == false)
		cout<<-1 _ -1 _ -1<<"\n";
	else cout<<c _ b _ a<<"\n";
	return 0;
}




Measured memory_bytes: 256
import kotlin.math.PI

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val K = readInt()
    val (A, B) = readInts()
    println(if ((A..B).any { it % K == 0 }) "OK" else "NG")
}


Measured memory_bytes: 36560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint t(N+1),x(N+1),y(N+1);
    t[0]=x[0]=y[0]=0;
    for(int i=1;i<=N;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    
    bool ok=true;
    REP(i,N){
        int dt=t[i+1]-t[i];
        int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);

        if(dt<dist or dt%2!=dist%2){ 
            ok=false; break;
        }
    }
    cout<<(ok? "Yes":"No")<<endl;
    
}


Measured memory_bytes: 2560