akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
//プロトタイプ宣言
int calculate_area(int depth,int width);
int calculate_total_length(int depth,int width);

int main(void){
	int depth,width,output_area,output_length;
	scanf("%d%d",&depth,&width);
	output_area=calculate_area(depth,width);
	output_length=calculate_total_length(depth,width);
	printf("%d %d\n",output_area,output_length);
	return 0;
}

int calculate_area(int depth,int width){
	int calculated_result_value = depth * width ;
	return calculated_result_value;
}

int calculate_total_length(int depth,int width){
	int calculated_result_value = (depth * 2 )+(width * 2);
	return calculated_result_value;
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

int cmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}

int main(){
  LL H,i,a=1,ans=0;
  scanf("%lld",&H);
  while(H!=0)ans+=a,H/=2,a*=2;

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


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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int bit = 0;
    int n = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        while (i + n < N && (bit == 0 || (bit & A[i + n]) == 0))
        {
            bit += A[i + n];
            n++;
        }
        ans += n;
        n--;
        bit -= A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
let s = read_line ();;
let slen = String.length s;;

let rec loop1 i en = 
    if i == slen
    then 
        en
    else
        match s.[i] with
            |'Z' -> loop1 (i+1) i
            |_ -> loop1 (i+1) en;;

let rec loop2 i = 
    match s.[i] with
    |'A' -> i,loop1 i 0
    |_ -> loop2 (i+1);;


let (st,en) = loop2 0
    in
        Printf.printf "%d\n" (en - st+1)

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll w,a,b;
    cin>>w>>a>>b;
    if(a>b)
    {
        swap(a,b);
    }
    if(a+w<b)
        cout<<b-a-w<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, (input().split()))

msk = [0] * m
for i in range(m):
    lst = list(map(int, input().split()))
    for j in range(1, lst[0] + 1):
        msk[i] |= 1 << lst[j] - 1

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

ans = 0
for i in range(2 ** n):
    flg = True
    for j in range(m):
        tmp = i & msk[j]
        cnt = 0
        while tmp > 0:
            if tmp & 1:
                cnt += 1
            tmp >>= 1
        if cnt % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])
#define mod 1000000007

using namespace std;
// lower_bound
// it returns pos of the elmnt which is not less then the query elmn
#define ll long long

int main(){
    ll k;cin >> k;
    ll now = 0;
    for(ll i =0; i< k; i++){
        now = now*10+7;
        now %= k;
        if(!now){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3644
a = [int(_) for _ in input().split()]
if len(a) == 4 and all(1 <= item <= 10 for item in a):
    if a[0] + a[1] > a[2] + a[3]:
        print('Left')
    elif a[0] + a[1] == a[2] + a[3]:
        print('Balanced')
    else:
        print('Right')
else:
    print('hoge!')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 2);
    int all = 0;
    for (int i = 1; i <= n; i++) cin >> a.at(i);
    for (int i = 1; i <= n + 1; i++) all += abs(a.at(i) - a.at(i - 1));
    for (int i = 1; i <= n; i++) cout << (all + abs(a.at(i + 1) - a.at(i - 1)) - abs(a.at(i + 1) - a.at(i)) - abs(a.at(i) - a.at(i - 1))) << endl;
    return 0;
}


Measured memory_bytes: 1664
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 100031;

int n;
set<int> s;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (;n;--n)
	{
		int val;
		cin>>val;
		if (s.find(val)!=s.end())
			s.erase(val);
		else
			s.insert(val);
	}
	cout<<s.size()<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	int X = sc.nextInt();
    	int Y = sc.nextInt();
    	int Z = sc.nextInt();

    	System.out.print(Z+" ");
    	System.out.print(X+" ");
    	System.out.print(Y+" ");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
    for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Maxn = 1009, Mod = 1e9 + 7;
int a[Maxn][Maxn], n, m, dp[Maxn][Maxn];
char s[Maxn];

void init() {
	n = read(), m = read();
	rep (i, 1, n) {
		scanf("%s", s + 1);
		rep (j, 1, m) a[i][j] = s[j] == '#';
	}
}

void solve() {
	dp[1][1] = 1;
	rep (i, 1, n) {
		if (a[i][1]) break;
		dp[i][1] = 1;
	}
	rep (i, 1, m) {
		if (a[1][i]) break;
		dp[1][i] = 1;
	}
	rep (i, 2, n) 
		rep (j, 2, m) 
			if (i != 1 && j != 1) {
				if (a[i][j]) continue;	
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % Mod;
			}
	cout << dp[n][m] << endl;
}

int main() {
//	freopen("H.in", "r", stdin);
//	freopen("H.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



Measured memory_bytes: 8192
#フェネックバーサス　スヌーく
n=int(input())
tree_list={i:[] for i  in range(1,n+1)}
for i  in range(n-1):
    a,b=map(int,input().split())
    tree_list[a].append(b)
    tree_list[b].append(a)
painted=[False for i in range(n+1)]
painted[1]="black"
painted[n]="white"
from collections import deque
d_white=deque()
e_white=deque()

d_black=deque()
e_black=deque()

d_black.append(1)
d_white.append(n)

while(d_black or d_white):
    for some in d_black:
        for point in tree_list[some]:
            if painted[point]==False:
                painted[point]="black"
                e_black.append(point)
    d_black=e_black
    e_black=deque()
    
    for some in d_white:
        for point in tree_list[some]:
            if painted[point]==False:
                painted[point]="white"
                e_white.append(point)
    d_white=e_white
    e_white=deque()
sunke=0
fennec=0
for i in range(1,n+1):
  if painted[i]=="white":
    sunke+=1
  elif painted[i]=="black":
    fennec+=1
if fennec>sunke:
  print("Fennec")
else:
  print("Snuke")

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

int main(){
  int n;
  vector<char> ans;
  cin >> n;
  string s;
  cin >> s;
  ans.push_back(s[0]);
  for(int i = 1; i < n; ++i){
    if(s[i-1] != s[i]) ans.push_back(s[i]);
  }
  cout << ans.size() << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

void print(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		cout << arr[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
}

void insert_sort(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		for (int j = i; j > 0; --j) {
			if (arr[j - 1] > arr[j])
				swap(arr[j - 1], arr[j]);
		}
		print(arr);
	}
}

void bubble_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < arr.size(); ++i) {
		for (int j = n - 1; j > i; --j) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j - 1], arr[j]);
				cnt++;
			}
		}
	}
	print(arr);
	cout << cnt << endl;
}

void select_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int mi_idx = i;
		for (int j = i; j < n; ++j) {
			if (arr[j] < arr[mi_idx])
				mi_idx = j;
		}
		cnt += (i != mi_idx);
		swap(arr[i], arr[mi_idx]);
	}
	print(arr);
	cout << cnt << endl;
}

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

	vector<int> arr(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	select_sort(arr);

	return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>

void printa(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        printf("%d", A[i]);
        if (i < N-1) printf(" ");
    }
    printf("\n");
}

int main()
{
    int N;
    int A[100];
    int i, j, v;
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    printa(A, N);
    
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (A[j] > v && j >= 0) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        printa(A, N);
    }
    
    return 0;
}

Measured memory_bytes: 1032
#include <stdio.h>

int main(void)
{
	int n, x;
	int i, j, k;
	int cmb;

	while (1)
	{
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0)
			break;
                
                cmb = 0;

		for (i = 1; i <= n - 2; i++)
			for (j = i + 1; j <= n - 1; j++)
				for (k = j + 1; k <= n; k++)
					if (i + j + k == x)
						cmb++;

		printf("%d\n", cmb);
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.lang.Integer;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      
      int sumL = 0;
      int count = 0;
    
      while(X >= sumL){
        if(count < N){
          int L = sc.nextInt();
          sumL += L;
          count++;
        }
        else{
          count++;
          break;
        }
      }
      System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forr(a,b,v) for(int v=a; v<=b; v++)
#define ford(a,b,v) for(int v=a; v>=b; v--)
const int N = 100005;
int main () {
    int n;
    int A[N];
    // store the sum of the result in a long long pair
    ll s = 0;
    cin >> n;
    forr(1,n,i) {
        cin >> A[i];
    }

    forr(1,n-2,i) {
        if (A[i] < 0) {
            A[i] *= -1;
            A[i+1] *= -1;
        }
        s += A[i];
    }
    // if n is 2, we only need to consider those
    // Also , if the last 2 elements are either both positive
    // or both negative then we simply flip their signs too
    if ( (n==2) or
        (A[n] > 0 and A[n-1] > 0) or
        (A[n] < 0 and A[n-1] < 0) ) {
        s += max(A[n-1] + A[n], -A[n-1]-A[n]);
    }
    else {
        // find the min element in the list (excluding last 2 elements)
        int* mni = min_element( A+1, A+n-2);
        int mnv = *mni;

        // if the minimum value in the remaining list is larger than
        // the smaller value of the last 2 elements, then we should
        // just keep it positive
        if ( mnv > min(abs(A[n-1]), abs(A[n])) ) {
            s += max(A[n-1] + A[n], -A[n-1]-A[n]);
        }
        // otherwise, we can make that value negative, and include the
        // last 2 elements as positive elements
        else {
            s -= mnv * 2;
            s += abs(A[n-1]);
            s += abs(A[n]);
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3952
def print_map(li):
    for i in range(len(li)):
        print(" ".join([str(a) for a in li[i]]))
    

H,W = map(int, input().split(" "))
mapp = []
for i in range(H):
    temp = list(map(int, input().split(' ')))
    mapp.append(temp)

memo = []
for i in range(H):
    temp = [n%2 for n in mapp[i]]
    memo.append(temp)
num_odd = 0
for i in range(H):
    temp = sum(memo[i])
    num_odd = num_odd + temp
# print(num_odd)

# print_map(mapp)
# print_map(memo)

c=[1,1]
bc = [1,1]
ans = []
def pli(li):
    return(str(li[0])+" "+str(li[1]))
flag = 0
ans = []
while(1):
    if flag % 2 != 0 and flag != num_odd:
        ans.append(pli(bc)+" "+pli(c))
    if memo[c[0]-1][c[1]-1] == 1:
        flag = flag + 1
    bc[0] = c[0]
    bc[1] = c[1]
    if H % 2 == 0 and c[0] == H and c[1] == 1:
        break
    elif H % 2 != 0 and c[0] == H and c[1] == W:
        break
    elif c[0] % 2 != 0 and c[1] != W:
        c[1] = c[1] + 1
    elif c[0] % 2 != 0 and c[1] == W:
        c[0] = c[0] + 1
    elif c[0] % 2 == 0 and c[1] != 1:
        c[1] = c[1] - 1
    elif c[0] % 2 == 0 and c[1] == 1:
        c[0] = c[0] + 1
print(len(ans))
for l in ans:
    print(l)

Measured memory_bytes: 18480
#include<iostream>
using namespace std;
int s[10030];
int main()
{
	int N, M;
	cin >> N >> M;
	int ans = 0;
	for (int i = 0; i < M; i++)cin >> s[i];
	for (int i = 0; i < M; i++)
		ans += s[i];
	if (ans <= N)
	cout << N - ans;
	else cout << -1;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/04  Problem: 070_arc_b / Link: https://abc056.contest.atcoder.jp/tasks/arc070_b?lang=en  ----- */
/* ------問題------

シカのAtCoDeerくんは正整数が書かれたカードを N 枚持っています。i(1≦i≦N) 枚目に書かれている数は ai です。 AtCoDeerくんは大きい数が好きなので、カードに書かれた数の総和が K 以上になるようなカードの部分集合をよい集合と呼びます。
そして、各カード i に対して、そのカードが不必要かどうかを次のように判定します。
「カード i を含む任意のよい集合に対して、その集合からカード i を除いたものもよい集合」 ならカード i は不必要
それ以外の場合は、不必要でない
不必要なカードの枚数を求めてください。ただし、それぞれの判定は独立に行われ、不必要だからと言ってカードが途中で捨てられたりすることはありません。

-----問題ここまで----- */
/* -----解説等-----

これ嘘解法やん->あっている
大きい数を持ってきて最低限必要な要素を確保できたとする。
このとき他の要素はあってもなくても現在の状態でKを確保できているため不必要である。
一方ある要素がないとK以上にならないときは必要である。

----解説ここまで---- */

LL N,K;

LL ans = 0LL;

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

	cin >> N >> K;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	RSORT(a);
	FOR(i, 0, N) {
		LL ret = 0;
		FOR(j, 0, N) {
			if (i == j)continue;
			if (ret + a[j] < K) {
				ret += a[j];
			}
		}
		if (ret + a[i] >= K) {
			ans++;
		}

	}

	cout << N - ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
double a, b, c, d;
double f(double x){
  return a*x*x*x + b*x*x + c*x + d;
}
// 2次方程式 ax^2 + bx + c = 0の解
vector<double> quadratic(double a, double b, double c){
  assert(a != 0);
  double D = b*b - 4*a*c;
  if(abs(D) <  EPS) return vector<double>(2, -b/(2.0 * a));
  if(D < 0) return vector<double>();

  // |b| >> |ac|の時の桁落ちを避けるために
  // x_1 = (-b-sign(b)*sqrt(D))/(2*a), x_2 = c / (a*x_1)を利用する
  vector<double> res;
  int sign = (b >= 0) ? 1 : -1;
  double x1 = (-b - sign * sqrt(D))/(2.0 * a);
  double x2 = c / (a * x1);
  res.push_back(x1);
  res.push_back(x2);
  return res;
}
vector<double> solve(){
  if(a < 0){
    a *= -1;
    b *= -1;
    c *= -1;
    d *= -1;
  }
  double lb = -1e3, ub = 1e3;
  REP(iter, 300){
    double x = (ub + lb) / 2;
    if(f(x) > 0){
      ub = x;
    }else if(f(x) < 0){
      lb = x;
    }
  }
  double x1 = (ub + lb) / 2;
  double A = 1;
  double B = b/a + x1;
  double C = c/a + B * x1;
  vector<double> ans = quadratic(A, B, C);
  ans.push_back(x1);
  return ans;
}

int main(){
  int N;
  cin >> N;
  while(N --){
    cin >> a >> b >> c >> d;
    vector<double> ans = solve();
    int a[2] = {};
    REP(i, ans.size()){
      //printf("f(%lf) = %lf\n", ans[i], f(ans[i]));
      if(ans[i] >  EPS) a[0]++;
      if(ans[i] < -EPS) a[1]++;
    }
    printf("%d %d\n", a[0], a[1]);
  }
  /*
  REP(iter, 100000){
    a = rand() % 200 - 100;
    if(a == 0) continue;
    b = rand() % 20 -10;
    c = rand() % 20 -10;
    d = rand() % 20 -10;
    vector<double> ans = solve();
    REP(i, ans.size()){
      assert(abs(f(ans[i])) < EPS);
    }
  }
  */
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

int main()
{
  int n,tmp;
  
  scanf("%d",&n);
  
  tmp=n/2;
  
  if(n%2==0)
  {
    printf("%d",tmp);
  }
  else
  {
    printf("%d",tmp+1);
  }
  return 0;
}

Measured memory_bytes: 128
n, m = map(int,input().split())
s = []
for i in range(m):
    s.append(list(map(int,input().split())))

for num in range(1000):
    str_num = str(num)
    if len(str_num) != n:
        continue
    flag = True
    for i in range(m):
        keta = s[i][0]
        if str_num[keta - 1] != str(s[i][1]):
            flag = False
    if flag:
        print(num)
        exit()

print(-1)


Measured memory_bytes: 3068
import collections
n = int(input())
v = list(map(int, input().split()))

count = 0
v1 = []
v2 = []
while count < n:
  v1.append(v[count])
  v2.append(v[count + 1])
  count += 2

c1 = collections.Counter(v1)
c2 = collections.Counter(v2)

num1, count1 = c1.most_common()[0]
num2, count2 = c2.most_common()[0]

if num1 != num2:
  min_count = (n // 2 - count1) + (n // 2 - count2)
elif count1 == count2 and count1 == n // 2:
  min_count = (n // 2)
else:
  if len(c1.most_common()) > 1 and len(c2.most_common()):
    num3, count3 = c1.most_common()[1]
    num4, count4 = c2.most_common()[1]
    a = (n // 2 - count1) + (n // 2 -count4)
    b = (n // 2 - count2) + (n // 2 -count3)
    min_count = min(a,b)
  else:
    if count1 > count2:
      num2, count2 = c2.most_common()[1]
      min_count = (n // 2 - count1) + (n // 2 - count2)
    else:
      num1, count1 = c1.most_common()[1]
      min_count = (n // 2 - count2) + (n // 2 - count1)
print(min_count)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

int n;

int main(){
	cin >> n;
	if(n == 3 || n == 5 || n == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
void percent(int c[type+1],int s[][type+1],double pp[][type+1],int D)
{
  int i,j;
  for(i=1;i<=D;i++){
    int total=0;
    for(j=1;j<=type;j++) total+=s[i][j];
    for(j=1;j<=type;j++) pp[i][j]=(double)s[i][j]/total;
  }
}
void change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D,double pp[][type+1])
//ランダムび変更
{
  int d,ty,old,total=0,i,j;
  double t,sa=0,wa=0;
  d=rand()%D+1;
  t=(double)rand()/RAND_MAX;
  for(i=2;i<=type;i++){
    if(i==2) wa=0;
    else wa+=pp[d][i-1];
    sa+=wa+pp[d][i];
    if(t>=wa&&t<sa){
      ty=i-1;
      break;
    }
  }
  //printf("%d\n",ty);
  old=schedul[d];
  schedul[d]=ty;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  double pp[D+1][type+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  percent(c,s,pp,D);
  /*for(i=1;i<=type;i++) printf("%f ",pp[1][i]);
  printf("\n");*/
  start=clock();
  for(i=1;i<D+1;i++){
    int select;
    select=max(s,i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.98){
    change(c,last,s,sum,schedul,D,pp);
    count++;
    stop=clock();
  }
/*  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);*/
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()
	s := nextStr()
	t := nextStr()

	cnt := 0
	for i := range s {
		if s[i] != t[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

// ---- readfunc
func scanInit() {
	const cap = 1000000
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}

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


Measured memory_bytes: 2596
#include<iostream>
using namespace std;
int main()
{
	int i,n,sum,k;
	sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&k);
		sum+=(k-1);
	}
	printf("%d",sum);
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int res = 0;

  for(int i=0;i<4;i++){
    if(S.at(i) == '+'){
      res++;
    }
    if(S.at(i) == '-'){
      res--;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
const int SIZE = 100005;
vector<int> vec[SIZE];

bool use[SIZE]; //その頂点を使ったか判定
int dep[SIZE],deg[SIZE]; //


//全域木の構成をイメージ
void dfs(int v = 0,int p = -1,int d = 0){
    use[v] = true;
    dep[v] = d;
    //まずある頂点の出次数について考える
    for(int i = 0; i < vec[v].size(); i++){
        int to = vec[v][i];
        if (to != p){
            //未使用の頂点ならば再帰
            if (!use[to]) dfs(to,v,d+1);
            //頂点を使用済みならば比較(dep[v]=d)
            else if (dep[to] < dep[v]){
                cout << v+1 << " " << to+1 << endl;
                deg[v]++;
            }
        }
    }
    if (p != -1){
        //偶奇で分けて出力する頂点を選択
        if (deg[v]%2 == 1){
            cout << v+1 << " " << p+1 << endl;
            deg[v]++;
        } else {
            cout << p+1 << " " << v+1 << endl;
            deg[p]++;
        }
    }
}

int main(){
    int n,m; cin >> n >> m; 
    for(int i = 0; i < m; i++){
        int a,b; cin >> a >> b;
        a--; b--;
        //辺の挿入
        vec[a].push_back(b);
        vec[b].push_back(a);
    }

    //全ての辺の個数が奇数ならば不成立
    if (m % 2 == 1){
        cout << "-1" << endl;
        return 0;
    }
    //関数＆出力
    dfs();
    return 0;
}

  



Measured memory_bytes: 15616
fun main(args: Array<String>) {
    val k = readLine()!!.split(" ").map { it.toInt() }[0]
    var queue = mutableListOf<Long>()
    for (i in 0 until 9){
        queue.add(i.toLong() + 1)
    }
    for (i in 0 until k){
        val x = queue[0]
        queue.minusAssign(queue[0])
        if (i == k - 1) println(x)
        if (x % 10 != 0L){
            queue.add(10 * x + (x % 10) - 1)
        }
        queue.add(10 * x + (x % 10))
        if (x % 10 != 9L){
            queue.add(10 * x + (x % 10) + 1)
        }
    }
}

Measured memory_bytes: 46540
n = int(input())
a = list(map(int, input().split()))

s = [i + 1 + a[i] for i in range(n)]
dic = {}
for i in range(n):
    d = i + 1 - a[i]
    if d in dic:
        dic[d] += 1
    else:
        dic[d] = 1
ans = sum([dic[si] if si in dic else 0 for si in s])
print(ans)

Measured memory_bytes: 144012
package main

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

var (
	dy = [2]int{-1, 0}
	dx = [2]int{0, -1}
)

func solve() {
	h, w := getInt(), getInt()
	g := make([][]rune, h)
	for i := range g {
		g[i] = getRunes()
	}

	dp := make([][]int, h)
	for i := range dp {
		dp[i] = make([]int, w)
	}
	dp[0][0] = 1

	for y := range dp {
		for x := range dp[y] {
			if g[y][x] == '#' {
				continue
			}

			for i := 0; i < 2; i++ {
				y1, x1 := y+dy[i], x+dx[i]
				if (y1 < 0) || (x1 < 0) {
					continue
				}

				dp[y][x] = (dp[y][x] + dp[y1][x1]) % mod
			}
		}
	}

	fmt.Fprintln(wr, dp[h-1][w-1])
}

// -----------------------------------------

const (
	inf = 1 << 60
	mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 13184
N = int(input())
A = list(map(int, input().split()))

ans = 0

leaves = sum(A)
node_num = 1

for i in range(N+1):
    if A[i] > node_num:
        print(-1)
        exit()
    ans += min(node_num, leaves)

    leaves -= A[i]
    node_num -= A[i]
    node_num *= 2
print(ans)



Measured memory_bytes: 20144
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;

ll dp[65][101010];

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

	ll n;
	cin >> n;
	Array x(n);
	REP(i, n)cin >> x[i];
	ll m, k;
	cin >> m >> k;
	Array a(m);
	REP(i, m)cin >> a[i], a[i]--;
	Array d(n - 1);
	REP(i, n - 1)d[i] = x[i + 1] - x[i];
	Array p(n - 1);
	REP(i, n - 1)p[i] = i;
	REP(i, m)swap(p[a[i]], p[a[i] - 1]);
	REP(i, n - 1) dp[0][i] = p[i];
	REP(i, 63)REP(j, n - 1)dp[i + 1][j] = dp[i][dp[i][j]];
	cout << x[0] << "\n";
	REP(i, n - 1) {
		ll now = i;
		REP(j, 61)if (k & (1LL << j))now = dp[j][now];
		x[i + 1] = x[i] + d[now];
		cout << x[i + 1] << "\n";
	}

	return 0;
}

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

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

int Q;
int l, r;
int memo[100010];

void sieve() {
	for (int i = 0; i <= 100000; i++)memo[i] = 1;
	int M = sqrt(100000);
	memo[0] = memo[1] = 0;
	for (int i = 2; i <= M; i++) {
		if (!memo[i])continue;
		for (int j = 2; (j * i) <= 100000; j++)memo[i * j] = 0;
	}
}

int main()
{
	cin >> Q;
	sieve();
	//素数累積和
	int v[100010];
	for (int i = 0; i <= 100000; i++)v[i] = 0;
	for (int i = 1; i <= 100000; i += 2)
		if (memo[i] && memo[(i + 1) / 2])v[i]++;
	for (int i = 1; i <= 100000; i++)v[i] += v[i - 1];
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << v[r] - v[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, v[500500], mem[500500];
void solve(int l, int r) {
	if(r - l == 1) return; c += r - l;
	solve(l, (l + r) / 2);
	solve((l + r) / 2, r);
	merge(v + l, v + (l + r) / 2, v + (l + r) / 2, v + r, mem);
	for(int i = l; i < r; i++) v[i] = mem[i - l];
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &v[i]);
	solve(0, n);
	for(int i = 0; i < n; i++) {
		if(i) printf(" ");
		printf("%d", v[i]);
	}
	printf("\n%d\n", c);
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<sz(s);i++){
		if(i&1){
			if(s[i]=='R'){
				cout<<"No";
				return 0;
			}
		}
		else{
			if(s[i]=='L'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using ll = long long;

const int maxn = 2e5+5;
int N, K, a[maxn];
//how many subarrays have sum >= 0?
ll pre[maxn];

template <class K, class V = __gnu_pbds::null_type>
using ordered_multiset = __gnu_pbds::tree<K, V, std::less_equal<K>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] -= K;
        pre[i] = pre[i-1] + a[i];
    }
    ordered_multiset<ll> ms;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ms.insert(pre[i-1]);
        ans += ms.order_of_key(pre[i]+1);
    }
    cout << ans << '\n';
}



Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	
fast;

ll a;
cin>>a;

cout<<a+a*a+a*a*a<<'\n';

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

int main()
{
    string S;
    cin >> S;
    vector<string> Str = split(S,"/");
    if(Str[1] == "01" || Str[1] == "02" || Str[1] == "03" || Str[1] == "04")
    {
        cout << "Heisei";
    }
    else
    {
        cout <<"TBD";
    }
}

vector<string> split(string str, string separator) 
{
    if (separator == "") 
        return {str};
    vector<string> result;
    string tstr = str + separator;
    long long unsigned int l = tstr.length(), sl = separator.length();
    string::size_type pos = 0, prev = 0;
    
    for (;pos < l && (pos = tstr.find(separator, pos)) != string::npos; prev = (pos += sl))
    {
        result.emplace_back(tstr, prev, pos - prev);
    }
    return result;
}

Measured memory_bytes: 256
//AOJ 0518: The Oldest Site
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[3001][2], x, y, ans = 0;
bool pillar[5001][5001];
int main() {
	while (cin>>n){
		if(n==0)
		return 0;
		ans = 0;
		for (int i = 0; i < 5001; i++){
			for (int j = 0; j < 5001; j++){
				pillar[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++){
			cin >> a[i][0] >> a[i][1];
			pillar[a[i][0]][a[i][1]] = 1;
		}
		for (int i = 0; i < n; i++){
			for (int j = i + 1; j < n; j++){
				x = a[i][0] - a[j][0];
				y = a[i][1] - a[j][1];
				if (a[i][1] >= x&&a[j][1] >= x&&a[i][0] + y > 0 && a[j][0] + y > 0 && a[i][1] - x < 5001 && a[j][1] - x < 5001 && a[i][0] + y < 5001 && a[j][0] + y < 5001){
					if (pillar[a[i][0] + y][a[i][1] - x] == 1 && pillar[a[j][0] + y][a[j][1] - x] == 1){
						ans = max(ans, (x + y)*(x + y) - (x*y * 2));
					}
				}
				if (a[i][0] >= y&&a[j][0] >= y&&a[i][1] + x > 0 && a[j][1] + x > 0 && a[i][0] - y<5001 && a[j][0] - y<5001 && a[i][1] + x <5001 && a[j][1] + x <5001){
					if (pillar[a[i][0] - y][a[i][1] + x] == 1 && pillar[a[j][0] - y][a[j][1] + x] == 1){
						ans = max(ans, (x + y)*(x + y) - (x*y * 2));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 25608
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int K,S;
	public void solve() {
		K = nextInt();
		S = nextInt();

		int ans = 0;
		for(int i = 0;i <= K;i++){
			for(int j = 0;j <= K;j++){
				if(S - i - j <= K && S - i - j >= 0){
					ans++;
				}

			}
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 8400
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 02-Aug-2020 18:24:44
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 5e5 + 7;
const int inf = 1e9 + 7;

int a[N];
int last[N];
vector <int> t[N << 2];

void build(int nd, int s, int e) {
    if (s == e) {
        t[nd].push_back(a[s]);
        return;
    }
    int md = s + e >> 1;
    build(nd << 1, s, md);
    build(nd << 1 | 1, md + 1, e);

    t[nd].resize(t[nd << 1].size() + t[nd << 1 | 1].size());
    merge(all(t[nd << 1]), all(t[nd << 1 | 1]), t[nd].begin());
}

int ask(int nd, int s, int e, int l, int r) {
    if (e < l or s > r) return 0;
    if (s >= l and e <= r) {
        int x = upper_bound(all(t[nd]), l - 1) - t[nd].begin();
        // int y = lower_bound(all(t[nd]), k) - t[nd].begin();
        return x;
    }
    int md = (s + e) >> 1;
    int c1 = ask(nd << 1, s, md, l, r);
    int c2 = ask(nd << 1 | 1, md + 1, e, l, r);
    return c1 + c2;
}

int solve() {
    int n, q; INT(n, q);
    vector<int> b(n);
    for (int &x : b) {
        INT(x);
    }

    mem(last, -1);

    for (int i = 0; i < n; ++i) {
        a[i + 1] = last[b[i]];
        last[b[i]] = i + 1;
    }

    build(1, 1, n);

    while (q--) {
        int l, r; INT(l, r);
        printf("%d\n", ask(1, 1, n, l, r));
    }

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 119192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int Sn = 0;
            for (int i = 0; i < N.Length; i++)
            {
                Sn += int.Parse(N[i].ToString());
            }

            string ans = "Yes";
            if (int.Parse(N) % Sn != 0)
            {
                ans = "No";
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


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

using namespace std;

char a[15];
char b[15];
char t[15];

int main()
{
    int n, m;

    cin >> a >> b;
    cin >> n >> m;
    cin >> t;

    if (strcmp(a, t) == 0)
        n--;
    else
        m--;

    cout << n << " " << m;

    return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int h,w,n;cin>>h>>w>>n;
  cout << min((h+n-1)/h,(w+n-1)/w) << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int max = (int)Math.max(n+m, n-m);
        System.out.println((int)Math.max(max, n*m));
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
const int maax = 100 * 1000 + 150;
vi adj[maax];
bool vis[maax];

pll dfs(int x)
{
	vis[x] = 1;
	pll tmp;
	tmp.F = 1;
	tmp.S = 1;
	REP(i,0,adj[x].Z)
	{
		if (vis[adj[x][i]] == 0)
		{
			pll tt = dfs(adj[x][i]);
			tmp.F *= tt.S;
			tmp.F %= mod;
			tmp.S *= (tt.F + tt.S);
			tmp.S %= mod;
		}
	}
	return (tmp);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	REP(i,0,n-1)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj[a].PB(b);
		adj[b].PB(a);
	}
	pll out = dfs(0);
	cout << (out.F + out.S)%mod;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
		return a<x.a;
	}
};
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=998244353ll,inf=1000000000000000000ll;
const int N=200005;

int main(){
	int n,i,j,a,k;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		for(j=i+1;j<n;++j){
			a=i^j;
			for(k=0;;++k)if(a>>k&1){printf("%d ",k+1);break;}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
    int main(){
    int a[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
    int x,y;
    cin >> x >> y;
    if(a[x]==a[y]){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
    }

Measured memory_bytes: 256