akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        x: usize,
        v: [usize; n]
    }
    let mut d = 0;
    let mut i = 0;
    while i < n && d <= x {
        d += v[i];
        i += 1;
    }
    if d <= x {
        i += 1;
    }
    println!("{}", i);
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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

int n, q;
Graph G(2*100000+5);
vector<int>score(2*100000+5);
vector<int> res(2*100000+5);

void dfs(int v, int par, int sum){
    res[v] = sum;

    for(auto nv : G[v]){
        if( nv == par )continue;
        dfs(nv, v, sum+score[nv]);
    }
}



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

    rep(i , n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

   
    rep(i, q){
        int a, b;
        cin >> a >> b;
        a--;
        score[a] += b;
    }
    dfs(0, -1, score[0]);
    rep(i , n)cout << res[i] << " ";
}

Measured memory_bytes: 24320
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		
		double a = saori.Hayamin()*2;
		System.out.println(a*3.14);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

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

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

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

#define file "I1"

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

const int MAXN = 1e5 + 5;

vector<pii> ans;

void solve(){
	int n, mn = INF, mx = -INF, mini = -1, maxi = -1, a;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &a);
		if (a > mx){
			mx = a;
			maxi = i;
		}
		if (a < mn){
			mn = a;
			mini = i;
		}
	}
	//printf("%d %d %d %d\n", mn, mini, mx, maxi);
	if (mn < 0 && -mn > mx){
		REP(i, 0, n){
			if (i != mini){
				ans.pb(mp(mini, i));
			}
		}
		REP(i, 1, n){
			ans.pb(mp(n - i, n - i - 1));
		}
	} else {
		REP(i, 0, n){
			if (i != maxi){
				ans.pb(mp(maxi, i));
			}
		}
		REP(i, 1, n){
			ans.pb(mp(i - 1, i));
		}
	}
	printf("%d\n", SZ(ans));
	REP(i, 0, SZ(ans)){
		printf("%d %d\n", ans[i]._1 + 1, ans[i]._2 + 1);
	}
}   

int main(){

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


Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0 || n==1) return dp[n]=1;
  if(dp[n] != -1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}
    



Measured memory_bytes: 2048
#include <stdio.h>
int main()
{
  int a,b,c,sum,n,sumx,cou=0;
  while(1){
    scanf("%d %d",&n,&sumx);
    if(n==0&&sumx==0){
      break;
    }
    for(a=1;a<=n;a++){
      for(b=a+1;b<=n;b++){
	for(c=b+1;c<=n;c++){
	  sum=a+b+c;
	  if(sum==sumx&&a!=b&&b!=c&&c!=a){
	    cou=cou+1;
	  }
	}
      }
    }
    printf("%d\n",cou);
    cou=0;
  }
  return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    int H, W,i,j;
    char u, d, r, l;
    char s[51][60] = {""};

    scanf("%d %d", &H, &W);

    for (i = 0; i < H; i++) {
        scanf("%s", s[i]);
    }

    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {

            if (i - 1 < 0)
                u = 0;
            else
                u = s[i - 1][j];

            if (j - 1 < 0)
                l = 0;
            else
                l = s[i][j - 1];

            d = s[i + 1][j];
            r = s[i][j + 1];

            if (s[i][j] == '#') {
                if (u == '#' || d == '#' || r == '#' || l == '#')
                    continue;
                else {
                    printf("No");
                        return 0;
                }
            }
        }
    }


    printf("Yes");
      

    return 0;
}


Measured memory_bytes: 2152
def f(x):
    if x==2:
        return 1
    if x<2 or x%2==0:
        return 0
    i=3
    while i<=x**(1/2):
        if x%i==0:
            return 0
        i+=2
    return 1

n=int(input())
s=0
for i in range(n):
    x=int(input())
    s+=f(x)
print(s)


Measured memory_bytes: 5660
#include <iostream>
#include <cmath>
#include <time.h>
#include <algorithm>
#include <string>
#include <map>

using namespace std;
typedef long long int lint;

int main()
{
	lint A, N;
	map<lint, lint> rect;
	cin >> N;

	for (lint i = 0; i < N; i++) {
		cin >> A;
		rect[A]++;
	}
	
	lint first = 0, second = 0;

	//first
	for (auto itr = rect.rbegin(); itr != rect.rend(); itr++) {
		if (itr->second >= 2) {
			first = itr->first;
			itr->second -= 2;
			break;
		}
	}

	//second
	for (auto itr = rect.rbegin(); itr != rect.rend(); itr++) {
		if (itr->second >= 2) {
			second = itr->first;
			break;
		}
	}

	cout << ((first * second == 0) ? 0 : first * second) << endl;

	return 0;
}

Measured memory_bytes: 6528
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int k;
	scanf("%d", &k);

	int a = 7;
	REP(i, 0, 1e6){
		a %= k;
		if(a==0){
			printf("%ld\n", i+1);
			return 0;
		}
		a = a * 10 + 7;
	}
	puts("-1");
	return 0;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i=min(a,b); i>=1; i--){
        if(a%i == 0 && b%i == 0){
            cnt++;
        }
        if(cnt == k){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main(void) {
	int N, M;
	scanf("%d %d", &N, &M);
	int a[50], b[50], c[50], d[50];
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &c[i], &d[i]);
	}
	for (int i = 0; i < N; i++) {
		int nearest = 2000000000;
		int ans;
		for (int j = 0; j < M; j++) {
			int dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (dis < nearest) {
				nearest = dis;
				ans = j + 1;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, q, a[100010];
ll cum[100010], cum2[100010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> q;
	for (int i = 0; i < n; i++)cin >> a[i];
	cum[0] = a[0]; cum[1] = a[1];
	for (int i = 2; i < n; i++)cum[i] = cum[i - 2] + a[i];
	for (int i = n - 1; i >= 0; i--)cum2[i] = cum2[i + 1] + a[i];
	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		int mi = 0, ma = n;
		while (ma - mi > 1) {
			int md = (mi + ma) / 2;
			int x = lower_bound(a, a + n, a[md]) - lower_bound(a, a + n, p - (a[md] - p));
			if ((n - md) - 1 > x)mi = md;
			else ma = md;
		}
		cout << cum2[ma] + cum[n - (n - ma) * 2 - 1] << endl;
	}
}

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

int main(){
    int n;
    while(cin >> n, n){
        string s;
        cin >> s;
        int a[n], b[n];
        for(int i = 0; i < n; i++)  cin >> a[i] >> b[i];
        for(int i = n-1; i >= 0; i--){
            int c = abs(a[i]-b[i]);
            s[a[i]-1] = (char)('a' + (s[a[i]-1]-'a'+c)%26);
            s[b[i]-1] = (char)('a' + (s[b[i]-1]-'a'+c)%26);
            swap(s[a[i]-1], s[b[i]-1]);
        }
        cout << s << endl;
    }

}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ll n;
  cin >> n;

  ll ans = 999;

  for (int i = 2; i < 10; i++) {
    ll mod = 1;
    REP(j, i + 1) mod *= 10;

    ll x = n % mod;
    REP(j, i - 2) x /= 10;

    ans = min(ans, abs(x - 753));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int h[100005];
  int cnt = 0;
  int mx = 0;
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> h[i];
  }

  for(int i = n - 1;i > 0;i--){
    if(h[i - 1] - h[i] == 1){
      h[i - 1]--;
    }else if(h[i - 1] - h[i] > 1){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
}


Measured memory_bytes: 256
# Import
from collections import deque
import math

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return [type(i) for i in input().split()]
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
# class ModInt:
#     def __init__(self, n, MOD):
#         self.n = n
#         self.MOD = MOD
    
#     def __add__(self, o):
#         return ModInt((self.n + o.n) % self.MOD, self.MOD)

#     def __sub__(self, o):
#         return ModInt((self.n - o.n + self.MOD) % self.MOD, self.MOD)

#     def __mul__(self, o):
#         return ModInt((self.n * o.n) % self.MOD, self.MOD)

#     def __iadd__(self, o):
#         self.n = (self.n + o.n) % self.MOD
#         return self

#     def __isub__(self, o):
#         self.n = (self.n - o.n + self.MOD) % self.MOD
#         return self

#     def __imul__(self, o):
#         self.n = (self.n * o.n) % self.MOD
#         return self

#     def __str__(self): return str(self.n)

MOD = 998244353
N, S = read_tupple()
A = read_array()

dp = [[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i + 1][j] = (dp[i + 1][j] + 2 * dp[i][j]) % MOD
        if j - A[i] >= 0:
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - A[i]]) % MOD
print(dp[N][S])

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

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

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

long long int gcd(long long int g_a,long long int g_b){
	if(g_a<g_b)gcd(g_b,g_a);
	if(g_b==0)return g_a;
	return gcd(g_b,g_a%g_b);
}

long long int divide(long long int d_a,long long int d_b,long long int d_p=1e9+7){
	// d_a/d_b mod d_p
	// prime:d_p is prime
	if(d_a>=d_p)d_a%=d_p;
	if(d_a<0)d_a+=d_p;
	if(d_b>=d_p)d_b%=d_p;
	if(d_b<0)d_b+=d_p;
	d_a*=pow_mod(d_b,d_p-2,d_p);
	return d_a%d_p;
}

LL comb(LL a,LL b){
	LL s=1;
	int i;
	for(i=0;i<b;i++){
		s*=(a-i);
		s%=MAX;
		s=divide(s,i+1);
	}
	return s;
}

int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c;
	cin>>n;
	cin>>a>>b;
	LL s=pow_mod(2,n)-1;
	s-=comb(n,a)+comb(n,b);
	if(s<0)s+=MAX*10;
	s%=MAX;
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <functional>
using namespace std;
int main()
{
	int n,k;
	int node[101][101];
	while(cin>>n>>k,n|k){
	
		for(int i=0; i<101; i++)
			for(int j=0; j<101; j++)
				node[i][j] = INT_MAX;
		
		while(k--){
			int m;
			cin>>m;
			if( m ){
				int c,d,e;
				cin>>c>>d>>e;
				node[c][d] = node[d][c] = min(node[c][d],e);
			}else{
				int a,b;
				cin>>a>>b;
				/*
				for(int i=1; i<=n; i++){
					for(int j=1; j<=n; j++)
						printf("%13d,",node[i][j]);
					puts("");
				}*/
				int memo[101];
				priority_queue< pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
				for(int i=0; i<101; i++)memo[i]=INT_MAX;
				pq.push(make_pair(0,a));
				memo[a]=0;
				while( !pq.empty() ){
					pair<int,int> pi = pq.top();
					if( pi.second == b )break;
					pq.pop();
					for(int i=1; i<=n; i++){
						if( node[pi.second][i]!=INT_MAX &&
							 node[pi.second][i]+pi.first < memo[i] ){
							memo[i] = node[pi.second][i] + pi.first;
							pq.push(make_pair(memo[i],i));
						}
					}
				}
				printf("%d\n",memo[b]==INT_MAX?-1:memo[b]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 956
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long m = 1LL << 62;
    for(int i = 0; i < 5; i++){
        long long a;
        cin >> a;
        m = min(m, a);
    }
    cerr << m << endl;
    cerr << (N/m) << endl;
    if(N==m){
        cout << 5 << endl;
        return 0;
    }
    if(m == 1){
        cout << (5 + (N / m)-1) << endl;
        return 0;
    }
    cout << (5 + (N / m)) << endl;

    return 0;
}


Measured memory_bytes: 256
S=list(input())
A=S.copy()
A.reverse()
if S!=A:
    print("No")
    exit()
N=len(S)
kari=S[:int(((N-1)/2))]
ans=kari.copy()
ans.reverse()
if kari!=ans:
    print("No")
    exit()
tekitou=S[int(((N+3)/2)-1):]
unti=tekitou.copy()
unti.reverse()
if tekitou!=unti:
    print("No")
else:
    print("Yes")

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

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			long hi = sc.nextLong();
			map[i] = hi;
		}
		
		Arrays.sort(map);
		
		long min = Integer.MAX_VALUE;
		for (int i = 0; i <= N - K; i++) {
			long sub = map[i + K - 1] - map[i];
			min = Math.min(min, sub);
		}
		
		System.out.println(min);
	}
	
}

Measured memory_bytes: 66528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define PI 3.14159265358979323846264338327950L
using namespace std;

typedef long long ll;
typedef long double ld;


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

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

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}

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

	ld A, B;

	cin >> A >> B;

	ld ans = A * B;

	cout << (ll)floor(ans) << endl;

	return 0;
}

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

int main(){
  int ans=0;
  string board;
  cin >> board;
  char piece=board[0];
  
  for(int i=1;i<board.size();i++){
    if(piece!=board[i]) {
      piece=board[i];
      ans++;
    }
  }
  cout << ans << endl;
  
}
  

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N;
  int ans=0;

  cin >> N;

  vector<string> s(N);
  vector<int> p(N);
  vector<pair<pair<string, int>, int>> sp(N);
  for(long i = 0; i < N; i++){
    cin >> s[i] >> p[i];
    sp[i] = make_pair(make_pair(s[i], -p[i]), i+1);
  }

  sort(sp.begin(), sp.end());
  
  for(long i = 0; i < N; i++){
    cout << sp[i].second << endl;
  }
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n,k,ind=-1;
	cin>>n>>k;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int res=0,done=0;
	while(done<n){
		if(!done){
			done+=k;
		}
		else{
			done+=k-1;
		}
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main(void) {

	LL n;
	cin >> n;

	vector<LL> x(n);
	vector<LL> temp(n);

	for (LL i = 0; i < n; i++) {
		cin >> x[i];

		temp[i] = x[i];
	}

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

	for (LL i = 0; i < n; i++) {
		if (temp[i] < x[(n / 2)]) {
			cout << x[n / 2] << endl;
		}else{
			cout << x[(n / 2) - 1] << endl;
		}
	}

	/*
	for (LL i = 0; i < n/2; i++) {
		cout << x[n / 2] << endl;
	}
	for (LL i = n / 2; i < n; i++) {
		cout << x[(n / 2) - 1] << endl;
	}
	*/
	
	return 0;
}


Measured memory_bytes: 5376
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

H, W = LI()

ans = 0

if H == 1 or W == 1:
    print(1)
    exit()
    
if W % 2 == 0:
    ans = W // 2 * (math.ceil(H / 2) + math.floor(H / 2))
else:
    ans = W // 2 * (math.ceil(H / 2) + math.floor(H / 2)) + math.ceil(H / 2) 

print(ans)

Measured memory_bytes: 67436
#!/usr/bin/env python3
MOD = 998244353
n = int(input())
s = input()
ans = 1
for i in range(n):
    ans *= i + 1
    ans %= MOD
cnt = [0] * 3
dic = {'R': 0, 'G': 1, 'B': 2}
for c in s:
    p = dic[c]
    m = min(cnt[p - 1], cnt[p - 2])
    if m > 0:
        ans *= m
        cnt[p - 1] -= 1
        cnt[p - 2] -= 1
    else:
        ans *= max(1, cnt[p - 1] + cnt[p - 2] - cnt[p])
        cnt[p] += 1
    ans %= MOD
print(ans)


Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;

int main(){
  int N;cin>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    a[i]--;
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  for(int i=0;i<N-1;i++){
    cin>>c[i];
  }
  int ans=0;
  int ideal_next=1;
  for(int i=0;i<N;i++){
    ans+=b[a[i]];
  }
  for(int i=0;i<N-1;i++){
    if(a[i]==a[i+1]-1){
      ans+=c[a[i]];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N=gets.to_i
A=gets.split.map(&:to_i)
c=Hash.new{0}
A.each{|a|
    c[a]+=1
}
r=0
c.each_key{|k|
    if c[k]<k
        r+=c[k]
    elsif c[k]>k
        r+=c[k]-k
    end
}
puts r


Measured memory_bytes: 25388
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 500010;
ll num, A, B, C, M, N, X, Y, ans=0, count=0, sum=0;

void PUSH(priority_queue<ll, vl, less<ll>> &a) {
    cin >> num;
    a.push(num);
    return;
}

int main() {
    cin >> X >> Y >> A >> B >> C;
    priority_queue<ll, vl, less<ll>> p, q, r;
    priority_queue<ll, vl, greater<ll>> cp, cq;
    rep(i, A) PUSH(p);
    rep(i, B) PUSH(q);
    rep(i, C) PUSH(r);

    rep(i, X) {cp.push(p.top()); p.pop();}
    rep(i, Y) {cq.push(q.top()); q.pop();}

    while((X>0 || Y>0) && C>0) {
        C--;
        if(X>0 && Y>0) {
            if(cp.top() <= cq.top()) {
                if(cp.top() < r.top()) {cp.pop(); cp.push(r.top()); r.pop(); X--;}
            }else {
                if(cq.top() < r.top()) {cq.pop(); cq.push(r.top()); r.pop(); Y--;}
            }
        }
        if(Y==0) if(cp.top() < r.top()) {cp.pop(); cp.push(r.top()); r.pop(); X--;}
        if(X==0) if(cq.top() < r.top()) {cq.pop(); cq.push(r.top()); r.pop(); Y--;}
    }
    M=cp.size();
    N=cq.size();

    rep(i, M) {sum += cp.top(); cp.pop();}
    rep(i, N) {sum += cq.top(); cq.pop();}

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4852
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

int main(){
    int H,i,A[MAX+1];
    cin >> H;
    for(i = 1; i <= H; i++){
        cin >> A[i];
    }
    
    for(i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

char versus( char genomu ) {
  if ( genomu == 'A' ) return 'T';
  else if ( genomu == 'T' ) return 'A';
  else if ( genomu == 'G' ) return 'C';
  else return 'G';
}
int main () {
  char genomu;
  cin >> genomu;
  cout << versus( genomu ) << endl;  
  
  return 0;
}


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

int main(){
	int N,count=0;
	//読み込み
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++)
		cin >> A[i];
	//整列
	for(int i=0;i<N;i++)
		for(int j=N-1;j>i;j--)
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				count++;
			}
	//出力
	for(int i=0;i<N;i++){
		if(i>0)	cout<<" ";
		cout<< A[i];
	}
	cout<< endl << count << endl;
	return 0;
}

Measured memory_bytes: 1164
#!/usr/bin/env python3

def main():
    *I, = map(int, open(0).read().split())
    N = I[0]
    d = I[1:]
    s= []

    for i in range(0, len(d)):
        for k in range(0, len(d)):
            if not i == k and i > k:
                s.append(d[i] * d[k])

    print(sum(s))


main()

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

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		int idx = -1;
		for(int i = 0; i < 5; ++i){
			if(s[i] == s[i + 1]){
				idx = i;
				break;
			}
		}
		if(idx >= 0){
			c += (idx + 1) * 0.1 * CLOCKS_PER_SEC;
			while(clock() < c);
		}
		cout << "No\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll x[n];
    rep(i,n)cin >> x[i];
    ll ans = 0;
    srep(i,1,n){
        if((x[i]-x[i-1])*a > b) ans += b;
        else ans += (x[i]-x[i-1])*a;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4340
N = int(input())
S = []
for i in range(N):
  S.append(input())
T = []
M = int(input())
for j in range(M):
  T.append(input())

C = []  
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count = count + 1
  for k in range(M):
    if S[i] == T[k]:
      count = count -1
  C.append(count)

print(max(0,(max(C))))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MOD 1000000007

int n,x,y,z;
ll check,mask;

ll dp[41][1<<17];

int main()
{
	cin >> n >> x >> y >> z;
	
	mask = (1<<17)-1;
	check = (1<<(x-1));
	check = (check<<y)+(1<<(y-1));
	check = (check<<z)+(1<<(z-1));
	
	//cout << static_cast<bitset<20> >(check) << endl;
	
	dp[0][0] = 1;
	
	for(int i = 0;i < n;i++)
	{
		REP(j,(1<<17))
		{
			if(dp[i][j])
			{
				REP(k,10)
				{
					ll tmp = j;
					tmp = ((tmp<<(k+1))+(1<<k))&mask;
					if((tmp&check) == check)continue;
					dp[i+1][tmp] = (dp[i+1][tmp]+dp[i][j])%MOD;
				}
			}
		}
	}
	
	ll ans = 1;
	REP(i,n)
	{
		ans = (ans*10)%MOD;
	}
	ll sa = 0;
	REP(i,1<<17)
	{
		sa = (sa+dp[n][i])%MOD;
	}
	//cout << ans << ' ' << sa << endl;
	ans = (ans-sa+MOD)%MOD;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 40192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace Atcoder {
    class Program {
        static void Main(string[] args) {
            var N = Input.Str.ToCharArray();


       
            Console.WriteLine(700 + N.Where(c=>c == 'o').Count() * 100);
                return;
        }

        static long max(long left, long right) {
            if (left >= right)
                return left;
            return right;
        }

        static long min(long left, long right) {
            if (left >= right)
                return right;
            return left;
        }

        static long Kumiawase(int n, int r) {
            return Getkaijo(n) / (Getkaijo(n - r) * Getkaijo(r));

        }

        static long Getkaijo(int n) {
            if (n == 1)
                return n;
            return n * Getkaijo(n - 1);
        }
    }

    public static class Input {
        public static string Str => Console.ReadLine().Trim();
        public static int Int => int.Parse(Str);
        public static long Long => long.Parse(Str);
        public static double Double => double.Parse(Str);

        public static string[] StrArr => Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries).ToArray();
        public static int[] IntArr => StrArr.Select(int.Parse).ToArray();
        public static double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
        public static long[] LongArr => StrArr.Select(long.Parse).ToArray();

        public static List<string> StrList => Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries).ToList();
        public static List<int> IntList => StrArr.Select(int.Parse).ToList();
        public static List<double> DoubleList => StrArr.Select(double.Parse).ToList();
        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                            : eq<T, long>() ? ct<T, long>(long.Parse(s))
                            : eq<T, double>() ? ct<T, double>(double.Parse(s))
                            : eq<T, char>() ? ct<T, char>(s[0])
                                              : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(Str);
        static void Multi<T, U>(out T a, out U b) {
            var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c) {
            var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }

        static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
            var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
    }
}


Measured memory_bytes: 11220
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
cnt = 0
tmp = 1
while tmp <= n:
    tmp *= k
    cnt += 1
print(cnt)

Measured memory_bytes: 38256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int n;
	cin >> n;
	int x = 800 * n;
	debug_cout(x);
	int y = (n / 15) * 200;
	debug_cout(y);
	cout << (x - y);
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define llu unsigned long long int
#define scll(x) scanf("%lld",&x)
#define scld(x) scanf("%lf",&x)
#define scull(x) scanf("%llu",&x)
#define scch(x) scanf(" %c",&x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ppb() pop_back()
#define ppf() pop_front()
#define Pi acos(-1.0)
#define INF 1e18
#define ff first
#define ss second
#define mpr make_pair
ll  _xor(ll a,ll b){return a^b;}
ll _and(ll a,ll b){return a&b;}
ll _or(ll a,ll b){return a|b;}
ll _not(ll a){ return ~a;}
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
           #ifndef ONLINE_JUDGE 
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         #endif
    ll b,c,d,e,f,g,h,i,j,k,l1,l2,l3,t,a,m,n,p,q,r,s,u,v,x,y,c1,c2,c3;

        //scll(t);
        //while(t--)
        //{
             scll(n);
            set<string>st;
            string str;
            for(i=0;i<n;i++){
            	cin>>str;
                st.insert(str);
            }

                cout<<st.size();
return 0;
}

Measured memory_bytes: 19276
S = input()

i = 0
h = 0
c = 0

while i < len(S):
  hx = 0
  while i < len(S) and S[i] == '<':
    i += 1
    hx += 1
  c += hx * (hx + 1) // 2
  h = hx
  #
  hx = 0
  while i < len(S) and S[i] == '>':
    i += 1
    hx += 1
  c += hx * (hx + 1) // 2
  c -= h if hx > h else hx
  h = hx

print(c)

Measured memory_bytes: 4116
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

long long n, m, a[300009], c, p[300009];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n - 1; i++) { c += (a[i + 1] - a[i] + m) % m; }
	for (int i = 1; i <= n - 1; i++) {
		long long L = a[i] + 2, R = a[i + 1] + 1;
		if (L > R)R += m;
		if ((a[i + 1] - a[i] + m) % m < 2)continue;
		p[L]++; p[R] -= (R - L + 1); p[R + 1] += (R - L);
	}
	for (int i = 1; i <= 300000; i++)p[i] += p[i - 1];
	for (int i = 1; i <= 300000; i++)p[i] += p[i - 1];
	long long maxn = 0;
	for (int i = 1; i <= m; i++)maxn = max(maxn, p[i] + p[i + m] + p[i + m + m]);
	cout << c - maxn << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

signed main()
{
int a,b,c;
cin>>a>>b>>c;
if(a+b+c<22)
    cout<<"win"<<endl;
else
    cout<<"bust"<<endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;

ll x[110000],l[110000];
pair<ll,ll> f[110000];
main(){
    ll n,ans=0;
    cin>>n;
    
    rep(i,0,n)cin>>x[i]>>l[i];
    rep(i,0,n)f[i]=mp(x[i]+l[i],x[i]-l[i]);
    sort(f,f+n);
    ll tmp=-1e9;
    rep(i,0,n){
        if(tmp<=f[i].second){ans++;tmp=f[i].first;}
    }
    cout<<ans;
}

Measured memory_bytes: 3328
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n, k;
    int[] a;

    scan(n, k);
    a = readln.split.to!(int[]);

    a.sort();

    auto dp1 = new bool[][](n + 1, k + 1);
    auto dp2 = new bool[][](n + 1, k + 1);

    dp1[0][0] = 1;

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 0 .. k + 1) {
            dp1[i][j] = dp1[i-1][j];

            if (j - a[i-1] >= 0) dp1[i][j] |= dp1[i-1][j-a[i-1]];
        }
    }

    dp2[n][0] = 1;

    foreach_reverse (i ; 0 .. n) {
        foreach (j ; 0 .. k + 1) {
            dp2[i][j] = dp2[i+1][j];

            if (j - a[i] >= 0) dp2[i][j] |= dp2[i+1][j-a[i]];
        }
    }

    int ans;

    foreach (i ; 0 .. n) {
        auto c = iota(0, k).filter!(j => dp1[i][j]);
        auto b = iota(0, k).filter!(j => dp2[i+1][j]).array.retro;

        int v;

        while (!c.empty) {
            while (!b.empty) {
                if (c.front + b.front < k) {
                    v = max(v, c.front + b.front);
                    break;
                }
                else {
                    b.popFront;
                }
            }
            c.popFront;
        }

        if (k - a[i] > v) ans++;
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

const int N = 105;
int dp[N][4][4][4];
const int mod = 1e9 + 7;

void add(int &x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        if (!(i == 0 && j == 1 && k == 2) && !(i == 1 && j == 0 && k == 2) && !(i == 0 && j == 2 && k == 1)) {
          dp[3][i][j][k] = 1;
        } else {
          dp[3][i][j][k] = 0;
        }
      }
    }
  }
  int ans = 0;
  int n;
  cin >> n;
  for (int i = 4; i < N; i++) {
    for (int j = 0; j < 4; j++) {
      if (j == 0 || j == 3) {
        for (int ii = 0; ii < 4; ii++) {
          for (int jj = 0; jj < 4; jj++) {
            for (int kk = 0; kk < 4; kk++) {
              if (!(ii == 0 && jj == 1 && kk == 2)) {
                add(dp[i][jj][kk][j], dp[i - 1][ii][jj][kk]);
              }
            }
          }
        }
      }
      if (j == 1) {
        for (int ii = 0; ii < 4; ii++) {
          for (int jj = 0; jj < 4; jj++) {
            for (int kk = 0; kk < 4; kk++) {
              if (!(jj == 0 && kk == 2)) {
                add(dp[i][jj][kk][j], dp[i - 1][ii][jj][kk]);
              }
            }
          }
        }
      }
      if (j == 2) {
        for (int ii = 0; ii < 4; ii++) {
          for (int jj = 0; jj < 4; jj++) {
            for (int kk = 0; kk < 4; kk++) {
              if (!(jj == 0 && kk == 1) && !(ii == 0 && kk == 1) && !(ii == 0 && jj == 1) && !(jj == 1 && kk == 0)) {
                add(dp[i][jj][kk][j], dp[i - 1][ii][jj][kk]);
              }
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        add(ans, dp[n][i][j][k]);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int _;
  cin >> _;
  while (_--) {
    long long n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << (long long)atcoder::floor_sum(n, m, a, b) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3664