akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

ll d(P a,P b){
    return abs((a.first-b.first))+abs((a.second-b.second));
}

int main() {
   int n,m;cin >>n>>m;
   vector<Pll>stu(n);
   vector<Pll>pos(m);
    for (int i = 0; i < n; ++i) {
        ll a,b;cin >>a>>b;
        stu[i]={a,b};
    }
    for (int j = 0; j < m; ++j) {
        ll c,d;cin >>c>>d;
        pos[j]={c,d};
    }
    vector<int>ans(n);
    for (int i = 0; i < n; ++i) {
        ll mint=INFll;
        for (int j = 0; j < m; ++j) {
            if(d(stu[i],pos[j])<mint){
                ans[i]=j;
                mint=d(stu[i],pos[j]);
            }
        }
    }
    for (int k = 0; k < n; ++k) {
        cout <<ans[k]+1<<endl;
    }
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# 初めて参照しました。
# ありがとう！

k = int(input())
i = k
#print(k)
mon_str = input()
[a, b] = mon_str.split(" ")
a = int(a)
b = int(b)
#print(a, b)

while i <= b:
    if i >= a and i <= b:
        print("OK")
        exit()
    else:
        i += k

#print(i)
print("NG")


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, y; cin >> x >> y;
	if(x <= y){
		int ans = y - x;
		if(abs(x) <= abs(y)){
			ans = min(ans, 1 + y + x);
		} else {
			int mv = abs(x) - abs(y);
			x += mv;
			if(x != y) ans = min(ans, mv + 1);
			else ans = min(ans, mv);
		}
		cout << ans << endl;
		return 0;
	}
	int ans = 0;
	if(abs(x) >= abs(y)){
		x *= -1;
		int mv = abs(x) - abs(y);
		x += mv;
		if(x != y) ans = mv + 2;
		else ans = mv + 1;
	} else {
		int go = abs(y);
		ans = go - x;
		ans = min(ans, go + x + 1);
		ans += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    int count = 0;
    int n = s.length();
    rep(i, n/2)
    {
        if (s[i] == s[n-i-1]) count++;
    }
    cout << n / 2 - count << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

lli N, K;

lli reppow(lli x, lli p)
{
	if (p == 0) return 1;
	if (p == 1) return x % inf;
	lli b = reppow(x, p / 2) % inf;
	if (p % 2 == 0) { return (b * b) % inf; }
	else { return (x * ((b * b) % inf)) % inf; }
}

lli nCr(int n, int r) {
	lli a = 1;
	for (lli i = 0; i < r; i++) { a *= (n - i); a %= inf; }
	lli b = 1;
	for (lli i = 2; i <= r; i++) { b *= i; b %= inf; }
	b = reppow(b, inf - 2) % inf;
	return (a * b) % inf;
}

lli nHr(int n, int r) {
	return nCr(n + r - 1, r) % inf;
}

int main()
{
	cin >> N >> K;
	int red = N - K;
	int sukima = 0;
	for (int i = 1; i <= K; i++) {
		//i回で回収する
		lli A = nCr(K - 1, sukima);
		lli B = nHr(sukima + 2, red - sukima);
		if (red < sukima) { cout << 0 << endl; continue; }
		cout << (A * B) % inf << endl;
		sukima++;
	}
	return 0;
}

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

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s: String = read().unwrap();
    // 0 initialize
    let mut a: [i32; 3] = [0; 3];
    for c in s.chars() {
        if c == 'a' {
            a[0] += 1;
        } else if c== 'b' {
            a[1] += 1;
        } else {
            a[2] += 1;
        }
    }
    if a[0] == 1 && a[1] == 1 && a[2] == 1 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto k = modpow(t, N);
        ans += (k + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - k;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int a,b,c;cin>>a>>b>>c;
  if(b-a == c-b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max((h2 - h1) * 60 + m2 - m1 - k, 0) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define LENGTH 10

typedef struct list{
	char str[11];
	int num;
	struct list* next;
} List;

void sort(char* str, int n){
	int i, j;
	for(i = 0; i < n - 1; i++){
		for(j = i + 1; j < n; j++){
			if(str[i] > str[j]){
				char temp;
				temp = str[i];
				str[i] = str[j];
				str[j] = temp;
			}
		}
	}
}
int hash(char* str, int n){
	int str_int = 0;
	int i;
	for(i = 0; i < n; i++){
		str_int += str[i] - 'a';
	}
	return str_int;
}
void Insert(List* pre){
	List* new_entry = malloc(sizeof(List));
	new_entry -> next = pre -> next;
	pre -> next = new_entry;
}

int main(void){
	int N;
	int i;
	long long ans = 0;
	List* head[LENGTH * ('z' - 'a') + 1];
	List dummy[LENGTH * ('z' - 'a') + 1];
	List* cullent;
	char buf[11];
	
	//ハッシュテーブル基礎作成
	for(i = 0; i <= LENGTH * ('z' - 'a'); i++){
		head[i] = &dummy[i];
		dummy[i].next = NULL;
		dummy[i].num  = 0;
		strcpy(dummy[i].str, "\0");
	}
	
	scanf("%d", &N);
	//文字列入力
	for(i = 0; i < N; i++){
		//文字列入力
		scanf("%s", buf);
		//文字列をAtoZにソートする
		sort(buf, LENGTH);
		//要素を昇順に追加(ハッシュテーブル)
		cullent = head[hash(buf, LENGTH)];
		while(cullent -> next != NULL && strcmp(cullent -> next -> str, buf) != 0){
			cullent = cullent -> next;
		}
		if(cullent -> next == NULL){
			Insert(cullent);
			cullent = cullent -> next;
			strcpy(cullent -> str, buf);
			cullent -> num = 1;
		}
		else{
			cullent = cullent -> next;
			strcpy(cullent -> str, buf);
			cullent -> num += 1;
		}
	}
	//組み合わせ数を数える
	for(i = 0; i <= LENGTH * ('z' - 'a'); i++){
		for(cullent = head[i]; cullent != NULL; cullent = cullent -> next){
			//nC2 を計算
			ans += (long long)cullent -> num * (cullent -> num - 1) / 2;
		}
	}
	printf("%I64llu", ans);

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#define range(i, l, r) for(int i=l;i<r,i++)
using namespace std;
long long retint(long long n){
  switch(n%4){
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
  }
  return 0;
}
int main(int argc, char const *argv[]) {
  long long A, B;
  std::cin >> A >> B;
  std::cout << (retint(B)|((A|retint(A))-(A&retint(A)))) - (retint(B)&((A|retint(A))-(A&retint(A))))<< '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/*

int main() {
    long long int n, ans, sum, div, A[200005];
    long long int i,j;
    scanf("%lld", &n);
    for(i=0;i<n;i++) {
        scanf("%lld", A+i);
    }
    
    ans = 0;
    sum = 0;
    div = 1000000007;

    for(i=0; i<n-1; i++) {
        for(j=i+1;j<n;j++) {
            sum = (A[i] * A[j]) % div;
            ans += sum;
            ans = ans % div;
        }
    }

    
    printf("%lld",ans);
    return 0;
}a

*/

int main() {
    int n, i, mod, A[200001];
    long long int sum = 0;
    long long int ans = 0;
    mod = 1000000007;
    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%d",A+i);
        sum += A[i];
        sum %= mod;
    }
    for (i=0;i<n;i++) {
        sum -= A[i];
        if(sum<0) sum += mod;
        ans += A[i] * sum;
        ans %= mod;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 2516
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] s = new int[m];
        int[] c = new int[m];
        for (int i = 0 ; i < m ; i++) {
            s[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        for (int i = 0 ; i < Math.pow(10, n) ; i++) {
            String x = String.valueOf(i);
            boolean flg = true;
            if (x.length() != n) {
                flg = false;
            }
            for (int j = 0 ; j < m ; j++) {

                if (x.length() < s[j]) {
                    flg = false;
                } else {
                    if (Integer.valueOf(x.substring(s[j] - 1, s[j])) != c[j]) {
                        flg = false;
                    }
                }
            }
            if (flg) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);

    }

}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
int n;
string s,s1,s2;
int main(){
 	cin>>n>>s;
  	for(int i=0;i<n/2;i++) s1 += s[i];
  	for(int i=n/2;i<n;i++) s2 += s[i];
  	if(s1 == s2) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
}

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

inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
} 

int k, n, m;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout); 
	
	cin >> k >> n >> m;
	
	for(int i=n; i<=m; i++){
		if(i%k==0){
			cout << "OK";
			return 0;
		}
	}
	
	cout << "NG";
	 
	return 0;
}

Measured memory_bytes: 3656
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define max1 100005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
typedef pair<ll,ll> pr;
#define rte cout<<"Correct";exit(0);

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll ans=0,s=inf;
  for(ll i=0;i<n;i++)
  {
    s=min(s,a[i]);
    if(s==a[i])
    {
      ans++;
    }
  }
  cout<<ans<<endl;
} 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,/*st[N],loc[N],t,lst=-1,now,*/ans1,ans2;
char S[N];
bool used[2];
int main()
{
	scanf("%s",S);
	n=strlen(S);ans1=ans2=n;
	for(int i=0;i<n;i++)
    {
        used[S[i]-'0']=1;
        if(S[i]=='1')
        ans1=min(ans1,max(i,n-i-1));
    }
	for(int i=0;i<n;i++)
    {
        if(S[i]=='0')
        ans2=min(ans2,max(i,n-i-1));
    }
    printf("%d",(used[0]^used[1])?n:max(ans1,ans2));
	/*
	for(int i=0;i<n;i++)
    {
        if(S[i]!=lst)
        st[t]=now,loc[t++]=i,now=0,lst=S[i];
        now++;
    }
    if(now)st[t]=now,loc[t++]=n;
    now=t>>1;
    if(t&1)
    ans=max(st[now],n-loc[now]);
    else ans=min(st[now-1]+st[now],max(st[t-1],n-loc[now]+st[now]));
    printf("%d",ans);*/
}

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

int N, M;
bool path[10][10];
bool used[10];
int ans = 0;

void dfs(int n) {
  bool all_used = true;
  for (int i=0; i<N; i++) {
    if (!used[i]) all_used = false;
  }
  if (all_used) ans++;

  for (int i=0; i<N; i++) {
    if (!path[n][i]) continue;
    if (used[i]) continue;
    used[i] = true;
    dfs(i);
    used[i] = false;
  }
}

int main() {
  cin >> N >> M;
  int a, b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    path[a-1][b-1] = path[b-1][a-1] = true;
  }
  used[0] = true;
  dfs(0);
  cout << ans << endl;
  return 0;
}


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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : route( 0 ), prev( NULL ), next( NULL ){}

	int route;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = mSize; i > 0; --i ){
			tCell* it = tail->prev;
			it->prev->next = it->next;
			it->next->prev = it->prev;
			SAFE_DELETE( it );
		}
		mSize = 0;
	}

	void alloc( int n ){
		if ( n <= mSize ) return;
		while ( n != mSize ) pushBack();
	}
	void pushBack(){
		tCell* it = new tCell;
		it->prev = tail->prev;
		it->next = tail;
		it->prev->next = it;
		it->next->prev = it;
		++mSize;
	}
	int size(){ return mSize; }

	int& operator[]( int index ){
		tCell* it = head->next;
		for ( int i = 0; i < index; ++i ){
			it = it->next;
		}
		return it->route;
	}

private:
	int mSize;
	tCell *head, *tail;
};

int main(){
	int a, b;
	MyArray list;

	while ( cin >> a >> b ){
		if ( !a && !b ){
			bool enable = true;
			if ( !( list[ 1 ] % 2 && list[ 2 ] % 2 ) ){
				enable = false;
			}else{
				for ( int i = 3; i <= list.size(); ++i ){
					if ( list[ i ] % 2 ){
						enable = false;
						break;
					}
				}
			}
			cout << ( enable ? "OK" : "NG" ) << endl;

			list.init();
		}else{
			list.alloc( a + 1 );
			list.alloc( b + 1 );
			++list[ a ];
			++list[ b ];
		}
	}
}

Measured memory_bytes: 0
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
// 双対BIT -> 区間更新
// 和のquery O(log n)
constexpr int MX = 5e5+3;
template<class T> 
struct BIT
{
	/* data */
	vector<T> bit[2];
	T UNITY_SUM = 0;

	BIT(int n){
		for(int i=0; i<2; i++) bit[i].assign(n+1, UNITY_SUM);
	}

	/* p = 0 or 1 */
	inline void _add(int p, int a, T x) {
		for(; a<(int)bit[p].size(); a+=a&-a) bit[p][a] += x;
	}

	/* l,r are 1-indexed, [l,r) */
	inline void add (int l, int r, T x) {
		_add(0, l, -x*(l-1));
		_add(1, l, x);
		_add(0, r, x*(r-1));
		_add(1, r, -x);
	}

	inline T _sum(int p, int a) {
		T res = UNITY_SUM;
		for(; a>0; a-=a&-a) res += bit[p][a];
		return res;
	}

	/* l,r are 1-indexed, [l,r) */
	inline T sum(int l, int r) {
		T res = UNITY_SUM;
		res += _sum(0, r-1) + _sum(1, r-1)*(r-1); // sum of [1,r-1]
		res -= _sum(0, l-1) + _sum(1, l-1)*(l-1);
		return res;
	}

    /* debug */
    void print() {
        for(int i=1; i<(int)bit[0].size(); i++) cout << sum(i, i+1) << " ";
        cout << endl;
    }
};
vector<int> c;
vector<int> lefts, rights;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n,q; cin >> n >> q;
    c.resize(n+1);
    FOR(i,1,n) cin >> c[i];
    BIT<int> bt(n+1);

    lefts.resize(q);
    rights.resize(q);
    vector<int> ids(q);
    rep(i,q) {
        cin >> lefts[i] >> rights[i]; 
        ids[i] = i;
    }
    sort(ALL(ids), [&](int l, int r) {
        return rights[l] < rights[r];
    });
    // rep(i,q) cout << ids[i] << endl;

    vector<int> prev(n+1,0);
    vector<int> ans(q);
    int cur = 1;
    rep(i, q) {
        FOR(j, cur, rights[ids[i]]) {
            bt.add(prev[c[j]]+1, j+1, 1);
            // cout << prev[c[j]]+1 << " " << j+1;
            // bt.print();
            prev[c[j]] = j;
        }
        ans[ids[i]] = bt.sum(lefts[ids[i]], lefts[ids[i]]+1);
        cur = rights[ids[i]] + 1;
    }
    // bt.print();

    rep(i,q) cout << ans[i] << endl;    

    return 0;
}


Measured memory_bytes: 19444
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as := make([]int, n)
	g := 0
	for i := 0; i < n; i++ {
		as[i] = nextInt()
		g = gcd(g, as[i])
	}

	if g != 1 {
		fmt.Println("not coprime")
		return
	}

	pm := make(map[int]int)
	for i := 0; i < n; i++ {
		ps := primeFactorization(as[i])
		for p := range ps {
			pm[p]++
			if pm[p] > 1 {
				fmt.Println("setwise coprime")
				return
			}
		}
	}

	fmt.Println("pairwise coprime")
}

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

func primeFactorization(n int) map[int]int {
	pm := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			n /= i
			pm[i]++
		}
	}
	if n != 1 {
		pm[n]++
	}
	return pm
}

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 18072
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, r[105], c[105];
int dp[105][105];


int main() {
    cin >> n;
    rep(i, n) cin >> r[i] >> c[i];

    rep(i, n) rep(j, n) dp[i][j] = i == j ? 0 : INF;

    for (int i = 1; i < n; i++) {
        for (int j = i-1; j >= 0; j--) {
            for (int k = 0; k < i; k++) {
                int cost = dp[i][k+1] + dp[k][j] + r[j]*c[k]*c[i];
                chmin(dp[i][j], cost);
            }
        }
    }
    cout << dp[n-1][0] << endl;
}



Measured memory_bytes: 3128
using System;
using System.Linq;

namespace _0510
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b= Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = a[0] + a[1] + a[2] + a[3];
            int y = b[0] + b[1] + b[2] + b[3];
            if (x > y) { Console.WriteLine(x); }
            else if (x < y) { Console.WriteLine(y); }
            else if(x==y)
            {
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 9532
import java.util.Scanner;


public class Main {
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[][][] data = new int[4][3][10];
		
		for(int i = 0; i < n; i++) {
			int b = stdIn.nextInt();
			int f = stdIn.nextInt();
			int r = stdIn.nextInt();
			int v = stdIn.nextInt();
			
			data[b-1][f-1][r-1] += v;
		}
		
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 10; k++) {
					System.out.print(" " + data[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3) {
			System.out.println("####################");
			}
		}
	}

}


Measured memory_bytes: 29924
import sys
X, N = [int(x) for x in input().split()]
if N == 0:
    print(X)
    sys.exit()

p = [int(x) for x in input().split()]

p.sort()

t = []
t.append(p[0] - 1)

for i in range(p[0], p[N-1]+1):
    if i not in p:
        t.append(i)
t.append(p[N-1]+1)

_min = 1000000000000
res = 100000000000
for i in t:
    if abs(X - i) == _min:
        res = min(res, i)
    if abs(X - i) < _min:
        _min = abs(X - i)
        res = i

print(res)


Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1190&lang=jp
#define INF 1<<30
int n;
vector<double> x;
vector<double> y;
vector<double> l;
double ans_X, ans_Y;
double check_y(double X, double Y) {
	double Sum = INF;
	for (int i = 0; i < n;i++) {
		double L = pow(X - x[i], 2) + pow(Y - y[i], 2);
		Sum = min(Sum, l[i] - L);
	}
	return Sum;
}

double check_x(double X) {
	double yl = -100, yr = 100;
	for (int i = 0; i < 150; i++) {
		double mid1 = yl + (yr - yl) / 3;
		double mid2 = yl + (yr - yl) * 2 / 3;
		if (check_y(X, mid1) > check_y(X, mid2)) {
			yr = mid2;
		}
		else {
			yl = mid1;
		}
	}
	ans_Y = yl;
	return check_y(X, ans_Y);
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> n, n) {
		x.clear(), y.clear(), l.clear();
		x.resize(n), y.resize(n), l.resize(n);
		for (int i = 0; i < n;i++) { cin >> x[i] >> y[i] >> l[i]; l[i] *= l[i]; }
		double xl = -100, xr = 100;
		for (int i = 0; i < 159; i++) {
			double mid1 = xl + (xr - xl) / 3;
			double mid2 = xl + (xr - xl) * 2 / 3;
			if (check_x(mid1) > check_x(mid2)) {
				xr = mid2;
			}
			else {
				xl = mid1;
			}
		}
		ans_X = xl;
		cout << fixed << setprecision(15) << sqrt(check_y(ans_X, ans_Y)) << endl;
	}
	return 0;
}

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

#define mod 1000000007
 
int main(){
    int n;
	cin>>n;
	long long arr[n];
	long long sum[n];
	sum[0] = arr[0];
	for(int i = 0;i<n;i++)cin>>arr[i];
	for(int i = 1;i<n;i++){
		sum[i] = sum[i-1] + arr[i];
	}
	long long ans = 0;
	for(int i = 0;i<n;i++){
		ans += (arr[i] * ((sum[n-1] - sum[i])%mod) % mod);
		ans %= mod;
	}
	if(ans < 0){
		ans += mod;
	}
	cout<<ans;
    return 0;
}

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


int main(){
	int n,a;
	string command;
	list<int> lst;
	cin >> n;
	while(n--){
		cin >> command;
		if(command == "insert"){
			cin >> a;
			lst.push_front(a);
		}else if(command == "delete"){
			cin >> a;
			for(list<int>::iterator lit=lst.begin();lit!=lst.end();lit++){
				if(*lit==a){
					lst.erase(lit);
					break;
				}
			}
		}else if(command =="deleteFirst"){
			lst.pop_front();
		}else if(command =="deleteLast"){
			lst.pop_back();
		}
	}
	list<int>::iterator it = lst.begin();
	cout <<*it;
	it++;
	while(it != lst.end()){
		cout << " "<< *it;
		it++;
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 34420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();
		if(op.equals("+")) {
			System.out.println(A+B);
		}else {
			System.out.println(A-B);
		}
	}
}


Measured memory_bytes: 21844
#ITP1_4_C:   Simple Calculator
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '?':
        break
    elif op =='+':
        print(a+b) 
    elif op =='-':
        print(a-b)    
    elif op =='*':
        print(a*b)
    elif op =='/':
        print(a//b)

Measured memory_bytes: 7600
def main(X):
    cntS = 0; cntT = 0
    for x in X:
        if x == 'T' and cntS == 0:
            cntT += 1
        elif x == 'S':
            cntS += 1
        elif x == 'T' and cntS > 0:
            cntS -= 1
        else:
            pass
    return cntS + cntT
    
if __name__ == "__main__":
    X = list(input())
    ans = main(X)
    print(ans)


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	cin >> n;

	ll ans = 1;
	for(int i = 0; i < n; ++i)
	{
		ll a;
		cin >> a;

		if (a == 0)
		{
			cout << 0;
			return;
		}
		if (ans > LLONG_MAX / a || 1000000000000000000 < ans * a)
		{
			for (int j = i; j < n; ++j)
			{
				ll b;
				cin >> b;
				if (b == 0)
				{
					cout << 0;
					return;
				}
			}
			cout << -1;
			return;
		}
		ans *= a;
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int kiriage(int x){
    if(x%10 == 0)
        return x;
    else
        return kiriage(x+1);
}

int main(){
    int a,b,c,d,e;
    cin >> a >>b >> c >>d >> e;
    int min = 10;
    if(a%10 != 0 && a%10 < min)
        min = a%10;
    if(b%10 != 0 && b%10 < min)
        min = b%10;
    if(c%10 != 0 && c%10 < min)
        min = c%10;
    if(d%10 != 0 && d%10 < min)
        min = d%10;
    if(e%10 != 0 && e%10 < min)
        min = e%10;
    int ans = kiriage(a) + kiriage(b) + kiriage(c) + kiriage(d) + kiriage(e) - (10-min);
    cout << ans << endl;
}


Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

template <typename T>
void chkmax(T &dp, const T &val) {
    if (val > dp) dp = val;
}

const size_t N = 1.5e6 + 5;

char s[N], ss[N], t[N];
int ls, lt, z[N], indeg[N], dis[N];
bool ok[N];
vector<int> g[N];

void z_func(char s[], int z[]) {
    int len = strlen(s);
    for (int i = 1, l = 0, r = 0; i < len; ++i) {
        if (i < r) {
            z[i] = min(z[i - l], r - i);
        }
        for (; i + z[i] < len && s[i + z[i]] == s[z[i]]; ++z[i]) {}
        if (r <= i + z[i]) {
            l = i;
            r = i + z[i];
        }
    }
}

int main() {
    scanf("%s%s", s, t);
    ls = strlen(s);
    lt = strlen(t);
    copy(t, t + lt, ss);
    for (int i = 0, j = lt; j < N - 1; (++i) %= ls, ++j) {
        ss[j] = s[i];
    }
    z_func(ss, z);
    int cnt = 0;
    for (int i = 0; i < ls; ++i) {
        if (z[i + lt] >= lt) {
            cnt += ok[i] = true;
        }
    }
    if (!cnt) {
        return puts("0"), 0;
    }
    for (int i = 0; i < ls; ++i) {
        if (ok[i] && ok[(i + lt) % ls]) {
            g[i].emplace_back((i + lt) % ls);
            ++indeg[(i + lt) % ls];
        }
    }

    static int que[N];
    int ql = 0, qr = 0;
    for (int i = 0; i < ls; ++i) {
        if (ok[i] && !indeg[i]) {
            dis[i] = 1;
            que[qr++] = i;
        }
    }
    int ans = 0;
    while (ql < qr) {
        int x = que[ql++];
        chkmax(ans, dis[x]);
        for (int y : g[x]) {
            chkmax(dis[y], dis[x] + 1);
            if (!(--indeg[y])) {
                que[qr++] = y;
            }
        }
    }
    if (qr < cnt) ans = -1;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 73216
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string s,t,u; cin>>s>>t;
  	int a,b; cin>>a>>b;
  	cin>>u;
  	if(s==u) cout<<a-1<<' '<<b;
  	else cout<<a<<' '<<b-1;
	return 0;
}


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

int main(){
  ll N;
  
   cin >> N;
  
   vector<string> data(N);
    map<string, int> hist;
  
  	hist["AC"] = 0;
    hist["WA"] = 0;
    hist["TLE"] = 0;
 	hist["RE"] = 0;

    for(int i = 0; i < N; i++)
    {
        cin >> data.at(i);
    }

    for(int i = 0; i < N; i++)
    {
        hist[data.at(i)]++;
    }

  
  cout << "AC x " << hist["AC"] << endl;
  cout << "WA x " << hist["WA"] << endl;
  cout << "TLE x " << hist["TLE"] << endl;
  cout << "RE x " << hist["RE"] << endl;
  
}


Measured memory_bytes: 6432
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    bool first=false;
    for(int i=x-k+1;i<=x+k-1;i++){
        if(first) cout<<" ";
        else first=true;
        if(i>=-2000000 && i<=2000000) cout<<i;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<int>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9+7;
ll power(ll num,ll g,ll mod)
{
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 
  
int main() { 
 	int n;
 	cin >> n;
 	string s;
 	cin >> s;
 	if (n%2==0){
 		if (s.substr(0,n/2)==s.substr(n/2, n/2)) cout << "Yes";
 		else cout << "No";
 	}
 	else{
 		cout << "No";
 	}

} 

Measured memory_bytes: 256
n,m=map(int,input().split())
x=input().split()
x=list(map(int,x))
a=[]
x.sort()
sum=0
if(m<=n):
    print(0)
else:
    for i in range(m-1):
        a.append(x[i+1]-x[i])
    a.sort()
    for j in range(m-n):
        sum+=a[j]
    print(sum)    

Measured memory_bytes: 13968
#include<iostream>
#include<vector>
#include<algorithm>
#define N 20000

using namespace std;

int Prim(const vector< vector<int> >& data){
  vector<bool> is_reached(data.size(), false);
  vector<int> cost(data.size(), N);
  int i, j, ans;
  i = 0;
  ans = 0;
  cost[i] = 0;
  while(i != -1){
    ans += cost[i];
    is_reached[i] = true;
    for(j=0; j<data[i].size(); ++j){
      cost[j] = min(cost[j], data[i][j]);
    }
    for(i=-1, j=0; j<is_reached.size(); ++j){
      if(!is_reached[j] && (i < 0 || cost[i] > cost[j])) i = j;
    }
  }
  return ans;
}

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

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    vector< vector<int> > data(n, vector<int>(n, N));
    for(int i=0; i<m; ++i){
      cin >> a >> b >> c;
      data[a][b] = c;
      data[b][a] = c;
    }
    cout << Prim(data) << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main(void){
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < m; i++){
        if (a[i] > x){
            ans1 += 1;
        }
        if (a[i] < x){
            ans2 += 1;
        }
    }
    if (ans1 <= ans2){
        printf("%d\n", ans1);
    }
    else {
        printf("%d\n", ans2);
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define PI 3.141592653589

int main()
{
	int a,b;
	char op ;

	while(1)
	{
		cin >> a >> op >> b ;
		if(op == '?') break;

		if(op == '+') cout << a + b << endl ;
		else if(op == '-') cout << a - b << endl ;
		else if(op == '*') cout << a * b << endl ;
		else if(op == '/') cout << a / b << endl ;
	}

	return 0;
}

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

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long k, long long q, std::vector<long long> d, std::vector<long long> n, std::vector<long long> x, std::vector<long long> m){
    rep(qi,0,q) {
        ll answer = n[qi] - 1;
        debug(answer);
        vector<ll> di(k);
        rep(i,0,k) di[i] = d[i] % m[qi];
        ll dsum = accumulate(all(di), 0LL);
        rep(i,0,k) {
            if (di[i] == 0) {
                debug(i);
                answer -= (n[qi]-1) / k;
                if (i < (n[qi] - 1) % k) answer--;
            }
        }
        ll ani = x[qi] + ((n[qi]-1) / k) * dsum;
        rep(i,0,(n[qi]-1) % k) {
            ani += di[i];
        }
        debug(answer);
        debug(ani);
        answer -= ani / m[qi] - x[qi] / m[qi];
        cout << answer << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long k;
    scanf("%lld",&k);
    long long q;
    scanf("%lld",&q);
    std::vector<long long> d(k-1-0+1);
    for(int i = 0 ; i < k-1-0+1 ; i++){
        scanf("%lld",&d[i]);
    }
    std::vector<long long> n(q);
    std::vector<long long> x(q);
    std::vector<long long> m(q);
    for(int i = 0 ; i < q ; i++){
        scanf("%lld",&n[i]);
        scanf("%lld",&x[i]);
        scanf("%lld",&m[i]);
    }
    solve(k, q, std::move(d), std::move(n), std::move(x), std::move(m));
    return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  double n;
  double t, a;
  vector<double> v;
  double m = 1000000;
  int ans=0;
  cin>>n;
  cin>>t>>a;
  for(int i=0; i<n; i++) {
    double h;
    cin>>h;
    double x = t-h*0.006;
    

    if(m > abs(x-a)) {
      m=abs(x-a);
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,d,n;
  while(cin>>a>>d>>n,a+d+n){
    int cnt=0;
    while(cnt!=n){
      if(a==1){a+=d;continue;}
      if(a==2){cnt++;a+=d;continue;}
      bool flag=true;
      for(int i=2;i<=sqrt(a);i++)
	if(a%i==0){
	  flag=false;
	  break;
	}
      if(flag)cnt++;
      a+=d;
    }
    cout<<a-d<<endl;
  }
  return 0;
}

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

using namespace std;

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

  int D[110];
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
  }

  sort(D, D + N);
  D[N] = -1;

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (D[i - 1] != D[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a,b;
    
    scanf("%d %d ",&a,&b);
    
    
    if(a>b){
        printf("a > b\n");
        
    }
    if(a<b){
        printf("a < b\n");
        
    }
    if(a==b){
        printf("a == b\n");
        
    }
    
    
}



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

#define PI 3.14159265358979

using namespace std;
typedef long long int lint;

void answer()
{
	double r;
	cin >> r;
	printf("%lf %lf\n", PI * r * r, 2 * PI * r);
}

int main()
{
	answer();
	return 0;
}

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

using namespace std;

void dfs(vector<vector<int> >& map, int y, int x, int H, int W, int index)
{
  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

  map[y][x] = index;
  for (int i = 0; i < 8; i++)
  {
    if (y + dy[i] >= 0 && y + dy[i] < H && x + dx[i] >= 0 && x + dx[i] < W){
      if (map[y + dy[i]][x + dx[i]] == 1)
      {
        dfs(map, y + dy[i], x + dx[i], H, W, index);
      }
    }
  }
}

int main()
{
  int W,H;
  int index = 2;
  while(1){
    cin >> W >> H;
    if(W == 0 && H == 0){
      break;
    }
    vector<vector<int> > map(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W;j++){
        cin >> map[i].at(j);
      }
    }
    for (int i = 0; i < H;i++){
      for (int j = 0; j < W;j++){
        if(map[i][j] == 1){
          dfs(map, i, j, H, W, index);
          index++;
        }
      }
    }

    cout << index - 2 << endl;
    index = 2;
    map.clear();
  }
  return 0;
}


Measured memory_bytes: 3460
N = int(input())
P = list(map(int, input().split()))
p_list = []
cnt = 0
for i in range(1, N-1):
    p = [P[i-1], P[i], P[i+1]]
    if(max(p) != p[1] and min(p) != p[1]):
        cnt += 1
print(cnt)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int M1, D1, M2, D2;

int main()
{
    cin >> M1 >> D1;
    cin >> M2 >> D2;

    if (M1 != M2)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    while (true) {
        size_t H, W;
        scanf("%zu %zu", &H, &W);

        if (!W && !H)
            return 0;

        for (size_t i=0; i<H; ++i) {
            for (size_t j=0; j<W; ++j)
                printf("%c", i>0&&i<H-1&&j>0&&j<W-1? '.':'#');

            printf("\n");
        }

        printf("\n");
    }
}

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

int main() {
  int n;
  cin >> n;
  
  int x, y, z;
  x= n%10;
  n /= 10;
  
  y= n%10;
  n /= 10;
  
  z= n %10;
  
  if(x !=7 && y !=7 && z !=7 )
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#                         author:  kagemeka 
#                         created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n = int(sys.stdin.readline().rstrip())
    s = sys.stdin.readline().rstrip()

    opposite = collections.Counter(s)
    opposite['W'] = 0
    minimum = n
    for i in range(n):
        if s[i] == 'E':
            opposite['E'] -= 1
        minimum = min(minimum, sum(opposite.values()))
        if s[i] == 'W':
            opposite['W'] += 1
    print(minimum)




if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main() {

  for(;;) {

    int m , f , r , C;

  cin >> m >> f >> r;

  C = m + f;

  if(m == -1 && f == -1 && r == -1) break;

  if(m == -1 || f == -1) {

    cout << "F" << "\n";

    continue;

  }

  if(C >= 80) {

    cout << "A" << "\n";

  } else if(C < 80 && C >= 65) {

    cout << "B" << "\n";

  } else if(C < 65 && C >= 50 || r >= 50) {

    cout << "C" << "\n";

  } else if(C < 50 && C >= 30) {

    cout << "D" << "\n";

  } else if(C < 30) {

    cout << "F" << "\n";

  }

  }

  return 0;

}

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

const int N = 2003;
int n, m;
vector<int> G[N];
int fa[N][N], tp[N][N];
vector<pair<int, int>> event;

void dfsi(int x, int pre, int rt) {
  fa[rt][x] = pre;
  for (auto y : G[x]) if (y != pre) {
    dfsi(y, x, rt);
  }
}
void dfsx(int x, int md, int rt) {
  for (auto y : G[x]) if (y != fa[rt][x]) {
    if (~tp[rt][y]) {
      event.emplace_back(y, md);
    } else {
      tp[rt][y] = md;
      dfsx(y, md, rt);
    }
  }
}
void connect(int a, int b) {
  if (tp[a][b] == b || tp[b][a] == a) return;
  if (~tp[a][b]) {connect(tp[a][b], b); return;}
  if (~tp[b][a]) {connect(tp[b][a], a); return;}
  tp[a][b] = b;
  tp[b][a] = a;
  dfsx(b, b, a);
  dfsx(a, a, b);
}
int ans = 0;
void dfs(int x, int pre, int ls) {
  if (ls != x && tp[ls][x] == x) {
    ans++;
    ls = x;
  }
  for (auto y : G[x]) if (y != pre) {
    dfs(y, x, ls);
  }
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    dfsi(i, 0, i);
  }
  memset(tp, -1, sizeof tp);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    event.emplace_back(x, y);
    do {
      x = event.back().first, y = event.back().second;
      event.pop_back();
      connect(x, y);
    } while (!event.empty());
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, -1, i);
  }
  printf("%d\n", ans >> 1);
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int K;
void input() {
  cin >> N >> K;
  rep(i, 0, N - 1) {
    int a;
    cin >> a;
    va.push_back(a);
  };
  ;
}
int r[2222];
int l[2222];
void solve() {
  int one = 0;
  rep(i, 0, N - 1) {
    rep(j, i + 1, N - 1) {
      if (va[i] > va[j]) one++;
    }
  }
  int two = 0;
  rep(i, 0, N - 1) {
    rep(j, 0, N - 1) {
      if (va[i] > va[j]) two++;
    }
  }
  int ans = (((K * (K - 1) / 2) % MOD) * two) % MOD + (one * K % MOD);
  cout << ans % MOD << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

using namespace std;

const int MAXN = 100010;
int N, K;
int H[MAXN];

int DP[MAXN];

int main(){

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    DP[1] = abs(H[1] - H[1 - 1]);

    for (int i = 2; i < N; i++) {
        int mn = 1e9;

        for (int j = i - 1, cnt = 0; j >= 0 && cnt < K; j--, cnt++) {
            mn = min(mn, abs( H[j] - H[i]) + DP[j] );
        }
        DP[i] = mn;
    }

    cout << DP[N - 1];



    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
using namespace std;
using ll = long long;
const int mod = 1000000007;
ll pl(ll N){
    if(N%2==1){
        if(((N+1)/2)%2==0)return 0;
        return 1;
    }else{
        return (pl(N+1))^(N+1);
    }
}

int main(){
    ll A,B;
    cin>>A>>B;
    cout<<(pl(B)^pl(A-1))<<endl;

    
}

Measured memory_bytes: 256
"""
E
"""
import sys
from operator import mul
from functools import reduce
def cmb(n,r):
    r=min(n-r,r)
    if r==0:
        return 1
    over=reduce(mul,range(n,n-r,-1))
    under=reduce(mul,range(1,r+1))
    return over//under


N=list(input())
N=list(map(int,N))
K=int(input())

L=len(N)
if L<K:
    print(0)
    sys.exit()
ans=0
if L>K:
    ans+=cmb(L-1,K)*(9**K)
ans+=(N[0]-1)*cmb(L-1,K-1)*(9**(K-1))


if K==1:
    ans=(L-1)*9+N[0]
    
elif K==2:
    H=[0]*L
    H[0]=N[0]
    for i in range(1,L):
        for j in range(1,10):
            H[i]=j
            if N>=H:
                ans+=1
        H[i]=0
    
else:
    H=[0]*L
    H[0]=N[0]
    for i in range(1,L-1):
        for k in range(1,10):
            H[i]=k
            for j in range(i+1,L):
                for l in range(1,10):
                    H[j]=l
                    if N>=H:
                        ans+=1
                H[j]=0
        H[i]=0
print(ans)

Measured memory_bytes: 40940