akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int w, h, n; cin >> w >> h >> n;
    int sx, sy, gx, gy;
    cin >> gx >> gy; --n;

    int ans = 0;
    FOR(i, 0, n) {
        sx = gx, sy = gy;
        cin >> gx >> gy;
        if ((sx < gx) == (sy < gy)) {
            ans += max(abs(sx - gx), abs(sy - gy));
        }
        else {
            ans += abs(sx - gx) + abs(sy - gy);
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3208
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size(),m=t.size(),k=-1;;
  sort(all(s)),sort(all(t)),reverse(all(t));
  rep(i,min(m,n)){if(s[i]!=t[i]){k=i;break;}}
  if(k==-1&&n>=m){cout<<"No"<<endl;}
  else if(k==-1&&n<m){cout<<"Yes"<<endl;}
  else if(s[k]>t[k]){cout<<"No"<<endl;}
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int main(){
	ll x,y;
	scanf("%lld%lld",&x,&y);
	if(x%y==0)puts("-1");
	else printf("%lld\n",x);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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


Measured memory_bytes: 26836
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int P = 700;
		for (int i = 0; i < 3; i++) {
			if (S.substring(i, i + 1).equals("o")) {
				P += 100;
			}
		}
		System.out.println(P);
	}
}

Measured memory_bytes: 20816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = RLong();
            int rootN = (int)Math.Sqrt(n);

            long cnt = 0;
            for (int r = 1; r <= rootN + 1; r++)
            {
                long pq = n - r;
                long p = pq / r;
                if (n == r * (p + 1) && n % r == 0 && pq % r == 0 && p > r)
                {
                    cnt += p;
                }
            }
            Console.WriteLine(cnt);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13140
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

mod = 10 ** 9 + 7
fac = [1]
1.upto(n-1) {|i| fac << fac[i-1] * i % mod}

rfac = Array.new(n,1)
t = fac[n-1]
"111011100110101100101000000101".reverse.each_char do |c|
    rfac[n-1] = (rfac[n-1] * t) % mod if (c == '1')
    t = t ** 2 % mod
end
(n-2).downto(0) {|i| rfac[i] = rfac[i+1] * (i+1) % mod}

ans = 0
n.times do |i|
    if i > n - k && i < k - 1
        next
    elsif i < k - 1
        ans = (ans - a[i] * fac[n-i-1] * rfac[k-1] * rfac[n-i-k]) % mod
    elsif i > n - k
        ans = (ans + a[i] * fac[i] * rfac[k-1] * rfac[i-k+1]) % mod
    else
        ans = (ans - a[i] * fac[n-i-1] * rfac[k-1] * rfac[n-i-k]) % mod
        ans = (ans + a[i] * fac[i] * rfac[k-1] * rfac[i-k+1]) % mod
    end
end

puts ans

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

using namespace std;

int main(){
  long long n, k;
  std::cin >> n >> k;

  vector<int> h(n);
  for(int idx = 0; idx < n; idx++) std::cin >> h[idx];

  sort(h.begin(), h.end(), greater<int>());

  long long min = LLONG_MAX;
  for(int idx = 0; idx + k - 1 < n; idx++){
    long long judge = h[idx] -  h[idx +  k - 1];
    if(min > judge){
      min = judge;
    }
  }

  std::cout << min << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
#define SORT(x) sort(x.begin(),x.end())
using ll = long long;

vector <ll> divisor(ll n) {
	vector<ll> ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.pb(i);
			if (i * i != n) ret.pb(n / i);
		}
	}
	SORT(ret);
	return ret;
}

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

	vector<ll> ret = divisor(n);
	ll ans = 1e12 + 7;
	rep(i, 0, ret.size() / 2 + 1) {
		ll a = (ret[i] - 1) + (ret[ret.size() - i - 1] - 1);
		if (ret[i] * ret[ret.size() - i - 1] == n || ret[i] * ret[i] == n) {
			ans = min(ans, a);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 15;

int MOD = 1000000007;

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

    int a,b,k; cin >> a >> b >> k;
    int cnt = 0;
    std::vector<int> v;
    for(int i=1; i<=max(a,b); ++i){

        if(a%i==0 && b%i==0){
            v.push_back(i);
        }
    }

    reverse(v.begin(), v.end());

    cout << v[k-1] << endl;

    return 0;
}

// int main(){
//     std::ios_base::sync_with_stdio(false);
//
//     string s; cin >> s;
//     int n = s.length();
//     int cnt = 0;
//
//     for(int i=0; i<n; ++i){
//         if(s[i] != s[i+1]){
//             cnt+=2;
//             i++;
//         }
//     }
//
//     cout << cnt ::
//
//     return 0;
// }


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

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *NIL, *root = NIL;


void insert(int k) {
    Node *z,*y = NIL,*r = root;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    z->parent = NIL;

    if ( r == NIL ) {
        root = z;
        return;
    }

    while ( r != NIL ) {
        y = r;
        if ( k < r->key) r = r->left;
        else r = r->right;
    }

    z->parent = y;
    if ( k < y->key ) y->left = z;
    else y->right = z;
}

Node* find(int k) {
    Node * z = root;
    while ( z != NIL ) {
        if( k == z->key ) break;
        else if ( k < z->key ) z = z->left;
        else z = z->right;
    }

    if ( z == NIL || k != z->key ) return NIL;
    else {
            return z;
    }

    return NIL;
}

void inorder(Node*u) {
    if ( u == NIL ) return;
    inorder(u->left);
    cout << ' ' << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if ( u == NIL ) return;
    cout << ' ' << u->key;
    preorder(u->left);
    preorder(u->right);
}

Node * treeSuccessor(Node * x) {
    Node * y = x;
    while ( y != NIL) y = x->left;
    return y;
}

void deleteNode(int k) {
    Node *z = find(k);
    Node *y, *x = NIL;
    if ( z == NIL ) return;
    if ( z->left == NIL || z->right == NIL ) y = z;
    else { y = treeSuccessor(y->right); z->key = y->key;

    if ( y->left != NIL ) x = y->left;
    else if ( y->right != NIL ) x = y->right;

    if ( x != NIL ) x->parent = y->parent;
    if ( y->parent == NIL ) root = x;
    else if ( y == y->parent->left ) y->parent->left = x;
    else if ( y == y->parent->right ) y->parent->right = x;

    free(y);

}
}

int main(){
    int n,i,temp,b;
    char a[20];
   cin >> n;
    for ( i = 0; i < n; i++ ) {
        cin >> a;
        if ( strcmp(a,"insert") == 0 ) {
             cin >> temp;
            insert(temp);
        }
        else if ( strcmp(a,"print") == 0 ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        else if ( strcmp(a,"find") == 0 ){
            cin >> b;
            if (find(b) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if ( strcmp(a,"delete") == 0 ) {
            cin >> b;
            deleteNode(b);
        }
    }
    return 0;
}



Measured memory_bytes: 21824
import sys
from math import gcd
input = sys.stdin.readline

mod = 10 ** 9 + 7

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

d = {}
z = 0

pow_2 = [1]

for i in range(n):
    pow_2.append(pow_2[-1] * 2 % mod)

for a, b in ab:
    if a == 0 and b == 0:
        z += 1
        continue

    if a == 0 and b != 0:
        key = (0, 1)
    elif a * b > 0:
        g = gcd(a, b)
        key = (abs(a // g), abs(b // g))
    else:
        continue

    if key not in d:
        d[key] = [0, 0]
    d[key][0] += 1

for a, b in ab:
    if a != 0 and b == 0:
        key = (0, 1)
    elif a * b < 0:
        g = gcd(a, b)
        key = (abs(b // g), abs(a // g))
    else:
        continue
    
    if key in d:
        d[key][1] += 1


lo = n - z

ans = 1

for x, xi in d.values():
    if x * xi > 0:
        ans *= ((pow_2[x] - 1) + (pow_2[xi] - 1) + 1)
        ans %= mod
        lo -= x + xi

ans = (ans * pow_2[lo] + z - 1) % mod   

print(ans)




Measured memory_bytes: 79332
#[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 ( 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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ 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 , 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" ) } ; }

fn main() {
    input! {
        n: u64
    }

    let mut hmap = std::collections::HashMap::new();
    for i in 1..n+1 {
        let h = prime_factors(i);
        for (&k, &v) in h.iter() {
            *hmap.entry(k).or_insert(0) += v;
        }
    }
    // p4q4r2, p14q4, p24q2, p74
    let mut c4 = 0;
    let mut c2 = 0;
    let mut c14 = 0;
    let mut c24 = 0;
    let mut c74 = 0;
    for &v in hmap.values() {
        if v >= 2 {
            c2 += 1;
        }
        if v >= 4 {
            c4 += 1;
        }
        if v >= 14 {
            c14 += 1;
        }
        if v >= 24 {
            c24 += 1;
        }
        if v >= 74 {
            c74 += 1;
        }
    }
    println!("{}",
        (c4 * (c4 - 1) / 2) * (c2 - 2) + c14 * (c4 - 1) +
        c24 * (c2 - 1) + c74
    );
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn prime_factors(n_: u64) -> std::collections::HashMap<u64, u64> {
    let mut ret = std::collections::HashMap::new();
    let n = std::cell::Cell::new(n_);
    for i in (2..).take_while(|&i| i * i <= n.get()) {
        while n.get() % i == 0 {
            *ret.entry(i).or_insert(0) += 1;
            n.set(n.get() / i);
        }
    }
    if n.get() != 1 {
        ret.insert(n.get(), 1);
    }
    ret
}

Measured memory_bytes: 4476
N = int(input())
A, B = map(int, input().split())
P = [int(i) for i in input().split()]

ret = [0] * 3
for p in P :
  if p <= A :
    ret[0] += 1
  elif A + 1 <= p <= B :
    ret[1] += 1
  else :
    ret[2] += 1
    
print(min(ret))

Measured memory_bytes: 38256
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n,x = read_ints()
a = read_ints()
a.sort()
ans = 0
for i in range(len(a)):
    if i == len(a)-1 and x == a[i]:
        ans += 1 
    elif i != len(a)-1 and a[i] <= x:
        ans += 1 
        x -= a[i] 
print ans 


Measured memory_bytes: 2952
INF = 10**10


def merge(ary, left, mid, right):
    lry = ary[left:mid]
    rry = ary[mid:right]

    lry.append(INF)
    rry.append(INF)
    i = 0
    j = 0

    for k in range(left, right):
        if lry[i] <= rry[j]:
            ary[k] = lry[i]
            i += 1
        else:
            ary[k] = rry[j]
            j += 1

    return right - left


def merge_sort(ary, left, right):
    cnt = 0
    if left + 1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(ary, left, mid)
        cnt += merge_sort(ary, mid, right)
        cnt += merge(ary, left, mid, right)
    return cnt


if __name__ == '__main__':
    n = int(input())
    ary = [int(_) for _ in input().split()]
    cnt = merge_sort(ary, 0, n)
    print(*ary)
    print(cnt)



Measured memory_bytes: 61652
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s,t;
    cin>>s>>t;
    int ans = inf;
    rep(i,0,s.length()-t.length()+1){
        int cnt = 0;
        rep(j,0,t.length()){
            string str = s.substr(i,t.length());
            if ( s[j+i] != t[j] ){
                cnt++;
            }
        }
        ans = min(ans,cnt);
    }

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;

        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);

        for (int i = 6; i <= N; i *= 6) {
            list.add(i);
        }

        for (int i = 9; i <= N; i *= 9) {
            list.add(i);
        }

        Collections.sort(list);

        int[] dp = new int[N+1];

        for (int i = 0; i < N+1; i++) {
            dp[i] = i;
        }

        for (int j = 1; j < list.size(); j++) {
            int item = list.get(j);

            for (int i = item; i < dp.length; i++) {
                if (dp[i - item] + 1 < dp[i]) {
                    dp[i] = dp[i - item] + 1;
                }
            }
        }

        System.out.println(dp[N]);
    }
}

Measured memory_bytes: 23380
N = int(input())
Si = [input() for i in range(N)]

C0 = 0
C1 = 0
C2 = 0
C3 = 0

for in1 in Si:
    if in1 == "AC":
        C0 +=1
    elif in1 == "WA":
        C1 += 1
    elif in1 == "TLE":
        C2 += 1
    elif in1 == "RE":
        C3 += 1

print("AC x {}".format(C0))
print("WA x {}".format(C1))
print("TLE x {}".format(C2))
print("RE x {}".format(C3))


Measured memory_bytes: 16288
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
Q = int(input())
ans = [0] * (10**5+1)
prime = [0] * (10**5+1)
for i in range(1,10**5+1):
    if is_prime(i):
        prime[i] = 1
        if prime[(i+1)//2] == 1:
            ans[i] = ans[i-1] + 1
            continue
    ans[i] = ans[i-1]
disp_ans = 0
for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r]-ans[l-1])

Measured memory_bytes: 52828
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N , W;
    cin >> N >> W;
    
    vector<int> wt(N) , score(N);
    for (int i = 0; i < N; ++i) {
        cin >> wt[i] >> score[i];
    }

    long long dp[N+1][W+1];

    for (int i = 0; i <= N; ++i) {
        for (int w = 0; w <= W; ++w) {
            if (i == 0 || w == 0) dp[i][w] = 0;
            else {
                long long inc = 0 , exc = 0;
                if (wt[i-1] <= w) inc = score[i-1] + dp[i-1][w-wt[i-1]];
                exc = dp[i-1][w];
                dp[i][w] = max(inc,exc);
            }
        }
    }

    cout << dp[N][W];
}

Measured memory_bytes: 82388
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	X = getlist()

	#例外
	if N == 2:
		print(X[1] - X[0])
		return

	#前処理
	ans = 0
	left = [1] * (N - 1)
	right = [N - 1] * (N - 1)
	for i in range(N - 2):
		left[i + 1] = (left[i] * (i + 2)) % con
		right[N - 3 - i] = (right[N - 2 - i] * (N - 2 - i)) % con

	# print(left)
	# print(right)

	fig = [0] * (N - 1)
	fig[0] = left[N - 2]
	for i in range(1, N - 2):
		fig[i] = (left[i - 1] * right[i + 1]) % con
	fig[N - 2] = left[N - 3] #チェック

	# print(fig)

	figsum = [0] * (N - 1)
	figsum[0] = fig[0]
	for i in range(N - 2):
		figsum[i + 1] = (figsum[i] + fig[i + 1]) % con

	# print(figsum)

	for i in range(N - 1):
		dist = X[i + 1] - X[i]
		val = figsum[i]
		ans += dist * val
		
	ans %= con
	print(ans)


if __name__ == '__main__':
	main()

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

ll f(ll A, ll B, ll n)
{
    auto hoge1 = ((A % n) == 0) ? A : (A - (A % n)) + n;
    auto hoge2 = (B / n) * n;
    auto a = (hoge2 - hoge1) / n + 1;
    return a;
}

void main_()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    auto CDlcm = C / __gcd(C, D) * D;

    auto x1 = f(A, B, C);
    auto x2 = f(A, B, D);
    auto x3 = f(A, B, CDlcm);

    ll ans = B - A + 1 - x1 - x2 + x3;
    cout << ans << 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>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> T(Q), F(Q, -1);
  vector<char> C(Q);
  vector<int> reve(Q, 0);

  for(int i = 0; i < Q; i++){
    cin >> T.at(i);
    if(T.at(i) == 1) reve.at(i) = 1;
    if(T.at(i) == 2){
      cin >> F.at(i) >> C.at(i);
    }
  }

  //反転回数に関する累積和
  vector<int> revsum(Q, 0);
  for(int i = 0; i < Q; i++){
    if(i == 0) revsum.at(i) = reve.at(i);
    else{
      revsum.at(i) = revsum.at(i-1) + reve.at(i);
    }
  }

  //Sの反転
  if(revsum.at(Q-1) % 2 != 0) reverse(ALL(S));

  string pre = "", epi = "";

  for(int i = 0; i < Q; i++){
    int rev = revsum.at(Q-1) - revsum.at(i);
    if(T.at(i) == 2 && F.at(i) == 1){ //もとは先頭
      if(rev %2 == 0) pre = C.at(i) + pre;
      if(rev %2 == 1) epi = epi + C.at(i);
    }
    if(T.at(i) == 2 && F.at(i) == 2){ //もとは後
      if(rev %2 == 0) epi = epi + C.at(i);
      if(rev %2 == 1) pre = C.at(i) + pre;
    }
  }

  cout << pre + S + epi << endl;

}

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

#define MAX 300

using namespace std;

int g[MAX][MAX];

int main(void)
{
    int n;

    cin>>n;

    for(int i = 0;i < n;i++)
        for(int j = 0;j < n;j++)
            cin>>g[i][j];


    long long ans = 0;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < i;j++)
            ans += g[i][j];

    for(int s = 0;s < n;s++) {
        for(int e = 0;e < s;e++) {
            for(int i = 0;i < n;i++) {
                if(s == i || e == i)
                    continue;
                if(g[s][e] == g[s][i]+g[i][e]) {
                    ans -= g[s][e];
                    break;
                }
                else if(g[s][i]+g[i][e] < g[s][e])
                {
                    cout<<-1<<endl;

                    return 0;
                }
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define mod 1000000007
    #define all(v)  v.begin(),v.end()
    #define pb push_back
    #define size(v)  (int) v.size()
    #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
    ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
    ll inv(ll a){return power_mod(a,mod-2);}    
    ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

    int main(){
        ll n;;
        cin>>n;
        string s;
        cin>>s;
        ll ans=0;
        for(int i=0;i<n;){
             char now = s[i];
             while(s[i]==now && i<n){
                 i++;
             }
             ans++;
        }
        cout<<ans<<endl;
    }




Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p>q)?(p):(q))

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=max(x.a,y.a);
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/



//座圧(破壊的)
int cocomp(ll*a,int n){
	//0～cnt-1に圧縮
	ll*b=(ll*)malloc(sizeof(ll)*n);
	memcpy(b,a,sizeof(ll)*n);
	sortup(b,n);
	int cnt=1;
	rep(r,1,n)if(b[r]!=b[cnt-1])b[cnt++]=b[r];
	rep(i,0,n){
		int l=0,r=cnt;
		while(r-l>1){int m=(l+r)/2;if(b[m]>a[i])r=m;else l=m;}
		a[i]=l;
	}
	free(b);
	return cnt;
}

ll a[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	cocomp(a,n);
	seguse(1<<17);
	for(int i=0;i<n;i++){
		atai t=segcalc(0,a[i]);
		t.a++;
		segupdate(a[i],t);
	}
	printf("%lld\n",segcalc(0,n).a);
}


Measured memory_bytes: 4684
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int func(int x){
	if(x != 0 &&x % 2 == 0){
		return func(x / 2) + 1;
	}
	return 0;
}

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

	int count = 0;
	for(int i = 0; i < N; ++i){
		int pre;
		cin >> pre;
		count += func(pre);
	}
	cout << count << endl;
}


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


int main(void){
  int n,i;
  double x,ans=0.0;
  string u;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> x >> u;
    if (u=="JPY") ans+=x;
    else ans+=x*380000;
  }
  
  printf("%.10lf\n",ans);
  
  return 0;
}

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

const int mod = 1000000007;

int main(){
  int s; cin >> s;
  ll F[2005] = {0};
  F[0] = F[1] = F[2] = 0;
  F[3] = 1;
  for(int i = 4; i <=s; i++){
    F[i]=F[i-1]+F[i-3];
    F[i] %= mod;
  }
  cout << F[s] << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010],b[100010],cnt=0,sum_n=0,sum_p=0;
    vll v;
    cin>>n;
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n){
        if(a[i]<b[i]){
            cnt++;
            sum_n+=(b[i]-a[i]);
        }
        if(a[i]>b[i]){
            v.pb(a[i]-b[i]);
            sum_p+=(a[i]-b[i]);
        }
    }
    if(sum_p<sum_n){
        cout<<-1<<endl;
    } else if(sum_n==0) {
        cout<<0<<endl;
    } else{
        sort(all(v));
        reverse(all(v));
        rep(i,(ll)v.size()){
            cnt++;
            sum_n-=v[i];
            if(sum_n<=0) break;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 2428
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
using namespace std;

int main(){
  int n; cin >> n;
  int a[101];
  for (int i=0;i<n;i++) cin >> a[i];

  int ans = 0;

  for (int i=0;i<n;i++){
    int minj = i;
    for (int j=i;j<n;j++){
      if (a[j] < a[minj]) minj = j;
    }
    if (minj != i){
      swap(a[i],a[minj]);
      ans++;
    }
  }
  for (int i=0;i<n;i++){
    cout << a[i];
    if (i != n-1) cout << " ";
  }
  cout << endl << ans << endl;

  return 0;
}




Measured memory_bytes: 3116
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	int count = 0;
	int result = 0;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
			count++;
			if(result < count) {
				result = count;
			}
		} else {
			count = 0;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    rep(i, A+B+1) {
        if (i == A) {
            if (S[i] != '-') {
                no;
                return 0;
            }
        } else {
            if (S[i] == '-') {
                no;
                return 0;
            }
        }
    }
    yes;
    return 0;
}


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

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

    for (int i=1; i<=1000; ++i) {
        int a = i * 0.08;
        int b = i * 0.1;
        if (a == A and b == B) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val sweets = Array.fill(k * 2)(readLine().split(" ").map(_.toInt))
    .zipWithIndex.collect {
    case (list, index) if index % 2 == 1 => list.map(_ - 1)
  }


  def solve() = {
    val hasSweetArr = Array.fill(n)(false)
    sweets.foreach { list =>
      list.foreach { i =>
        if(!hasSweetArr(i)) hasSweetArr(i) = true
      }
    }
    hasSweetArr.count(!_)
  }

  println(solve())

}



Measured memory_bytes: 55140
list1 = input().split()
n = int(list1[0])
m = int(list1[1])
pre = [[] for i in range(n)]

for j in range(m):
    data = input().split()
    p = int(data[0])
    y = int(data[1])
    pre[p - 1].append((j, y))

inums = []
for k in range(n):
    if len(pre[k]) == 0:
        pass
    else:
        sorted_y = sorted(pre[k], key = lambda x:x[1])
        for l in range(len(sorted_y)):
            s1 = str(k + 1).zfill(6)
            s2 = str(l + 1).zfill(6)
            inums.append((sorted_y[l][0], s1 + s2))

ans = sorted(inums, key = lambda x:x[0])
for h in range(m):
    print(ans[h][1])

Measured memory_bytes: 43404
// finish date: 2018/01/23
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, M;
    cin >> N >> M;
    vi to;
    map<int, int> mp;
    int a, b;
    rep(i, M) {
        cin >> a >> b;
        if (a == 1) to.push_back(b);
        if (b == N) mp[a] = 1;
    }
    rep(i,to.size()){
        if(mp.count(to[i])!=0){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;


    return 0;
}



Measured memory_bytes: 5368
# include <iostream>
using namespace std;
int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	int c=0;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0) c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3628
import std.stdio,std.string,std.conv;
void main(){
	
	int sum;
	while( 1 ){
		auto rd = readln().chomp();
		if( !rd ){	break;	}
		
		sum=0;
		int d = to!int(rd);
		for( int i=d; i<600; i+=d ){
			sum += i*i*d;
		}
		writeln(sum);
	}
}

Measured memory_bytes: 1052
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;
typedef long long ll;

vector<vector<ll>> to;
vector<bool> visited;
vector<ll> depth;

ll dfs(ll cur){
    visited.at(cur) = true;
    for(ll nxt : to.at(cur)){
        if(!visited.at(nxt)){
            dfs(nxt);
        }
        depth.at(cur) = max(depth.at(cur), depth.at(nxt) + 1);
    }
    return depth.at(cur);
}

int main(){
    ll n, m;
    cin >> n >> m;
    to.resize(n);
    for(int i = 0; i < m; ++i){
        ll xi, yi;
        cin >> xi >> yi;
        xi--; yi--;
        to.at(xi).push_back(yi);
    }

    ll ans = 0;
    visited.resize(n, false);
    depth.resize(n, 0);
    for(int i = 0; i < n; ++i){
        if(!visited.at(i)){
            ans = max(ans, dfs(i));
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
	int a, b; cin >> a >> b;

	if (a + b == 15) cout << "+" << endl;
	else if (a*b == 15) cout << "*" << endl;
	else cout << "x" << endl;
}

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

int main() {
  
  int N, M;
  cin >> N >> M;
  
  if((N == 1 && M ==2) ||(N == 2 && M == 1)){
    cout << 3 << endl;
  }
  if((N == 2 && M == 3) ||(N == 3 && M == 2)){
    cout << 1 << endl;
  }
  if((N == 1 && M == 3) ||(N == 3 && M == 1)){
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;

typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;




int main() {
	
	int N,X;
	cin >> N >> X;
	VI M(N);
	LL num = 0;
	int m = 1145148;
	REP(i, N) { cin >> M[i]; X -= M[i]; num++; m = min(m,M[i]); }

	cout << num + (X / m) << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	char N[4];
	int x;
	scanf("%s",&N);
	x=strlen(N);
	if(N[x-1]=='3'){
		printf("bon\n");
	}
	else if((N[x-1]=='0')||(N[x-1]=='1')||(N[x-1]=='6')||(N[x-1]=='8')){
		printf("pon\n");
	}
	else{
		printf("hon\n");
	}
	return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

int N;cin>>N;
  
string S=to_string(N);
 // cout<<S[2];
  for(int i=0;i<3;i++){
    if(S[i]=='9'){
      cout<<"1";
    }else if(S[i]=='1'){
      cout<<"9";
    }else{cout<<S[i];
         }
  }
  cout<<endl;
      
  
  
  
}


Measured memory_bytes: 256
s = gets.chomp
bool = Array.new(26, false)
s.each_char { |c|
	bool[c.ord - 'a'.ord] = true
}
(0...26).each{ |i|
  if bool[i] == false
    puts (i + 'a'.ord).chr
    exit
  end
}
puts "None"


Measured memory_bytes: 1916
use proconio::input;

const MOD: usize = 998244353;

fn main() {
    input!{
        n: usize,
        k: usize,
        lr: [(usize, usize); k],
    }
    let mut dp = vec![0; n+1];
    let mut diff = vec![0; n+1];
    dp[0] = 1;
//    dp[1] = MOD-1;
    for i in 0..n {
        if i > 0 {
            dp[i] += diff[i];
            dp[i] %= MOD;
        }
        for (l, r) in lr.iter() {
            if i + l < n {
                diff[i+l] += dp[i];
                diff[i+l] %= MOD;
            }
            if i + r + 1 < n {
                diff[i+r+1] = diff[i+r+1] + MOD - dp[i];
                diff[i+r+1] %= MOD;
            }
        }
        diff[i+1] += diff[i];
        diff[i+1] %= MOD;
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
//#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define MOD 998244353
#define NUM -1

struct Info{
	Info(int arg_X,int arg_D){
		X = arg_X;
		D = arg_D;
	}
	bool operator<(const struct Info &arg) const{

		return X < arg.X;
	}

	int X,D;
};

int N;
int table[1000005];
int R[200005];
ll dp[200005];


void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = max(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_max = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_max = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return max(left_max,right_max);
}


int main(){

	int first_N;
	N = 1;

	scanf("%d",&first_N);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	int X,D;
	vector<Info> info;

	for(int i = 0; i < first_N; i++){

		scanf("%d %d",&X,&D);
		info.push_back(Info(X,D));
	}

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

	int left,right,mid;

	for(int i = 0; i < info.size(); i++){

		left = i,right = info.size()-1,mid = (left+right)/2;
		R[i] = i;

		while(left <= right){

			if(info[i].X+info[i].D > info[mid].X){

				R[i] = mid;
				left = mid+1;

			}else{

				right = mid-1;
			}
			mid = (left+right)/2;
		}
		//printf("i:%d X:%d R:%d\n",i,info[i].X,R[i]);
		update(i,R[i]);
	}

	dp[first_N] = 1;

	for(int i = info.size()-1; i >= 0; i--){

		int tmp = query(i,R[i],0,0,N-1)+1;

		dp[i] = dp[i+1]+dp[tmp];
		dp[i] %= MOD;

		update(i,tmp-1);
	}

	printf("%lld\n",dp[0]);

	return 0;
}


Measured memory_bytes: 8048
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	cout << a + b + c - max({a, b, c}) << endl;
	return 0;
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Solve(ll) {
  string str;
  ll k;
  if (not(cin >> str >> k))
    return;
  set<string> subs;
  VEVE(i, 0, SIZE(str)) {
    VEVE(j, 1, min(k, SIZE(str) - i) + 1) {
      subs.insert(str.substr(i, j));
    }
  }
  VEVE(its, 0, k - 1) subs.erase(subs.begin());
  cout << *subs.begin() << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 1664
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
String s[]=line.split(" ",0);
int n=Integer.parseInt(s[0]);
int k=Integer.parseInt(s[1]);
int a=k-n;
int u=0;
for(int i=1;i<=a;i++){
u+=i;
}
        System.out.println(u-k);
    }
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int res = 0;
  for (int i = (S.size() - 1) / 2; i > 0; --i) {
    if (S.substr(0, i) == S.substr(i, i)) {
      res = i;
      break;
    }
  }
  cout << 2 * res << endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const string a[] = {"SUN","MON","TUE","WED","THU","FRI","SAT" };
int main(void) {
    string S;
    cin >> S;

    REP(i, 7) if (a[i] == S) {
        cout << 7 - i << endl;
    }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
const int INF=10000000;

int main() {
    string s;
    cin >> s;
    bool ok=false;
    for(int i=0;i<2;++i) {
        if(s[i]!=s[i+1]) ok=true;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;

int main()

{
	string s;
	cin >> s;

	string ans="";

	for (int i = 0; i < s.size(); i++) {
		if ((i + 1 ) % 2 != 0) {
			ans = ans + s[i];
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3812
import numpy as np

def solve():
    N = int(input())
    a = list(map(int, input().split()))
    
    m = np.mean(a)
    m_ceil = np.ceil(m)
    m_floor = np.floor(m)
    
    ans1 = 0
    ans2 = 0
    for ai in a:
        ans1 += (ai - m_ceil) ** 2
        ans2 += (ai - m_floor) ** 2
    
    return int(min(ans1, ans2))

print(solve())

Measured memory_bytes: 12504