akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ_ITP_1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            //原点を左下の頂点とする長方形の幅、高さ
            int W = int.Parse(s[0]);
            int H = int.Parse(s[1]);
            //円の中心の座標と半径
            int x = int.Parse(s[2]);
            int y = int.Parse(s[3]);
            int r = int.Parse(s[4]);
            //円が長方形の内部にあるならYes、はみ出すならNoと出力
            if(x+r <= W && x - r >= 0 && y + r <= H && y - r >= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17912
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

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

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

void solve() {
   int k,x;
   cin >> k >> x;
   for(int i = -k+1;i < k;i++){
       if(x+i >= -10000000 && x+i <= 10000000) cout << x+i << " ";
   }
   
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100000
#define NIL -1

/*

G':1-2-4 3-5
color:1 2

*/

vector<int> G[MAX];
int color[MAX];

void dfs(int u, int c) {
	stack<int> S;
	S.push(u);
	color[u] = c;
	while (!S.empty()) {
		int u = S.top(); S.pop();
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			if (color[v] == NIL) {
				color[v] = c;
				S.push(v);
			}
		}
	}
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int s, t; cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	fill(color, color + MAX, NIL);
	int id = 1;
	for (int u = 0; u < n; u++) {
		if (color[u] == NIL)dfs(u, id++);
	}

	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int s, t; cin >> s >> t;
		//cout << color[s] << " " << color[t] << endl;
		if (color[s] == color[t]) { cout << "yes" << endl; }
		else { cout << "no" << endl; }
	}

	return 0;
}

Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int gcd(int a,int b){
	if(a>b) return gcd(b,a);
	int r;
	while(r=a%b){
		a=b;
		b=r;
	}
	return b;
}

int main(){
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	//gcdが最大になるにはi以外のgcdを求め、そのiをgcdに合わせればいい
	int l[n],r[n];
	l[0]=a[0];r[n-1]=a[n-1];//l,rはiから見た右左のgcdととする

	for(int i=1;i<n;i++) l[i]=gcd(l[i-1],a[i-1]);
	for(int i=n-2;i>=0;i--) r[i]=gcd(r[i+1],a[i+1]);

	int ans=-inf;
	for(int i=0;i<n;i++){
		if(i==0) ans=max(ans,r[0]);
		else if(i==n-1) ans=max(ans,l[n-1]);
		else ans=max(ans,gcd(l[i],r[i]));
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
char s[] = "RGYB";
int n, m, k;
int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; putchar(10), i++)
		for (int j = 0; j < m; j++)
			putchar(s[(i + j) / k % 2 * 2 + (i + m - j) / k % 2]);
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
const int N=1000010;
vector<int> g[N];
int s1[N];
int s2[N];
int b[N];
void dfs(int x,int fa)
{
	s1[x]=0;
	int num=0;
	for(auto v:g[x])
		if(v!=fa)
		{
			dfs(v,x);
			s1[x]+=s1[v];
			if(!s1[v])
				num++;
		}
	if(num)
		s1[x]+=num-1;
}
void dfs2(int x,int fa)
{
	int temp1=s2[x];
	int temp2=(fa?(s2[x]?0:1):0);
	for(auto v:g[x])
		if(v!=fa)
		{
			temp1+=s1[v];
			temp2+=(s1[v]?0:1);
		}
	for(auto v:g[x])
		if(v!=fa)
		{
			s2[v]=temp1-s1[v]+(temp2-!s1[v]?temp2-!s1[v]-1:0);
			dfs2(v,x);
		}
}
void dfs3(int x,int fa)
{
	s1[x]=0;
	int num=0;
	for(auto v:g[x])
		if(v!=fa)
		{
			dfs3(v,x);
			s1[x]+=s1[v];
			if(!s1[v])
				num++;
		}
	if(num)
	{
		s1[x]+=num-1;
		for(auto v:g[x])
			if(v!=fa)
			{
				if(!s1[v]&&num>1)
				{
					b[v]=1;
					num--;
				}
			}
	}
}
void solve()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		g[i].clear();
		b[i]=s1[i]=s2[i]=0;
	}
	int x,y;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
      x++;
      y++;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	dfs2(1,0);
	pii ans(0x7fffffff,0);
	for(int i=1;i<=n;i++)
		ans=min(ans,pii(s1[i]+s2[i]+1,i));
	for(int i=1;i<=n;i++)
	{
		b[i]=0;
		s1[i]=0;
	}
	dfs3(ans.second,0);
	b[ans.second]=1;
	printf("%d\n",ans.first);
}
int main()
{
	open2("g");
		solve();
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int N,a,b;
    cin >> N >> a >> b;
    int sum=0;
    for(int i=0; i<=N; i++){
        int num = i, sum2=0, dig;

        while(num){
            dig = num % 10;
            sum2 = sum2 + dig;
            num = num / 10;
        }

        if(a <= sum2 && sum2 <= b){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         998244353 
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
void solve(){   
    int n,q;
    cin >> n;
    vector<int>cnt(maxn);
    FOR(i,1,n+1){
        int x;
        cin >> x;
        cnt[x]++;
    }
    int sum = 0;
    FOR(i,0,maxn)sum += cnt[i]*i;
    cin >> q;
    while(q--){
        int b,c;
        cin >> b >> c;
        sum -= cnt[b]*b;
        sum -= cnt[c]*c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        sum += cnt[c]*c;
        cout << sum << "\n";
    }
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 4808
while True:
    a,b = map(int,input().split())
    if a == b == 0:break
    else:
        for t in range(a):
            for y in range(b):
                if (t+y) % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()
        


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

int main(){
	int x,y,a=0,b=0,c=0;
	scanf("%d %d",&x,&y);
	if(x==4 || x==6 || x==9 || x==11){
		a = a + 1;
	}
	else if(x==2){
		b = b + 1;
	}
	else{
		c = c + 1;
	}
	if(y==4 || y==6 || y==9 || y==11){
		a = a + 1;
	}
	else if(y==2){
		b = b + 1;
	}
	else{
		c = c + 1;
	}
	if(a==2 || b==2 || c==2){
		printf("Yes");
	}
	else{
		printf("No");
	}
}

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

int main(){
	int n;
	string s;

	cin >> n;
	cin >> s;

	int cnt = 1;

	for(int i = 1;i<n;i++){
		if(s[i]!=s[i-1]){
			cnt++;
		}
	}

	cout<< cnt;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>


int main(){
	long long w,h;
	cin >> w >> h;
	if(h==1||w==1)cout << 1;
	else cout << (h*w+1)/2;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <string>

using namespace std;

void dbg(vector<vector<int> > &res)
{
    for(int i = 0; i < res.size(); i++){
        bool first = true;
        for(int j = 0; j < res[i].size(); j++){
            if(first){
                printf("%d", res[i][j]);
                first = false;
            }else{
                printf(" %d", res[i][j]);
            }
        }
        printf("\n");
    }
}

void hDraw(vector<int> &v, int s, int e, int col)
{
    for(int i = s; i < e; i++){
        v[i] = col;
    }
}

void vDraw(vector<int> &v, vector<vector<int> > &res, int s, int e)
{
    for(int i = s; i < e; i++){
        for(int j = 0; j < res[i].size(); j++){
            res[i][j] = v[j];
        }
    }
}

void hFill(vector<vector<int> > &res)
{
    for(int i = 0; i < res.size(); i++){
        int drawStart = 0;
        int drawColor = -1;
        for(int j = 0; j < res[i].size(); j++){
            if(res[i][j] != 0){
                if(drawColor != -1){
                    hDraw(res[i], drawStart, j, drawColor);
                    drawStart = j;
                }
                drawColor = res[i][j];
            }
        }
        if(drawColor != -1){
            hDraw(res[i], drawStart, res[i].size(), drawColor);
        }
    }
}

void vFill(vector<vector<int> > &res)
{
    int drawStart = 0;
    int drawBaseH = -1;
    bool needDraw = false;
    for(int i = 0; i < res.size(); i++){
        if(res[i][0] == 0){
            if(!needDraw){
                drawStart = i;
                needDraw = true;
            }
        }else{
            drawBaseH = i;
            if(needDraw){
                vDraw(res[drawBaseH], res, drawStart, i);
                needDraw = false;
            }
        }
    }
    if(needDraw){
        vDraw(res[drawBaseH], res, drawStart, res.size());
    }
}

int main(void)
{
    int h,w,k, kct = 0;
    cin >>h >>w >>k;

    vector<vector<int> > res(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        string tmp;
        cin >>tmp;
        for(int j = 0; j < w; j++){
            if(tmp[j] == '#'){
                kct++;
                res[i][j] = kct;
            }
        }
    }


    hFill(res);
    vFill(res);
    dbg(res);

    return 0;
}

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

int main(){
  int N,count=0,min=1000000;
  cin>>N;
  for(int i=0;i<N;i++){
    int P;
    cin>>P;
    if(min>=P){
      count++;
      min=P;
    }
  }
  cout<<count<<endl;

return 0;
}


Measured memory_bytes: 256
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	k := nextInt()
	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = nextInt()
	}
	sort.Ints(l)
	ans := 0
	for i := 0; i < k; i++ {
		ans += l[n-i-1]
	}
	fmt.Println(ans)
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for i in range(n-1):
    if a_ls[i+1] - a_ls[i] == 1:
        cnt += c_ls[a_ls[i]-1]
cnt += sum(b_ls)
print(cnt)

Measured memory_bytes: 3064
import os
from collections import defaultdict

N = int(input())
A = list(map(int, input().split(" ")))

pow2 = defaultdict(int)

ret = 0
lim = [0] * (N + 1)
# for i in range(N + 1):
#     pow2[i] = 2 ** i

for i in range(N + 1):
    if i == 0:
        r = 1 - A[i]
    else:
        r = 2 * lim[i - 1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim[i] = r

for d in reversed(range(N + 1)):
    # if A[d] > pow2[d]:
    #     print(-1)
    #     exit(0)
    if d == N:
        #n = min(A[d], pow2[d])
        n = A[d]
    else:
        #n = min(A[d] + min(n, lim[d]), pow2[d])
        n = A[d] + min(n, lim[d])
    ret += n

print(ret)


Measured memory_bytes: 668708
#include <iostream>
#include <vector>
#include <tuple>
#include <functional>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<pair<long long, long long>, long long>> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i].first.first >> A[i].first.second;
        A[i].second = i;
    }
    vector<pair<int, string>> ans;
    vector<int> cnt(N, 1);
    sort(A.begin(), A.end());
    for (int i = 0; i < M; i++) {
        int num = A[i].second;
        int pre = A[i].first.first;
        int ran =cnt[pre-1]; cnt[pre-1]++;
        string P = "00000" + to_string(pre);
        string R = "00000" + to_string(ran);
        P = P.substr((int)P.length() - 6, 6);
        R = R.substr((int)R.length() - 6, 6);
        string S = P + R;
        ans.emplace_back(num, S);
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < M; i++) {
        cout << ans[i].second << endl;
    }
    return 0;
}


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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if((x+r)<=W&&(x-r)>=0&&(y+r)<=H&&(y-r)>=0){
            cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,m;
    cin>>n>>m;
    ll ans[n+1];
    for(ll i=0;i<=n;i++)
    {
        ans[i]=1;
    }
    ll x;
    for(ll i=0;i<m;i++)
    {
        cin>>x;
        ans[x]=0;
    }
    for(ll i=2;i<=n;i++)
    {
        ans[i]*=(ans[i-1]+ans[i-2]);
        ans[i]%=mod;
    }
    cout<<ans[n];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	ll cnt=b-a-1;
	if(cnt%2==1){
		 cout<<(cnt+1)/2<<endl;
	}else{
		cout<<min(a+cnt/2,n-b+1+cnt/2)<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int aa,ab,tmp;
  for(int i=0;i<k;i++){
      if(i%2==0){
        if(a%2==0){
          //a=a/2;
        }
        else{
          a=a-1;
        }
        a=a/2;
        b+=a;
      }

      else{
        if(b%2==0){
          //b=b/2;
        }
        else{
          b=b-1;
        }
        b-=b/2;
        a+=b;
      }

    //   a-=a/2;
    //   b-=b/2;
    //   //ここに問題あり
    //   tmp=a;
    //   a+=b;
    //   b+=tmp;
  }
  aa=a;
  ab=b;

    cout<<aa<<" "<<ab<<endl;


}





Measured memory_bytes: 256
N = int(input())
S = input()

from collections import defaultdict 


counter = [defaultdict(int) for _ in range(N)]
for n in range(N):
    for i in range(n, N):
        counter[n][S[i]] += 1


ans = 0
for x in range(N):
    for y in range(x + 1, N):
        if S[x] != S[y]:
            length = y - x
            if "R" not in (S[x], S[y]):
                color = "R"
            elif "G" not in (S[x], S[y]):
                color = "G"
            else:
                color = "B"

            if (y + 1) < N:
                ans += counter[y + 1][color]

            if (y + length) < N and S[y + length] == color:
               ans -= 1

print(ans)
    


Measured memory_bytes: 72044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,m,A[301][301],B[301][301];
    cin>>n>>m;
    rep(i,n)rep(j,m) cin>>A[i][j],B[i][A[i][j]]=j+1;
    int num[301],ans=n;
    rep(i,m) num[i+1]=1;
    rep(i,m){
        int C[301]={0};
        rep(j,n){
            int a=m,b;
            rep(k,m) if(num[k+1]){
                if(a>=B[j][k+1]) a=B[j][k+1],b=k+1;
            }
            C[b]++;
        }
        int a=0,b;
        rep(j,m) if(a<=C[j+1]) a=C[j+1],b=j+1;
        ans=min(ans,a),num[b]--;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
#define pi acos(-1.0)

int main() {
	double r;
	cin >> r;
	cout << 2 * pi * r << endl;
	return 0;
}

Measured memory_bytes: 3784
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
const int mod=1e9+7;

int main(){
   int n;
  map<string,int>mp;
  cin>>n;
for(int i=1;i<=n;++i){
string s;
cin>>s;
mp[s]++;
}  
cout<<"AC x "<<mp["AC"]<<endl;

cout<<"WA x "<<mp["WA"]<<endl;

cout<<"TLE x "<<mp["TLE"]<<endl;

cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
} 

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(void){
    int a;
    scanf("%d", &a);
    if (1<=a && a<=10){
        printf("%d\n",  (int)(a+pow(a, 2)+pow(a, 3)));
        return 0;
    }
    else return 1;
}

Measured memory_bytes: 2596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

VI norm(const VI &a) {
  int n = a.size();
  vector<PI> b(n);
  REP(i, 0, n) {
    b[i] = PI(a[i], i);
  }
  sort(b.begin(), b.end());
  VI ret(n);
  REP(i, 0, n) {
    ret[b[i].second] = i;
  }
  return ret;
}



int main(void){
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  a = norm(a);
  int cnt = 0;
  REP(i, 0, (n + 1) / 2) {
    if (a[2 * i] % 2 != 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

bool has3(int x)
{
	while (true)
	{
		if (x % 10 == 3)
		{
			return true;
			break;
		}
		else if (x == 3)
		{
			return true;
			break;
		}
		else if (x < 3)
		{
			return false;
			break;
		}
			x /= 10;
	}
}

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

	for (int i = 1; i <= n; i++)
	{
		if ((i % 3 == 0) || (has3(i) == 1))
		{
			cout << " " << i;
		}
	}
	cout << endl;
}


Measured memory_bytes: 3100
// --------------
// Tejas Pandey  |
// 26 - 01 - 20  |
// ATCODER #153  |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll h,a;
		cin >> h >> a;
		cout << (ll)ceil(h/(a*1.0)) << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Robo{
	int l, r;

	public Robo(int l, int r) {
		super();
		this.l = l;
		this.r = r;
	}
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		Robo[] robo = new Robo[n];
		for(int i=0;i<n;i++) {
			int x = fs.nextInt();//x
			int L = fs.nextInt();//L
			robo[i] = new Robo(x-L,x+L);
		}
		Arrays.sort(robo, (r1,r2)->r1.r - r2.r); //終端でソート
		//右が小さいものから取っていく。
		long INF = Long.MAX_VALUE / 2;
		long memo = -INF;
		int cnt = 0;
		for(int i=0;i<n;i++) {
			Robo now = robo[i];
			if(now.l>=memo) {
				memo = now.r;
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 45780
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    ll x;
    cin>>x;
    ll z=x/500;
    ll hap=(1000*z);
    if(x%500!=0){
        ll y=(x%500)/5;
        hap+=(5*y);
    }
    cout<<hap<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int R,G,B,N;
  scanf("%d%d%d%d", &R, &G, &B, &N);

  int X = 0;
  for(int i = 0; i <= N; i+=R) {
    for(int j = 0; j <= N; j+=G) {
      int Y = N - (i + j);
      if(Y < 0) {
	break;
      } else if(Y == 0) {
	X++;
      } else {
	if((Y % B) == 0) {
	  X++;
	}
      }
      //printf("R=%d G=%d B=%d\n", i, j, Y);
    }
  }

  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <functional>

using namespace std;

void solve()
{
	map<string, priority_queue<int, vector<int>, greater<int> > > Map;
	string str;
	int page;
	while(cin >> str >> page)
	{
		Map[str].push(page);
	}
	for(map<string, priority_queue<int, vector<int>, greater<int> > >::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		cout << Ite->first << endl;
		bool FirstFlag = true;
		while(!Ite->second.empty())
		{
			if(FirstFlag)
			{
				cout << Ite->second.top();
				FirstFlag = false;
			}
			else
			{
				cout << " " << Ite->second.top();
			}
			Ite->second.pop();
		}
		cout << endl;
	}
}

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

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; ll K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    ll ok = INF, ng = 0;
    ll m = (ok+ng)/2;
    while(abs(ok-ng) > 1){
        ll acc = 0;
        rep(i, N){
            //A[i]/k <= m なる最小のk
            if(A[i] <= m) continue;
            if(A[i] % m == 0) acc += A[i]/m - 1;
            else acc += A[i]/m;
            if(acc > K) break;
        }
        if(acc > K) ng = m;
        else ok = m;
        m = (ok+ng)/2;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.
)");
#define cin input
#endif

int main()
{
	int h, w;
	cin >> h >> w;
	string result = "Yes";

	string s0 = string(w+2, '.');
	string s1, s2;
	cin >> s1 >> s2;
	s1 = '.'+s1+'.';
	s2 = '.'+s2+'.';

	for (int i=1; i<=h; i++)
	{
		for (int j=1; j<=w; j++)
		{
			if (s1[j]=='#'&&s1[j-1]=='.'&&s1[j+1]=='.'&&s0[j]=='.'&&s2[j]=='.')
			{
				result="No";
				break;
			}
		}

		if (i<h-1)
		{
			s0=s1;
			s1=s2;
			cin >> s2;
			s2 = '.'+s2+'.';
		}
		else
		{
			s0=s1;
			s1=s2;
			s2 = string(w+2, '.');
		}
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N,M;
int A[SIZE],B[SIZE]={0},C[SIZE]={0},cov[SIZE]={0};
int main(){
	cin>>N>>M;
	int ans=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		B[A[i]]++;
	}
	for(int i=1;i<=N;i++){
		C[max(1,i-B[i]+1)]++;
		C[i+1]--;
	}
	int sum=0;
	for(int i=1;i<=N;i++){
		sum+=C[i];
		cov[i]=sum;
	}
	for(int i=1;i<=N;i++){
		if(cov[i]==0)ans++;
	}
	/*for(int i=1;i<=N;i++){
			cout<<cov[i]<<" ";
	}
	cout<<endl;*/
	for(int i=0;i<M;i++){
		int X,Y;
		cin>>X>>Y;X--;
		if(A[X]-B[A[X]]+1>=1){
			cov[A[X]-B[A[X]]+1]--;
			if(cov[A[X]-B[A[X]]+1]==0)ans++;
		}
		B[A[X]]--;
		if(Y-B[Y]>=1){
			if(cov[Y-B[Y]]==0)ans--;
			cov[Y-B[Y]]++;
		}
		B[Y]++;
		/*for(int i=1;i<=N;i++){
			cout<<cov[i]<<" ";
		}
		cout<<endl;*/
		cout<<ans<<endl;
		A[X]=Y;
	}
}

Measured memory_bytes: 4480
eval'N,K,*A='+`dd`.split*?,
K.times{b=[t=0]*N*3
N.times{b[[0,_1-A[_1]].max]+=1
b[_1-~A[_1]]-=1}
A=b[0...N].map{t+=_1}
A.min<N||break}
p *A

Measured memory_bytes: 115344
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long dp[100005][2];
int main()
{
    char s[100005];
    cin>>s+1;
    dp[0][1]=1;
    dp[0][0]=0;
    int n=strlen(s+1);
    for(int i=1; s[i]; i++)
    {
        dp[i][0]=(dp[i-1][0]*3)%mod;
        if(s[i]=='1')
        {
            dp[i][1]=(dp[i-1][1]*2)%mod;
            dp[i][0]+=dp[i-1][1];
            dp[i][0]=(dp[i][0])%mod;
        }
        else
        {
            dp[i][1]=dp[i-1][1];
        }
    }
    printf("%lld\n",(dp[n][1]+dp[n][0])%mod);
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;

ll n, realdist[100002], dist[100002], sts[100002];
vector<int>v[100002];

bool cmp(int a, int b)
{
    return realdist[a] < realdist[b];
}

void dfs(int dad, int nod)
{
    for(int i = 0; i < v[nod].size(); ++i)
    {
        int vecin = v[nod][i];
        if(vecin == dad)
            continue;
        dfs(nod, vecin);
        dist[nod] = dist[nod] + dist[vecin] + sts[vecin];
    }
}
vector<int>p;
void dfs2(int dad, int nod, ll nodes, ll dst)
{
    if(nod == p[0])
    {
        if(dist[nod] != realdist[nod])
        {
            cout << -1;
            exit(0);
        }
    }
    else
    {
        if(dist[nod] + dst != realdist[nod])
        {
            cout << -1;
            exit(0);
        }
    }
    for(int i = 0; i < v[nod].size(); ++i)
    {
        int vecin = v[nod][i];
        if(vecin == dad)
            continue;
        int new_amount = nodes + sts[nod] - sts[vecin];
        ll new_dist = dst + new_amount + dist[nod] - dist[vecin] - sts[vecin];
        dfs2(nod, vecin, new_amount, new_dist);
    }
}
set<pair<ll, int> >s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> realdist[i];
        s.insert({realdist[i], i});
        p.pb(i);
    }
    sort(p.begin(), p.end(), cmp);
    int z = 0;
    pair<int, int> edg[100002];
    for(int i = n-1; i > 0; --i)
    {
        ++sts[p[i]];
        pair<ll, int> q = *s.lower_bound({realdist[p[i]] - n + 2 * sts[p[i]], 0});
        if(q.first != realdist[p[i]] - n + 2 * sts[p[i]])
        {
            cout << -1;
            return 0;
        }
        sts[q.se] += sts[p[i]];
        v[q.se].pb(p[i]);
        v[p[i]].pb(q.se);
        edg[++z] = {q.se, p[i]};
        if(edg[z].fi > edg[z].se)
            swap(edg[z].fi, edg[z].se);
    }
    sts[p[0]]++;
    dfs(0, p[0]);
    dfs2(0, p[0], 0, 0);
    sort(edg + 1, edg + n);
    for(int i = 1; i < n; ++i)
        cout << edg[i].fi << " " << edg[i].se << '\n';
    return 0;
}


Measured memory_bytes: 20600
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

vector<ll> next(int pos, int W) {
	vector<ll> ans(3, 0);
	for (int i = 0; i < (1 << (W-1)); i++) {
		bool flag = false;
		for (int j = 1; j < W - 1; j++) {
			if (i & (1 << (j - 1)) && i & (1 << j)) {
				flag = true;
				break;
			}
		}
		if (flag)continue;
		if (i & (1 << (pos - 1)))ans[0]++;
		else if (i & (1 << pos))ans[2]++;
		else ans[1]++;
	}
	return ans;
}
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<ll> > dp(H+1, vector<ll>(W, 0));
	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			dp[i][j] %= MOD;
			auto a = next(j, W);
			if (j != 0)dp[i + 1][j - 1] += dp[i][j] * a[0];
			dp[i + 1][j] += dp[i][j] * a[1];
			if (j != W - 1)dp[i + 1][j + 1] = dp[i][j] * a[2];
		}
	}
	cout << dp[H][K - 1] % MOD << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Template for vjudge contest
	CodeForces ID: The_Silent_Man
	LightOJ ID: 29578
*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int n, m, q;
vector<ii> vp;
ii arr[MAX];
int bit[MAX], ans[MAX], temp[MAX];

struct Query
{
	int u, v, x, idx;
	Query(int a, int b, int c, int d)
	{
		u = a, v = b, x = c, idx = d;
	}
};
vector<Query> query;

void update(int idx, int val)
{	
	while(idx <= m){
		bit[idx] += val;
		idx += (idx & -idx);
	}
}

int getValue(int idx)
{
	int sum = 0;
	while(idx > 0){
		sum += bit[idx];
		idx -= (idx & -idx);
	}

	//cout<<"debug"<<endl;
	return sum;
}
bool compare(Query q1, Query q2)
{
	return q1.x < q2.x;
}

bool comp(ii a, ii b)
{
	return a.ss < b.ss;
}


void solve()
{
	//cout<<"I came Here"<<endl;
	int curr = 0;
	for(int i = 0; i < q; i++){
		while(arr[curr].ss <= query[i].x){
			if(arr[curr].ss > query[i].x || curr >= m)
				break;
			update(arr[curr].ff + 1, 1);
			curr++;
		}
		ans[query[i].idx] = getValue(query[i].v + 1) - getValue(query[i].u); 
	}
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    cin>>n>>m>>q;

    int l, r;
    for(int i = 0; i < m; i++){
    	cin>>l>>r;
    	vp.pb(mp(l, r));
    }

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


    for(int i = 0; i < vp.size(); i++){
    	arr[i].ff = i;
    	arr[i].ss = vp[i].ss;
 		temp[i] = vp[i].ff;
    }

    for(int i = 0; i < q; i++){
    	cin>>l>>r;
    	int lidx = lower_bound(temp, temp + m, l) - temp;
    	int ridx = upper_bound(temp, temp + m, r) - temp;
    	query.pb(Query(lidx, ridx - 1, r, i));
    	//cout<<lidx<<" "<<ridx<<" "<<r<<endl;
    }

    sort(query.begin(),  query.end(), compare);
    sort(arr, arr + m, comp);

    solve();

    for(int i = 0; i < q; i++){
    	cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 7664
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        printArray(a);

        for (int i = 1; i < n; i++) {
            int key = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > key) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = key;
            printArray(a);
        }
    }

    public static void printArray(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println(a[a.length - 1]);
    }
}


Measured memory_bytes: 32192
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

H,W=MI()
h,w=MI()
ans=H*W-h*W-H*w+h*w
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

int main() {
    int n;
    int A[101];
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int min_index = i;
        for (int j = i; j < n; ++j) {
            if (A[j] < A[min_index]) {
                min_index = j;
            }
        }
        swap(A[i], A[min_index]);
        if (min_index != i) {
            ans++;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            cout << A[i];
        } else {
            cout << ' ' << A[i];
        }
    }

    cout << endl;
    cout << ans << endl;
}



Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys


def solve(X: int):
    i = 2
    vals = [1]
    while i * i <= X:
        tmp = i
        while tmp <= X:
            #print(tmp)
            vals.append(tmp)
            tmp *= i
        i += 1
    vals.sort()
    ret = vals[-1]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector < vector <int >  > F,P;





int main()
{

	cin >> N;
	F.resize(N);
	P.resize(N);

	REP(i,N){
		F[i].resize(10);
		REP(j,10){
			cin >> F[i][j];
		}
	}

	REP(i,N){
		P[i].resize(11);
		REP(j,11){
			cin >> P[i][j];
		}
	}



	int ans0 = -1000000000;
	FOR(i,1,pow(2,10)){
		int D[10];
		int ii = i;
		RREP(j,10){
			D[j] = ii%2;
			ii /=2;
		}
		int ans = 0;
		REP(j,N){
			int num = 0;
			REP(k,10){
				if(D[k]&&F[j][k])
					num++;
			}
			ans+=P[j][num];
		}
		ans0 = max(ans,ans0);

	}

	cout << ans0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long LCM(long long n,long long m){
  if (n>m) swap(n,m);
  for (int i=1;i<=n;i++){
    if (i*m%n!=0) continue;
    return i*m;
  }
}


int main(){
  int N;
  long long ans=1;
  long long T;
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> T;
    ans=LCM(ans,T);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
characters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
numbers = []
for i in range(26):
    numbers.append(1*10**(i))

def calc(str):
    x = 0
    for i in str:
        ind = characters.index(i)
        x += numbers[ind]
    return x

n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    num = str(calc(i))
    if num in d:
        d[num] += 1
    else:
        d[num] = 1

ans = 0
for i in d:
    #print(i,d[i])
    if d[i] >= 2:
        ans +=  d[i] * (d[i]-1) / 2

print(int(ans))

Measured memory_bytes: 26276
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
	{
		puts("Yes");
		return 0;	
	}	
	puts("No");
	return 0;
} 

Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

n = parseInt(
	require('fs')
	.readFileSync(config.input, 'ascii'));

dept = 100; // [unit : kilo-yen]
for (i = 0; i < n; i++)
	dept = Math.ceil(dept * 1.05);

console.log(dept + '000');

Measured memory_bytes: 15468
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX_M 105
#define MAX_N 105
#define INF (1 << 30)
using namespace std;

int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

double width(int X[], int Y[], int n, double x)
{
    double lb = INF, ub = -INF;
    for (int i = 0; i < n; i++)
    {
        double x1 = X[i], y1 = Y[i];
        double x2 = X[(i + 1) % n], y2 = Y[(i + 1) % n];
        if ((x1 - x) * (x2 - x) <= 0 && x1 != x2)
        {
            double a = (y1 - y2) / (x1 - x2);
            double b = (y1 * x2 - y2 * x1) / (x2 - x1);
            double y = a * x + b;
            lb = min(lb, y);
            ub = max(ub, y);
        }
    }
    return max(0.0, ub - lb);
}

void solve()
{
    int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
    int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
    vector<int> xs;
    for (int i = 0; i < M; i++)
        xs.push_back(X1[i]);
    for (int i = 0; i < N; i++)
        xs.push_back(X2[i]);
    sort(xs.begin(), xs.end());

    double res = 0;
    for (int i = 0; i < xs.size() - 1; i++)
    {
        double a = xs[i], b = xs[i + 1], c = (a + b) / 2;
        if (min1 <= c && c <= max1 && min2 <= c && c <= max2)
        {
            double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
            double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
            double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
            res += (b - a) / 6 * (fa + 4 * fc + fb);
        }
    }

    printf("%.10f\n", res);
}

int main()
{
    while (true)
    {
        scanf("%d %d", &M, &N);
        if (M == 0 && N == 0)
            break;

        for (int i = 0; i < M; i++)
            scanf("%d %d", &X1[i], &Y1[i]);
        for (int i = 0; i < N; i++)
            scanf("%d %d", &X2[i], &Z2[i]);

        solve();
    }
}


Measured memory_bytes: 2616
#include <stdio.h>
#include <stdlib.h>

int main() {
    unsigned long long A[100][100],B[100][100], C[100][100];
    unsigned long long n, m, l, i, j, k;

    scanf("%d %d %d", &n, &m, &l);
    for(i=0; i<n; ++i) {
        for(j=0; j<m; ++j) {
            scanf("%llu", &A[i][j]);
        }
    }

    for(i=0; i<m; ++i) {
        for(j=0; j<l; ++j) {
            scanf("%llu", &B[i][j]);
        }
    }


    for(i=0; i<n; ++i) {
        for(j=0; j<l; ++j) {
            C[i][j] = 0;
            for(k=0; k<m; ++k) {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }

    for(i=0; i<n; ++i) {
        for(j=0; j<l; ++j) {
            printf("%s%llu", j?" ":"", C[i][j]);
        }
        printf("\n");
    }

}

Measured memory_bytes: 2912