akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  long double L;
  cin >> L;
  
  long double a=L/3,b=a,c=a;
  
  cout << fixed << setprecision(10);
  cout << a*b*c;
}

Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300000
#define INF 1000000001
using namespace std;

int a[N+2];
int diff;

void update(int i,int v){
    diff -= (a[i-1]>a[i])+(a[i]>a[i+1]);
    a[i] = v;
    diff += (a[i-1]>a[i])+(a[i]>a[i+1]);
}

int main(){
	int n,q; 
	scanf("%d",&n);
	a[0]=-INF;
	a[n+1]=INF;
	for(int i=1;i<n+1;i++)
		scanf("%d",a+i);
	
	// 大小関係が間違っているものの数をdiffとする
	for(int i=1;i<n+1;i++){
		diff +=  (a[i-1]>a[i]);
	}

	if (!diff){
		printf("0\n");
		return 0;
	}

	scanf("%d",&q);
	rep(i,q){
		int sw1,sw2;
		scanf("%d %d",&sw1,&sw2);
		int next1,next2;
		next1 = a[sw2];
		next2 = a[sw1];

        update(sw1,next1);
        update(sw2,next2);

		if (!diff){
			printf("%d\n",i+1);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 12;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

vs m(N);

void dfs(int, int);

int main(void){
    int cnt;
    for(string in; cin >> in; cout << cnt << endl){
        m[0] = in;
        COUNT(i, N - 1) cin >> in, m[i] = in;

        cnt = 0;
        rep(x, N) rep(y, N) if(m[y][x] == '1') dfs(x, y), cnt++;
    }

    return 0;
}

void dfs(int x, int y){
    if(x < 0 || N <= x ||
       y < 0 || N <= y) return;
    if(m[y][x] == '0') return;
    
    m[y][x] = '0';
    rep(i, 4) dfs(x + dx[i], y + dy[i]);
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;


int main() {
	int n, m;
	int max_x;
	int min_y;
	cin >> n >> m >> max_x >> min_y;
	rep(i, 0, n) {
		int xx;
		cin >> xx;
		max_x = max(max_x, xx);
	}
	rep(i, 0, m) {
		int yy;
		cin >> yy;
		min_y = min(min_y, yy);
	}
	if (max_x < min_y) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
using Int = long long;

int main() {

	Int a, b, x;
	std::cin >> a >> b >> x;

	Int ans = 0;
	if (a)ans = b / x - (a - 1) / x;
	else ans = b/x+1;

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
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; }

// 最大公倍数
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
// 最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a/g*b;
}

int main() {
    ll N, ans = 0;
    cin >> N;
    FOR(a, 1, N+1) {
        FOR(b, 1, N+1) {
            FOR(c, 1, N+1) {
                int d = gcd(b, c);
                ans += gcd(a, d);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
from itertools import accumulate
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a2=[0]+a2
a1=list(accumulate(a1))
a2=list(accumulate(a2))
ans=0
s=a2[-1]
for i in range(n):
    t=0
    t+=a1[i]
    t+=s-a2[i]
    ans=max(t,ans)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,K,Q;
  in(N,K,Q);
  map<long,long>score;
  ull A;
  rep(i,Q){
    in(A);
    score[--A]++;
  }
  rep(i,N){
    if(K-Q+score[i]>0)out("Yes");
    else out("No");
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 6912
import math

a,b,volume=map(int,input().split())
V=a*a*b
space=V-volume
if space>volume:
  high=volume*2/a/b
  print(math.degrees(math.atan(b/high)))
elif space<=volume:
  high2=space*2/a/a
  print(math.degrees(math.atan(high2/a)))


Measured memory_bytes: 2940
#include <stdio.h>
#define SIZE 200000

int main(void){
    int i=0, count=0;
    char a[SIZE], b[SIZE];
    scanf("%s", a);
    scanf("%s", b);

    while(1){
        if(a[i] != b[i]) count++;
        i++;
        if(a[i] == '\0' || b[i] == '\0') break;
    }

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


Measured memory_bytes: 2124
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        a = in.nextInt();
        b = in.nextInt();
        c = in.nextInt();
        l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = in.nextInt();
        }
        System.out.println(backtrack(0, 0, 0, 0));
    }

    static int a;
    static int b;
    static int c;
    static int[] l;

    private static int backtrack(int currA, int currB, int currC, int i) {
        if (i == l.length) {
            if (currA == 0 || currB == 0 || currC == 0) {
                return Integer.MAX_VALUE / 2;
            }
            return Math.abs(a - currA) + Math.abs(b - currB) + Math.abs(c - currC) - 30;
        }
        int nothing = backtrack(currA, currB, currC, i + 1);
        int addToA = backtrack(currA + l[i], currB, currC, i + 1) + 10;
        int addToB = backtrack(currA, currB + l[i], currC, i + 1) + 10;
        int addToC = backtrack(currA, currB, currC + l[i], i + 1) + 10;
        return Math.min(nothing, Math.min(addToA, Math.min(addToB, addToC)));

    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath> 

using namespace std;

int main(void) {
    double a, b, x;
    
    cin >> x >> a >> b;

    if( fabs(x-a) < fabs(x-b) ) cout << 'A' << endl;
    else cout << 'B' << endl;
    
    return 0;
}

Measured memory_bytes: 256
// Implement stak using queue
// making push operation costly
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l, r, d, count = 0;
    cin >> l >> r >> d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            count++;
    }
    cout << count;
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int maxv = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		
		for(int j = 0; j < n; j++) {
			int r = sc.nextInt();
			maxv = Math.max(maxv, r - min);
			min = Math.min(min, r);
		}
		
		System.out.println(maxv);
	}
}


Measured memory_bytes: 67516
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define lli long long int
#define test                lli t;cin>>t;while(t-->0)
#define ainput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define vec vector<lli>v;
vec
#define avinput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];v.push_back(a[i]);}
#define vp  for(lli i=0;i<v.size();i++) {cout<<v[i]<<" ";}cout<<endl;
#define vp1  for(lli i=0;i<v1.size();i++) {cout<<v1[i]<<" ";}cout<<endl;
#define vp2  for(lli i=0;i<v2.size();i++) {cout<<v2[i]<<" ";}cout<<endl;
#define vp3  for(lli i=0;i<v3.size();i++) {cout<<v3[i]<<" ";}cout<<endl;
#define vp6  for(lli i=0;i<v6.size();i++) {cout<<v6[i].first<<" "<<v6[i].second<<endl;}
#define vp16  for(lli i=0;i<v16.size();i++) {cout<<v16[i].first<<" "<<v16[i].second<<endl;}
#define ln cout<<endl;
  //cout << fixed << setprecision(10) <<((double)((sum*1.0)/((n*1.0-k*1.0)+1.0))) << endl;
set<lli>s1;
set<lli>s2;
set<string>st2;
vector<lli>v1;
vector<lli>v2;
vector<lli>v3;
vector<lli>v4;
vector<lli>v5;
vector<pair<lli,lli> >v6;
vector<pair<lli,lli> >v16;
vector<string>v7;
vector<string>v8;
vector<char>v9;
vector<double>v11;
list<lli>l;
//****coding start****
int main(){
lli n;cin>>n;
lli a[n],b[n+1];
for(lli i=0;i<n+1;i++){
    cin>>b[i];
}
for(lli i=0;i<n;i++){
    cin>>a[i];
}
lli sum=0;
for(lli i=0;i<n;i++){
    sum=sum+min(a[i],b[i]);
    a[i]=a[i]-min(a[i],b[i]);
    sum=sum+min(a[i],b[i+1]);
    b[i+1]=b[i+1]-(min(a[i],b[i+1]));
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 5140
PROGRAM ATCODER

implicit none
integer(16) :: n,k,count,i,j

read(*,*) n,k    !ここが入力欄

count = k*(k-1)**(n-1)

! ここに出力結果
write(*,'(i0)') count

contains
!!!!!! サブルーチンは↓

!!!!!!

END PROGRAM ATCODER


Measured memory_bytes: 896
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
m = max(list(c.values()))
d = sorted(c.items(), key=lambda x: x[1], reverse=True)

t = set()
for i, j in d:
    if j == m:
        t.add(i)
    else:
        break
for i in sorted(t):
    print(i)

Measured memory_bytes: 62996
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

bool k[202];
int main(void){
	int x=nextint();
	int n=nextint();
	for(int i=0; i<n; i++){
		k[nextint()]=true;
	}
	if(!k[x]){
		printf("%d\n", x);
		return 0;
	}
	for(int i=1; ; i++){
		if(x-i<0 || !k[x-i]){
			printf("%d\n", x-i);
			return 0;
		}
		if(!k[x+i]){
			printf("%d\n", x+i);
			return 0;
		}
	}
}



Measured memory_bytes: 1604
n = int(input())
count = 0


for i in range(0, n):
  tmp = input()
  if tmp.split()[0] == tmp.split()[1]:
    count += 1
    if count == 3:
        break
  else:
    count = 0


if count == 3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 8992
import java.io.IOException;
import java.util.Scanner;

class Main {
    private static final Scanner scanner = new Scanner(System.in);
    public static void main(final String[] args) throws IOException {
            String s = scanner.nextLine();
            int ans = 0;
            for (int i = 0; i < (s.length()/2); i++) {
                if (!s.substring(i, i + 1).equals(s.substring(s.length()-i -1, s.length()-i))) {
                    ans++;
                }
            }
            System.out.println(ans);
        }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
bool cek_mon(string a)
{

	int hasil=((int)a[0]-'0')*10+((int)a[1]-'0');
	if(hasil<=12)
	{
		return true;
	}
	return false;
}
bool cek_valid(string a)
{
		int hasil=((int)a[0]-'0')*10+((int)a[1]-'0');
	if(hasil>0)
	{
		return true;
	}
	return false;
}
int main()
{
	string a;
	cin>>a;
	string fi,se;
	fi=a[0];
	fi+=a[1];
	se=a[2];
	se+=a[3];
	if(cek_valid(fi)==0||cek_valid(se)==0)
	{
		if(cek_valid(fi)==1&&cek_mon(fi)==1)
		{
			cout<<"MMYY"<<endl;
		}
		else if(cek_valid(se)==1&&cek_mon(se)==1)
		{
			cout<<"YYMM"<<endl;
		}
		else
		{
			cout<<"NA"<<endl;
		}
	}
	else
	{
		if(cek_mon(fi)&&cek_mon(se))
		{
		cout<<"AMBIGUOUS"<<endl;
		}
		else if(cek_mon(fi))
		{
			cout<<"MMYY"<<endl;
		}
		else if(cek_mon(se))
		{
			cout<<"YYMM"<<endl;
		}
		else
		{
			cout<<"NA"<<endl;
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    char tmp;

    int flag = 0;

    tmp = s[0]; 
    for(int i = 0; i < 3; i++){
        if(tmp != s[i]){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

L = sorted(A)
while N > 1:
    s = set()
    for i in range(len(L)-1):
        s.add(L[i+1]-L[i])
    L = list(s)
    L.sort()
    if L[0] == 1 or len(L) == 1:
        break

if K > max(A):
    ans = "IMPOSSIBLE"
elif K in A or L[0] == 1:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"
    for a in A:
        if a-K < 0:
            continue
        if (a-K)%L[0] == 0:
            ans = "POSSIBLE"
            break

print(ans)

Measured memory_bytes: 14224
N=int(input())
A=list(map(int,input().split()))
Ans=0
for i in A:
  if i%2==1:
    continue
  else:
    C=0
    n=i
    while n%2==0:
      C=C+1
      n=n//2
    Ans=Ans+C
print(Ans)
    

Measured memory_bytes: 4148
n,m=map(int,input().split())
l=list(map(int,input().split()))
suml=sum(l)
##print(suml)

l.sort(reverse=True)

temp=4*m
temp=suml/temp

if l[m-1]>=temp:
    print("Yes ")
else:
    print("No ")
    
##
##flag=False
##
##for i in range(n):
##    if m==0:
##        flag=True
##        break
##    else:
##        if l[i]>temp:
####            print(l[i],temp)
##            m-=1
##
##if flag:
##    print("Yes ")
##else:
##    print("No ")
##    


Measured memory_bytes: 38468
import java.util.Scanner;

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

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

        int[] l = new int[n + 1];
        int[] r = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            l[i] = gcd(l[i - 1], a[i - 1]);
            r[n - i] = gcd(r[n + 1 - i], a[n - i]);
        }

        int result = 0;
        for (int i = 0; i < n; i++) {
            result = Math.max(result, gcd(l[i], r[i + 1]));
        }

        System.out.println(result);
    }

    private static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }
}


Measured memory_bytes: 47088
n,m=map(int,input().split())
a=[]
cnt=0
for i in range(n):
    k,j=input().split()

    a.append([int(k),int(j)])
a=sorted(a)
for i in range(n):
    if a[i][1]>=m:
        cnt+=a[i][0]*m
        break
    else:
        cnt+=a[i][0]*a[i][1]
        m-=a[i][1]
print(cnt)

Measured memory_bytes: 24924
n = gets.to_i
input_array = []
n.times do
  input_array << gets.to_i
end
maxv = input_array[1] - input_array[0]
minv = input_array[0]
input_array.each_with_index do |value, index|
  next if index.zero?
  maxv = value - minv if value - minv > maxv
  minv = value if value < minv
end

puts maxv



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

int main(){
  double a, b, c, d, ret=0;
  cin >> a >> b >> c >> d;
  for(double i=0.5; i<=100; i+=1){
    if(a<=i && i<=b && c<=i && i<=d)ret++;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
# D - Integer Cards

# 小さい数字から順になるべく大きい数字に書き換える

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]

BC = sorted(BC, key = lambda x : x[1], reverse = True)

idx = 0
for i in range(M):
    for _ in range(BC[i][0]):
        if idx <= N-1 and A[idx] < BC[i][1]:
            A[idx] = BC[i][1]
            idx += 1
        else:
            break
    else:
        continue
    break
    
print(sum(A))

Measured memory_bytes: 33640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    k=int(input())
    A=list(map(int,input().split()))
    l=2; r=2
    for a in A[::-1]:
        # l 以上の a の倍数
        l=((l-1)//a+1)*a
        # r 以下の a の倍数 + (a-1)
        r=(r//a)*a+(a-1)
        if(l>r or r<2):
            print(-1)
            return
    print(l,r)
resolve()

Measured memory_bytes: 63856
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

var mod = 1000000007

func f(n int, m map[int]int) int {
	v, ok := m[n]
	if ok {
		return v
	}
	m[n] = (f(n/2, m) + f((n-1)/2, m) + f(n/2-1, m)) % mod
	return m[n]
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	m := make(map[int]int)
	m[0] = 1
	m[1] = 2
	out(f(N, m))
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int
main(int argc, char *argv[])
{
  ll s;
  scanf("%lld", &s);

  ll t = s;
  int cnt = 0;
  while(t > 0){
    t /= 10;
    cnt++;
  }
  cnt--;

  ll r = 1;
  if(cnt % 2 == 1){
    cnt = cnt / 2 + 1;
    while(cnt > 0){
      r *= 10;
      cnt--;
    }
  }
  else{
    if(cnt == 18){
      cnt /= 2;
      while(cnt > 0){
	r *= 10;
	cnt--;
      }
    }else{
      cnt = cnt / 2 + 1;
      while(cnt > 0){
	r *= 10;
	cnt--;
      }
    }
  }
  r += 1;
  
  ll l = 0; ll p;
  while(r - l > 1){
    p = (l + r) / 2;
    if(p * p <= s) l = p;
    else r = p;
  }
  ll k = l;
  
  ll a, b;
  a = k * (k + 1) - s; b = (k + 1) * (k + 1) - s;
  ll min;
  printf("0 0 ");
  if(k * k == s){
    printf("%lld 1 0 %lld\n", k, k);
  }
  else if(a >= 0) printf("%lld 1 %lld %lld\n", k, a, k + 1);
  else printf("%lld 1 %lld %lld\n", k + 1, b, k + 1);

  return 0;
}


Measured memory_bytes: 128
n, k = gets.split.map!(&:to_i)

table = Array.new(n + 1, 0)

k.times do
  d = gets.to_i
  a = gets.split.map!(&:to_i)
  a.each { |i| table[i] += 1 }
end

puts table.count(0) - 1


Measured memory_bytes: 14280
fun main(args: Array<String>) {
    val N = nextInt()
    val X = listOfInt().mapIndexed { index, value -> IndexedValue(index, value) }.sortedBy { it.value }
    val P = IntArray(N)
    repeat(N) { n -> P[X[n].index] = n }
    val c = N / 2
    val ans = Array(N) { n ->
        val i = if (P[n] >= c) c - 1 else c
        X[i].value
    }
    println(ans.joinToString("\n"))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }


Measured memory_bytes: 129524
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
int UF[1010];
char str[1010][1010];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int v;
int fi;
int dp[1010][1010][2];
int solve(int a,int b,int c){
	if(~dp[a][b][c])return dp[a][b][c];
	int n=a+b;
	int used=(fi-n)+v;
	if(n==2){
		//printf("%d %d %d %d: %d\n",a.p[0],a.p[1],a.p[2],a.p[3],!(t==used%2));
		if(used%2==c)return dp[a][b][c]=0;
		return dp[a][b][c]=1;
	}
	if(a&&b&&!solve(a-1,b,c))return dp[a][b][c]=1;
	if(a>=2&&!solve(a-1,b,c))return dp[a][b][c]=1;
	if(b>=2&&!solve(a+1,b-2,!c))return dp[a][b][c]=1;
	
//	printf("%d %d %d %d: 0\n",a.p[0],a.p[1],a.p[2],a.p[3]);
	return dp[a][b][c]=0;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)
		if(str[i][j]=='Y')UNION(i,j);
	for(int i=0;i<a;i++)for(int j=i+1;j<a;j++)if(str[i][j]=='Y')v++;
	for(int i=0;i<1010;i++)for(int j=0;j<1010;j++)for(int k=0;k<2;k++)
		dp[i][j][k]=-1;
	int sa=0;
	int sb=0;
	int sc=0;
	for(int i=0;i<a;i++)if(UF[i]<0){
		int n=-UF[i];
		if(n&2)sc=!sc;
		fi++;
		if(n%2)sb++;
		else sa++;
	}
	if(solve(sa,sb,sc)==1)printf("Taro\n");
	else printf("Hanako\n");
}

Measured memory_bytes: 10052
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	int ans = 0;
	for(int i=1;i<=N;i++){
		//iの桁数を求めたい
		int t = i;
		int c = 0;
		while(t){
			t/= 10;
			c++;
		}
		if(c%2==1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = in.nextInt();
        if (n % 2 == 1) {
            System.out.printf("%.6f", (double) (n / 2 + 1) / n);
        } else {
            System.out.printf("%.6f", 0.5);
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
  string s;
  std::cin >> s;
  int n=s.size();
  int a=0,b=0;
  rep(i,n){
    if(s[i]=='0')a++;
    else b++;
  }
  std::cout << 2*min(a,b) << std::endl;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> as(n); cin >> as;
    vector<ll> accs(n + 1);
    for(int i = 1; i <= n; i++){
        accs[i] = accs[i - 1] + as[i - 1];
    }
    int n2 = n * (n + 1) / 2;
    vector<ll> as2;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            as2.push_back(accs[j] - accs[i]);
        }
    }
    printde(n2, as2.size());

    ll ans = 0;
    for(int i = 45; i >= 0; i--){
        vector<ll> next;
        int cnt = 0;
        for(auto& e : as2){
            if(e >> i & 1){
                cnt++;
                next.push_back(e);
            }
        }
        if(cnt >= k){
            ans |= 1ll << i;
            next.swap(as2);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6124
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
typedef vector<pi> vc; 
const int N=5e5+5;
int ls[N],rs[N],w[N],mn[N],n,l,r,mid,ans;vc f[N];
inline int min(R int x,R int y){return x<y?x:y;}
inline void swap(R int &x,R int &y){R int t=x;x=y,y=t;}
inline bool cmpx(const pi &x,const pi &y){return x.fi<y.fi;}
inline bool cmpy(const pi &x,const pi &y){return x.se<y.se;}
void merge(vc &a,vc &ls,vc &rs){
	R int n=ls.size(),m=rs.size();
	if(!n||!m)return;
	if(n>m)ls.swap(rs),swap(n,m);
	sort(ls.begin(),ls.end(),cmpy);
	sort(rs.begin(),rs.end(),cmpx);
	mn[0]=rs[0].se;fp(i,1,m-1)mn[i]=min(mn[i-1],rs[i].se);
	for(R int i=0,j=m-1;i<n;++i){
		while(j>=0&&ls[i].se+rs[j].fi>mid)--j;
		if(j<0)break;a.pb(pi(ls[i].fi,mn[j]));
	}
	sort(ls.begin(),ls.end(),cmpx);
	sort(rs.begin(),rs.end(),cmpy);
	mn[0]=rs[0].fi;fp(i,1,m-1)mn[i]=min(mn[i-1],rs[i].fi);
	for(R int i=0,j=m-1;i<n;++i){
		while(j>=0&&ls[i].fi+rs[j].se>mid)--j;
		if(j<0)break;a.pb(pi(mn[j],ls[i].se));
	}
}
void dfs(int u){
	f[u].clear();if(!ls[u])return f[u].pb(pi(w[u],w[u])),void();
	dfs(ls[u]),dfs(rs[u]);
	merge(f[u],f[ls[u]],f[rs[u]]);
	for(auto &v:f[u])v.fi+=w[u],v.se+=w[u];
}
int main(){
	scanf("%d",&n);
	for(R int i=2,fa,x;i<=n;++i){
		scanf("%d%d",&fa,&x);
		(ls[fa]?rs[fa]:ls[fa])=i,w[i]=x;
	}
	l=0,r=1e9,ans=1e9;
	while(l<=r){
		mid=(l+r)>>1,dfs(1);
		f[1].empty()?l=mid+1:(ans=mid,r=mid-1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 30204
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

  int a,b,w,h,c,sho;

  cin>>w>>h>>c;
  a=w;
  b=h;
  if(w<h) swap(w,h);
  while(1){
    if(w%h==0){
      sho=h;
      break;
    }
    sho=w%h;
    w=h;
    h=sho;
  }

  cout<<(a/sho)*(b/sho)*c<<endl;

  return 0;

}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    double x,y;
    cin>>x>>y;
    double z=ceil((x+y)/2.0);
    int a=z;
    cout<<a<<endl;


    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int a[105];
int main()
{
    int n;
    while(scanf("%d",&n) != EOF)
    {
        int f = 0;
        for(int i = 0; i < n; i++)
            scanf("%d",&a[i]);
        for(int i = 0; i < n; i++)
        {
            for(int j = n-1; j >= i+1; j--)
            {
                if(a[j] < a[j-1])
                {
                    f++;
                    int t = a[j];
                    a[j] = a[j-1];
                    a[j-1] = t;
                }
            }
        }
        for(int i = 0; i < n-1; i++)
            printf("%d ",a[i]);
        printf("%d\n",a[n-1]);
        printf("%d\n",f);
    }
    return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <queue>

using namespace std;

int main() {
    priority_queue<int, deque<int>, std::greater<int> > pq;
    long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    pq.push(a*x+b*y);
    pq.push(2*c*x+b*y);
    pq.push(a*x+2*c*y);
    pq.push(2*c*max(x,y));
    if (x >= y) pq.push(a*(x-y)+2*c*y);
    else pq.push(2*c*x+b*(y-x));
    cout << pq.top() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IO ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define up(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define down(a,b,c) for(ll (a)=(b)-1;(a)>=(c);(a)--)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define mii map<int,int>
#define mll map<ll,ll>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define debug(x) cout << "\t" << (#x) << " = " << (x) << endl
#define debugl(x,y) cout << "on loop " << (#x) << " : " << (x) << ", " << (#y) << " = " << (y) << endl 
#define N 300050

using namespace std;

int main(){
	IO;
	ll n;
	cin >> n;
	ll counting[n+5];
	memset(counting,0,sizeof(counting));
	ll arr[n+4];
	up(i,0,n){
		cin >> arr[i];
		counting[arr[i]]++;
	}
	ll ans=0;
	up(i,1,n+4){
		ans+=((counting[i]*(counting[i]-1))/2);
	}
	up(i,0,n){
		ll now=arr[i];
		ll combi=counting[now]-1;
		cout << ans-((counting[now]*(counting[now]-1))/2)+(combi*(combi-1)/2) << endl;
	}
}

Measured memory_bytes: 5760
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ou.println((int)Math.pow(Integer.parseInt(sc.next()) , 2) - Integer.parseInt(sc.next()));
		ou.flush();
	}
}

Measured memory_bytes: 35908
S = input()[::-1]
 
T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
size = 0

while size < len(S):
	if S[size:size+5] == T[0] or S[size:size+5] == T[2]:
		size += 5
	elif S[size:size+6] == T[3]:
		size += 6
	elif S[size:size+7] == T[1]:
		size += 7
	else :
		print('NO')
		exit()
print('YES')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll a, b;
	cin >> a >> b;
	auto time = [a, b]() {return (a + b) % 24; };
	cout << time() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int count = 0, min = 1001;
    for(int i=0; i<=s.size() - t.size(); i++){
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != t[j]) count++;
        }
        if(min>count) min=count;
        count = 0;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
l = list(input()) #str
#print(n, l)
l_r = sorted(l)
r = l.count('R')
w = l.count('W')
#print(r,w)
#print(l_r)

dif = 0
for i in range(n):
    if l[i] != l_r[i]:
        dif += 1
#print(dif)
print(dif //2 + dif%2)




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

int main() {
  string s;
  cin>>s;
  if(s.substr(2,1)==s.substr(3,1)&&s.substr(4,1)==s.substr(5,1)){
    cout<<"Yes"<<endl;
  }
  else{cout<<"No"<<endl;}

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,b,c,d,e=0,f=0;
signed main(){
	cin>>a>>b>>c>>d;
	rep(i,100){
		if(a==i){
			e++;
		}
        if(c==i){
            e++;
        }
        if(b==i){
			e--;
		}
        if(d==i){
            e--;
        }
		if(e==2){
			f++;
		}
	}
	cout<<f;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  if(2*k >= n)
    cout << 1;
  else
  {
     int des = 1,cnt=0;
     for(des = k+1;des<=n;des+=2*k+1) cnt++;
     //cout << des << endl;
     des -= k;

     if(des <= n)
     cout << cnt+1;
     else cout << cnt;
  }

}


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

int main(){

    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (int i=0; i<m; i++){
        cin >> b.at(i);
    }

    vector<int> a(m);
    int sum = 0;
    int ans = 0;
    for (int i=0; i<n; i++){
        sum = 0;
        for (int j=0; j<m; j++){
            cin >> a.at(j);
            sum += a.at(j)*b.at(j);
        }
        if (sum+c > 0){
            ans++;
        }
    }

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

Measured memory_bytes: 384
open Batteries

let () =
  let h, w = Scanf.scanf "%d %d " (fun a b -> a, b) in
  let arr = Array.init h (fun _ -> Scanf.scanf "%s " (fun s -> 
      let str_list = Str.split (Str.regexp "") s in
      Array.of_list str_list
    )) in

  let res = ref true in

  for i = 0 to h-1 do
    for j = 0 to w-1 do
      if arr.(i).(j) = "#" then (
        let tmp = ref false in
        if i <> 0 then (
          if arr.(i-1).(j) = "#" then tmp := true;
        );
        if i <> h-1 then (
          if arr.(i+1).(j) = "#" then tmp := true;
        );
        if j <> 0 then (
          if arr.(i).(j-1) = "#" then tmp := true;
        );
        if j <> w-1 then (
          if arr.(i).(j+1) = "#" then tmp := true;
        );
        if !tmp = false then res := false
      );
    done;
  done;

  print_endline (if !res then "Yes" else "No")


Measured memory_bytes: 1536
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005


struct Data{
	Data(int arg_left,int arg_right){
		left = arg_left;
		right = arg_right;
	}
	bool operator<(const struct Data &arg) const{

		return right < arg.right;
	}

	int left,right;
};

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int left,right;
	vector<Data> D;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&left,&right);
		left--;
		right--;
		D.push_back(Data(left,right));
	}

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

	int last = -1;
	int ans = 0;

	for(int i = 0; i < D.size(); i++){

		if(D[i].left <= last){

			continue;
		}else{

			ans++;
			last = D[i].right-1;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 4308
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();

        for (int i = 0; i < a * b; i++) {
            if (a * i % b == c) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> ans(n+1);
  rep(i, n-1) {
    int a; cin >> a;
    ++ans[a];
  }
  for(int i = 1; i <= n; ++i) cout << ans[i] << endl;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var even = nm[0];
            var odd = nm[1];
            Func<int, int> func = n => n * (n - 1) / 2;

            Console.WriteLine(func(even) + func(odd));
        }
    }
}


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

int N;
char f[104];
double memo[104][104];

//n : ¡¢éê, t : cèÌ^[
//ßèl : m¦
double solve(int n,int t){
	if(n == N && t >= 0) return 1;
	if(t <= 0) return 0;
	if(memo[n][t] >= 0) return memo[n][t];

	double sum = 0;
	for ( int i = 1; i <= 6; i++ ) {
		int nextIndex = n + i;
		if(nextIndex > N) //ÜèÔµ
			nextIndex = N - (nextIndex - N);

		switch(f[nextIndex]){ //Áêã, ÄA
		case 'L': sum += solve(nextIndex, t-2); break;
		case 'B': sum += solve(0, t-1); break;
		default : sum += solve(nextIndex, t-1); break;
		}
	}

	memo[n][t] = sum / 6;
	return memo[n][t];
}

int main(void){
	int t,l,b;

	while(cin>>N>>t>>l>>b && N){
		memset(f,0,sizeof(f));
		memset(memo,-1,sizeof(memo));

		int index;
		while ( l-- ) { cin>>index; f[index] = 'L'; }
		while ( b-- ) { cin>>index; f[index] = 'B'; }

		printf("%.6lf\n", solve(0,t) );
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[200200];
int Asum[200200];

void solvePQ(int k, int &P, int &Q) {
    //[0,k)
    int sum = Asum[k - 1];
    int l = 0, r = k - 1;
    rep(i, 100) {
        //[0,mid],(mid,k)
        int mid = (l + r) / 2;
        int ll = Asum[mid];
        int rr = sum - ll;
        if (ll < rr) {
            l = mid;
        } else {
            r = mid;
        }
    }
    int P1 = Asum[l], Q1 = sum - P1;
    int P2 = Asum[r], Q2 = sum - P2;
    if (abs(P1 - Q1) < abs(P2 - Q2)) {
        P = P1;
        Q = Q1;
        return;
    } else {
        P = P2;
        Q = Q2;
        return;
    }
}

void solveRS(int k, int &R, int &S) {
    //[k,N)
    int sum = Asum[N - 1] - Asum[k - 1];
    int l = k, r = N - 1;
    while (r - l > 1) {
        //[k,mid],(mid,N)
        int mid = (l + r) / 2;
        int ll = Asum[mid] - Asum[k - 1];
        int rr = sum - ll;
        if (ll < rr) {
            l = mid;
        } else {
            r = mid;
        }
    }
    int R1 = Asum[l] - Asum[k - 1], S1 = sum - R1;
    int R2 = Asum[r] - Asum[k - 1], S2 = sum - R2;
    if (abs(R1 - S1) < abs(R2 - S2)) {
        R = R1;
        S = S1;
        return;
    } else {
        R = R2;
        S = S2;
        return;
    }
}


signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        Asum[i] = i ? Asum[i - 1] + A[i] : A[i];
    }
    int ans = INF;
    for (int i = 2; i < N - 1; ++i) {
        //[0,i)|[i,N)
        int P = 0, Q = 0;
        solvePQ(i, P, Q);
        int R = 0, S = 0;
        solveRS(i, R, S);
        int score = max(abs(P - Q), abs(P - R));
        score = max(score, abs(P - S));
        score = max(score, abs(Q - R));
        score = max(score, abs(Q - S));
        score = max(score, abs(R - S));
        ans = min(ans, score);
    }
    cout << ans << endl;
    return 0;
}
//D


Measured memory_bytes: 3328
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
//QAQ

//   ^--^
//  (*-_-)
//   --~-	
//  / ":"\
// /  ":" \

int main()
{
	//freopen("tt.txt","r",stdin);
	int l,r;
	char h;
	cin>>l>>h>>r;
	if(h=='+')
		cout<<l+r;
	if(h=='-')
		cout<<l-r;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

	Scanner std = new Scanner(System.in);
	List<Integer> list = new ArrayList<>();
	int N = std.nextInt();

	int gray = 0;
	int tea = 0;
	int green = 0;
	int lightblue = 0;
	int blue = 0;
	int yellow = 0;
	int orange = 0;
	int red = 0;
	int rainbow1 = 0;
    int rainbow2 = 0;

    int min = 0;
    int max = 0;

	for(int i = 0; i < N; i++) {
	   int a = std.nextInt();
	   list.add(a);
	}
	for(int i = 0; i < N; i++) {
	int x = list.get(i);

	if(1 <= x && x <= 399) {
		gray = 1; }

	if(400 <= x && x <= 799) {
	    tea = 1;}

	if(800 <= x && x <= 1199) {
		green = 1;
	}

	if(1200 <= x && x <= 1599) {
		lightblue = 1;
	}

	if(1600 <= x && x <= 1999) {
		blue = 1;
	}

	if(2000 <= x && x <= 2399) {
		yellow = 1;
	}

	if(2400 <= x && x <= 2799) {
		orange = 1;
	}

	if(2800 <= x && x <= 3199) {
		red = 1;
	}

	if(3200 <= x && x <= 4800 ) {
		rainbow1 = 1;
		rainbow2++;
	}


	}

	if(gray + tea + green + lightblue + blue + yellow + orange + red  == 0) {
	min = 1;
	}

	else {
		min = gray + tea + green + lightblue + blue + yellow + orange + red;
	}

	max = gray + tea + green + lightblue + blue + yellow + orange + red + rainbow2;

	System.out.println(min + " " + max);


	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
vector<int>parl;
vector<int>parr;
int rool(int v) {
  if (v == parl[v]) return v;
  return parl[v] = rool(parl[v]);
}
int roor(int v) {
  if (v == parr[v]) return v;
  return parr[v] = roor(parr[v]);
}
void unil(int a, int b) {
  a = rool(a);
  b = rool(b);
  if (a == b) return;
  if (a > b) swap(a, b);
  parl[b] = a;
}
void unir(int a, int b) {
  a = roor(a);
  b = roor(b);
  if (a == b) return;
  if (a > b) swap(a, b);
  parr[a] = b;
}
int main () {
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N + 1);
  parl.resize(N);
  parr.resize(N);
  for (int i = 0; i < N; i ++) {
    cin >> A[i];
    B[A[i]] = i;
    parl[i] = i;
    parr[i] = i;
  }
  long long ans = 0;
  for (int i = N; i > 0; i --) {
    int v = B[i];
    long long l = (long long)v - rool(v) + 1;
    long long r = (long long)roor(v) - v + 1;
    long long j = (long long)i;
    //cout << i * l * r << endl;
    ans += (i * l * r);
    if (v > 0) unir(v, v - 1);
    if (v < N - 1) unil(v, v + 1);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3328
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
//#define ForJ(n) for(int j=0;j<n;j++)
//#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

int Product_set_min(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= lb;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= la;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= la;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
int Product_set_max(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= rb;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
string min (string m){
    transform(m.begin(), m.end(), m.begin(),towlower);
    return m;
}
signed  main(){
    string s;
    cin >> s;
    int sum =0 ;
    For(3, i){
        if(s[i]=='o'){
            sum++;
        }
    }
    cout<<700+sum*100<<endl;
    return 0;
}



Measured memory_bytes: 256