akhauriyash/Code-Regression huggingface dataset:
k=int(input())
if k%7==0:
    k//=7
ans=0
if k%2==0 or k%5==0:
    ans=-1
else:
    cnt=1
    x=1
    while x%k!=0:
        cnt+=1
        x%=k
        x*=10
        x+=1
    ans=cnt
print(ans)

Measured memory_bytes: 9148
use std::str::FromStr;
use std::io::*;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n: usize = read();
    let v :Vec<i32> = (0..n).map(|_| read()).collect();
    let c :Vec<i32> = (0..n).map(|_| read()).collect();
    
    let mut m = 0;
    for k in 0..n {
    	if v[k] - c[k] > 0 {
        	m += v[k] - c[k];
        }
    }
    println!("{}",m);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, x; cin >> N >> x;
  vector<int> a(N); REP(i, N) cin >> a[i];

  sort(ALL(a));

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    x -= a[i];
    if (x < 0 || (i == N-1 && x != 0)) {
      break;
    }

    ans = i+1;
  }

  cout << ans << endl;
}

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

bool solve(string s, string t){
  map<char,char> mp;
  for(int i=0;i<s.size();i++){
    if(mp.count(s[i])){
      if(mp[s[i]] != t[i])
        return false;
    }
    else
      mp[s[i]] = t[i];
  }
  return true;
}

int main(){
  string S,T;
  cin>>S>>T;
  if(solve(S,T) && solve(T,S))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 1544
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
H = iil()

cnt = 0
ans = 0

for i in range(1,len(H)):
#    print(i)
    if H[i-1] >= H[i]:
#        print('hoge')
        cnt += 1
    else:
        ans = max(cnt,ans)
        cnt = 0
print(max(cnt,ans))

Measured memory_bytes: 14480
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 100100
typedef long long LL;
LL ans;
int n,a[N],v[N];
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
		scanf("%d",&a[i]),v[i] = a[i];
	sort(v + 1,v + 1 + n);
	for(int i = 1,id;i <= n;i++)
	{
		id = lower_bound(v + 1,v + 1 + n,a[i]) - v;
		ans += (1 & id) ^ (1 & i);
	}
	printf("%lld",ans >> 1);
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n;

	cin >> n;
	vector<int> p(n), pos(n);
	REPU(i, 0, n) {
		cin >> p[i];
		pos[--p[i]] = i;
	}
	vector<int> a(n), b(n);
	a[0] = 0, b[0] = pos[0];
	REPU(i, 1, n) {
		int sum = pos[i];
		a[i] = a[i - 1] + 1, b[i] = sum - a[i];
		while (b[i] >= b[i - 1]) {
			a[i]++, b[i]--;
		}
	}
	int a_mini = *min_element(ALL(a));
	if (a_mini <= 0) {
		REPU(i, 0, n) a[i] -= a_mini - 1;
	}
	int b_mini = *min_element(ALL(b));
	if (b_mini <= 0) {
		REPU(i, 0, n) b[i] -= b_mini - 1;
	}
	REPU(i, 0, n) printf("%d%c", a[i], " \n"[i == n - 1]);
	REPU(i, 0, n) printf("%d%c", b[i], " \n"[i == n - 1]);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

void ans(map<int, set<int>> &tree, VI &cnt, int t, int parent) {
    // if (tree[t].empty()) return;

    for (int s : tree[t]) {
        if (s == parent) continue;
        cnt[s-1] += cnt[t-1];
        ans(tree, cnt, s, t);
    }
}

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

int N, Q; cin >> N >> Q;
VP ab(N-1), px(Q);
rep(i,0,N-1) cin >> ab[i].first >> ab[i].second;
rep(i,0,Q) cin >> px[i].first >> px[i].second;

map<int, set<int>> tree;
rep(i, 0, N-1){
    tree[ab[i].first].insert(ab[i].second);
    tree[ab[i].second].insert(ab[i].first); // 親か子かわからないので，双方向に記録
}

// sort(ALL(px));

VI cnt(N, 0);
rep(i, 0, Q){
    cnt[px[i].first - 1] += px[i].second;
}

ans(tree, cnt, 1, -1);

rep(i, 0, N) cout << cnt[i] << ' ';
cout << endl;

return 0;
}

// 境界，出力文字列 チェック



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

#define MAX 8005

int convert_idx(int x)
{
    return x + MAX;
}

bool is_valid(vector<int> c, int t)
{
    vector<vector<bool>> dp(c.size() + 1, vector<bool>(2 * MAX, false));
    dp.front()[convert_idx(0)] = true;
    for (int i = 0; i < c.size(); i++)
    {
        for (int j = 0; j < dp[i].size(); j++)
        {
            if (dp[i][j])
            {
                dp[i + 1][j + c[i]] = true;
                dp[i + 1][j - c[i]] = true;
            }
        }
    }
    if (0 <= convert_idx(t) && convert_idx(t) < dp.back().size())
    {
        return dp.back()[convert_idx(t)];
    }
    else
    {
        return false;
    }
}

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

    int x, y;
    cin >> x >> y;

    auto itr = S.begin();
    while (itr != S.end() && *itr == 'F')
    {
        x--;
        itr++;
    }

    vector<vector<int>> count(2, vector<int>(1, 0));
    int direction = 0;
    for (; itr != S.end(); itr++)
    {
        if (*itr == 'T')
        {
            direction ^= 1;
            count[direction].push_back(0);
        }
        if (*itr == 'F')
        {
            count[direction].back()++;
        }
    }

    if (is_valid(count[0], x) && is_valid(count[1], y))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 8320
import sys
 
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    H, W = map(int, file().split())
    S = [None] * H
    for i in range(H):
        S[i] = list(file())
    left, right, up, down = [[0 for i in range(W)] for j in range(H)], [[0 for i in range(W)] for j in range(H)],[[0 for i in range(W)] for j in range(H)],[[0 for i in range(W)] for j in range(H)]
    for h in range(H):
        if S[h][0] == ".": left[h][0] += 1
        if S[h][W-1] == ".": right[h][W-1] += 1
    for w in range(W):
        if S[0][w] == ".": up[0][w] += 1
        if S[H-1][w] == ".": down[H-1][w] += 1

    for h in range(H):
        for w in range(1, W):
            if S[h][w] == ".":
                left[h][w] = left[h][w-1] + 1
            if S[h][W-w-1] == ".":
                right[h][W - w - 1] = right[h][W - w] + 1
    for h in range(1, H):
        for w in range(W):
            if S[h][w] == ".":
                up[h][w] = up[h-1][w] + 1
            if S[H-h-1][w] == ".":
                down[H-h-1][w] = down[H-h][w] + 1

    maxlight = 0
    for h in range(H):
        for w in range(W):
            maxlight = max(maxlight, left[h][w] + right[h][w] + up[h][w] + down[h][w] - 3)
    print(maxlight)   
 
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 311944
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  cout << ((a<=9&&b<=9)? a*b : -1) << endl;
}


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

int main() {
	int x,y; cin >> x >>y;
	int m =0;
	if(x==3){m+=100000;}
	else if(x==2){m+=200000;}
	else if(x==1){m+=300000;}
	if(y==3){m+=100000;}
	else if(y==2){m+=200000;}
	else if(y==1){m+=300000;}
	if(y==1 && x==1){m+=400000;}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int N;
  static int K;
  static int A[];
  static int DP[];
  static int DPK[];
  static int ans;
  public static void main(String args[]){
    int ans = 1100000000;
   Scanner sc = new Scanner(System.in);
   N = sc.nextInt();
   K = sc.nextInt();
   A = new int[N];
   DP = new int[N];
   DPK = new int[N];
   for(int i=0;i<N;i++){
     A[i]=sc.nextInt();
   }
   DP[0]=0;
   DP[1]=Math.abs(A[0]-A[1]);
   for(int i=2;i<N;i++){
     for(int j=i-1;j>i-K-1;j--){
       if(j<0){}
         else{
           DPK[j]=DP[j]+Math.abs(A[j]-A[i]);
           if(ans>=DPK[j]){
             ans=DPK[j];
           }
         }
     }
     DP[i]=ans;
     ans = 1100000000;
   }
   System.out.println(DP[N-1]);
 }

}


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

bool f(const vector<char>& Ds, ll num)
{
    return all_of(begin(Ds), end(Ds), [num_s = to_string(num)](auto ch) { return num_s.find(ch) == string::npos; });
}

void main_()
{
    ll N, K;
    cin >> N >> K;
    vector<char> Ds;
    Ds.reserve(K);
    copy_n(istream_iterator<char>(cin), K, back_inserter(Ds));

    while (!f(Ds, N)) {
        N++;
    }

    cout << N << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int a[MAXN], b[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	ll sum = 0ll;
	int mini = -1;
	REP(i, 0, n){
		scanf("%d%d", &a[i], &b[i]);
		sum += a[i];
		if (a[i] > b[i] && (mini == -1 || b[i] < b[mini])){
			mini = i;
		}
	}
	ll ans = 0ll;
	if (mini != -1){
		ans = sum - b[mini];
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    string s;
    string ans="";
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            ans = ans + s[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3160
import sys
import math
readline = sys.stdin.readline

def main():
  A, B, H, M = map(int, readline().split())
  ax = A * math.cos(2 * math.pi * (H + M / 60) / 12)
  ay = A * math.sin(2 * math.pi * (H + M / 60) / 12)
  bx = B * math.cos(2 * math.pi * M / 60)
  by = B * math.sin(2 * math.pi * M / 60)
  l = math.sqrt((ax-bx)**2 + (ay - by)**2)
  print(l)

if __name__ == '__main__':
  main()

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    int s, w;
    cin>>s>>w;
    if(w >= s){
        cout<<"unsafe";
    } else cout<<"safe";
}

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

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

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

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

int main()
{
    int p,q;
    cin >> p >> q;
    q /= gcd(p,q);
    int mx = (int)(sqrt(q));
    int ans = 1;
    for(int i=2;i<=mx;i++){
        if(q % i == 0){
            ans *= i;
            while(q % i == 0){
                q /= i;
            }
        }
    }
    if(q != 1){
        ans *= q;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3096
#[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)*}
    };
}

#[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)*}
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a1: usize,
        a2: usize,
        a3: usize,
    }
    if a1 + a2 + a3 > 21 {
        println!("bust");
    } else {
        println!("win");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  string s ;
  cin >> s;
  
  int count = 0;
  
  for (char c : s){
    if (c== 'o'){
      count++;
    }
  }
    
  if(15-s.size() + count > 7){
    cout << "YES" <<endl;
  }
  
  else{
    cout << "NO" <<endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	if(abs(b-a)%2)
		cout << "Borys" << endl;
	else
		cout << "Alice" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];

  bool isone = true;
  repr(i,1,N) isone &= A[i]>A[i-1];
  if (isone) {
    cout << 1 << endl;
    return 0;
  }

  ll l = 2, r = N;
  while (l!=r) {
    ll mid = (l+r)/2;
    map<ll, ll> now;
    bool ok = true;
    rep(i,N) {
      if (i!=0) {
        if (now.size()==0) now[A[i]-1] = 1; 
        else {
          if (A[i-1]<A[i]) continue;
          else if (A[i-1]>A[i]) {
            auto p = now.upper_bound(A[i]-1);
            now.erase(p,end(now));
          }
          now[A[i]-1]++;
          ll pos = A[i]-1;
          while (now[pos]==mid) {
            now.erase(pos); now[pos-1]++;
            pos--;
          }
        }
      }
      if (now.count(-1)) {
        ok = false;
        break;
      }
    }
    // cout << l << " " << mid << " " << r << endl;
    // for (auto x: now) cout << x.first << "->" << x.second << " "; cout << endl;
    if (ok) r = mid;
    else l = mid+1;
  }
  ll result = l;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	set<int> s;
	rep(i,0,n){
		int temp;
		cin>>temp;
		s.insert(temp);
	}
	if(s.size()==n){
		cout<<"YES"<<endl;
	} else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 9600
def c():
    n = int(input())
    ss = []
    s_min = 101
    for _ in range(n):
        si = int(input())
        ss.append(si)
        if si % 10 != 0:
            s_min = min(s_min, si)

    m = sum(ss)
    if m % 10 == 0:
        if s_min > 100:
            print(0)
        else:
            print(m - s_min)
    else:
        print(m)

c()


Measured memory_bytes: 3060
#include <iostream>
#include <set>

int main()
{	
	std::multiset<int> S;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op, x, L, R;
		std::cin >> op;
		if (op==0) {
			std::cin >> x;
			S.insert(x);
			std::cout << S.size() << std::endl;
		}
		else if (op==1) {
			std::cin >> x;
			std::cout << S.count(x) << std::endl;
		}
		else if (op==2) {
			std::cin >> x;
			S.erase(x);
		}
		else {
			std::cin >> L >> R;
			std::set<int>::iterator lb = S.lower_bound(L);
			std::set<int>::iterator ub = S.upper_bound(R);
			for (std::set<int>::iterator it = lb; it != ub; ++it) std::cout << *it << std::endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 12364
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cmath>

typedef long long ll;
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template<class T> T    abs(const T& a) { if(a<0) return -a; else return a; }

int main()
{
    long long N,Z,W;
    scanf("%lld %lld %lld", &N, &Z, &W);
    std::vector<long long> A(N);
    for (int i=0; i<N; ++i)
        scanf("%lld", &A[i]);
    ll ans = 0;

    auto NS = A.size();

    if (NS > 1)
        chmax(ans, abs(A[NS-2] - A[NS-1]));
    chmax(ans, abs(A[NS-1] - W));
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())

Y = Y//1000

isok = False
for x in range(N+1):
    for y in range(N+1-x):
        if (10*x)+(5*y)+(N-x-y)==Y:
            isok = True
            print("{} {} {}".format(x,y,N-x-y))
            break
    if isok:break
        
if not isok:
    print("{} {} {}".format(-1,-1,-1))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>

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

int main(){
	std::string N;
	std::cin >> N;
	ll ans = 0;
	int sz = N.size();
	rep(i, sz){
		ans += N[i] - '0';
		ans %= 9;
	}
	if(ans == 0){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3700
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int a,b;
 cin>>a>>b;
 int cnt=0;
 for(int i=a;i<=b;i++){
   string str=to_string(i);
   string str2=str;
   reverse(all(str));
   if(str2==str){
     cnt+=1;
   }  
 }
 cout<<cnt<<endl;
}



Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define N 600020
const int mod=200003;
const int G=2;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
typedef vector<int> poly;
int g[N],n,id[N],lim,cnt[N],tr[N];
ll ans;
void init(){
	int now=1;
	for(int i=0;i<mod-1;++i){
		g[i]=now;
		id[now]=i;
		now=now*G%mod;
	}
}
struct Complex{
	double x,y;
	Complex(double _x,double _y){x=_x,y=_y;} Complex(){x=y=0;}
	Complex operator +(Complex b){
		return Complex(x+b.x,y+b.y);
	}
	Complex operator -(Complex b){
		return Complex(x-b.x,y-b.y);
	}
	Complex operator *(Complex b){
		return Complex(x*b.x-y*b.y,x*b.y+y*b.x);
	}
}f[N<<1];
void FFT(Complex *f,int flag,int n){
	for(int i=0;i<n;i++){
		if(i<tr[i])swap(f[i],f[tr[i]]);
	}
	for(int p=2;p<=n;p<<=1){
		int len=(p>>1);
		Complex wn(cos(2*PI/p),sin(2*PI/p));
		if(!flag)wn.y*=-1;
		for(int k=0;k<n;k+=p){
			Complex buf(1,0);
			for(int i=k;i<k+len;i++){
				Complex tmp=buf*f[len+i];
				f[len+i]=f[i]-tmp;
				f[i]=f[i]+tmp;
				buf=buf*wn;
			}
		}
	}
}
int main(){
	n=read();
	init();
	for(int i=1;i<=n;++i){
		int x=read();
		if(!x)continue;
		++cnt[x];
	}
	for(int i=1;i<mod;++i){
		f[id[i]].x=cnt[i];
	}
	lim=1;
	while(lim<mod<<1)lim<<=1;
	for(int i=0;i<lim;i++){
		tr[i]=((tr[i>>1]>>1)|((i&1)?lim>>1:0));
	}
	FFT(f,1,lim);
	for(int i=0;i<lim;++i){
		f[i]=f[i]*f[i];
	}
	FFT(f,0,lim);
	for(int i=0;i<mod<<1;++i){
		ans+=(ll)(f[i].x/lim+0.49)*g[i%(mod-1)];
	}
	for(int i=1;i<mod;++i){
		ans-=cnt[i]*(1LL*i*i%mod);
	}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 27048
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(c-a+b<=0) co(0);
  else co(c-a+b);
  
  return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define MOD 1000000007

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  int h1[4] = {1, 0, 1, 0};
  int h2[4] = {1, 0, 0, 1};

  rep(i, 0, 4) {
    int k[n + 1] = {h1[i], h2[i]};
    k[2] = s[1] == 'o' ? k[0] : !k[0];
    if(!k[1]) k[2] = !k[2];
    int sy = s[0] == 'o' ? k[1] : !k[1];
    if(!k[0]) sy = !sy;
    rep(i, 2, n) {
      k[i + 1] = k[i] ? k[i - 1] : !k[i - 1];
      if(s[i] == 'x') k[i + 1] = !k[i + 1];
    }
    if(k[n] == k[0] && k[n - 1] == sy) {
      rep(i, 0, n) cout << (k[i] == 1 ? 'S' : 'W');
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 976
import java.util.Scanner;
class Main{
    public static void main(String[] a){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] s=new int[n];
for(int i=0;i<n;i++){
s[i]=sc.nextInt();
}
int q=sc.nextInt();
int[] t=new int[n];
for(int i=0;i<q;i++){
t[i]=sc.nextInt();
}
sc.close();
int ans=0;
for(int i=0;i<q;i++){
for(int j=0;j<n;j++){
if(t[i]==s[j]){
ans++;
break;
}
}
}
System.out.println(ans);
    }
}

Measured memory_bytes: 39960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll x = a+b*(n-1);
    ll y = a*(n-1)+b;
    cout << max((ll)0,x-y+1) << endl;
    return 0;
}

Measured memory_bytes: 256
n,*a=`dd`.split.map &:to_i
M=10**9+7;I=[1,1];*F=I;*T=0,1
2.upto(n){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;T<<(T[-1]+z)%M}
r=0
n.times{|i|r=(r+a[i]*(T[i+1]+T[n-i]-1))%M}
p r*F[n]%M

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

using namespace std;

const int INF = 1 << 29;

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

int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int> A(N), B(N), C(N);
	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i] >> C[i];
	}
	vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(401, vector<int>(401, INF)));
	dp[0][0][0] = 0;
	for(int i = 1; i <= N; i++) {
		for(int j = 0; j <= 400; j++) {
			for(int k = 0; k <= 400; k++) {
				if (j - A[i - 1] >= 0 && k - B[i - 1] >= 0) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - A[i - 1]][k - B[i - 1]] + C[i - 1]);
				dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
			}
		}
	}

	int ans = INF;
	for(int j = 0; j <= 400; j++) {
		for(int k = 0; k <= 400; k++) {
			if (j == 0 && k == 0) continue;
			int g = gcd(j, k);
			if (j == Ma * g && k == Mb * g) {
				ans = min(ans, dp[N][j][k]);
			}
		}
	}
	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}

}


Measured memory_bytes: 27264
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] two = new long[61];
		Arrays.fill(two, 0);
		
		for(int i = 0; i < N; i++) {
			long x = sc.nextLong();
			for(int j = 0; j < 61; j++) {
				two[j] += x & 1;
				x /= 2L;
			}
		}
		sc.close();
		
		long sum = 0;
		for(int i = 0; i < 61; i++) {
			sum += ((long)Math.pow(2, i) % 1000000007) * ((two[i]*(N - two[i])) % 1000000007);
			sum %= 1000000007;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 88584
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>

using llong = long long;

int main() {
	std::uint64_t N;
	std::uint64_t a;

	std::cin >> N;
	std::vector<llong> S(N + 1, 0);

	for (std::uint64_t i = 1; i <= N; ++i) {
		std::cin >> a;
		S[i] = S[i - 1] + a;
	}

	llong min_diff = LLONG_MAX;
	for (std::uint64_t i = 1; i <= N - 1; ++i) {
		min_diff = std::min<llong>(min_diff, std::llabs(S[N] - 2 * S[i]));
	}

	std::cout << min_diff << std::endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <map>
using namespace std;
const int N = 300001;
typedef long long ll;
priority_queue<ll, vector<ll>, greater<ll>> minH;
priority_queue<ll> maxH;
ll a[N], fl[N], fr[N];
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    ll left = 0, right = 0;
    cin >> n;
    for(int i = 0; i < (n * 3); i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        minH.push(a[i]);
        left += a[i];
    }
    for(int i = n; i < (n * 2); i++) fl[i] = fr[i] = 0;
    for(int i = n * 2; i < (n * 3); i++){
        maxH.push(a[i]);
        right += a[i];
    }
    fl[n - 1] = left;
    fr[n * 2] = right;
    ll ans = left - right;
    for(int i = n; i < (n * 2); i++){
        if(a[i] > minH.top()){
            left -= minH.top();
            minH.pop();
            left += a[i];
            minH.push(a[i]);
        }
        if(a[n * 3 - i - 1] < maxH.top()){
            right -= maxH.top();
            maxH.pop();
            right += a[n * 3 - i - 1];
            maxH.push(a[n * 3 - i - 1]);
        }
        fl[i] = left;
        fr[n * 3 - i - 1] = right;
    }
    for(int i = n - 1; i < (n * 2); i++) ans = max(ans, fl[i] - fr[i + 1]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 8308
S = input()
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        print(i + 1, i + 2)
        break
    if i < len(S) - 2 and S[i] == S[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 5100
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string s; cin >> s;
    vl v(26,0);
    rep(i,s.size()) v[s[i]-'a']++;
    rep(i,26){
        if(v[i] == 0){
            char ans = i+'a';
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    long long m = min(A, min(B, min(C, min(D, E))));
    cout << (N + m - 1) / m + 4 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	if (s[4] == s[5] && s[2] == s[3])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    string c;
    R(c);
    if(c[0]>='A'&&c[0]<='Z')W('A');
    else W('a');
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>

int main()
{
	int A, B, C, temp = 0;
	scanf("%d %d %d", &A, &B, &C);
	temp = B; 
	B = A;
	A = C;
	C = temp;
	printf("%d %d %d", A, B, C);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int N,K;
int a[60];

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

  std::cin >> N >> K;
  for (int i = 0; i < N; i++) std::cin >> a[i];

  sort(a,a + N,std::greater<int>());
  int total = 0;
  for (int i =0; i < K;i++){
    total += a[i];
  }
  std::cout << total << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, pair <int, ll> > PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 100010;

int main()
{
	int a, n, b;
	cin >> n >> a >> b;
	int dist = abs(a - b);
	if (dist % 2 == 0) cout << "Alice";
	else cout << "Borys";
}


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

int main() {
    int n;
    cin >> n;
    int a[101000];
    bool d[101000];
    int c = 0;
    int ans = 0;
    
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    
    rep(i, n) d[i] = false;
    
    while(true) {
        if (d[c]) {
            ans = -1;
            break;
        }
        
        if (c == 1) {
            break;
        }
        
        d[c] = true;
        c = a[c];
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

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

signed main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    rep(i,b)cout<<a;
  }else{
    rep(i,a)cout<<b;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int i,n,k,p;
	scanf("%d",&n);
	for (i = 1; i <= n; i++) {
		scanf("%d %d", &k, &p);
		if (k%p == 0) {
			printf("%d\n", p);
		}
		else {
			printf("%d\n", k%p);
		}
	}
	return 0;
}


Measured memory_bytes: 2732
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a<b) cout << "a < b" << endl;
    else if(a>b) cout << "a > b" << endl;
    else if(a==b) cout << "a == b" << endl;
    return 0;
    
}


Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int x;
int main()
{
	cin>>x;
	if(x>=400&&x<=599) cout<<"8"<<endl;
	if(x>=600&&x<=799) cout<<"7"<<endl;
	if(x>=800&&x<=999) cout<<"6"<<endl;
	if(x>=1000&&x<=1199) cout<<"5"<<endl;
	if(x>=1200&&x<=1399) cout<<"4"<<endl;
	if(x>=1400&&x<=1599) cout<<"3"<<endl;
	if(x>=1600&&x<=1799) cout<<"2"<<endl;
	if(x>=1800&&x<=1999) cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    int64_t sum = 0;
    for (int i = 1; i <= N; ++i) {
        sum += i;
        if (sum == N) {
            for (int j = 1; j <= i; ++j) {
                std::cout << j << std::endl;
            }
            return 0;
        }
        else if (sum > N) {
            auto diff = sum - N;
            for (int j = 1; j <=i; ++j) {
                if (j != diff) {
                    std::cout << j << std::endl;
                }
            }
            return 0;
        }
    }

    return 0;
}


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

int main()
{
  int n, score;
  string name;
  vector<tuple<string, int, int>>restaurants;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> name >> score;
    restaurants.push_back(make_tuple(name, -score, i));
  }
  sort(restaurants.begin(), restaurants.end());
  for (auto r : restaurants)
    cout << get<2>(r) + 1 << endl;
}


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

int main()
{
    int a[3][3];
    rep (i, 3)
        rep (j, 3)
            cin >> a[i][j];

    int n;
    cin >> n;
    vector<int> b(n);
    rep (i, n)
        cin >> b[i];

    bool mark[3][3];
    rep (r, 3)
            rep (c, 3)
                mark[r][c] = false;
    rep (i, n)
        rep (r, 3)
            rep (c, 3)
                if (b[i] == a[r][c])
                    mark[r][c] = true;

    bool ok = false;
    rep (i, 3)
        if (mark[i][1] == true && mark[i][0] == mark[i][1] && mark[i][1] == mark[i][2])
            ok = true;
    rep (i, 3)
        if (mark[1][i] == true && mark[0][i] == mark[1][i] && mark[1][i] == mark[2][i])
            ok = true;
    if (mark[1][1] == true && mark[0][0] == mark[1][1] && mark[1][1] == mark[2][2])
        ok = true;
    if (mark[1][1] == true && mark[0][2] == mark[1][1] && mark[1][1] == mark[2][0])
        ok = true;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define ld long double
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define printv(a) {\
    for (auto y : a) cout << y << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define readfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int mod = 998244353, x = 864197532, N = 20, logN = 18, K = 350, all = (1 << N) - 1;

int main () {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0, j = n - 1; i < j;) {
		while (i < j && s[i] == 'R') i++;
		while (i < j && s[j] == 'W') j--;
		if (i == j) break;
		swap(s[i], s[j]);
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3724
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;

bool func(const pair<long long, long long> &a, const pair<long long, long long> &b)
{
	return a.first < b.first;
}

class comp
{
public:
	bool operator() (const pair<long long, long long> &a, const pair<long long, long long> &b)
	{
		return a.second < b.second;
	}
};

int main()
{
	int n, m;
	vector<pair<long long, long long>> work;
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, comp> pq;
	long long input1, input2;
	int i, j, ptr;
	long long sol = 0;

	scanf("%d %d", &n, &m);
	
	for (i = 0; i < n; i++)
	{
		scanf("%lld %lld", &input1, &input2);

		work.push_back(pair<long long, long long>(input1, input2));
	}

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

	ptr = 0;

	for (i = 1; i <= m; i++)
	{
		for (j = ptr; j < n; j++)
		{
			if (work[j].first > i)
			{
				break;
			}

			pq.push(work[j]);
		}

		if (!pq.empty())
		{
			sol += pq.top().second;

			pq.pop();
		}

		ptr = j;
	}

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

	return 0;
}

Measured memory_bytes: 4848
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	cin >> s;

	string t;
	for( int i = 0; i < s.size(); ++i ) {
		if( (s[i] == 'K' || s[i] == 'B' || s[i] == 'R') && (t == "" || s[i-1] != 'A') ) {
			t += 'A';
		}

		t += s[i];
	}

	if( t.back() == 'R' ) {
		t += 'A';
	}

	cout << (t == "AKIHABARA" ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int ans=0,a,b,c,k;
  cin>>k;
  for (a=1;a<=k;a++)
  {
    for (b=1;b<=k;b++)
    {
      for (c=1;c<=k;c++)
		ans+=__gcd(a,__gcd(b,c));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<pair<int, int>> R(N), B(N);
  rep(i, N) cin >> R[i].first >> R[i].second;
  rep(i, N) cin >> B[i].first >> B[i].second;
  vector<bool> used(N);
  sort(all(R), [&](pair<int, int> p1, pair<int, int> p2) {
      return p1.second > p2.second;
    });
  sort(all(B));
  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if(!used[j] &&
         R[j].first < B[i].first &&
         R[j].second < B[i].second) {
        ans++;
        used[j] = true;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

prime = [True] * 1001
prime[0] = prime[1] = False
primes = []
for i in range(2, 1001):
  if prime[i]:
    primes.append(i)
    for j in range(i*i, 1001, i):
      prime[j] = False

soinsuu = {}
for i in range(1, N+1):
  x = i
  for p in primes:
    while x % p == 0:
      soinsuu[p] = soinsuu.get(p, 0) + 1
      x //= p

ans = 1
for n in soinsuu.values():
  ans = (ans * (n+1)) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3064
n,m,q = map(int,input().split())
ab = [0]*q
for i in range(q):
    ab[i] = list(map(int,input().split()))
import itertools
data = list(range(m))
r = n
c = list(itertools.combinations_with_replacement(data, r))
ans = 0
for L in c:
    m = 0
    for i in range(q):
        if L[ab[i][1]-1] - L[ab[i][0]-1] == ab[i][2]:
            m += ab[i][3]
    ans = max(ans,m)
print(ans)

Measured memory_bytes: 21644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

bool ok[10];
vector<int> a;
void add(int now,int times) {
	if (times == 0)a.push_back(now);
	else {
		f(i, 0, 9)if (!ok[i]) {
			int tmp = now * 10 + i; add(tmp, times - 1);
		}
		if (now == 0)add(0, times - 1);
	}
}
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n);
	int k; sf(k);
	f(i, 1, k) {
		int d; sf(d); ok[d] = 1;
	}
	add(0, 5); sort(all(a));
	cout << *lower_bound(all(a), n);
}

Measured memory_bytes: 892