akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp
 
using namespace std;
 
typedef pair<int, int> P;
typedef long long ll;
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
 
string grid[401];
int H, W;
ll result = 0;

vector<P> path[401][401]; // 各マスから移動できる経路
ll col[401][401] = {0}; // そのマスがどの連結成分に属するか
ll cnts = 0; // 連結成分のID
ll B[160802] = {0}; // 各連結成分ごとの黒の数
ll WW[160802] = {0}; // 各連結成分ごとの白の数
 
void dfs(int x, int y) {
    if (col[x][y] > 0) return;
    col[x][y] = cnts;
    if (grid[x][y] == '.') WW[cnts]++;
    if (grid[x][y] == '#') B[cnts]++;
    rep(i, path[x][y].size()) {
        dfs(path[x][y][i]._1, path[x][y][i]._2);
    }
}
 
int main() {
    cin >> H >> W;
    rep(i, H) {
        string si;
        cin >> si;
        grid[i] = si;
    }

    // 各マスの経路作成
    rep(i, H) {
        rep(j, W) {
            char ci = grid[i][j];
            rep(d, 4) {
                int x = i + dx[d];
                int y = j + dy[d];
                if (x < 0 || x >= H || y < 0 || y >= W) continue;
                if (ci == '.' && grid[x][y] == '#') {
                    path[i][j].pb(make_pair(x, y));
                }
                if (ci == '#' && grid[x][y] == '.') {
                    path[i][j].pb(make_pair(x, y));
                }
            }
        }
    }

    // 連結成分作成しつつ、白黒の数を深さ優先でカウント
    rep(i, H) {
        rep(j, W) {
            if (col[i][j] != 0) continue;
            cnts++;
            dfs(i, j);
        }
    }

    // 全ての連結成分の個数分 白 * 黒を足し合わせる
    for (int i = 1; i <= cnts; i++) {
        result += 1LL * B[i] * WW[i];
    }
 
    cout << result << endl;
}

Measured memory_bytes: 18432
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int a[3];
  	cin >> a[0] >>a[1] >> a[2];
  	sort(a,a+3);
  	if(a[0] == 5 && a[1] == 5 && a[2] == 7)
    	cout << "YES\n";
  	else
    	cout << "NO\n";
   	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [ int(v) for v in input().split(" ") ]

for i in range(len(A)):
    while i > 0:
        if A[i] < A[i-1]:
            A[i], A[i-1] = A[i-1], A[i]
            i -= 1
        else:
            break
    print (" ".join([str(v) for v in A]))



Measured memory_bytes: 5604
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())


def xor(n):
    if n % 4 == 3:
        return 0
    if n % 4 == 0:
        return n
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return 1 ^ n


a, b = get_numbers()
print(xor(a - 1) ^ xor(b))

Measured memory_bytes: 38384
n, m = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
a = [0]*n
l.each_cons(2){|s| s.sort!; a[s[0]-1] += 1; a[s[1]-1] -= 1 }
(1...n-1).each{ |i| a[i] += a[i-1] }
sum = 0
(n-1).times do |i|
  p, q, r = gets.split.map(&:to_i)
  sum += [p*a[i],q*a[i]+r].min
end
p sum

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

using graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  graph to(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  vector<int> from(n, -1);
  queue<int> q;
  q.push(0);
  from.at(0) = 0;
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    for (auto x : to.at(t)) {
      if (from.at(x) != -1) continue;
      q.push(x);
      from.at(x) = t;
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < n; i++) {
    cout << from.at(i) + 1 << "\n";
  }
}


Measured memory_bytes: 10116
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
a = [[] for _ in range(H)]
for i in range(H):
    a[i] = list(map(int, input().split()))
b = [[] for _ in range(H)]
for i in range(H):
    b[i] = list(map(int, input().split()))

for i in range(H):
    for j in range(W):
        a[i][j] =abs(a[i][j]-b[i][j])

dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(a[0][0])
for i in range(1,H):
    t = a[i][0]
    tmp = set()
    for k in dp[i-1][0]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[i][0] = tmp
for j in range(1,W):
    t = a[0][j]
    tmp = set()
    for k in dp[0][j-1]:
        tmp.add(k+t)
        tmp.add(abs(k-t))
    dp[0][j] = tmp
for i in range(1,H):
    for j in range(1,W):
        t = a[i][j]
        tmp = set()
        for k in (dp[i-1][j] | dp[i][j-1]):
            tmp.add(k+t)
            tmp.add(abs(k-t))
        dp[i][j] = tmp
        dp[i-1][j-1] = set()

ls = list(dp[H-1][W-1])
print(min(ls))


Measured memory_bytes: 149512
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n").map(Number);
var str="";
for(var i=0;i<Arr.length;i++){
if(Arr[i]===0)break;
str+="Case "+(i+1)+": "+Arr[i]+"\n";
}
console.log(str.trim());

Measured memory_bytes: 11216
#include <iostream>
#include <cstdio>
#define MAX_N 100000
using namespace std;
typedef long long ll;
struct Edge {
	int next, to; ll c;
} edge[(MAX_N<<1)+5];
int n, m, k, cnt;
int d[MAX_N+5], p[MAX_N+5][25], first[MAX_N+5];
ll tofa[MAX_N+5][25];
bool vis[MAX_N+5];
void INSERT(int a, int b, ll c) {
	edge[++cnt].next = first[a], edge[cnt].c = c;
	edge[cnt].to = b, first[a] = cnt;
}
void DFS(int u) {
	vis[u] = true;
	for (int i = 1; (1<<i) <= n; i++) {
		if ((1<<i) <= d[u]) {
			p[u][i] = p[p[u][i-1]][i-1];
			tofa[u][i] = tofa[u][i-1]+tofa[p[u][i-1]][i-1];
		}
	}
	for (int i = first[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (!vis[v]) {
			d[v] = d[u]+1;
			p[v][0] = u;
			tofa[v][0] = edge[i].c;
			DFS(v);
		}
	}
}
ll LCA(int a, int b) {
	int i, j; ll ret = 0;
	if (d[a] < d[b])	swap(a, b);
	for (i = 0; (1<<i) <= d[a]; i++) {}
	i--;
	for (j = i; j >= 0; j--) {
		if (d[a]-(1<<j) >= d[b]) {
			ret += tofa[a][j];
			a = p[a][j];
		}
	}
	if (a == b) {
		return ret;
	}
	for (j = i; j >= 0; j--) {
		if (p[a][j] != p[b][j]) {
			ret += (tofa[a][j]+tofa[b][j]);
			a = p[a][j];
			b = p[b][j];
		}
	}
	return ret+tofa[a][0]+tofa[b][0];
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v, c; cin >> u >> v >> c;
		INSERT(u, v, c), INSERT(v, u, c);
	}
	DFS(1);
	scanf("%d%d", &m, &k);
	for (int i = 0; i < m; i++) {
		int x, y; scanf("%d%d", &x, &y);
		printf("%lld\n", LCA(x, k)+LCA(k, y));
	}
	return 0;
}


Measured memory_bytes: 38272
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[int(input())-1])

Measured memory_bytes: 38408
list = input().split(" ")
A = int(list[0])
B = int(list[1])
C = int(list[2])

if (A == B) and (A != C):
    print("Yes")
elif (A == C) and (A != B):
    print("Yes")
elif (B == C) and (B != A):
    print("Yes")
else:
    print("No")

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

int main()
{
	int d;
	cin >> d;
	string ans;
	switch (d)
	{
	case 25:
		ans = "Christmas";
		break;
	case 24:
		ans = "Christmas Eve"; 
		break;
	case 23:
		ans = "Christmas Eve Eve";
		break;
	case 22:
		ans = "Christmas Eve Eve Eve";
		break;
	default:
		break;
	}
	cout << ans << endl;
    return 0;
}



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

using namespace std;

int n, m, k;
int l[100010], h[100010];
long long best;
pair <long long, int> X[100010], Y[100010];

struct edge
{
    int u, v;
    long long w;
    bool operator < (const edge& other) const
    {
        return w < other.w;
    }
} e[100010];

int Find(int x)
{
    return x == l[x] ? x : l[x] = Find(l[x]);
}

int Union(int u, int v)
{
    if ((u = Find(u)) == (v = Find(v))) return 0;
    if (h[u] < h[v]) swap(u, v);
    l[v] = u;
    h[u] += h[v];
    return 1;
}


int main()
{
//    freopen("BUILD.inp", "r", stdin);
//    freopen("BUILD.out", "w", stdout);

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

    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        l[i] = i, h[i] = 1;
        long long x, y;
        cin >> x >> y;
        X[i] = {x, i};
        Y[i] = {y, i};
    }
    sort(X + 1, X + n + 1);
    sort(Y + 1, Y + n + 1);
    for (int i = 1; i < n; ++i)
        e[++m] = {X[i].second, X[i + 1].second, X[i + 1].first - X[i].first};
    for (int i = 1; i < n; ++i)
        e[++m] = {Y[i].second, Y[i + 1].second, Y[i + 1].first - Y[i].first};
    sort(e + 1, e + m + 1);
    for (int i = 1; i <= m; ++i)
        if (Union(e[i].u, e[i].v))
            best += e[i].w;
    cout << best;
}

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

int main(){
	int n,c,k;
	cin>>n>>c>>k;

	long long t[100000];
	for (int i = 0; i < n; ++i){
		cin>>t[i];
	}
	sort(t,t+n);


	int ans=1,cnt=1,s=t[0];
	for (int i = 1; i < n; ++i){
		if(s+k>=t[i] && cnt<c)
			cnt++;
		else{
			ans++;
			cnt=1;
			s=t[i];
		}
	}

	cout<<ans<<endl;

}


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

using namespace std;

int main()
{
    int H,W;
    cin >> H >> W;
    vector <string> a(H);
    for (int i = 0; i < H; i++){
        cin >> a.at(i);
    }

    int cnt = 0;
    string str(W,'.');
    for (int i = 0; i < H; i++){
        if(a[i - cnt] == str){
            a.erase(a.begin() + i - cnt);
            cnt++;
        }
    }
    
    int cnt2 = 0;
    
    for (int j = 0; j < W; j++){
        bool flag = true;
        for (int i = 0; i < H - cnt; i++){
            if (a[i][j - cnt2] != '.'){
                flag = false;
                break;
            }
        }
        if (flag){
            for (int i = 0; i < H - cnt; i++){
                a[i].erase(a[i].begin() + j - cnt2);
            }
            cnt2++;
        }
    }
    
    for (int i = 0; i < H - cnt; i++){
        cout << a.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

#include<math.h>
#include <algorithm>
using namespace std;


int main()
{

    long long int x;
    cin>>x;
    long long int a[x],z=0,b;

    for(int i=0;i<x;i++){
        cin>>a[i];
        a[i]=a[i]-i-1;
    }


    sort(a,a+x);

    b=a[x/2];



    for(int i=0;i<x;i++){
        z+=abs(a[i]-b);
    }

    cout<<z;





    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n, l, t, ans = 1e9;
int main(){
    cin >> n >> l;
    t = n*(l*2 + n-1)/2;
    if(l > 0) ans = t - l;
    else if(l+n-1 >= 0) ans = t;
    else ans = t - (l+n-1);
    printf("%d\n", ans);
}

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

vector< vector<int> > G(200005);
vector< int64_t > cnt(200005, 0);
vector< bool > visit(200005, false);

void BFS( int v, int64_t pval ) {
  cnt[v] += pval;
  visit[v] = true;
  for( auto a : G[v] ) {
    if ( visit[a] ) continue;
    BFS( a, cnt[v] );
  }
}

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

  for( int i=0; i<N-1; ++i) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for( int i=0; i<Q; ++i) {
    int64_t p,x;
    cin >> p >> x;
    cnt[--p] += x;
  }

  BFS(0,0);

  for( int i=0;i<N;i++ ) {
    cout << cnt[i] << " ";
  }
  
  cout << endl;

}


Measured memory_bytes: 24320
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;

signed main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,h,m,s;
	cin>>a;
	h=a/3600;
	m=(a-h*3600)/60;
	s=a-h*3600-m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


Measured memory_bytes: 3092
import java.util.*;
import java.util.stream.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		char[] s = sc.next().toCharArray();
		System.out.println(IntStream.range(1, s.length).filter(i -> s[i - 1] != s[i]).count() + 1);
	}
}


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

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 1e6;

int ans[N];
int c[N];
vector<pair<int, int> > qs[N];
int lst[N];

int fenw[N];

void add(int pos, int x)
{
    while (pos < N)
    {
        fenw[pos] += x;
        pos = pos | (pos + 1);
    }
}

int get(int x)
{
    int res = 0;
    while (x >= 0)
    {
        res += fenw[x];
        x = (x & (x + 1)) - 1;
    }
    return res;
}

int get(int l, int r)
{
    if (l == 0) return get(r);
    return get(r) - get(l - 1);
}

signed main()
{
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        qs[r].push_back({l, i});
    }
    for (int i = 0; i < N; i++) lst[i] = -1;
    for (int i = 0; i < n; i++)
    {
        if (lst[c[i]] != -1)
            add(lst[c[i]], -1);
        add(i, 1);
        lst[c[i]] = i;
        for (int j = 0; j < qs[i].size(); j++)
        {
            ans[qs[i][j].second] = get(qs[i][j].first, i);
        }
    }
    forn(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 27020
from math import sqrt, cos, radians

a, b, h, m = map(int, input().split())
mm = h * 60 + m
ag_s = 360 * (mm / (12*60))
ag_l = 360 * (m / 60)
theta = abs(ag_s - ag_l)
ans = sqrt(a**2 + b**2 - 2*a*b * cos(radians(theta)))
print(ans)


Measured memory_bytes: 9500
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <cstdlib>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i,n) for(i = 0;i<n;i++)

using namespace std;

int main() {
	
	int  a, b, c;

	cin >> a >> b >> c;

	if (b-a == c - b) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
rank = [2,3,4,5,6,7,8,9,10,11,12,13,1]
ranka = rank.index(a)
rankb = rank.index(b)
if ranka == rankb:
    print('Draw')
elif ranka > rankb:
    print('Alice')
else:
    print('Bob')

Measured memory_bytes: 3060
use std::io::*;
use std::str::*;

fn main() {
    let s: Vec<char> = read_chars();
    let mut k: u64 = read();

    for c in s.iter() {
        if *c == '1' {
            k -= 1;
            if k == 0 {
                println!("{}", c);
                return;
            }
        } else {
            println!("{}", c);
            return;
        }
    }
}

fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_chars() -> Vec<char> {
    let s = stdin().bytes().map(|c| c.unwrap() as char)
                   .skip_while(|c| c.is_whitespace())
                   .take_while(|c| !c.is_whitespace())
                   .collect::<Vec<char>>();
    s
}

Measured memory_bytes: 4352
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,s,n) for(int i=s; i<n; i++)

using namespace std;

int main() {
    string a,b;
    cin >> a >> b;
    reverse(b.begin(), b.end());
    string ans = (a == b) ? "YES" : "NO";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
#include <map>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
typedef unsigned long long ULL;

int H, W;
string Blocks[300];
int DP[301][301];
int Cost[301][301];

void input() {
	REP(i, 0, H) {
		cin >> Blocks[i];
	}
}

int calc(int row) {
	REPM(i, H + 1, 0) {
		REPM(j, H + 1, 0) {
			if (i == H) {
				Cost[i][j] = 0;
			} else {
				Cost[i][j] = (j == H ? 0 : Cost[i + 1][j + 1] + (Blocks[H - 1 - i][row] == Blocks[H - 1 - j][row + 1]));
			}
		}
	}

	REP(i, 0, H + 1) {
		REP(j, 0, H + 1) {
			if (i == 0) {
				DP[i][j] = (j == 0 ? 0 : DP[i][j - 1] + Cost[i][j - 1]);
			} else {
				DP[i][j] = (j == 0 ? DP[i - 1][j] + Cost[i - 1][j] :
					min(DP[i - 1][j] + Cost[i - 1][j], DP[i][j - 1] + Cost[i][j - 1]));
			}
		}
	}
	return DP[H][H];
}

int main() {
	cin >> H >> W;
	input();
	int sum = 0;
	REP(i, 0, W - 1) {
		sum += calc(i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1280
// https://atcoder.jp/contests/abc143/tasks/abc143_b

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N;
  cin >> N;
  VL ds(N);
  rep(i, 0, N) cin >> ds[i];

  ll res = 0;

  rep(i, 0, N) rep(j, i + 1, N) { res += ds[i] * ds[j]; }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
from fractions import gcd
r,g,b,n=map(int,input().split())
t=0
for i in range(0,(n-1)//r+2):
    d=n-r*i
    if d%gcd(g,b)==0:
        c=0
        for j in range(0,(d-1)//b+2):
            if (d-j*b)%g==0:
                c=1
                break
        if c==1:
            t+=(d-j*b)//(g*b//gcd(g,b))+1
print(t)

Measured memory_bytes: 5308
n =int(input())
s = input()
s = list(s)
for i in range(len(s)):
    if s[i] =='o':
        s[i] = int(1)
    else:
        s[i] = int(-1)

syoki_list = [[1,1],[1,-1],[-1,1],[-1,-1]]
a = "-1"
for i in range(len(syoki_list)):
    t = []
    t.append(syoki_list[i][0])
    t.append(syoki_list[i][1])
    for j in range(2,n+1):
        t.append(t[j-2] * t[j-1] * s[j-1])
    if t[0] == t[n] and t[1] == t[n-1] * t[n]*s[0]:
        for i in range(n+1):
            if t[i] == 1:
                t[i] = "S"
            else:
                t[i] = "W"
        a= "".join(t[:n])
        break

print(a)

Measured memory_bytes: 5532
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv


S = int(input())
MOD = 10**9+7
comb = Combination(2000, MOD)
i = 1
answer = 0
while i*3 <= S:
    t = S - (i*3)
    answer += comb(t+i-1,t)
    i+=1
print(answer%MOD)

Measured memory_bytes: 65480
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<ll> P(n);
    loop (n, i) cin >> P[i];
    V<int> I(n + 1);
    loop (n, i) {
        I[P[i]] = i;
    }

    ll ans = 0;
    set<int> S = { -2, -1, n, n + 1};
    loop (n, i) {
        int idx = I[n - i];
        S.insert(idx);
        auto itr = S.lower_bound(idx);
        ll l1 = *prev(itr), l2 = *prev(itr, 2);
        ll r1 = *next(itr), r2 = *next(itr, 2);

        if (r1 < n) {
            ans += (r2 - r1) * (idx - l1) * P[idx];
        }
        if (l1 >= 0) {
            ans += (l1 - l2) * (r1 - idx) * P[idx];
        }

    }

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



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

int main()
{
    int n;
    cin>>n;
    vector<tuple<int,int,char,int64_t,string> >a(n,tuple<int,int,char,int64_t,string>());
    int v,w;
    char t;
    int64_t d;
    string s;
    REP(i,n)
    {
        cin>>v>>w>>t>>d>>s;
        a.at(i)=make_tuple(v,w,t,d,s);
    }
    sort(a.begin(),a.end());
    REP(i,n)cout<<get<0>(a.at(i))<<" "<<get<1>(a.at(i))<<" "<<get<2>(a.at(i))<<" "<<get<3>(a.at(i))<<" "<<get<4>(a.at(i))<<endl;
}


Measured memory_bytes: 12152
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n,m = map(int, input().split())
    As = list(map(int, input().split()))
    As.sort()
    As.reverse()
    cnt = 0
    sm = sum(As)
    k = sm / (4*m)
    for i in range(n):
        if not (As[i] < k):
            cnt += 1
    if cnt >= m:
        print('Yes')
    else:
        print('No')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5328
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	s := make([]int, n)
	for i := 1; i <= n; i++ {
		x := nextInt()
		s[x-1] = i
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d", s[i])
		if i != n - 1 {
			fmt.Printf(" ")
		}
	}
}


Measured memory_bytes: 3328
void main()
{
    long x = rdElem;

    bool[] lists = new bool[x+1];
    lists[1] = true;
    for (long i = 2; i * i <= x; ++i)
    {
        for (long j = i * i; j <= x; j *= i)
        {
            lists[j] = true;
        }
    }

    foreach_reverse (i, y; lists)
    {
        if (y)
        {
            i.writeln;
            return;
        }
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}

Measured memory_bytes: 3588
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e6 + 10 , P = 1e9 + 7;
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
int f[N],n;

int main(){
  scanf("%d",&n);
  f[0] = 1;
  f[1] = n;
  int s = 0;
  rep(i,2,n+1) {
    f[i] = f[i-1];
    if(i-3>=0)
      pp(s , f[i-3]);
    pp(f[i] , s);
    pp(f[i] , n-1-(i-2));
    pp(f[i] , ll(n - 1) * (n - 1) % P);
  }
  printf("%d\n",f[n]);
  return 0;
}


Measured memory_bytes: 4096
S=list(input())
k=int(input())
for i in range(len(S)):
    s=S[i]
    if s=="a":continue
    x=123-ord(s)
    #print(s,x,ord("z"))
    if k>=x:
        k-=x
        S[i]="a"

    else:continue
k%=26
for i in range(len(S)):
    if S[-1-i]!="a":
        S[-1-i]=chr((ord(S[-1-i])-97+k%26)+97)
        print("".join(S));break
else:
    S[-1]=chr((ord(S[-1])-97+k%26)+97)
    print("".join(S))

Measured memory_bytes: 4152
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int q; cin >> q;
    rep(i,q){
        ll a,b; cin >> a >> b;
        if(a > b) swap(a,b);
        ll ans = 0;
        ll p = a*b;
        ll n = sqrt(static_cast<long double>(p));
        if(p == n*n && a != b) n--;
        if(a == b) ans = 2*n-2;
        if(b - a == 1) ans = 2*n-2;
        else{
            if(p <= n*(n+1)) ans = 2*n-2;
            else ans = 2*n-1;
        } 
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
arr2 = []
count = 0
for _ in range(int(input())):
    arr = list(map(int, input().split()))
    arr2.append(arr)
for k in range(len(arr2)):
    if arr2[k][0] == arr2[k][1]:
        count += 1
        if count == 3:
            print("Yes")
            exit()
    else:
        count = 0
print("No")


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string S;
	string T;
	cin>>S;cin>>T;
	int N=S.size();
	int M=T.size();
	vector< vector<int > > lcs(N+1, vector<int> (M+1.0));
	for(int i=0;i<=N;i++)
	{
		for(int j=0;j<=M;j++)
		{
			if(i==0 or j==0)
			{
				lcs[i][j]=0;
			}
			else if(S[i-1]==T[j-1])
			{
				lcs[i][j]=1+lcs[i-1][j-1];
			}
			else 
			{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	int i=N;
	int j=M;
	string ans="";
	while(i>=1 and j>=1)
	{
		if(S[i-1]==T[j-1])
		{
			ans+=S[i-1];
			i--;
			j--;
		}
		else
		{
			if(lcs[i-1][j]>lcs[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<"";
}

Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N,M;
    cin>>N;
    vector<string> blue(N);
    for(int i = 0;i < N; i++){
        cin>>blue.at(i);
    }
    cin>>M;
    vector<string> red(M);
    for(int j = 0;j < M; j++){
        cin>>red.at(j);
    }
    
    vector<int> Rcount(N);    
    for(int k = 0;k < N; k++){
        for(int l = 0;l < M;l++){
            if( blue.at(k) == red.at(l) ){
                Rcount.at(k) = Rcount.at(k) + 1;
            }
        }
    }
    
    vector<int> Bcount(N);    
    for(int n = 0;n < N; n++){
        for(int m = 0;m < N; m++){
            if( blue.at(n) == blue.at(m) ){
                Bcount.at(n) = Bcount.at(n) + 1;
            }
        }
    }
    
    vector<int> answer(N);
    for(int o = 0; o < N; o++){
        answer.at(o) = Bcount.at(o) - Rcount.at(o);
    }
    
    int max = 0;
    for(int p = 0; p < N; p++){
        if( max < answer.at(p) ){
            max = answer.at(p);
        }
    }
        
        cout<<max<<endl;
}

Measured memory_bytes: 256
// AOJ 1507 Dungeon (II)
// 2018.3.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 高速数値入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数のみ
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

/* UNION-FIND library */
#define MAX 200005
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
	int i = root(p), j = root(q); if (i == j) return;
	if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

// 本問題関連
typedef struct { int a, b, c; } T;
T t[MAX]; int N;

int cmp(const void *a, const void *b) {	return ((T *)a)->c - ((T *)b)->c; }

int main()
{
	int i, a, b;
	long long ans;

	N = in() - 1;
	for (i = 0; i < N; i++)
		t[i].a = in(), t[i].b = in(), t[i].c = in();
	qsort(t, N, sizeof(T), cmp);
	init(N + 1);
	ans = 0;
	for (i = 0; i < N; i++) {
		a = t[i].a, b = t[i].b;
		ans += (long long)size[root(a)] * size[root(b)] * t[i].c;
		unite(a, b);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=5010;
char str[N<<1];
int n,k;
char ch;
int len[N<<1];
int ansl,ansr;
int anslen;
void upd(int l,int r) {
	if(!ansl) return (void)(ansl=l,ansr=r);
	for(int i=0;i<anslen;++i)
		if(str[r-i]!=str[ansr-i]) {
			if(str[r-i]<str[ansr-i])
				ansr=r,ansl=l;
			return;
		}
}
int main() {
	rd(n),rd(k);
	scanf("%s",str+1);
	ch=127;
	for(int i=1;i<=n;++i) {
		str[n+i]=str[n-i+1];
		ch=min(ch,str[i]);
	}
	int mxlen=0;
	for(int i=1;i<=n*2;++i) {
		if(str[i]==ch) len[i]=len[i-1]+1;
		else len[i]=0;
		mxlen=max(mxlen,len[i]);
//		cout<<i<<':'<<len[i]<<endl;
	}
	if(mxlen*(1ll<<(min(k-1,20)))>=n) {
		for(int i=1;i<=n;++i) putchar(ch);
		return 0;
	}
	int _len=mxlen*(1<<k-1); anslen=n-_len;
	if(k==1) {
		int ansp=1;
		for(int i=2;i<=n+1;++i) {
			for(int j=0;j<n;++j)
				if(str[i+j]!=str[ansp+j]) {
					if(str[i+j]<str[ansp+j]) ansp=i;
					break;
				}
		}
		for(int j=0;j<n;++j) putchar(str[ansp+j]);
		return 0;
	}
	for(int i=1;i<=n+1;++i) {
		if(len[i+n-1]<mxlen) continue;
		upd(i+n-mxlen-anslen,i+n-1-mxlen);
	}
//	cout<<ansl<<' '<<ansr<<endl;
	for(int i=1;i<=_len;++i) putchar(ch);
	for(int i=ansr;i>=ansl;--i) putchar(str[i]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char s[100];
  long long k;
  bool flag = true;
  scanf("%s\n", s);
  scanf("%lld\n",&k );
  for (long long i = 0; s[i] != '\0' && i < k; i++) {
    if(s[i] != '1') {
      putchar(s[i]);
      flag = false;
      break;
    }
  }
  if(flag)  puts("1");
  return 0;
}

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

long calc(long x, long y);

int main() {
    long h, w, ans;
    cin >> h >> w;
    ans = min(calc(h, w), calc(w, h));
    cout << ans << endl;
}

long calc(long x, long y) {
    long a, b, c, ans = LONG_MAX;
    rep(i, x - 1) {
        a = (i + 1) * y;
        b = (x - i - 1) * (y / 2);
        c = ((x - i - 1) * (y - y / 2));
        ans = min(ans, max(a, c) - min(a, b));
        b = (x - i - 1) / 2 * y;
        c = ((x - i - 1) - (x - i - 1) / 2) * y;
        ans = min(ans, max(a, c) - min(a, b));
    }
    return ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s[100];
int f[101][101] = {0};

int getsum(int t, int l, int b, int r){
  return f[b][r] - f[b][l] - f[t][r] + f[t][l];
}
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int3(n, m, d);
    rep(i, n)cin >> s[i];
    rep(i, n)rep(j, m)if(s[i][j] == '#')f[i + 1][j + 1]++;

    rep(i, n + 1)rep(j, m)f[i][j + 1] += f[i][j];
    rep(j, m + 1)rep(i, n)f[i + 1][j] += f[i][j];

    int res = 0;
    rep(i, n)rep(j, m - d + 1)if(getsum(i, j, i + 1, j + d) == 0)++res;
    rep(j, m)rep(i, n - d + 1)if(getsum(i, j, i + d, j + 1) == 0)++res;

    pri(res);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3300
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n,r = map(int, input().split())
    if n >= 10:
        print(r)
        return 
    print(r + 100 * (10 - n))
   

main()


Measured memory_bytes: 3316
n,m = map(int,input().split())
il = []
for i in range(m):
  a,b = map(int,input().split())
  il.append([a,b])
il = sorted(il,key = lambda x:x[1])
count = 0

brr = -99999
for i in range(m):
  if il[i][0] >= brr:
    count += 1
    brr = il[i][1]
print(count)
         

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

Measured memory_bytes: 3632
from collections import defaultdict


def main():
    N = int(input())
    A = list(map(int, input().split()))
    MAX_EXP = 30  # 2**30 < 2 * (10 ** 9) < 2**31
    pow2 = [1] * (MAX_EXP + 1)
    for e in range(1, MAX_EXP + 1):
        pow2[e] = 2 * pow2[e - 1]
    counter = defaultdict(int)
    for a in A:
        counter[a] += 1
    DISTINCT_A = list(counter.keys())
    DISTINCT_A.sort(reverse=True)  # 大きい順に並べておく
    # 和が2のべき乗になるペアの間をedgeで結んだグラフを考え
    # ノードの値が大きい順に貪欲にペアを作っていく
    ans = 0
    for a in DISTINCT_A:
        b = pow2[a.bit_length()] - a
        if counter[b] == 0:
            continue
        cnt = min(counter[a], counter[b])
        ans += cnt
        counter[a] -= cnt
        counter[b] -= cnt
    # 最後に2のべき乗のノードはそれ単体でペアを作れるので、その分を足す
    for e in range(MAX_EXP + 1):
        a = pow2[e]
        ans += counter[a] // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++);
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}
map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int n;
	cin >> n;
	cout << n / 2 + n % 2;
	return 0;
}









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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    char c; cin >> c;
    if(c - 'A' < 26) out("A");
    else out("a");
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;


typedef struct rv {
  int i;
  int x;
} rv;

bool compar_rv(const rv &a, const rv &b) {
  return a.i < b.i || (a.i == b.i && a.x < b.x);
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<rv> rs(n * 2);
  int rsi = 0;
  for (int i = 0; i < n; i++) {
    int s, t, x;
    cin >> s >> t >> x;
    rs[rsi].i = s - x;
    rs[rsi].x = x;
    rsi++;
    rs[rsi].i = t - x;
    rs[rsi].x = ~x;
    rsi++;
  }
  sort(rs.begin(), rs.end(), compar_rv);
  set<int> sts;
  vector<int> dks(n * 2);
  vector<int> dvs(n * 2);
  rsi = -1;
  for (int rsj = 0; rsj < 2 * n; rsj++) {
    if (rs[rsj].x < 0) {
      sts.erase(~rs[rsj].x);
    } else {
      sts.insert(rs[rsj].x);
    }
    // if (rsi < 0 || dks[rsi] != rs[rsj].i) {
      dks[++rsi] = rs[rsj].i;
    // }
    dvs[rsi] = sts.size() ? *sts.begin() : -1;
  }
  for (int i = 0; i < q; i++) {
    int d;
    cin >> d;
    int j;
    {
      int l = 0;
      int u = rsi + 1;
      while (l + 1 < u) {
        int m = (l + u) / 2;
        if (dks[m] > d) {
          u = m;
        } else {
          l = m;
        }
      }
      j = l;
    }
    if (0 <= j && j < rsi && dks[j] <= d && d < dks[j + 1]) {
      cout << dvs[j] << endl;
    } else {
      cout << (-1) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
int mod;
int power(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int32_t main()
{
	IOS;
	int l;
	cin>>l;
	if(l%3)
	{
		double ans=l/3.0;
		ans=ans*ans*ans;
		cout<<setprecision(12)<<ans;
	}
	else
	{
		int ans=l/3;
		ans=pow(ans,3);
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

 #include <iostream>
#include<algorithm>
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long 
#define PB push_back
#define MP make_pair
#define ff first
#define pri 1000000007
#define ss second
using namespace std;
using namespace std;

int main() {
	ll n;
    cin>>n;
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
     ll k= min(min(min(min(a,b),c),d),e);
    cout<<(n-1)/k+5;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  DV(G,lli,3,N,0);
  rep(i,0,3)rep(j,0,N)cin >> G[i][j];
  Sort(G[0]);
  Sort(G[2]);
  rep(i,0,N){
    num=0;
    int ok=N;
    int ng=-1;
    while(ok-ng>1){
      int mid=(ok+ng)/2;
      if(G[2][mid]>G[1][i])ok=mid;
      else ng=mid;
    }
    num=N-ok;
    ok=-1;
    ng=N;
    while(ng-ok>1){
      int mid=(ok+ng)/2;
      if(G[1][i]>G[0][mid])ok=mid;
      else ng=mid;
    }
    sum+=num*ng;
  }
  Out(sum);
}

Measured memory_bytes: 3456