akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){
	char a[1009],b[1009],c[1009];
	scanf("%s%s",a,b);
	int aa=strlen(a);
	int bb=strlen(b);
	if(aa!=bb){
		if(aa>bb)printf("GREATER\n");
		else if(aa<bb)printf("LESS\n");
	}
	else{
		int f = 1;
		for(int i = 0;i<aa;i++){
			if(a[i]!=b[i]){
				if(a[i]>b[i])printf("GREATER\n");
				else if(a[i]<b[i])printf("LESS\n");
				f = 0;
				break;
			}
		}	
		if(f)printf("EQUAL\n");
	}
	
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a%3 == 0)
    {
        cout << "Possible" << endl;
    }
    else if (b%3==0)
    {
        cout << "Possible" << endl;

    }
    else if ((a+b) % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;
use std::io::{Write, BufWriter};

// static MOD: usize = 998244353;
static MOD: usize = 1000000007;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! println_stderr(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

struct graph {

}

fn diameter(edge: &Vec<Vec<usize>>) -> (usize, usize, i64) {
    let n = edge.len();
    let mut result = vec![0;n];
    dfs(0,n,0,&edge,&mut result);
    let (s,_) = result.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap();
    result = vec![0; n];
    dfs(s,n,0,&edge,&mut result);
    let (t,val) = result.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap(); 
    (s,t,*val)
}

fn dfs(s: usize, p: usize, dist: i64, edge: &Vec<Vec<usize>>, result: &mut Vec<i64>) {
    result[s] = dist;
    for &e in &edge[s] {
        if p==e {continue;}
        dfs(e, s, dist+1, edge, result);
    }
}

fn solve() {
    input! {
        n: usize,
        st: [(usize,usize);n-1],
    }  
    let mut edge = vec![vec![];n];
    for (s,t) in st {
        edge[s-1].push(t-1);
        edge[t-1].push(s-1);
    }
    let (s,t,val) = diameter(&edge);
    if val%3==1 {println!("Second");}
    else {println!("First");}
    println_stderr!("{} {} {}", s, t, val);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 37116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

struct point {
    int x, y;
};
int distance(point a, point b) {
    return abs(a.x-b.x) + abs(a.y-b.y);
}
int main() {
    int n,m; cin >> n >> m;
    vector<point> stu(n),che(m);
    rep(i,n) cin >> stu[i].x >> stu[i].y;
    rep(i,m) cin >> che[i].x >> che[i].y;
    rep(i,n) {
        int ans;
        int minD = 1<<30;
        int index = 0;
        rep(j,m) {
            int d = distance(stu[i],che[j]);
            if (d < minD) {
                minD = d; index = j;
            }
        }
        cout << index+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import queue

H, W = map(int, input().split())
S = []

for _ in range(H):
    S.append(list(input()))

SS = []
for _ in range(H):
    SSS = []
    for __ in range(W):
        SSS.append(-1)
    SS.append(SSS)

SS[0][0] = 0

sp = (0, 0, 0)
dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

q = queue.Queue()
q.put(sp)

ans = -1
complete = False
while not q.empty():

    n = q.get()
    if n[0] == W-1 and n[1] == H-1:
        ans = n[2]
        complete = True
        break

    for d in range(4):
        nx = n[0] + dx[d]
        ny = n[1] + dy[d]

        if W > nx >= 0 and H > ny >= 0 and SS[ny][nx] == -1 and S[ny][nx] != '#':
            q.put((nx, ny, n[2]+1))
            SS[ny][nx] = n[2] + 1

wcnt = 0
for _ in range(H):
    for __ in range(W):
        if S[_][__] == '.':
            wcnt += 1
if complete:
    print(wcnt - ans - 1)
else:
    print(-1)

Measured memory_bytes: 9712
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

double k, l, r, p, e, t;
double rec(int k, double l, double r){
	if(l >= t - e && r <= t + e) return 1.0;
	if(r < t - e || l > t + e) return 0.0;
	if(k == 0) return abs(t - (l + r) / 2) <= e ? 1.0 : 0.0;
	
	double m = (l + r) / 2, res = 0;
	if(m < t){
		res += rec(k - 1, m, r) * (1 - p);
		res += rec(k - 1, l, m) * p;
	}
	else{
		res += rec(k - 1, l, m) * (1 - p);
		res += rec(k - 1, m, r) * p;
	}
	return res;
}
int main(){
	cin >> k >> l >> r;
	cin >> p >> e >> t;
	double ans = rec(k, l, r);
	printf("%.9f\n", ans);
	return 0;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

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

ll H;
int main () {
    cin >> H;
	ll cnt = 1, ans = 0;
	while (H > 0) {
		ans += cnt;
		H /= 2;
		cnt *= 2;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 504
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
print((1000 - n) % 1000)


Measured memory_bytes: 68376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <set>
#include <map>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

int main() {
    VI v;
    int n;
    cin >> n;
    REP(i,n) {
        long a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    if (n == 2) {
        cout << v.back() << " " << v.front() << endl;
        return 0;
    }
    long big = v.back();
    long a = *(lower_bound(v.begin(), v.end(), big / 2) - 1);
    long b = *lower_bound(v.begin(), v.end(), big / 2);
    if (abs(a - big / 2) < abs(b - big / 2)) {
        cout << big << " " << a << endl;
        return 0;
    } else {
        cout << big << " " << b << endl;
    }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,A,B;
  cin >> N >> A >> B;
  vector<int> t(N);
  rep(i,N) cin >> t[i];
  int count = 0;
  rep(i,N)
  {
    if(t[i]<A||t[i]>=B)
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

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

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

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

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

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

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

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

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

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

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

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

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),a=read(),b=read(),c=read(),d=read();
	REP(i,n){
		int x=a+c*i-(n-1-i)*d,y=a+d*i-(n-1-i)*c;
		if(x<=b&&b<=y){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = []
dict = {}
for i in range(1, n+1):
    dict[i] = 0
for i in range(m):
    a, b = map(int, input().split())
    dict[a] += 1
    dict[b] += 1
for i in range(1, n+1):
    print(dict[i])

Measured memory_bytes: 3060
import java.util.Scanner;
public  class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[26];
    String str = sc.next();
    char[] ch = str.toCharArray();
    for(int i = 0; i < ch.length; i++){
      a[ch[i]-'a']++; 
    }
    for(int i = 0; i < a.length; i++){
      if(a[i] == 0){
    	  char ans = (char) (i + 'a');
        System.out.println(ans);
        return;
      }
    }
    System.out.println("None");
  }
}

Measured memory_bytes: 27880
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

list<int> Prime(int num) {
	list<int>P;
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	P.push_front(3);
	P.push_front(2);
	return P;
}

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

	list<int>P = Prime(1000000);
	vector<bool>flag(1000001);
	for (auto i : P) {
		if (i > 1000000) {
			break;
		}
		flag[i] = true;
	}
	cin >> N;
	vector<int>v(N + 4);
	v[0] = 0;
	v[N + 1] = MOD;
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	vector<long long int>dp(N + 4);
	dp[0] = 1;
	for (int i = 0; i <= N; i++) {
		if (!i){
			if (flag[v[1]]) {
				dp[1] = 1;
			}
			continue;
		}
		if (v[i] < v[i + 1]) {
			if (v[i + 1] == MOD || flag[v[i + 1]]) {
				dp[i + 1] += dp[i];
				dp[i + 1] %= MOD;
			}
		}
		if (v[i] < v[i + 2]) {
			if (v[i + 2] == MOD || flag[v[i + 2]]) {
				dp[i + 2] += dp[i];
				dp[i + 2] %= MOD;
			}
		}
	}
	cout << dp[N + 1] << endl;
	return 0;
}


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

int main() {
    int k, i, j, l, m,ans = 0;
    cin >> k;
    for(i = 1; i <= k; i++){
        for(j = 1; j <= k; j++){
            for(l = 1; l <= k; l++){
                int small = min(min(i,j), l);
                int gcd = 1;
                for(m = 2; m <= small; m++){
                    if(i % m == 0 && j % m == 0&&l % m == 0) gcd = m;
                }
                ans += gcd;
            }
        }
    }
    cout << ans << endl;
}

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

long long int f(int n, int W, vector<long long int> &w, vector<long long int> &v)
{
    vector<vector<long long int>> dp(n+1, vector<long long int>(W+1, 0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=W; j++){
            if(j-w[i-1]>=0)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            else
                dp[i][j] = dp[i-1][j];
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    return dp[n][W];
}


int main()
{
    int n, W;
    cin >> n >> W;
    vector<long long int> w(n);
    vector<long long int> v(n);
    for(int i=0; i<n; i++)
        cin >> w[i] >> v[i];
    
    cout << f(n, W, w, v) << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, b, q;
    cin >> n >> b >> q;
    for(int i = b; i < 100000; i += b) {
        if(i >= n) {
            cout << (i * q) / b;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3688
#pragma region Header

#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

template <typename T>
int SZ(T x)
{
    return static_cast<int>(x.size());
}

#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n; cin >> n;
    vector<int> x_s(n);
    rep(i, n)
    {
        cin >> x_s[i];
    }
    int ans = 100'00'00;
    FOR(p, 1, 101)
    {
        int ans1 = 0;
        for (auto x : x_s)
        {
            ans1 += (x - p) * (x - p);
        }
        ans = min(ans, ans1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>


int numOfDigits(long n) {
    int cnt = 0;
    while (n != 0) {
        cnt += 1;
        n = n / 10;
    }
    return cnt;
}

int main() {

    long N;
    std::cin >> N;

    std::vector<int> ps;
    for (long i = 1; i * i <= N; ++i) {

        if (N % i == 0) {
            ps.push_back(numOfDigits(N / i));
        }
    }

    std::cout << *std::min_element(ps.begin(), ps.end()) << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = 800 * n;
        int y = (n - (n % 15)) / 15 * 200;
        System.out.println(x - y);
    }
}

Measured memory_bytes: 35592
import java.util.HashSet;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    HashSet<Integer> S = new HashSet<Integer>();
    HashSet<Integer> T = new HashSet<Integer>();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 0; i < n; i++)
	S.add(sc.nextInt());
    int q = sc.nextInt();
    for(int i = 0; i < q; i++)
	T.add(sc.nextInt());
    int count = 0;
    for(Integer T1 : T)
	if(S.contains(T1)) count++;
    System.out.println(count);
    }
}


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

int main() {
	int n,a=0,count=0;
	cin>>n;
	int arr[n];
	cin>>arr[0];
	for(int i=1;i<n;i++)
	{
	    cin>>arr[i];
	    if(arr[i]<=arr[i-1])
	    {
	        count++;
	    if(a<count)
	    {
	        a=count;
	    }
	    }
	    else
	    count=0;
	    
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 640
fn main() {
    let (n,k) = {
        let s =rv::<u64>();
        (s[0],s[1])
    };
    let mut c=1;
    let mut h=1;
    let mut t=1;
    for i in 1..std::cmp::min(n,k+1) {
        let j =inv(i);
        c=c*(n+1-i)%MOD*j%MOD;
        h=h*(n-i)%MOD*j%MOD;
        t=(t+c*h)%MOD;
    }
    println!("{}",t);
}
const MOD: u64=1000000007;
fn inv(mut a: u64) -> u64 {
    let mut n=MOD-2;
    let mut b=1;
    while n>0 {
        if n&1==1 {
            b=b*a%MOD;
        }
        a=a*a%MOD;
        n>>=1;
    }
    b
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    string s, t;
    cin >> s;
    cin >> t;

    int n = s.size(), m = t.size();

    vector<vector<int>> is(26);
    REP(i, n)
    is[s[i] - 'a'].push_back(i);
    REP(i, n)
    is[s[i] - 'a'].push_back(i + n);

    ll ans = 0;
    int p = 0;

    REP(i, m)
    {
        int c = t[i] - 'a';
        if (sz(is[c]) == 0)
        {
            puts("-1");
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n)
        {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7, LOG = 61;
const ll INF = 1e18;

ll a, b, ans;
int main()
{                         
	cin >> a >> b;
	if(a == b)
		ans = 1;
	for(int i = LOG - 1; i >= 0; i--){
		if((b >> i) & 1){
			if((a >> i) & 1){  
				a ^= (1ll<< i);
				b ^= (1ll<< i);
				continue;
			}
			ll x = (1ll << i);
			ans += (x - a);
			
			b ^= x;                                   
			for(int j = LOG - 1; j > 0; j--)
				if((b >> j) & 1)
					b |= (1ll << (j - 1));	

			if(b >= a)
				ans += x;
			else
				ans += (x - a) + b + 1;
			break;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
int main()
{
ios_base::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
 cout.precision(15);
ll int n;
cin>>n;
vector<double>p(n);
rep(i,0,n)
cin>>p[i];
double dp[n+1][n+1];
dp[0][0]=1;
rep(i,1,n+1)
dp[0][i]=0;
rep(i,1,n+1)
{
dp[i][0]=1;
rep(j,0,i)
dp[i][0]*=(1-p[j]);
}
rep(i,1,n+1)
{
rep(j,1,n+1)
{dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);}	
}
double c=0;
rep(j,n/2+1,n+1)
c+=dp[n][j];
cout<<c;
}


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

int main(){
    int N, M; 
    int x, y, z;
    int Max=0;
    cin >> N >> M;

    for(int i = 0; i <= N; i++){
        if(M-i<0) break;
        for(int j = 0; j <= N; j++){
            if (0<= M-i-j && M-i-j<=N) {
                Max++;
            }
            if(M-i-j<0) break;
        }   
    }

    cout << Max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int main(){
    int x;
    cin>>x;
    if(x) cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3512
S = input()
s = S[::-1]
a = "dream"[::-1]
b = "dreamer"[::-1]
c = "erase"[::-1]
d = "eraser"[::-1]

idx = 0
ans = "YES"
while idx < len(s):
    if s[idx] == "m":
        if s[idx : idx + 5] == a:
            idx = idx + 5
        else:
            ans = "NO"
            break

    elif s[idx] == "e":
        if s[idx : idx + 5] == c:
            idx = idx + 5
        else:
            ans = "NO"
            break

    elif s[idx] == "r":
        if s[idx : idx + 7] == b:
            idx = idx + 7
        elif s[idx : idx + 6] == d:
            idx = idx + 6
        else:
            ans = "NO"
            break

    else:
        ans = "NO"
        break

print(ans)

Measured memory_bytes: 9264
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

#define d7 1000000007
#define l7 998244353
vector<ll> primes;

int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    
    ll n;
    cin>>n;
    ll k=n/500;
    cout<<(1000*k+5*((n%500)/5));
    
//code ends
    return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

B = (4,6,9,11)
C = (1,3,5,7,8,10,12)
if x==y==2:
  print("Yes")
elif x in B and y in B:
  print("Yes")
elif x in C and y in C:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

int main() {
	int w, h;
	while(cin >> w >> h, w) {
		vvi field(h, vi(w));

		int xs, ys, xg, yg, n;
		cin >> xs >> ys >> xg >> yg >> n;
		
		int c, d, x, y;
		REP(i, n) {
			cin >> c >> d >> x >> y;
			
			REP(j, 4) {
				REP(k, 2) {
					if(!d) {
						field[y-1+k][x-1+j] = c;
					} else {
						field[y-1+j][x-1+k] = c;
					}
				}
			}
		}

		bool goal = false;
		int color = field[ys-1][xs-1];
		stack<pii> S;
		S.push(make_pair(xs-1, ys-1));
		vvi visit(h, vi(w));
	
		if(color == 0) {
			goto show;
		}

		while(!S.empty()) {
			pii p = S.top();
			S.pop();

			visit[p.second][p.first] = 1;
			if(p.first == xg-1 && p.second == yg-1) {
				goal = true;
				goto show;
			}
			
			REP(d, 4) {
				int nx = p.first + dx[d];
				int ny = p.second + dy[d];

				if(0<=nx && nx<w && 0<=ny && ny<h && field[ny][nx] == color && !visit[ny][nx]) {
					S.push(make_pair(nx, ny));
				}
			}
		}

show:
		cout << (goal ? "OK" : "NG") << endl;
	}

	return 0;
}

Measured memory_bytes: 1296
use std::io::stdin;

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    let x: u64 = line.trim().parse().unwrap();
    let ans = x / 11 * 2;
    match x % 11 {
        0 => println!("{}", ans),
        1...6 => println!("{}", ans + 1),
        _ => println!("{}", ans + 2),
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000009;
#define PI 3.14159265
int dp[100005];
int main()
{
    fastio;
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    dp[0] = 0;
    for(int i=1;i<n;i++)
    {
        if(i==1)
            dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        else
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
num_list = input().split(' ')
N = int(num_list[0])
A = int(num_list[1])
B = int(num_list[2])
total = 0
for n in range(N+1):
  calc_num = 0
  for s in str(n):
    calc_num += int(s)
  if A <= calc_num <= B:
    total += n
print(total)

Measured memory_bytes: 9072
def main():
    N,Y = [int(x) for x in input().split()]
    for x in range(N+1):
        if 10000*x > Y:
            break
        for y in range(N+1):
            if 10000*x+5000*y > Y:
                break
            z = N-(x+y)
            if z < 0 or z > N:
                continue
            # print(x,y,z,Y,10000*x+5000*y+1000*z)
            if Y == 10000*x+5000*y+1000*z:
                print(x,y,z)
                return
    print(-1,-1,-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N,M=map(int,input().split(' '))
AC=[0]*N
WA=[0]*N
for i in range(M):
    p,s=input().split(' ')
    p=int(p)
    if s=='AC':
        AC[p-1]=1
    elif not AC[p-1]:
        WA[p-1]+=1
print(sum(AC),sum([i if j==1 else 0 for i,j in zip(WA,AC)]))

Measured memory_bytes: 5528
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;




int main(){
    int N;cin >> N;
    vector<int> a(N);
    map<int,int> ma;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    sort(RALL(a));
    int ans=0;
    for (int i = 0; i < N; i++) {
        if(!ma[a[i]]) continue;
        int k=0;
        int s=a[i];
        while(s){
            s/=2;
            k++;
        }
        int t=(1<<(k))-a[i];
        if(a[i]==t){
          if(ma[t]>1){
            ans++;
            ma[t]-=2;
          }
        }
        else if(ma[t]){
            ans++;
            ma[t]--;
            ma[a[i]]--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19712
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    while(true){
	    	int x = Integer.parseInt(std.next());
	    	int y = Integer.parseInt(std.next());
	    	if(x!=0 || y!=0){
	    		if(x>y){int temp = x;x=y;y=temp;}
	    		System.out.println(x+" "+y);
	    	}else{
	    		break;
	    	}
	    }
	}}

Measured memory_bytes: 36228
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin >>s;
  	int max=0;
  	int count=0;
  	for(int i=0;i<s.size();i++){
    	if(s[i]=='R'){
          count++;
        }
      	else{
        	count=0;
        }
      	if(max<count){
          	max=count;
        }
    }
	cout << max << endl;
}

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

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

    set<string> ss;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size() << endl;
}


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    ll x;
    cin >> x;
    if(x%2==0 && x!=2)x++;
    while(1){
        bool fin = true;
        for(ll i=2;i*i<x;i++){
            if(x%i==0)fin = false;
        }
        if(fin){
            cout << x << endl;
            return 0;
        }
        x+=2;
    }
}


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

using namespace std;

int main() {
  int N, X, Y;
  cin >> N;
  cin >> X;
  cin >> Y;
  
  vector <int> ans(N, 0);
  
  for (int i = 1; i <= N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      int l = min(j - i, abs(i - X) + 1 + abs(j - Y));
      ans[l]++;
    }
  }
  
  for (int i = 1; i < N; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
// Example program
#include <iostream>
using namespace std;

int main()
{
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1){
            cout << "F" << endl;
        } else if (f == -1){
            cout << "F" << endl;
        } else if (m + f >= 80){
            cout << "A" << endl;
        } else if (65 <= m + f){
            cout << "B" << endl;
        } else if (50 <= m + f){
            cout << "C" << endl;
        } else if (30 <= m + f && r < 50){
            cout << "D" << endl;
        } else if (30 <= m + f && r >= 50){
            cout << "C" << endl;
        } else {
            cout << "F" << endl;
        }
    }
    return 0;
}



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

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

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

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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 1e5 + 5;

vector<pair<ll, ll>> adj[MAXN];
ll dis[MAXN];
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;

int N, Q, K;

void dijkstra(int start) {
    fill(dis, dis+N+1, 1LL*1e18);
    pq.push({0, start});
    while(sz(pq)) {
        pair<ll, ll> cur = pq.top();
        pq.pop();
        for(pair<ll, ll> v : adj[cur.second]) {
            if(v.first+cur.first > dis[v.second]) continue;
            dis[v.second] = v.first + cur.first;
            pq.push({dis[v.second], v.second});
        }
    }
}

void solve() {
    cin >> N;
    for(int i=0; i<N-1; i++) {
        ll a, b, c; cin >> a >> b >> c;
        adj[a].pb({c, b});
        adj[b].pb({c, a});
    }
    cin >> Q >> K;
    dijkstra(K);
    while(Q--) {
        int a, b;
        cin >> a >> b;
        cout << dis[a] + dis[b] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 11120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

vector<P> v1;

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        v1.push_back(make_pair(a,0));
    }
    sort(v1.begin(),v1.end());
    for(i=0;i<n;i++){
        v1[i].second=i;
    }
    int s=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            a=v1[i].first+v1[j].first;
            auto itr=lower_bound(v1.begin(),v1.end(),make_pair(a,-1));
            itr--;
            b=itr->second-j;
            if(b>0)s+=b;
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
local day = io.read("*n")
local c = {}
for i = 1, 26 do
  c[i] = io.read("*n")
end
local s = {}
for id = 1, day do
  s[id] = {}
  for i = 1, 26 do
    s[id][i] = io.read("*n")
  end
end

local scores = {}
local penalties = {}
for i = 1, 26 do
  scores[i] = 0
  penalties[i] = 0
end
local function solveAll(t)
  local lastday = {}
  for i = 1, 26 do lastday[i] = 0 end
  for id = 1, day do
    local pid = t[id]
    scores[pid] = scores[pid] + s[id][pid]
    lastday[pid] = id
    for i = 1, 26 do
      penalties[i] = penalties[i] + c[i] * (id - lastday[i])
    end
  end
end
local function solveDiff(t, iday, pto)
  local pfrom = t[iday]
  scores[pfrom] = scores[pfrom] - s[iday][pfrom]
  scores[pto] = scores[pto] + s[iday][pto]
  t[iday] = pto
  penalties[pfrom] = 0
  penalties[pto] = 0
  local ld = {}
  for i = 1, 26 do ld[i] = 0 end
  for id = 1, day do
    local p = t[id]
    ld[p] = id
    for ip = pfrom, pto, (pto - pfrom) do
      penalties[ip] = penalties[ip] + c[ip] * (id - ld[ip])
    end
  end
end

local function solveSum()
  local z = 0
  for i = 1, 26 do z = z + scores[i] - penalties[i] end
  return z
end

local t = {}
for id = 1, day do
  t[id] = 1 + (id % 26)
end
solveAll(t)
local score = solveSum()
math.randomseed(1)
local iter = 1
local random = math.random
while os.clock() < 1.85 do
  iter = iter + 1
  local changeday = random(1, 365)
  local changeto = random(1, 25)
  local changefrom = t[changeday]
  if changefrom <= changeto then
    changeto = changeto + 1
  end
  solveDiff(t, changeday, changeto)
  local tmp = solveSum()
  if score < tmp then
    score = tmp
  else
    solveDiff(t, changeday, changefrom)
  end
end
-- print(iter)
print(table.concat(t, "\n"))


Measured memory_bytes: 3120
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > PY(M); 
    for (int i = 0; i < M; i++) {
        int p, y; cin >> p >> y;
        PY[i] = {y, p, i};
    }
    sort(PY.begin(), PY.end());
    map<int, int> city;
    vector<long long> ans(M);
    for (int i = 0; i < M; i++) {
        city[PY[i][1]]++;
        int j = city[PY[i][1]];
        ans[PY[i][2]] = j + (long long)1e6 * PY[i][1];
    }
    for (int i = 0; i < M; i++) {
        cout << setfill('0') << right << setw(12) << ans[i] << endl;
    }
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define MOD 998244353

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int64_t judge(int n, int *a, int *b) {
	for (int i = 0; i < n; i++) if (a[i] > b[i]) return -1;
	std::set<int> all;
	for (int i = 0; i < n; i++) {
		int prev = (i - 1 + n) % n;
		int next = (i + 1) % n;
		int sum = b[prev] + b[next];
		if (b[i] > sum) all.insert(i);
	}
	int64_t res = 0;
	while (all.size()) {
		int i = *all.begin();
		all.erase(i);
		int prev = (i - 1 + n) % n;
		int next = (i + 1) % n;
		int sum = b[prev] + b[next];
		if (b[i] >= sum) {
			int yo = b[i] - a[i];
			res += yo / sum;
			b[i] -= yo / sum * sum;
			int pprev = (prev - 1 + n) % n;
			int nnext = (next + 1) % n;
			if (b[prev] > b[pprev] + b[i]) all.insert(prev);
			if (b[next] > b[nnext] + b[i]) all.insert(next);
		}
	}
	for (int i = 0; i < n; i++) if (a[i] != b[i]) return -1;
	return res;
}


int main() {
	int n = ri();
	int a[n], b[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	for (int i = 0; i < n; i++) b[i] = ri();
	std::cout << judge(n, a, b) << std::endl;
	return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();

            Array.Sort(s);

            long ans = 0;
            long target = s[0];
            long cnt = 1;
            if (n == 1)
            {
                WriteLine(s[0] == 1 ? "0":"1");
                return;
            }
            for (int i = 1; i < n; i++)
            {
                if (target == s[i])
                {
                    cnt++;
                }
                else
                {
                    if (cnt < target)
                    {
                        ans += cnt;
                    }
                    else if (cnt > target)
                    {
                        ans += cnt - target;
                    }
                    //初期化
                    target = s[i];
                    cnt = 1;
                }
                if (i == n-1)
                {
                    if (cnt < target)
                    {
                        ans += cnt;
                    }
                    else if (cnt > target)
                    {
                        ans += cnt - target;
                    }
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 25564
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

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

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll n,x,t;
	cin>>n>>x>>t;
	ll z=ceil((double)n/x);

	cout<<z*t;
	return 0;
}


Measured memory_bytes: 3700
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,h = li()
alis = []
blis = []
for _ in range(n):
    a,b = li()
    alis.append(a)
    blis.append(b)
    
amax = max(alis)
blis.sort()
buse = []
while blis:
    cur = blis.pop()
    if cur > amax:
        buse.append(cur)
    
cnt = 0
res = h
for b in buse:
    res -= b
    cnt += 1
    if res <= 0:
        break
    
if res > 0:
    cnt += -(-res//amax)
    
print(cnt)

Measured memory_bytes: 11600
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        a_: [i32; 3],
    }
    let mut a = a_.clone();
    a.sort();
    let ret = (a[2] - a[0]).abs();
    println!("{}", ret);
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    float num = 0;
    for(int i = 0; i < n; i++) {
    	num += 1/sc.nextFloat();
    }
    
    System.out.println(1/num);
    
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    return 0;
}

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

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

    bool flag = 0;
    while (n) {
        if (n%10 == 7) flag = 1;
        n /= 10;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
from itertools import*
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=0
for i in range(k+1):
  if i>n:break
  for j in range(i+1):
    c=0
    d=sorted(v[:j]+v[n-i+j:])
    l=k-len(d)
    for m in d:
      if m<0 and l:
        l-=1
        continue
      c+=m
    ans=max(ans,c)
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int

#define mp make_pair
#define pb push_back

int32_t main()
{
     IOS;
     
     int k;
     
     cin>>k;
     
     int i,c1=0,c2=0;
     
     for(i=1;i<=k;i++)
     {
          if(i%2==0)
          c1++;
          else
          c2++;
     }
     cout<<c1*c2;
     
     return 0;
}
 

Measured memory_bytes: 256