akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main()
{
  uint64_t N,K;
  std::cin>>N>>K;
  
  std::vector<uint64_t> A(N);
  for(auto &e:A)
    std::cin>>e;
  
  uint64_t currentPos=1;
  std::vector<uint64_t> firstFoundCount(N, 0);
  uint64_t loopLength=0;
  uint64_t loopStartCount=0;
  for(uint64_t i=1;;i++)
  {
    currentPos=A[currentPos-1];
    if(i==K)
    {
      int64_t result=currentPos;  
      std::cout<<result<<std::endl;
      return 0;
    }
    if(firstFoundCount[currentPos-1]!=0)
    {
      loopStartCount=firstFoundCount[currentPos-1];
      loopLength=i-firstFoundCount[currentPos-1];
      break;
    }
    firstFoundCount[currentPos-1]=i;
  }
  
  uint64_t newK=(K-loopStartCount)%loopLength;
  for(uint64_t i=0;i!=newK;i++)
  {
    currentPos=A[currentPos-1];
  }
  
  int64_t result=currentPos;
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 6080
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
ll static dp[101][100001];

ll knapsack(int wt[], int val[],int n,int w)
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {

            if(wt[i] <= j)
            dp[i][j] = max(dp[i-1][j-wt[i]] +val[i],dp[i-1][j]) ;

            else 
            dp[i][j] = dp[i-1][j];
        }
    }
    return (ll)dp[n][w];
}

int main()
{
    int n,w;
    cin>>n>>w;
    int wt[n] , val[n];
    for(int i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];

    }

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
        }
    }

    ll ans = knapsack(wt,val,n,w);

    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 82420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		String ans = "";

		int left = Integer.parseInt(S.substring(0,2));
		int right = Integer.parseInt(S.substring(2,4));


		if ((left>0&&left<13)&&(right>0&&right<13)) {
			ans = "AMBIGUOUS";
		} else if ((left==0 ||left>12) && (right<=12 && right>0)) {
			ans = "YYMM";
		} else if ((left<=12 && left>0) && (right==0 || right>12)) {
			ans = "MMYY";
		} else {
			ans = "NA";
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21332
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n, k = na()
  ab = [na() for _ in range(n)]
  ab.sort(key = lambda x: x[0])
  cnt = 0
  for a, b in ab:
    cnt += b
    if cnt >= k:
      print(a)
      return

main()

Measured memory_bytes: 29096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll res=0,ans=0;
    rep(i,N){
        ans+=max(res-A[i],(ll)0);
        chmax(res,A[i]);
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int>syukudai(M);
    int workingday=0;
    for(int i=0;i<M;i++){
        cin>>syukudai.at(i);
        workingday+=syukudai.at(i);

    }
    int playday;
    if(workingday>N){
        cout<<"-1"<<endl;
    }
    else{
        cout<<N-workingday<<endl;
    }
}

Measured memory_bytes: 3676
#include <stdio.h>

int W, H, N;
int x[112], y[112], a[112];
int square[112][112];
int ans = 0;

int main(void) {
	scanf("%d%d%d", &W, &H, &N);
	for (int i = 0; i < N; ++i) { scanf("%d%d%d", &x[i], &y[i], &a[i]); }
	for (int i = 0; i < N; ++i) {
		if (a[i] == 1) {
			for (int j = 0; j < x[i]; ++j) {
				for (int k = 0; k < H; ++k) {
					square[j][k] = 1;
				}
			}
		}
		if (a[i] == 2) {
			for (int j = x[i]; j < W; ++j) {
				for (int k = 0; k < H; ++k) {
					square[j][k] = 1;
				}
			}
		}
		if (a[i] == 3) {
			for (int j = 0; j < W; ++j) {
				for (int k = 0; k < y[i]; ++k) {
					square[j][k] = 1;
				}
			}
		}
		if (a[i] == 4) {
			for (int j = 0; j < W; ++j) {
				for (int k = y[i]; k < H; ++k) {
					square[j][k] = 1;
				}
			}
		}
	}
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < H; ++j) {
			if (square[i][j] == 0) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int t[4][14];
    int n, i, j, c;
    char m, d;
    
    for(i=0; i<4; i++){
        for(j=0; j<14; j++){
            t[i][j]=0;
        }
    }
    scanf("%d", &c);
    
    for(i=0; i<c; i++){
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        
        if (m == 'S') {
            t[0][n] = 1;
        }else if (m == 'H') {
            t[1][n] = 1;
        }else if (m == 'C') {
            t[2][n] = 1;
        }else if (m == 'D') {
            t[3][n] = 1;
        }
    }
    for (j=1; j<14; j++) {
        if (t[0][j] != 1) {
            printf("S %d\n", j);
        }
    }
    
    for (j=1; j<14; j++) {
        if (t[1][j] != 1) {
            printf("H %d\n", j);
        }
    }
    
    for (j=1; j<14; j++) {
        if (t[2][j] != 1) {
            printf("C %d\n", j);
        }
    }
    
    for (j=1; j<14; j++) {
        if (t[3][j] != 1) {
            printf("D %d\n", j);
        }
    }
    return 0;
}



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

#define ld long double
#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)100000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    int n, k;
    cin>>n>>k;
    int h = 0;
    int a[n];
    for (int i=0;i<n;++i)
    {
        cin>>a[i];
        h = max(a[i], h);
    }
    int l = 1;
    while(l<h)
    {
        int m = (l+h)/2;
        int x = 0;
        for (int i=0;i<n;++i)
        {
            x += (a[i] + m-1)/m - 1;
        }
        if (x <= k)
        {
            h = m;
        }
        else
            l = m+1;
    }
    cout << l << "\n";
    

    return 0;
} 



Measured memory_bytes: 5128
unittest
{
//	assert( [ "4 5", "1 2", "2 3", "2 4", "4 1", "4 3" ].parse.expand.solve == "3\n1\n2\n4" );
	assert( [ "4 5", "1 2", "2 3", "2 4", "4 1", "4 3" ].parse.expand.solve == "3\n2\n4\n1" );
	assert( [ "4 5", "1 2", "2 3", "2 4", "1 4", "4 3" ].parse.expand.solve == "-1" );
//	assert( [ "6 9", "1 2", "2 3", "3 4", "4 5", "5 6", "5 1", "5 2", "6 1", "6 2" ].parse.expand.solve == "4\n2\n3\n4\n5" );
	assert( [ "6 9", "1 2", "2 3", "3 4", "4 5", "5 6", "5 1", "5 2", "6 1", "6 2" ].parse.expand.solve == "4\n3\n4\n5\n2" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	// 辺を頂点基準に変換
	auto nss = new long[][ 1 + n ];
	auto rss = new long[][ 1 + n ];
	foreach( ab; abs )
	{
		nss[ ab[ 0 ] ] ~= ab[ 1 ];
		rss[ ab[ 1 ] ] ~= ab[ 0 ];
	}
	
	// 最短のサイクルを判定
	auto ms = [ long.max ];
	auto mi = 0L;
	foreach( ab; abs )
	{
		auto ds = bfs( nss, ab[ 1 ], ab[ 0 ] );
		if( ms[ mi ] <= ds[ ab[ 0 ] ] ) continue;
		ms = ds;
		mi = ab[ 0 ];
	}
	if( ms[ mi ] == long.max ) return "-1";		// サイクルなし
	
	// 経路を復元
	auto anss = new long[ ms[ mi ] + 1 ];
	anss[ $ - 1 ] = mi;
	auto t = mi;
	for( auto i = anss.length.signed - 1; 0 < i; i-- )
	{
		foreach( f; rss[ t ] )
		{
			if( ms[ f ] == ms[ t ] - 1 )
			{
				t = f;
				break;
			}
		}
		anss[ i - 1 ] = t;
	}
	return format( "%s\n%s", anss.length, anss.to!( string[] ).join( "\n" ) );
}

// グラフの始点終点指定最短経路探索（幅優先探索）
auto bfs( long[][] nss, long s, long g )
{
	import std.container.dlist;
	
	auto ds = new long[ nss.length ];
	ds[] = long.max;
	ds[ s ] = 0;
	auto queue = make!DList( s );
	while( !queue.empty )
	{
		auto f = queue.front;
		queue.removeFront();
		
		foreach( t; nss[ f ] )
		{
			if( ds[ t ] < long.max ) continue;
			ds[ t ] = ds[ f ] + 1;
			if( t == g ) break;
			queue.insertBack( t );
		}
	}
	return ds;
}


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

int main() {
    int n; cin >> n;
    vector<long long> a(n+1);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    long long s = 0;
    for (int i = 0; i < n; i++) {
        long long b; cin >> b;
        s += min(b, a[i]);
        if (a[i] > b) continue;
        b -= a[i];
        s += min(b, a[i+1]);
        a[i+1] = max(a[i+1] - b, 0LL);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <stdio.h>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    int S;
    cin >> S;

    int front = S / 100;
    int end = S % 100;
    
    if(front >= 1 && front <= 12){
        if(end >= 1 && end <= 12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else{
        if(end >= 1 && end <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int hoge[3] = {};
    string str;
    cin >> str;
    rep(i, 3) {
        int index = str[i] - 'a';
        if (hoge[index] == 0)
            hoge[index] = 1;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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

    if(D==0){
        if(N==100)cout<<N+1<<endl;
        else cout<<N<<endl;
    }else if(D==1){
        if(N==100)cout<<100*N+100<<endl;
        else cout<<100*N<<endl;
    }else{
        if(N==100)cout<<10000*N+10000<<endl;
        else cout<<10000*N<<endl;
    }
        
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[100010] = {}, f[100010];
double syo = 0, su = 0;
long long   mur = 0, kmr = 0, yju = 0, counto[5003], counto1[5003];
char fir, sec = 'z', mado[52][52],homu[52][52];
string rik[55],mrsm[55], tok[25003];
bool mazi[110], gi[110], zi, manji;
pair<int, int>n[110];
vector<int> aa[50] = {}, cc;
vector<char> bb,dd;
map<char, int>zis,uuu;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int main()
{
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		cin >> rik[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> mrsm[i];
	}
	for (int i = 0; i <= a -b; i++) {
		for (int j = 0; j <= a - b; j++) {
			for (int k = 0; k < b; k++) {
				if (rik[k+i].substr(j, b) == mrsm[k]) {
					c++;
				}
				else { c = 0; }

			}
			if (c == b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
	return 0;
}


Measured memory_bytes: 512
INF = 100000000.freeze
N, M, R = gets.split(' ').map(&:to_i)
r = gets.split(' ').map(&:to_i)

# cost = []
# N.times do |i|
#   N.times do |j|
#     cost[i] ||= []
#     cost[i][j] = i == j ? 0 : INF
#   end
# end
cost = Array.new(N) {Array.new(N, INF)}

M.times do
  a, b, c = gets.split(' ').map(&:to_i)
  cost[a-1][b-1] = c
  cost[b-1][a-1] = c
end

N.times do |k|
  N.times do |i|
    N.times do |j|
      cost[i][j] = cost[i][k] + cost[k][j] if cost[i][j] > cost[i][k] + cost[k][j]
    end
  end
end

min = INF
r.permutation(R) do |pat|
  cc = 0
  (pat.length-1).times do |i|
    cc += cost[pat[i]-1][pat[i+1]-1]
  end
  min = cc if cc < min
end

p min

Measured memory_bytes: 2428
#include <iostream>
#include <cstdlib>
#include <string>
#include <string.h>
#include <cmath>
using namespace std;
int n,len;
int r[12];
bool input(){
	string str="";
	if(!getline(cin,str)) return false;
	n=-1;
	for(int i=0;i<str.size();i++){
		char ch; ch=str[i];
		string tmp="";
		while(ch!=' '){
			tmp+=ch,i++; if(i>=str.size()) break;
			ch=str[i];
		}
		if(n==-1) len=atoi(tmp.c_str()),n++;
		else r[n++]=atoi(tmp.c_str());
	}
	return true;
}
double dp[1<<12][12];
double EPS=1e-10;
double ADD(double a,double b){
	if(abs(a+b)<=EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
double LEN(double a,double b){ return sqrt(4*a*b);}
int main() {
	while(input()){
		for(int i=0;i< 1<<n ;i++) for(int j=0;j<n;j++) dp[i][j]=100000;
		for(int i=0;i<n;i++) dp[((1<<n)-1)-(1<<i)][i]=r[i];
		//1が立っているところはまだ見てない
		for(int S=(1<<n)-2;S>=0;S--){
			//vが現在地
			for(int v=0;v<n;v++){
				for(int u=0;u<n;u++){
					if( S>>u & 1){
						dp[S-(1<<u)][u]=min(dp[S-(1<<u)][u],dp[S][v]+LEN(r[v],r[u]));
					}
				}
			}
		}
		double MIN=100000;
		for(int i=0;i<n;i++) if(MIN>dp[0][i]+r[i]) MIN=dp[0][i]+r[i];
		if(ADD(MIN,-len)<=0) cout << "OK" << '\n' ;
		else cout << "NA" << '\n' ;
		memset(r,0,sizeof(r));
	}
}

Measured memory_bytes: 1576
#include <iostream>
using namespace std;
int main(){
        int cards[300],n,m,k;
        cin >> n >> m;
        for( int i=0 ; i<2*n ; i++ )
                cards[i]=i;
        for( int all_counter=0 ; all_counter<m ; all_counter++ ){
                cin >> k;
                if(k==0){
                        int odd[200],even[200];
                        for( int i=0 ; i<n ; i++ )
                                odd[i]=cards[i];
                        for( int i=n ; i<2*n ; i++ )
                                even[i-n]=cards[i];
                        int j=0;
                        for( int i=0 ; i<2*n ; i+=2 ){
                                cards[i]=odd[j];
                                cards[i+1]=even[j];
                                j++;
                        }
                }
                else{
                        int odd[200],even[200];
                        for( int i=0 ; i<k ; i++ )
                                odd[i]=cards[i];
                        for( int i=k ; i<2*n ; i++ )
                                cards[i-k]=cards[i];
                        for( int i=0 ; i<k ; i++ )
                                cards[2*n-k+i]=odd[i];
                }
        }
        for( int i=0 ; i<2*n ; i++ )
                cout << cards[i]+1 << endl;
        return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

const int mod = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % mod;
		b = (b * b) % mod;
		e >>= 1; // e/=2;
	}
	return res;
}

ll fact[200005], inv[200005];
ll C(ll n, ll k)
{
	return (((fact[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

int main()
{
	fast;
	int a, b;
	cin >> a >> b;
	cout << a * b << en;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(a));i>=((int)(b));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

lli f(lli b, lli n){
	if(n<b) return n;
	else return f(b, n/b) + n%b;
}

int main(void){
	lli n, s; scanf("%lld%lld", &n, &s);
	
	if(s > n){
		cout << -1 << endl;
		return 0;
	}else if(s == n){
		cout << n+1 << endl;
		return 0;
	}else{
		lli sn = int(sqrt(n))+1;
		for(lli i = 2; i<=sn; i++) if(f(i,n) == s){
			cout << i << endl;
			return 0;
		}
		for(lli i = sn; i >= 1; i--) if(s>=i && (n-s)%i == 0 && s-i <= (n-s)/i && i <= (n-s)/i){
			cout << (n-s)/i + 1 << endl;
			return 0;
		}
		cout << -1 << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using  P = pair<int, int>;
 
//BITの実装
template<typename T>
struct BIT {
  int n;
  vector<T> bit;
  BIT(int n=0):n(n),bit(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      bit[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += bit[i];
    }
    return x;
  }
};
 
int main()
{	
  int n, q; cin >> n >> q;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    c[i]--;
  }
  
  //クエリを始点の大きさをもとに並べる---
  vector<vector<P>> query(n);
  rep(i,q){
    int l, r;
    cin >> l >> r;
    l--; r--;
    //番号も保持しておく
    query[l].emplace_back(r,i); 
  }
  
  //矢印の配列をつくる------------------
  vector<vector<int>> arrow(n);
  //既に現れた数字を格納する
  vector<int> app(n,-1); 
  
  rep(i, n)
  {
    int num = app[c[i]];
    if(num != -1)
    { 
      arrow[num].emplace_back(i);
    }
    app[c[i]] = i;
  }
 
  //X軸に関して走査を行う-----------------
  vector<int> ans(q);
  BIT<int> bit(n);
  
  //x軸の大きい順に調べる
  for(int x = n-1; x >= 0; --x)
  {
    //矢印の座標と一致したら、bitのy座標番目を+1
    for(int y : arrow[x]) bit.add(y, 1);
    //クエリを調べる
    for(P qu : query[x])
    {
      int r = qu.first, i = qu.second;
      //bitのrまでの数字の合計が重複分
      ans[i] = (r-x+1) - bit.sum(r);
    }
  }
  rep(i, q) cout << ans[i] << endl; 
  
  return 0;
}

Measured memory_bytes: 59936
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long

using namespace std;
int sum[100001];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a;
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a);
            sum[a+1]++;
            sum[a-1]++;
            sum[a]++;
        }
        sort(sum,sum+100001);
        printf("%d\n",sum[100000]);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(i%2==0)
      a+=v.at(i);
    else
      b+=v.at(i);
  }
  cout<<a-b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 3005
#define M 1000000007

ll arr[20][20], dp[1 << 17], cost[1 << 17];
int n;

void upd(int i, int om, int mask, int gm)
{
    if(i > n){
    dp[mask] = max(dp[mask], dp[om] + cost[gm]);
    return;
    }
    dp[mask] = max(dp[mask], dp[om] + cost[gm]);
    upd(i + 1, om, mask, gm);
    if(((om >> (i - 1)) & 1) == 0)
        upd(i + 1, om, mask | (1 << (i - 1)), gm | (1 << (i - 1)));
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
            cin >> arr[i][j];
    }
    for(int i = 0; i < (1 << n); i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if((i >> (j - 1)) & 1)
            {
                for(int k = j + 1; k <= n; k++)
                    if((i >> (k - 1)) & 1)
                        cost[i] += arr[j][k];
            }
        }
    }
    for(int i = 0; i < (1 << n); i++)
    {
        upd(1, i, i, 0);
    }
    cout << dp[(1 << n) - 1] << endl;
}



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

string s;
int sol, ans;

int main() {

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

    cin >> s;
    sol = 0, ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'S') sol++;
        else {
            if(sol > 0) sol--;
            else ans++;
        }
    }
    cout << ans + sol << "\n";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> odd(100001), even(100001);
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }
    for (int i=0; i<n; i+=2) {
        odd[v[i]]++;
    }
    for (int i=1; i<n; i+=2) {
        even[v[i]]++;
    }

    int odmx = 0, evmx = 0;
    int recod, recev;

    rep(i, 100001) {
        if (odmx < odd[i]) {
            recod = i;
            odmx = odd[i];
        }
        if (evmx < even[i]) {
            recev = i;
            evmx = even[i];
        }
    }

    if (recod != recev) {
        cout << n - odmx - evmx << endl;
        return 0;
    }

    int odmx2 = 0, evmx2 = 0;
    odd[recod] = 0; even[recev] = 0;

    rep(i, 100001) {
        if (odmx2 < odd[i]) odmx2 = odd[i];
        if (evmx2 < even[i]) evmx2 = even[i];
    }

    if (odmx2 >= evmx2) {
        cout << n - odmx2 - evmx << endl;
    }
    else {
        cout << n - evmx2 - odmx << endl;
    }

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 0;
int a[N+5];
int32_t main()
{

    string s;
    int i, j, k=0,x,y,z;
    vector < int > v;

    cin>>s;
    for(i=0; i<s.size(); i++){
        v.push_back(s[i]-'0');
        k+=v[i];
    }
    x=k-7;
    if(x)x/=2;
    int a=v[1]+v[2]+v[3];
    int b=v[1]+v[2];
    int c=v[1]+v[3];
    int d=v[2]+v[3];


    if(x==0){
        cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
        return 0;
    }
    else if(v[1]==x){
        cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
        return 0;
    }

    else if(v[2]==x){
        cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
        return 0;
    }

    else if(v[3]==x){
        cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
        return 0;
    }
    else if(x==a){
        cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
        return 0;
    }
    else if(b==x){
        cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
        return 0;
    }
    else if(c==x){
        cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
        return 0;
    }
    else if(d==x){
        cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
        return 0;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int main() {
	//code


	    int n,k;
	    cin>>n>>k;
	    int arr[n+1];
	    for(int i=1;i<=n;i++)
	    {
	        cin>>arr[i];
	    }
	vector<int>dp(n+1,0);
	dp[1]=0;
for(int i=2;i<=n;i++)
{
dp[i]=INT_MAX;
for(int j=i-1; j>=1 && (i-j)<=k;j--)
{
dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
}
}


	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
long long a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]=a[i]-i-1;
    }
    sort(a,a+n);
    long long ans=0;
    for(int i=0;i<n/2;i++) ans+=(long long)abs(a[i]-a[n-1-i]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
class UnionFindTree

  class ParArray < Hash
    def [] key
      self[key] = key if super(key).nil?
      super(key)
    end
  end

  class SizeArray < Hash
    def [] key
      self[key] = 1 if super(key).nil?
      super(key)
    end
  end

  def initialize()
    @par = ParArray.new
    @size = SizeArray.new
  end

  private

  def find(x)
    return x if x == @par[x]
    return @par[x] = find(@par[x])
  end

  public

  def unite(x, y)
    x = find(x)
    y = find(y)

    return nil if x == y
    x, y = y, x if @size[x] < @size[y]

    @par[y] = x
    @size[x] += @size[y]
  end

  def same?(x, y)
    return find(x) == find(y)
  end

  def size(x)
    return @size[find(x)]
  end

end

def cost l1,l2
  len = sqrt((l1[0]-l2[0])**2+(l1[1]-l2[1])**2+(l1[2]-l2[2])**2)-l1[3]-l2[3]
  if len <= 0
    return 0
  else
    return len
  end
end

ans = []
loop{
  n = gif
  break if n == 0
  l = []
  c = []
  un = UnionFindTree.new
  rep n do |i|
   ll = gf
   rep l.size do |j|
    c << [cost(l[j],ll),[i,j]]
  end
  l << ll
end
c.sort!
sum = 0
c.each do |cc|
  unless un.same? cc[1][0],cc[1][1]
    sum += cc[0]
    un.unite cc[1][0],cc[1][1]
  end
end
ans <<  format("%.3f", sum)
}

puts ans

Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    int n;
    cin >> n;
    int ans = n + n * n + n * n * n;
    cout << ans;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum+=a.at(i);
    }
    else{
      sum-=a.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
  double s,l,h,PI=acos(-1),cRad;
  int a,b,c;
  cin>>a>>b>>c;
  cRad=PI*c/180;
  s=a*b*sin(cRad)/2;
  l=a+b+sqrt(a*a+b*b-2*a*b*cos(cRad));
  h=b*sin(cRad);
  cout<<fixed<<s<<' '<<l<<' '<<h<<' '<<endl;
}



Measured memory_bytes: 3544
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(all(a), greater<int>());
	rep(i,k){
		ans+=a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説を思い出しながら自分で書く→自分で書けた
vector<int>to[100005];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    --a;--b;
    to[b].push_back(a);
    to[a].push_back(b);
  }
  queue<int> q;
  vector<int>dist(n,INT_MAX);
  vector<int>pre(n,-1);
  dist[0]=0;
  pre[0]=0;
  q.push(0);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int u:to[v]){
      if(dist[u]!=INT_MAX)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<n;i++)cout<<pre[i]+1<<endl;
  return 0;
}
    
  

Measured memory_bytes: 10652
///------------------------------------------
/// 踏まれても叩かれても、
/// 努力さえしつづけていれば、
/// 必ずいつかは実を結ぶ。
///
/// - 升田幸三 -
///------------------------------------------
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int M, D;
    cin >> M >> D;

    lint cnt = 0;
    for (int m = 1; m <= M; ++m)
    {
        for (int d = 10; d <= D; ++d)
        {
            int d10 = d / 10;
            int d1 = d % 10;
            if (d10 >= 2)
            {
                if (d1 >= 2)
                {
                    if (d1*d10 == m)
                    {
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)], key=itemgetter(1))

count = 0
Work = True
for i in range(n):
    if count + l[i][0] > l[i][1]:
        Work = False
        break
    else:
        count += l[i][0]

if Work:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 55268
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

long long knapsack(long long W, vector<long long> w, vector<long long> v, long long n) {
    vector<vector<long long>> dp(n+1, vector<long long>(W+1));

    for (long long i = 0; i <= n; i++) {
        for (long long wt = 0; wt <= W; wt++) {
            if (i == 0 || wt == 0)
                dp[i][wt] = 0;
            else if (w[i] <= wt) {
                dp[i][wt] = max(dp[i-1][wt], dp[i-1][wt-w[i]] + v[i]);
            }
            else {
                dp[i][wt] = dp[i-1][wt];
            }
        }
    }
    return dp[n][W];
}

int main() {

    long long n, W;

    cin >> n >> W;
    vector<long long> w(n+1, 0);
    vector<long long> v(n+1, 0);

    long long tw, tv;
    for (long long i = 1; i <= n; i++) {
        cin >> tw >> tv;
        w[i] = tw;
        v[i] = tv;
    }

    cout << knapsack(W, w, v, n) << "\n";

    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int N; cin>>N;
  string ans = "Yes";
  vector<string> W(N); REP(i,N) cin>>W.at(i);

  REP(i,N-1) {
    if(W[i].back() != W[i+1].front()) ans = "No";
  }

  SORT(W);
  REP(i,N-1) {
    if(W[i] == W[i+1]) ans = "No";
  }

  cout<<ans<<endl;
}

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{

    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(ll i=0;i<n;i++) cin>>h[i];

    sort(h.begin(),h.end(),greater<ll>());
    ll cnt=0;
    for(ll i=k;i<h.size();i++) 
    {
        cnt+=h[i];
    }

    cout<<cnt<<endl;

    return 0; 
}



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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

map<ll, ll> PrimeFactorial(ll n) {

    map<ll,ll> ret;
    
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while (n % i == 0) {
                ret[i]++;
                n /= i;
            }
        }
    }

    if(n > 1) { ret[n]++; }

    return ret;
}

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

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

ll nCr(ll n, ll r, ll mod) 
{
    ll x = 1, y = 1;
    
    lrep(i, r) {
        x *= n-i;
        x %= mod;

        y *= r-i;
        y %= mod;
    }

    ll rtn = (x * modinv(y, mod)) % mod;

    return rtn;
}

int main(void)
{
    int n, m;
    cin >> n >> m;
     
    auto prime = PrimeFactorial(m);
       
    ll ans = 1;
    for(auto p : prime) {
        ll tmp = nCr(n+p.second-1, p.second, IMOD);
        ans *= tmp;
        ans %= IMOD;
    }

    cout << ans << endl;

    return 0;
}
/** tcoder **/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int X; cin >> X;
  if (X==1) {
    cout << 1 << endl;
    return 0;
  }

  int retval = 2;
  for (int i=2;i<=X;i++){
    int x = i;
    while (x<=X){
      x *= i;
    }
    if (x/i>i)retval = max(x/i,retval);
  }

  cout << retval << endl;
  

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>

struct Circle2D {
	double x, y, r;
	static int Intersection(Circle2D &a, Circle2D &b);
};

int Circle2D::Intersection(Circle2D &a, Circle2D &b) {
	double diffABx = b.x - a.x, diffABy = b.y - a.y;
	double distanceCenterAB2 = diffABx * diffABx + diffABy * diffABy;
	double distanceCenterAB = sqrt(distanceCenterAB2);
	if (distanceCenterAB2 <= (a.r + b.r) * (a.r + b.r)) {
		if (a.r > b.r + distanceCenterAB) {
			return 2;
		}
		if (b.r > a.r + distanceCenterAB) {
			return -2;
		}
		return 1;
	}
	return 0;
}

int main() {
	int dataSet;
	Circle2D ca, cb;
	for (std::cin >> dataSet; dataSet > 0; --dataSet) {
		std::cin >> ca.x >> ca.y >> ca.r >> cb.x >> cb.y >> cb.r;
		std::cout << Circle2D::Intersection(ca, cb) << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdlib.h>

int main(void)
{
	int num1, num2;
	for (num1 = 1; num1 < 10; num1++){
		for (num2 = 1; num2 < 10; num2++){
			printf("%dx%d=%d\n", num1, num2, num1*num2);
		}
	}
	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	long long N,K;
	cin >> N >> K;

	if(K==0){
		cout << N*N << endl;
		return 0;
	}

	long long ans=0;
	for(int b=1;b<=N;b++){
		if(b<K+1)	continue;
		long long x=N/b;
		long long y=N%b;
		ans+=x*(b-K);
		ans+=max((long long)0,y-K+1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	string s;
	cin>>s;
	if(s.back()=='s')
	{
		s+="es";
	}
	else
	{
		s+="s";
	}
	cout<<s;

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<a[n-1];
	}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll x,y; cin >> x >> y;
  // a+b = x, 2a * 4b = y

  for(ll a = 0; a <= 200; a++){
    for(ll b = 0; (y - 2 * b >= 0 ) && (x - b >= 0); b++){
      if(2 * a + 4 * b == y && a + b == x){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n,p=1000000000+7;
  cin>>n;
  ll k=1;
  for(int i=1;i<=n;i++){
    k=k*i%p;}
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll a,b,c,d;
  std::cin>>a>>b>>c>>d;

  if((c-1)/b <= (a-1)/d)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int[] ans = new int[n+1];
        ans[0] = 1;
        for(int i = 0; i <= n; i++){
            if(i - r >= 0){
                ans[i] += ans[i-r];
            }
        }
        for(int i = 0; i <=n ; i++){
            if(i - g >= 0){
                ans[i] += ans[i-g];
            }
        }
        for(int i = 0; i <=n ; i++){
            if(i - b >= 0){
                ans[i] += ans[i-b];
            }
        }
        System.out.println(ans[n]);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    register int x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')
        ch=getchar();
    while(ch>='0'&&ch<='9')
        x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x;
}
inline void write(int x)
{
	register char st[10];
	register int top=0;
	if(!x)
		putchar('0');
	while(x) 
		st[++top]=(x%10)+48,x/=10;
   	while(top)
		putchar(st[top--]);
	putchar('\n');
}
const int N=200001;
int f1[N],f2[N];
int find(int x,int *f)
{
	return f[x]==x? f[x]:f[x]=find(f[x],f);
}
map<pair<int,int>,int>mp;
int main()
{
	register int n=read(),k=read(),l=read(),a,b;
	for(register int i=1;i<=n;++i)
		f1[i]=f2[i]=i;
	while(k--)
		if(find(a=read(),f1)!=find(b=read(),f1))
			f1[find(a,f1)]=find(b,f1);
	while(l--)
		if(find(a=read(),f2)!=find(b=read(),f2))
			f2[find(a,f2)]=find(b,f2);
	for(register int i=1;i<=n;++i)
		find(i,f1),find(i,f2);
	for(register int i=1;i<=n;++i)
		++mp[make_pair(f1[i],f2[i])];
	for(register int i=1;i<=n;++i)
		write(mp[make_pair(f1[i],f2[i])]);
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
using namespace std;
int main() {
    int N, maxA = 0, ans;
    cin >> N;
    for (int i = 0, A, B; i < N; i++) {
        cin >> A >> B;
        if (A > maxA) {
            maxA = A;
            ans = A + B;
        }
    }
    cout << ans << endl;
}


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

static const int N = 100;

int main()
{
    int n, p[N + 1], m[N + 1][n + 1];
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i - 1] >> p[i];
    }

    for (int i = 1; i <= n; i++)
        m[i][i] = 0;
    for (int l = 2; l <= n; l++)
    {
        for (int i = 1; i <= n - l + 1; i++)
        {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; k++)
            {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int work(int x, int y)
{
	if (x <= y) return y - x;
	else return x - y + 2;
}

int main()
{
	int x, y;
	gii(x, y);
	printf("%d\n", min(work(x, y), min(1 + work(-x, y), min(1 + work(x, -y), 2 + work(-x, -y)))));
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const a = parseInt(input.split(' ')[0])
    const b = parseInt(input.split(' ')[1])
    if(b < a){
        console.log(a - 1)
    }else{
        console.log(a)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372