akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
using namespace std;
int m[1000001];
typedef pair<int,int>pii;
main(){
	int n,q,a,v;
	pii P;
	priority_queue<pii>Q;
	for(scanf("%d%d",&n,&q);q--;){
		scanf("%d%d",&a,&v);
		m[a]+=v;
		Q.push(make_pair(m[a],-a));
		for(;P=Q.top(),m[-P.second]!=P.first;Q.pop());
		printf("%d %d\n",-P.second,P.first);
	}
}

Measured memory_bytes: 5840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadInts();

            var s = 0;
            var list = new List<int>() {};
            for (int i = 0; i < n; i++)
            {
                if (a[i] == 1)
                {
                    s++;
                }
                else
                {
                    list.Add(s);
                    s = 0;
                }
            }
            list.Add(s);
            WriteLine(list.Max() + 1);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18300
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main(){
    int n;
    while(cin >> n, n){
        vi m(n), a(n), b(n);
        vector<int> t;
        rep(i, 0, n){
            cin >> m[i] >> a[i] >>b[i];
            t.push_back(a[i]);
            t.push_back(b[i]);
        }
        sort(all(t));
        map<int, int> mp;
        rep(i, 0, t.size()){
            mp[t[i]] = i;
        }
        vector<int> d(t.size() + 1, 0);
        rep(i, 0, n){
            d[mp[a[i]]] += m[i];
            d[mp[b[i]]] -= m[i];
        }
        rep(i, 1, t.size() + 1){
            d[i] += d[i - 1];
        }
        bool ans = true;
        rep(i, 0, t.size()){
            if(d[i] > 150){
                ans = false;
            }
        }
        cout << (ans ? "OK": "NG") <<endl;
    }

}

Measured memory_bytes: 1228
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn gcd(a: usize, b: usize) -> usize {
    let mut a = a;
    let mut b = b;
    while b != 0 {
        let r = b;
        b = a % b;
        a = r;
    }
    a
}

fn lcm(a: usize, b: usize) -> usize {
    return a / gcd(a, b) * b;
}

fn main() {
    let (a, b, c, d) = get!(usize, usize, usize, usize);
    let rc = b / c - (a - 1) / c;
    let rd = b / d - (a - 1) / d;
    // eprintln!("rc: {}, rd: {}", rc, rd);
    let l = lcm(c, d);
    let rl = b / l - (a - 1) / l;
    // eprintln!("l: {}, rl: {}", l, rl);
    println!("{}", (b - a + 1) + rl - rc - rd);
}


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

string a, b;

int main() {
  cin >> a >> b;
  // 数値結合
  int union_int = stoi(a + b);
  int range = pow(union_int, 0.5);
  for (int i = 1; i <= range; ++i) {
    if (pow(i, 2) == union_int) {
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>





using namespace std;



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

	//constexpr int max = 50;
	//vector<vector<int>> a(n), b(m);
	//char a[max][max], b[max][max];
	
	const int nmmax = 50;
	char a[nmmax][nmmax], b[nmmax][nmmax];
	
	for (int y = 0; y < n; ++y) {
		for (int x = 0; x < n; ++x) {
			cin >> a[y][x];
		}
	}

	for (int y = 0; y < m; ++y) {
		for (int x = 0; x < m; ++x) {
			cin >> b[y][x];
		}
	}

	
	
	/*bool exist = false;
	for (int ly = 0; ly < n; ly++)
	{
		for (int lx = 0; lx < n; lx++)
		{
			if (ly + m - 1 >= n  or lx + m - 1 >= n) continue;
			
			
			bool match = false;

			for (int y = 0; y < m ; y++)
			{
				for (int x = 0; x < m ; x++)
				{
					if (a[ly + y][lx + x] != b[y][x]) match = false;
						
				}
			}

			if (match) exist = true;
			
		}
	}*/

	bool exist = false;

	for (int ly = 0; ly < n; ++ly) {
		for (int lx = 0; lx < n; ++lx) {
			if (ly + m - 1 >= n or lx + m - 1 >= n) continue;

			bool match = true;
			for (int y = 0; y < m; ++y) {
				for (int x = 0; x < m; ++x) {
					if (a[ly + y][lx + x] != b[y][x]) match = false;
				}
			}
			if (match) exist = true;
		}
	}

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

	
	return 0;

}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


@lru_cache(maxsize=None)
def mod_inv(a, mod):
    """
    a の逆元
    :param int a:
    :param int mod:
    :return:
    """
    return pow(a, mod - 2, mod)


factorials = defaultdict(int)
factorials[1] = 1
for i in range(2, N + 1):
    factorials[i] = factorials[i - 1] * i % MOD


def factorial(n):
    if factorials[n]:
        return factorials[n]
    factorials[n] = math.factorial(n) % MOD
    return factorials[n]


def ncr(n, r, mod=None):
    """
    scipy.misc.comb または scipy.special.comb と同じ
    組み合わせの数 nCr
    :param int n:
    :param int r:
    :param int mod: 3 以上の素数であること
    :rtype: int
    """
    if n < r:
        return 0

    # 何度も呼ぶ場合は最大の n 以下の階乗を事前に計算しておくといい
    if mod:
        return (
                factorial(n)
                * mod_inv(factorial(r), mod)
                * mod_inv(factorial(n - r), mod)
                % mod
        )
    else:
        return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


factors = get_factors(M)

ans = 1
for c in Counter(factors).values():
    # N 個の箱から重複ありで c 個選ぶ
    ans = ans * ncr(N + c - 1, c, MOD) % MOD
print(ans)


Measured memory_bytes: 27900
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

struct edge{
	int to;
	ll cost;
};

vector<vector<edge>> graph(100010);
vector<ll> dist(100010);
bool besucht[100010];

void dfs( int node, ll costsum ){
	dist[node] = costsum;
	besucht[node] = true;
	for( auto candy : graph[node] ){
		if( !besucht[candy.to] ){
			dfs( candy.to, costsum+candy.cost );
		}
	}
}

int main(){
	int n; cin >> n;
	for( int i = 0; i < n-1; ++i ){
		int a, b; ll c; cin >> a >> b >> c; --a; --b;
		edge tmp;
		tmp.to = b; tmp.cost = c;
		graph[a].push_back(tmp);
		tmp.to = a;
		graph[b].push_back(tmp);
	}
	int q, k; cin >> q >> k; --k;
	dfs( k, 0 );
	while( q-- ){
		int x, y; cin >> x >> y; --x; --y;
		cout << dist[x]+dist[y] << endl;
	}
	return 0;
}

// 18:39

Measured memory_bytes: 12800
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, r, s, p, i, j;
    cin>>n>>k;
    cin>>r>>s>>p;
    ll dp[n][3], ans = 0;
    string s1;
    string temp;
    cin>>s1;
    for(i=0; i<k; i++) {
    	temp.clear();
    	dp[0][0] = dp[0][1] = dp[0][2] = 0;
    	ll cnt = 1;
    	for(j=i; j<n; j+=k) {
    		temp.pb(s1[j]);
    	}
    	if(temp[0] == 's') {
    		dp[0][0] = r;
    	}
    	else if(temp[0] == 'r') {
    		dp[0][1] = p;
    	}
    	else {
    		dp[0][2] = s;
    	}
    	ll len = temp.length();
    	for(j=1; j<len; j++) {
    		if(temp[j] == 's') {
    			dp[cnt][0] = r + max(dp[cnt-1][1], dp[cnt-1][2]);
    			dp[cnt][1] = max(dp[cnt-1][0], dp[cnt-1][2]);
    			dp[cnt][2] = max(dp[cnt-1][0], dp[cnt-1][1]);

    		}
    		else if(temp[j] == 'r') {
				dp[cnt][0] = max(dp[cnt-1][1], dp[cnt-1][2]);
    			dp[cnt][1] = p + max(dp[cnt-1][0], dp[cnt-1][2]);
    			dp[cnt][2] = max(dp[cnt-1][0], dp[cnt-1][1]);    			
    		}
    		else {
    			dp[cnt][0] = max(dp[cnt-1][1], dp[cnt-1][2]);
    			dp[cnt][1] = max(dp[cnt-1][0], dp[cnt-1][2]);
    			dp[cnt][2] = s + max(dp[cnt-1][0], dp[cnt-1][1]);
    		}
    		cnt++;
    	}
		ans += max(dp[len-1][0], max(dp[len-1][1], dp[len-1][2]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2944
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 4
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

S = int(input())
ans = 0
length = 0
while S>=3:
    S -= 3
    length += 1
    check = cmb(S+length-1,S,p)
    ans += check
    ans %= p
print(ans % p)

Measured memory_bytes: 67752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n/2;++i){
        int a=n-i;
        if(a!=i)++cnt;
    }
    cout<<cnt<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;



int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("D.txt", "r", stdin);
    #endif
    int n, t;
    cin >> n >> t;
    for(int i=0; i<=n; i++)
    {
        for(int j=0; i+j<=n; j++)
        {
            int k = n-i-j;
            if(k*1000+i*10000+j*5000==t)
            {
                cout << i _ << j _ << k;
                return 0;
            }
        }
    }
    puts("-1 -1 -1");
}



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

int main() {
    int n; cin >>n;
    vector<int>v(n+1, 0);
    for(int i = 1; i <= n ; i++){
        cin >> v[i];
    }
    vector<int>p(n+1);
    p[0] = v[0];
    for(int i = 1; i <= n; i++){
        p[i] = __gcd(p[i-1],v[i]);
    }
    vector<int>s(n+2);
    s[n+1] = v[0];
    for(int i = n; i > 0; i--){
        s[i] = __gcd(s[i+1],v[i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, __gcd(p[i-1],s[i+1]));
    }
    cout << ans << endl;
	return 0;
}

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

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int gcd(int a,int b,int c){
return gcd(gcd(a,b),c);
}
int main(){
int n;
cin>>n;
long long cnt=0;
for(int a=1;a<=n;a++){
    for(int b=a;b<=n;b++){
        for(int c=b;c<=n;c++){
            if(a==b&&a==c)
            cnt+=a;
            else if(a==b||a==c||b==c)
                cnt+=3*gcd(a,b,c);
            else cnt+=6*gcd(a,b,c);

        }
    }
}


cout<<cnt;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  ll A[N];
  REP(i,N) cin>>A[i];
  
  ll POW2[50];
  POW2[0]=1;
  RREP(i,45) POW2[i]=POW2[i-1]*2;
  
  for(int i=40; i>=0; --i){
    ll cnt=0; // A[i](0<=i<N)で下からi番目のbitが1であるものの数
    for(int j=0; j<N; ++j){
      if(A[j]&POW2[i]) cnt++;
    }
    
    if(POW2[i]<=K && cnt*2<N){
      K-=POW2[i];
      ans+=POW2[i]*(N-cnt);
    }
    else{
      ans+=POW2[i]*cnt;
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 4348
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, K;
  scanf("%d",&N);
  scanf("%d",&K);
  double ans = 0.0;
  for (int i=1; i<=N; i++){
    if (i>=K){
      ans += 1.0;
    } else {
      ans += pow(0.5,int(log2((double)K/i)+0.999999999999));
    }
  }
  ans = ans/(double)N;
  printf("%.15lf\n",ans);
  return 0;
}


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

int partition(vector<pair<char, int>>& A, int p, int r){
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].second > A[r].second) continue;
        swap(A[++i], A[j]);
    }
    swap(A[++i], A[r]);
    return i;
}
void quick_sort(vector<pair<char, int>>& A, int p, int r){
    if (p >= r) return;
    int q = partition(A, p, r);
    quick_sort(A, p, q - 1);
    quick_sort(A, q + 1, r);
}
void merge_sort(vector<pair<char, int>>& A, int left, int right){
    if (left >= right) return;
    int mid = (left + right) / 2;
    merge_sort(A, left   , mid  );
    merge_sort(A, mid + 1, right);
    pair<char, int> A1[mid   - left + 2];
    pair<char, int> A2[right - mid  + 1];
    for (int i = 0; i < mid - left + 1; i++) {
        A1[i] = A[left+i];
    }
    A1[mid - left + 1].second = 1e9 + 1;
    for (int i = 0; i < right - mid; i++) {
        A2[i] = A[mid+1+i];
    }
    A2[right - mid].second = 1e9 + 1;
    int i1 = 0;
    int i2 = 0;
    for (int k = left; k <= right; k++) {
        A[k] = (A1[i1].second <= A2[i2].second ? A1[i1++] : A2[i2++]);
    }
}
int main(){
    int n;
    cin >> n;
    vector<pair<char, int>> A1(n);
    vector<pair<char, int>> A2(n);
    for (int i = 0; i < n; i++) {
        cin >> A1[i].first >> A1[i].second;
        A2[i] = A1[i];
    }
    quick_sort(A1, 0, n - 1);
    merge_sort(A2, 0, n - 1);
    bool is_same = true;
    for (int i = 0; i < n; i++) {
        if (A1[i] != A2[i]) {
            is_same = false;
            break;
        }
    }
    cout << (is_same ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; i++) {
        cout << A1[i].first << " " << A1[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n, m;
    cin >> n >> m;
    vector <vector <long long>> qw (n);
    map <long long, long long> xy;
    for (int i=0; i<m; ++i)
    {
        long long r, t;
        cin >> r >> t;
        qw[r-1].push_back(t-1);
        qw[t-1].push_back(r-1);
    }
    for (int i=0; i<n; ++i)
        xy[i]=1;
    long long r=0;
    long long f=xy.size();
    queue <long long> q;
    vector <int> us (n);
    while(xy.size()!=0)
    {
        q.push((*xy.begin()).first);
        us[(*xy.begin()).first]=1;
        xy.erase((*xy.begin()).first);
        while (!q.empty())
        {
            int v=q.front();
            q.pop();
            for (size_t i=0; i<qw[v].size(); ++i) {
                int to=qw[v][i];
                if (us[to]==0)
                {
                    us[to]=1;
                    q.push(to);
                    xy.erase(to);
                }
            }
        }
        if (r<f-xy.size())
            r=f-xy.size();
        f=xy.size();
    }
    cout << r << endl;
}


Measured memory_bytes: 29920
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int temp = n / 1000 * 1000;
        int result = temp == n ? 0 : temp + 1000 - n;
        System.out.println(result);
    }
}

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  rep(i, n) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(), v.end(), greater<int>());
  int total = 0;
  rep(i, k) {
    total += v[i];
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
a.sort()
sm=0
c=0
for l in a:
  if l[1]<m-c:
    c+=l[1]
    sm+=l[1]*l[0]
  else:
    sm+=(m-c)*l[0]
    break
print(sm)

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

int h, w;
string board[31];
string seq;


struct Dice {
	int l, r, f, b, d, u;
	Dice() {}

#define rotation(a,b,c,d) swap(a,b),swap(b,c),swap(c,d);

	void rot(int cur) {
		if (cur == 0) rotation(b, u, f, d);
		if (cur == 1) rotation(r, u, l, d);
		if (cur == 2) rotation(f, u, b, d);
		if (cur == 3) rotation(l, u, r, d);
	}

	int get_state() { return u * 36 + f * 6 + r;}
	void set_state(int cur) {
		r = cur % 6;  l = 5 - r;
		f = cur / 6 % 6, b = 5 - f;
		u = cur / 36, d = 5 - u;
	}
};

const int inf = 1 << 25;
int dist[31][31][216][7];
const int dy[4] = { -1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};

/*
top  red        0  up
south  magenta  1  front
east  blue      2  right
west  yellow    3  left
north  green    4  back
bottom  cyan    5  down

up front right
*/

string colors = "rmbygc";

int main(void) {
	while (cin >> w >> h) {
		if (h == 0 and w == 0) break;
		rep(i, h) cin >> board[i];
		cin >> seq;

		rep(i, h)rep(j, w)rep(k, 216)rep(l, 7) dist[i][j][k][l] = inf;

		int si = -1, sj = -1;
		rep(i, h)rep(j, w) {
			if (board[i][j] == '#') {
				si = i, sj = j;
			}
		}

		int ss = 0 * 36 + 1 * 6 + 2;

		dist[si][sj][ss][0] = 0;
		using state = tuple<int, int, int, int>;
		queue<state> q;
		q.push(state(si, sj, ss, 0));

		/*
		{
			Dice dice;
			dice.set_state(ss);
			dice.rot(2);
			cerr <<  dice.get_state() << endl;
			cerr << dice.u << " " << dice.f << " " << dice.r << endl;
		}
		*/

		while (!q.empty()) {
			int ci, cj, cs, tar;
			tie(ci, cj, cs, tar) = q.front(); q.pop();
			
			//cerr << ci << " " << cj << " " << cs << " " << tar << endl;
			if (tar >= 6) break;
			// East
			rep(dir, 4) {
				const int ni = ci + dy[dir], nj = cj + dx[dir];
				if (ni < 0 or h <= ni) continue;
				if (nj < 0 or w <= nj) continue;

				Dice dice;
				dice.set_state(cs);
				dice.rot(dir);
				const int ns = dice.get_state();

				if (board[ni][nj] == 'k') continue;

				if (board[ni][nj] == 'w' or board[ni][nj]=='#') {
					if (dist[ni][nj][ns][tar] > dist[ci][cj][cs][tar] + 1) {
						dist[ni][nj][ns][tar] = dist[ci][cj][cs][tar] + 1;
						q.push(state(ni, nj, ns, tar));
					}
				}

				/*
				if(ni == 2 and nj == 5 and ns == 3 * 36 + 0 * 6 + 2){
					cerr << "OK" << endl;
				}
				*/

				if (board[ni][nj] == seq[tar] and board[ni][nj] == colors[dice.u]) {
					const int ntar = tar + 1;
					
					if (dist[ni][nj][ns][ntar] > dist[ci][cj][cs][tar] + 1) {
						dist[ni][nj][ns][ntar] = dist[ci][cj][cs][tar] + 1;
						q.push(state(ni, nj, ns, ntar));
					}
				}

			}

		}

		int ans = inf;
		rep(i, h)rep(j, w)rep(s, 216) ans = min(ans, dist[i][j][s][6]);

		if(ans >= inf)
			puts("unreachable");
		else
			cout << ans << endl;



	}
	return 0;
}

Measured memory_bytes: 8524
#include "cstdio"
using namespace std;

int n, m;
char a[505][505], b[505][505];

signed main()
{
	scanf("%d %d", &n, &m); register int i, j;
	for(i=1; i<=n; ++i)
	{
		scanf("%s", a[i]+1);
		for (j=1; j<=m; ++j) 
			b[i][j]=a[i][j];
	}
	
	for(i=1; i<=n; ++i) a[i][1]=b[i][m]='#';
	for(i=2; i<n; i+=2)
		for (j=2; j<m; ++j) 
			a[i][j]='#';
			
	for(i=3; i<n; i+=2)
		for(j=2; j<m; ++j) 
			b[i][j]='#';
			
	for(i=1; i<=n; ++i) printf("%s\n", a[i]+1);
	putchar('\n');
	for(i=1; i<=n; ++i) printf("%s\n", b[i]+1);
}

Measured memory_bytes: 1152
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int M = 1e5 + 7;
int dp[M];
const int inf = 1e9 + 7;

int main() {
    int n, W;
    scanf("%d %d", &n, &W);
    
    for (int i = 0; i < M; ++i) dp[i] = inf;
    dp[0] = 0;
    
    for (int i = 1; i <= n; ++i) {
        int w, v;
        scanf("%d %d", &w, &v);
        for (int j = M - 1; j >= v; --j) {
            dp[j] = min(dp[j], dp[j - v] + w);
        }
    }
    
    int wyn = 0;
    for (int i = 0; i < M; ++i) if (dp[i] <= W) wyn = i;
    printf("%d\n", wyn);
    return 0;
}


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ll> vll;
typedef vector <int> vii;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
const int N = 2e6 + 5;
const int inf = 1e9 + 7;

int f[N];

ll binpow(ll a, ll b) {
	if (b == 0) return 1ll;
	if (b & 1) return (binpow(a, b - 1) * a) % inf;
	ll c = binpow(a, b / 2);
	return (c * c) % inf;
}

int cnk(int n, int k) {
	return 1ll * f[n] * binpow(f[k], inf - 2) % inf * 1ll * binpow(f[n - k], inf - 2) % inf;
}

void solve() {
	int n, k;
	ll ans = 0;
	string s;
	cin >> k >> s;
	n = s.size();
	for (int i = n; i <= n + k; i ++) {
		ans += 1ll * cnk(n + k, i) * binpow(25, n + k - i) % inf;
	}
	cout << ans % inf << endl;
}

int main() {
//	freopen ("input.txt", "r", stdin);
//	freopen ("output.txt", "w", stdout);
	f[0] = 1;
	for (int i = 1; i < N; i ++) 
		f[i] = (1ll * i * f[i - 1]) % inf;
	int tests = 1;
//	cin >> tests;
	while (tests --)
		solve();
	return 0;
}






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

void insert_sort(int a[], int n);


int main(){
    
    int n;
    int a[200];

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

    for(int k=0; k < n; ++k)
    {
        if(k != n-1)
        {
            cout << a[k] << " ";
        }
        else
        {
            cout << a[k] << endl;   
        } 
    }

    //cout << "adf" << endl;
    insert_sort(a,n);

    return 0;
}


void insert_sort(int a[], int n)
{
    for(int i=1; i<n; i++)
    {
        int v = a[i];
        int j = i -1;

        while(j >= 0 && v < a[j])
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    

        for(int k=0; k < n; ++k)
        {
            if(k != n-1)
            {
                cout << a[k] << " ";
            }
            else
            {
                cout << a[k] << endl;   
            } 
        }
    }
}


Measured memory_bytes: 3088
s=input()
d=[set(i) for i in s]
ans=0
for i in range(101):
    if len(d)==1: break
    tmp=d[0]
    for  j in range(1,len(d)):
        tmp=tmp&d[j]

    if len(tmp)>=1: break
    for j in range(len(d)-1):
        d[j]=d[j]|d[j+1]
    d.pop()
    ans+=1
print(ans)


Measured memory_bytes: 39792
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 666;

char a[maxn][maxn];
int ok[maxn][maxn];
int n;
int judge(int x , int y){
	for(int i = 2 ; i <= n ; ++ i)
		for(int k = 0 ; k < i ; ++ k)
			if(a[x + i][y + k] != a[x + k][y + i])
				return i - 1;
	return n;
}

int main(){
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 0 ; i < n ; ++ i)
		for(int j = 0 ; j < n ; ++ j)
			cin >> a[i][j];
	for(int i = 0 ; i < n ; ++ i)
		for(int j = n ; j < 2 * n ; ++ j)
			a[i][j] = a[i][j - n];
	for(int i = n ; i < 2 * n ; ++ i)
		for(int j = 0 ; j < 2 * n ; ++ j)
			a[i][j] = a[i - n][j];
	for(int i = 0 ; i < n ; ++ i)
		ok[n - 1][i] = judge(n - 1 , i);
	for(int i = 0 ; i < n ; ++ i)
		ok[i][n - 1] = judge(i , n - 1);
	for(int i = n - 2 ; i >= 0 ; -- i)
		for(int j = n - 2 ; j >= 0 ; -- j){
			ok[i][j] = ok[i + 1][j + 1] + 1;
			if(ok[i][j] > n) ok[i][j] = n;
			for(int k = 1 ; k < ok[i][j] ; ++ k)
				if(a[i + k][j] != a[i][j + k]){
					ok[i][j] = k;
					break;
				}
		}
	int ans = 0;
	for(int i = 0 ; i < n ; ++ i)
		for(int j = 0 ; j < n ; ++ j)
			ans += (ok[i][j] == n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import std.stdio, std.array, std.conv, std.string;

void main() {
  string[] input = split(readln());

  int W = to!int(input[0]), H = to!int(input[1]);
  int x = to!int(input[2]), y = to!int(input[3]), r = to!int(input[4]);

  if (r <= x && r <= (W - x) && r <= y && r <= (H - y)) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}

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

#define MOD 1000000007

using ll = int;

int main(void) {
    
    string s;
    cin >> s;
    
    if(s=="AKIHABARA" || s=="KIHABARA" || s=="AKIHBARA" || s=="AKIHABRA" ||
       s=="AKIHABAR" || s=="AKIHABR" || s=="AKIHBRA" || s=="AKIHBAR" ||
       s=="KIHABAR" || s=="KIHABRA" || s=="KIHBARA" || s=="AKIHBR" ||
       s=="KIHABR" || s=="KIHBAR" || s=="KIHBRA" || s=="KIHBR"){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {

	ll N, M;
	cin >> N >> M;
	vll P(M), Y(M);
	rep(i, M) cin >> P[i] >> Y[i];
	
	map<ll, vll> pref;
	rep(i, M) pref[P[i]].push_back(Y[i]);
	for (auto &p : pref) sort(all(p.second));

	rep(i, M) {
		// auto it = find(all(pref[P[i]]), Y[i]);
		ll ok = pref[P[i]].size();
		ll ng = -1;
		while (abs(ok - ng) > 1) {
			ll mid = (ok + ng) / 2;
			if (pref[P[i]][mid] < Y[i]) ng = mid;
			else if (pref[P[i]][mid] > Y[i]) ok = mid;
			else {
				cout << setw(6) << setfill('0') << P[i];
				cout << setw(6) << setfill('0') << mid + 1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 13952
parseInt(x) = parse(Int, x)

function main()
	s = sort(collect(chomp(readline())))
	t = sort(collect(chomp(readline())), rev=true)
	flg = 0
	sameflg = 0
	for i in 1:min(length(s),length(t))
		if s[i] > t[i]
			flg = 1
			break
		elseif s[i] == t[i]
			sameflg += 1
		else
			break
		end
	end
	if sameflg == length(t) && length(t) <= length(s)
		flg = 1
	end
	if flg == 0
		print("Yes")
	else
		print("No")
	end
end

main()

Measured memory_bytes: 117252
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int d1[6] = { 0,1,1,0,-1,-1 };
int d2[6] = { 1,0,-1,-1,-1,0 };
int d3[6] = { 1,1,0,-1,0,1 };
struct edge { int to, cost; };
vector<edge> G[300000];
int d[300000];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + 300000, (int)MOD);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	int room[203][203] = {};
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; sx += 101; sy += 101; gx += 101; gy += 101;
	int sta = sx + sy * 203; int goal = gx + gy * 203;
	int n; cin >> n;
	rep(i, n) {
		int x, y; cin >> x >> y; x += 101; y += 101; room[x][y] = 1;
	}
	int lx, ly; cin >> lx >> ly;
	rep(i, 203) {
		rep(j, 203) {
			if (i < 101 - lx || j < 101-ly || i > 101 + lx || j > 101 + ly) {
				room[i][j] = 1;
			}
		}
	}
	rep(i, 203 * 203 * 6) {
		int x = i % 203;
		int y = (i / 203) % 203;
		int z = (i / (203 * 203)) % 6;
		if (room[x][y])continue;
		int ord = abs((x - 101)*(y - 101)*z)% 6;
		G[i].push_back({ (i + 203 * 203) % (203 * 203 * 6),1 });
		rep(k, 6) {
			int nx = x + d1[k];
			int ny;
			if (x % 2) {
				ny = y + d2[k];
			}
			else {
				ny = y + d3[k];
			}
			if (room[nx][ny])continue;
			int ver = nx + ny * 203 + ((z+1)%6) * 203 * 203;
			if (k == ord) {
				G[i].push_back({ ver, 0 });
			}
			else {
				G[i].push_back({ ver,1 });
			}
		}
	}
	dijkstra(sta);
	int mi = (int)MOD;
	rep(i, 6) {
		mi = min(mi, d[goal + 203 * 203 * i]);
	}
	if (mi == (int)MOD) {
		cout << -1 << endl;
	}
	else {
		cout << mi << endl;
	}
	return 0;
}


Measured memory_bytes: 30040
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace::std;

int main(void){
  string a;
  unsigned long int b;
  char res;

  cin >> a;
  cin >> b;
  --b;

  unsigned long int i=0;
  while(a[i]=='1' && i < a.size()) i++;

  if(i>=a.size())i--;
  if(i>=b)res = a[b];
  else res = a[i==0?0:i];

  cout << res << endl;
  return 0;
}



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

#define int long long

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

  vector<int> a(N);
  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    cin >> a[i];
    sum += a[i];
  }

  int ans = 1e15;
  int now = 0;  
  for ( int i = 0; i < N-1; i++ ) {
    now += a[i];
    sum -= a[i];    
    ans = min(ans, abs(sum-now));    
  }

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


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll x;
  cin>>x;
  ll y=0,ans=0;
  for(int i=1;y<x;i++){
    y+=i;
    ans=i;
  }

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


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

int main(){
  int n;
  cin >> n;
  int df[n],dt[n];
  for(int i=0; i<n; i++){
    cin >> df[i] >> dt[i];
  }
  int a=0;
  for(int i=0; i<n; i++){
    if(df[i] == dt[i]){
      a++;
    } else {
      a = 0;
    }
    if(a == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll dp[101][4][2];
string s;
int n,K;
int main(){
    cin>>s>>K;
    n=s.size();
    dp[0][0][0]=1;
    rep(i,n)rep(j,4)rep(k,2){
        int t=s[i]-'0';
        if(k==1){
            if(j<3)dp[i+1][j+1][1]+=dp[i][j][1]*9;
            dp[i+1][j][1]+=dp[i][j][1];
        }
        else{
            dp[i+1][j][t==0?0:1]+=dp[i][j][k];
            if(j<3&&t>0){
                dp[i+1][j+1][1]+=dp[i][j][k]*(t-1);
                dp[i+1][j+1][k]+=dp[i][j][k];
            }
        }
    }
    cout<<dp[n][K][0]+dp[n][K][1]<<endl;
    return 0;
}

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

int main(){
    long long x,y;
    cin >> x >> y;
    long long ans;
    if(x==y) ans=0;
    else if(x*y>0&&y>x) ans=abs(abs(x)-abs(y));
    else if(x*y>0&&y<x) ans=abs(abs(x)-abs(y))+2;
    else if(x*y<0&&y>x) ans=abs(abs(x)-abs(y))+1;
    else if(x*y<0&&y<x) ans=abs(abs(x)-abs(y))+1;
    else if(y-x>0&&(x==0||y==0)) ans=abs(abs(x)-abs(y));
    else if(y-x<0&&(x==0||y==0)) ans=abs(abs(x)-abs(y))+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
sentinel = 1000000001

def merge(A, left, mid, right):
    L = A[left:mid]
    n1 = len(L)
    L.append(sentinel)
    R = A[mid:right]
    R.append(sentinel)
    i = 0
    j = 0
    cnt = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i
    return cnt

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = mergeSort(A, left, mid)
        cnt2 = mergeSort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0


n = int(input())
S = list(map(int, input().split()))

cnt = 0

n_ivs =  mergeSort(S, 0, n)

print(n_ivs)

Measured memory_bytes: 30444
#include <iostream>
#include <unordered_set>

using namespace std;

int main()
{
    int64_t N;
    cin >> N;
    unordered_set<string> S;
    int64_t ans = 0;
    for (int64_t n = 0; n < N; ++n)
    {
        string s;
        cin >> s;
        if (!S.count(s))
        {
            ++ans;
            S.emplace(s);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200005 ;
int main()
{
   fast ;
   ll tests=1 ;
   ///cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
      ///cout<<"Case #"<<testcase<<": " ;
      ///Read,Think ans Test Properly,then code
      ///Try to avoid using print statements debug on your own
      ll n,x,y ;
      cin>>n>>x>>y ;
      ll dist[n] ;
      memset(dist,0,sizeof(dist)) ;

      for(ll i=1;i<=n;i++)
      {
          for(ll j=i;j<=n;j++)
          {
              ll d=0 ;

              if(i<=x&&y<=j)
              {
                  d=x-i+1+j-y ;
              }
              else if(x<=i&&j<=y)
              {
                  d=min(j-i,i-x+y-j+1) ;
              }
              else if(j>=x&&j<y)
              {
                  d=x-i ;
                  d+=min(j-x,y-j+1) ;
              }
              else if(i>x&&i<=y)
              {
                  d+=j-y ;
                  d+=min(y-i,i-x+1) ;
              }
              else
              {
                  d=j-i ;
              }
              dist[d]++ ;
          }
      }
      for(ll i=1;i<n;i++)
        cout<<dist[i]<<endl ;

    }
}
/// ans ->for answer
/// cur ->for local answer
/// level ->for depth in tree
/// v -> adjacency matrix
/// r -> array
/// s ->string



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  for(int i=0;i<1000;i++){
    vector<int> a(3);
    a.at(2)=i%10;
    a.at(1)=(i/10)%10;
    a.at(0)=(i/100)%10;
    int k=0;
    bool flag=false;
    for(int j=0;j<N;j++){
      if(a.at(k)==S.at(j)-'0'){
        k++;
        if(k==3){
          flag=true;
          break;
        }
      }
    }
    if(flag){
      ans++;
    }
  }
  cout<<ans<<endl;

}


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

using namespace std;

const int MAX = 105 ;
const int MAX2 = 1e5+10 ;
long long arr[MAX] , arr2[MAX] ;
long long dp[MAX][MAX2];
int n , w ;

long long solve(int idx , long long rem)
{
    if(idx == n)
        return 0 ;
    long long &ret = dp[idx][rem] ;
    if(ret != -1)
        return ret ;
    long long choice1 = solve(idx+1 , rem) ;
    long long choice2 = -1e17 ;
    if(rem - arr[idx] >= 0)
        choice2 = solve(idx+1 , rem - arr[idx]) + arr2[idx] ;
    return (ret = max(choice1 , choice2));
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin>>n>>w ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i]>>arr2[i] ;
    return cout<<solve(0 , w)<<"\n" , 0 ;
}


Measured memory_bytes: 82432
// ABC145-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> x(10);
vector<int> y(10);
vector<ll> frac(10);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    rep(i,n) cin>>x[i]>>y[i];
    frac[0]=1;
    for(int i=1;i<=10;i++){
        frac[i]=frac[i-1]*i;
    }
    ll num=(n-1)*frac[n-2]*2;
    //cout<<num<<endl;
    double ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double dis=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
            //cout<<dis<<endl;
            ans+=num*dis;
        }
    }
    ans=ans/frac[n];
    cout<<ans<<endl;
    return 0;
}

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

//FILE *fin = freopen("d.in", "r", stdin);

int n;
char a[maxN], b[maxN];

int x[maxN], y[maxN];
struct Dist
{
    int x, y;
    bool operator < (const Dist &ot) const
    {
        if (x == ot.x)
            return y < ot.y;
        return x < ot.x;
    }
} v[maxN];
int maxY[maxN];

int ans;

/* ----------------------------------------------------- */

void getAns(int d)
{
    int sol = 0;

    for (int i = 0; i < n; ++ i)
        if (a[i] != b[(i + d + n) % n])
        {
            ++ sol;
            if ((d >= 0 && x[(i + d + n) % n] <= d) || (d <= 0 && y[(i + d + n) % n] <= -d))
                {
                    v[i].x = v[i].y = 0;
                    continue;
                }

                if (d < 0)
                    v[i].x = x[(i + d + n) % n];
                else
                    v[i].x = x[i];

           if (d < 0)
                    v[i].y = y[i];
                else
                    v[i].y = y[(i + d + n) % n];

        }
        else
            v[i] = {0, 0};
    sort(v, v + n);
    maxY[n - 1] = v[n - 1].y;
    for (int i = n - 2; i >= 0; -- i)
        maxY[i] = max(maxY[i + 1], v[i].y);
    int crtx = 0, crty = maxY[1];
    for (int i = 0; i <= n; ++ i)
    {
        if (ans > (sol + 2 * (crtx + crty) + abs(d)))
            ans = sol + 2 * (crtx + crty) + abs(d);
        crtx = v[i].x;
        crty = maxY[i + 1];
    }
}

int main()
{
    scanf("%s\n%s", a, b);
    n = strlen(a);
    bool ok = 1, one = 0;
    for (int i = 0; i < n; ++ i)
        if (a[i] == '1')
            ok = 0;
    for (int i = 0; i < n; ++ i)
        if (b[i] == '1')
        {
            ok = 1;
            one = 1;
        }
    if (!ok || !one)
    {
        printf("%d", !ok * (-1));
        exit(0);
    }
    if (one)

        for (int i = 0; i < n; ++ i)
        {
            for (int j = i; ; j --)
            {
                if (j < 0)
                    j = n - 1;
                if (b[j] == '1')
                    break;
                ++ x[i];
            }
            for (int j = i; ; ++ j)
            {
                if (j >= n)
                    j = 0;
                if (b[j] == '1')
                    break;
                ++ y[i];
            }
        }
    ans = 2 * n;
    for (int d = -n + 1; d < n; ++ d)
        getAns(d);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mxN=105;
long long n,w;
vector<long long>value(mxN),weight(mxN);
vector<vector<long long>>dp(mxN,vector<long long>(1e5+5,-1));
long long knapsack(long long idx,long long wt) {
  if(idx>=n) return 0;
  if(wt+weight[idx]>w) return dp[idx][wt]=knapsack(idx+1,wt);
  if(dp[idx][wt]!=-1) return dp[idx][wt];
  return dp[idx][wt]=max(value[idx]+knapsack(idx+1,wt+weight[idx]),knapsack(idx+1,wt));
}
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    cin>>n>>w;
    for(int i=0;i<n;i++) cin>>weight[i]>>value[i];
    long long ans=knapsack(0,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 83328
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	while(-1){
		string s;cin>>s;
		if(s=="-"){break;}
		int m,k=0,h;cin>>m;
		while(m--){cin>>h;k+=h;}
		for(h=k%s.size();h<s.size();h++){cout<<s[h];}
		for(h=0;h<k%s.size();h++){cout<<s[h];}
		cout<<endl;
	}
	RE;
}


Measured memory_bytes: 3160