akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
// 全ての駒は最終的に左端か右端に移動すると考える
int main() {
    lint n,l; cin >> n >> l;
    pair<lint,lint> pd[100000];
    rep(i,n) {
        cin >> pd[i].first >> pd[i].second;
    }
    sort(pd,pd+n);
    lint leftcsum[100001];
    lint rightcsum[100001];
    leftcsum[0] = 0;
    rightcsum[0] = 0;
    rep(i, n) {
        lint dis = pd[i].first - (i+1);
        if (pd[i].second == 0) leftcsum[i+1] = leftcsum[i] + dis;
        else leftcsum[i+1] = leftcsum[i] - dis;

        dis = (l-n+i+1) - pd[i].first;
        if (pd[i].second == 1) rightcsum[i+1] = rightcsum[i] + dis;
        else rightcsum[i+1] = rightcsum[i] - dis;
    }
    lint ans = 0;
    rep(i,n+1) {
        lint t = leftcsum[i] + rightcsum[n] - rightcsum[i];
        ans = max(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6184
fun main(args: Array<String>) {
    var (N,K) = readLine()!!.split(" ").map { it.toInt() }
    var p = readLine()!!.split(" ").map { it.toLong() }
    var s = 0.toLong()
    for(i in 0 until K)s += p[i]
    var result = s
    for(i in K until N){
        s += ( p[i] - p[i-K])
        if (s>result){
            result = s
        }
    }
    println((result+K).toFloat()/2)
}

Measured memory_bytes: 62012
N = int(input())
A = list(map(int, input().split()))
CNT = [0]*(N+1)
# IND = list(set(A))
# CNT = [A.count(x) for x in IND]
for i in A:
    CNT[i] += 1
# print(IND)
# print(CNT)
# CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]
CONB = [CNT[x]*(CNT[x]-1)//2 for x in range(len(CNT))]
# print(CONB)
SUM = sum(CONB)
for i in A:
    ans = SUM - CNT[i] + 1
    print(ans)

Measured memory_bytes: 24748
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  pr((n-1)*(m-1));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
  int N, M, P[100010], Y[100010];
  vector< vector<int> > p(100010);
  
  scanf("%d %d", &N, &M);
  for(int i = 0;i < M;i++){
    scanf("%d %d", &P[i], &Y[i]);
    p[P[i]].push_back(Y[i]);
  }
  
  for(int i = 1;i <= N;i++) sort(p[i].begin(), p[i].end());
  
  for(int i = 0;i < M;i++){
    printf("%06d%06d\n", P[i], int(lower_bound(p[P[i]].begin(), p[P[i]].end(), Y[i]) - p[P[i]].begin()) + 1);
  }
  
  return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> point(n, vector<int>(m));
    vector<int> cost(n);
    for (int j = 0; j < n; ++j) {
        cin >> cost[j];
        for (int i = 0; i < m; ++i) {
            cin >> point[j][i];
        }
    }
    int ans = 1001001001;
    for (int i = 0; i < (1 << n); ++i) {
        bitset<12> bs(i);
        int cnt = 0;
        vector<int> sum(m);
        for (int j = 0; j < 12; ++j) {
            if (bs.test(j)) {
                for (int k = 0; k < m; ++k) {
                    sum[k] += point[j][k];
                }
                cnt += cost[j];
            }
        }
        bool flag = false;
        for (int j : sum) {
            if (j < x) {
                flag = true;
                break;
            }
        }
        if (flag) continue;
        ans = min(ans, cnt);
    }
    if (ans == 1001001001) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3632
n,k=map(int,input().split())
r=[0]
l=[0]
ans=0
INF=10**9+7
for i in range(n+1):
    a=r[i]+i
    b=l[i]+n-i
    r.append(a)
    l.append(b)
#print(r)
#print(l)

for i in range(k,n+2):
    min_wa=r[i]
    max_wa=l[i]
    ans+=max_wa-min_wa+1
    
print(ans%INF)


Measured memory_bytes: 26932
#include "bits/stdc++.h"
using namespace std;

int n,l,sum=0,mx=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l;
		if(l>mx)
			mx=l;
		sum+=l;
	}
	sum-=mx;
	if(mx<sum)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define pb emplace_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using vstr = vector<string>;


int main() {
	int n,k,x;
	cin >> n >> k;
	rep (i,n) cin>>x; /* not needed*/

	if (k == 1) return log(n), 0;
 
	int c = 0, p = 0;
  
  	// log(ceil((n-1) / (k-1)));

	while (p < n-1) {
		p += k-1;
		c += 1;
	}

	log(c);

	
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System. out.printf("%d %d %.5f\n", a / b, a % b, (double)a / b);
    }
}


Measured memory_bytes: 26588
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    if(a%2==0) {
      if(a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

}


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

class Main {
    public static long comb(long a, long b, long mod, long[] pw, long[] ipw) {
        return (((pw[(int)a] * ipw[(int)a - (int)b]) % mod ) * ipw[(int)b]) % mod;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int max = 400000;
        int mod = 998244353;
        long[] pw  = new long[max];
        pw[0] = 1;
        long[] ipw = new long[max];
        BigInteger modb = new BigInteger(String.valueOf(mod));

        for(int i = 1; i < max; i++) {
            pw[i] = (i * pw[i-1]) % mod;
        }
        for(int i = 0; i < max; i++) {
            ipw[i] = new BigInteger(String.valueOf(pw[i])).modInverse(modb).longValue();
        }

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        long ans = 0;
        for(int A = 0; A <= n; A++) {
            if((k - A * a) % b != 0) continue;
            long B = (k - A * a) / b;
            if(B > n || B < 0) continue;



            ans += ( comb(n,A,mod,pw,ipw) * comb(n,B,mod,pw,ipw) ) % mod;
            ans %= mod;
        }

        System.out.println(ans);






    }
}

Measured memory_bytes: 108844
if __name__ == '__main__':
    n, cc = map(int, input().split())
    channels = [[] for _ in range(cc)]
    for i in range(n):
        s, t, c = map(int, input().split())
        c -= 1
        channels[c].append((s, t))
    for i in range(cc):
        channels[i].sort()
        merged_program = []
        for program in channels[i]:
            if not merged_program:
                merged_program.append(program)
            elif merged_program[-1][1] == program[0]:
                merged_program[-1] = (merged_program[-1][0], program[1])
            else:
                merged_program.append(program)
        channels[i] = merged_program
    events = []
    for programs in channels:
        for s, t in programs:
            events.append((s * 2 - 1, +1))
            events.append((t * 2, -1))
    events.sort()
    ans = 0
    cnt = 0
    for ti, ty in events:
        cnt += ty
        ans = max(ans, cnt)
    print(ans)


Measured memory_bytes: 76112
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for(;;){
			
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			
			int count = 0;
			for(int i = 1; i < 1001;i++){
				for(int j = i+1 ; j < 1001;j++){
					if((i+j)*(j-i+1)/2  == n){
						count++;
					}
				}
			}
			
			System.out.println(count);
		}
			
			
		
	}
}



Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repu(i,m,n) for(int i=m;i<n;i++)
#define repd(i,m,n) for(int i=m,i>n;i--)
#define pb push_back

int func(ll n,ll arr[],ll dp[]) {
    if(n==0)
    return 0;
    if(n<0)
    return 100000;
    
    if(dp[n]==-1)
    dp[n]=min(func(n-1,arr,dp)+abs(arr[n]-arr[n-1]),func(n-2,arr,dp)+abs(arr[n]-arr[n-2]));
    
    return dp[n];
}

int main() {
    ll n;
    cin>>n;
    ll arr[n];
    ll dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    repu(i,0,n)
    cin>>arr[i];
    ll num=func(n-1,arr,dp);
    cout<<num<<endl;
    
	return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>

int main()
{
    int i,l;
    char s[101];
    scanf("%s",s);
    for(i=0; i<strlen(s); i+=2)
        if(s[i]=='L')
        {
            printf("No\n");
            return 0;
        }
    for(i=1; i<strlen(s); i+=2)
        if(s[i]=='R')
        {
            printf("No\n");
            return 0;
        }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int r;
	cin >> r;
	double x = 3.14159265358979323846;
	double ans = 2 * r * x;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 3780
#include<set>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 500000+9;
int n,K;
int num[MAXN];
int loc[MAXN];
set<int> s;
set<int>::iterator I;
int ans[MAXN];
int indegree[MAXN];
struct E{
	int next,to;
}edge[MAXN*20];
int head[MAXN],edge_num;

void addedge(int x,int y){
	edge[++edge_num].next=head[x];
	edge[edge_num].to=y;
	head[x]=edge_num;
	indegree[y]++;
}

void Top_sort(){
	s.clear();
	int i;
	for(i=1;i<=n;i++)
		if(indegree[i]==0)
			s.insert(i);
	for(i=1;i<=n;i++){
		I=s.begin();s.erase(I);ans[*I]=i;
		for(int j=head[*I];j;j=edge[j].next){
			indegree[edge[j].to]--;
			if(indegree[edge[j].to]==0){
				s.insert(edge[j].to);
			}
		}
	}
	for(i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	puts("");
}

void solve(){
	int i;
	for(i=1;i<=n;i++){
		if(i>K)
			s.erase(num[i-K]);
		I=s.insert(num[i]).first;
		if((++I)!=s.end()){//不给自己连
			addedge(i,loc[*I]);
		}
	}
	s.clear();
	for(i=n;i;i--){
		if(i+K<=n)
			s.erase(num[i+K]);
		I=s.insert(num[i]).first;
		if((++I)!=s.end()){
			addedge(i,loc[*I]);
		}
	}
	Top_sort();
}

int main(){
	scanf("%d%d",&n,&K);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&num[i]);
		loc[num[i]]=i;
	}
	solve();
	return 0;
}


Measured memory_bytes: 45184
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

#define dump(x) cerr << #x " = " << boolalpha << (x) << endl;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;
  vector <size_t> l (n);
  rep (i, n) cin >> l [i];

  sort (ALL (l));

  vector <ll> cnt (2001, 0);
  {
    size_t pre_i = 0;
    ll c = 0;
    for (auto && elem : l)
    {
      FOR (i, pre_i, elem)
      {
        cnt [i] = c;
      }
      ++ c;
      pre_i = elem;
    }
    FOR (i, pre_i, 2001)
    {
      cnt [i] = c;
    }
  }


  ll ans = 0;
  rep (i, n) rep (j, i)
  {
    auto a = l [i];
    auto b = l [j];
    auto a_b = static_cast <size_t> (abs (static_cast <ll> (a) - static_cast <ll> (b)));
    auto c_num = cnt [a + b - 1] - cnt [a_b];
    if (a_b < a && a < a + b)
    {
      -- c_num;
    }
    if (a_b < b && b < a + b)
    {
      -- c_num;
    }
//    dump(a)
//    dump(b)
//    dump(a+b)
//    dump(a_b)
//    dump(cnt[a+b - 1])
//    dump(cnt[a_b])
//    dump(c_num)
    if (c_num > 0)
    {
      ans += c_num;
    }
  }
  cout << ans / 3 << endl;
}


Measured memory_bytes: 256
/*???????????????????????¢?????´???????????§?????????????°???¨??????????????????????????¢?´¢??????*/
/*????????????????????\????????¨???????????¨??§???????????????O((|E|+|V|)log|V|)?????§??????*/
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep0(i,i0,n) for(int i = i0;i<=n;i++)
using namespace std;
#define inf (1<<20)
#define MAX 100000

static const int White=0;
static const int Gray=1;
static const int Black=2;

int n;
vector<pair<int, int> > adj[MAX]; //??£??\?????????

void Dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int D[MAX];
    rep(i, n){
        D[i]=inf;
        color[i]=inf;
    }
    D[0]=0;
    PQ.push(make_pair(0, 0));
    color[0]=Gray;

    while(!PQ.empty()){
        pair<int, int> f=PQ.top(); PQ.pop();
        int u=f.second;
        color[u]=Black;

        //????°??????????????????????????????§???????????°????????????
        if(D[u] < f.first * (-1) ) continue;

        rep(j, adj[u].size()){
            int v =adj[u][j].first;
            if(color[v]==Black) continue;
            if(D[v] > D[u] + adj[u][j].second){
                D[v] = D[u] + adj[u][j].second;
                //????????????????????\????????§?????????????????????????????§????????????
                PQ.push(make_pair(D[v] * (-1), v));
                color[v]=Gray;
            }
        }
    }

    rep (i,n) cout << i << " " << ( D[i] == inf ? -1 : D[i]) << endl;
}

int main(void){
    int k,u,v,c;
    cin >> n;

    rep(i, n){
        cin >> u >>k;
        rep(j, k){
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    Dijkstra();

    return 0;
}

Measured memory_bytes: 10196
import math
X=int(input())

def is_prime(x):
    for i in range(2,int(math.sqrt(x))):
        if(x%i==0):
            return False
    return True

for i in range(X,100004):
    t=is_prime(i)
    if(not t):
        continue
    else:
        print(i)
        exit()

Measured memory_bytes: 3060
# coding: utf-8
import itertools
import math
import sys
#input→sys.stdin.readline半分の時間に
input=sys.stdin.readline
N = int(input())
S = list(input())

R = [0]*N
G = [0]*N
B = [0]*N

for i in range(N):
    if S[i] == 'R':
        R[i] += 1
    elif S[i] == 'G':
        G[i] += 1
    else:
        B[i] += 1

for i in range(N-1):
    R[i+1] += R[i]
    G[i+1] += G[i]
    B[i+1] += B[i]
ans = 0
#print(R,G,B)
for i in range(N-2):
    for j in range(i+1,N-1):
        if len(set([S[i],S[j]])) == 2:
            s = list(set(['R','G','B']) ^ set([S[i],S[j]]))[0]
            if s == 'R':
                ans += R[N-1] - R[j]
                if 2*j-i<=N-1 and S[2*j-i] == 'R':
                    ans -= 1
            if s == 'G':
                ans += G[N-1] - G[j]
                if 2*j-i <= N-1 and S[j+j-i] == 'G':
                    ans -= 1
            if s == 'B':
                ans += B[N-1] - B[j]
                if 2*j-i <= N-1 and S[j+j-i] == 'B':
                    ans -= 1
print(ans)


Measured memory_bytes: 69392
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    s64 h, w, k;
    cin >> h >> w >> k;

    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;
    vector< string > field(h);
    rep (i, h) cin >> field[i];

    const s64 inf = 1e18;
    s64 d[h][w];
    rep (i, h) rep (j, w) d[i][j] = inf;
    auto id = [&](s64 i, s64 j) { return (i << 30ll) + j; };

    queue<s64> q;
    q.push(id(si, sj));
    d[si][sj] = 0;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        s64 from = q.front(); q.pop();
        s64 fi = from >> 30;
        s64 fj = from & 0x3fffffff;
        rep (i, 4)
        {
            rep (j, k)
            {
                s64 ni = fi + dy[i] * (j + 1);
                s64 nj = fj + dx[i] * (j + 1);
                if (!(IN(0, h, ni) && IN(0, w, nj))) break;
                if (d[ni][nj] < d[fi][fj] + 1 || field[ni][nj] == '@') break;
                if (d[ni][nj] != inf) continue;
                d[ni][nj] = d[fi][fj] + 1;
                q.push(id(ni, nj));
            }
        }
    }

    s64 ans = d[ti][tj];
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 13156
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int[] S = new int[s.length()];
		
		for(int i = 0; i < s.length(); i++) {
			S[i] = s.charAt(i);
		}
		
		Arrays.sort(S);
		int check = 0;
		
		if(S[0] >= 98) {
			System.out.println("a");
		} else if(S.length == 1) {
			if(S[0] >= 98) {
				System.out.println("a");
			} else {
				System.out.println("b");
			}
		} else {
			for(int i = 0; i < S.length - 1; i++) {
				if(S[i] >= S[i + 1] - 1) {
					if(i == S.length - 2 && S[i + 1] != 122) {
						System.out.println((char)(S[i + 1] + 1));
					} else if(i == S.length - 2 && S[i + 1] == 122) {
						System.out.println("None");
					}
				} else {
					System.out.println((char)(S[i] + 1));
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 26940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void){

    double x;
    int n;
    cin>>n;
    for(x=0;x<1000000;x++){
        if(floor(x*1.08)==n){
            fin(x);
            return 0;
        }
    }
    fin(":(");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define _USE_MATH_DEFINES
    using namespace std;
    
    #define ll long long int
    #define pb push_back
    #define rep(i , j , n) for(ll i = j ; i < n ; i++)
    #define per(i , j , n) for(ll i = j ; i >= n ; i--)
    #define all(x) x.begin(), x.end()
    typedef pair<int, int>	pii;
    typedef pair<ll, ll>	pl;
    typedef vector<int>		vi;
    typedef vector<ll>		vll;
    typedef vector<bool>	vb;


int main(){ 
    ll n;
    cin >> n;
    vll a(n);
    ll x = 0;
    rep(i,0,n){
        cin >> a[i];
        x = x ^ a[i];
    }
    rep(i,0,n){
        a[i] = x ^ a[i];
        cout << a[i] << " ";
    }

}

Measured memory_bytes: 4844
let N = stdin.ReadLine() |> int

let S =
    [| for _ in 1..N -> stdin.ReadLine() |]
    |> Array.countBy id

let max =
    S
    |> Array.maxBy snd
    |> snd

S
|> Array.filter (fun x -> (x |> snd) = max)
|> Array.sortBy fst
|> Array.map fst
|> Array.iter stdout.WriteLine


Measured memory_bytes: 55780
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment

const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}
double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  return fabs(sum) / 2;
};

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0)
      ans.push_back(crossPoint(L(A,B), l));
  }
  return ans;
}

int n,m;
vector<P> mp;
double calc(int idx,vector<P>g){
  for(int i=0;i<m;i++){
    if(i==idx)continue;
    P t=mp[idx]-mp[i];
    P a=P(abs(t)/2,1)*t/abs(t)+mp[i];
    P b=P(abs(t)/2,-1)*t/abs(t)+mp[i];
    g=convex_cut(g,L(a,b));
  }
  return area(g);
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)break;
  vector<P> pl(n);
  mp.resize(m);
  for(int i=0,x,y;i<n;i++)cin>>x>>y,pl[i]=P(x,y);
  for(int i=0,x,y;i<m;i++)cin>>x>>y,mp[i]=P(x,y);
  for(int i=0;i<m;i++)printf("%.10f\n",calc(i,pl));
  }
  return 0;

}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep (i, n) cin >> a[i];
  map<ll, ll> cnt1;
  map<ll, ll> cnt2;

  rep (i, n) {
    cnt1[i + a[i]]++;
    cnt2[i - a[i]]++;
  }

  ll ans = 0;
  for (auto v : cnt1) {
    ans += cnt1[v.first] * cnt2[v.first];
  }

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


Measured memory_bytes: 38868
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
ll k;
ll n = 50;
int main(void){
  cin >> k;
  
  cout << n << endl;
  for(ll i = 0; i < n-k%n; i++)
    cout << n-1+(k/n)-(k%n) << " ";
  for(ll i = n-k%n; i < n; i++)
    cout << n-1+(k/n)+n-(k%n) << " ";
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 100000000

int main(void){
	int n, m, a, b, cost, time, l, p, q, r;
	int i, j, k;
	int d[100][100];
	int exp[100][100];

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

		for(i=0; i<m; i++){
			for(j=0; j<m; j++){
				d[i][j] = INF;
				exp[i][j] = INF;
			}
		}
		for(i=0; i<m; i++){
			d[i][i] = 0;
			exp[i][i] = 0;
		}

		for(i=0; i<n; i++){
			scanf("%d %d %d %d", &a, &b, &cost, &time);
			d[a-1][b-1] = time;
			d[b-1][a-1] = time;
			exp[a-1][b-1] = cost;
			exp[b-1][a-1] = cost;
		}
		for(k=0; k<m; k++){
			for(i=0; i<m; i++){
				for(j=0; j<m; j++){
					if(d[i][j] > d[i][k] + d[k][j]){
						d[i][j] = d[i][k] + d[k][j];
					}
					if(exp[i][j] > exp[i][k] + exp[k][j]){
						exp[i][j] = exp[i][k] + exp[k][j];
					}
				}
			}
		}
		scanf("%d", &l);
		for(i=0; i<l; i++){
			scanf("%d %d %d", &p, &q, &r);
			if(r == 0){
				printf("%d\n", exp[p-1][q-1]);
			}else if(r == 1){
				printf("%d\n", d[p-1][q-1]);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 492
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int e;
  while(cin>>e,e){
    int ans = 1000000;
    for(int z=0;z*z*z<=e;++z){
      for(int y=0;y*y+z*z*z<=e;++y){
	int x = e-y*y-z*z*z;
	ans = min(ans,x+y+z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.read_chars();
    let mut k: usize = sc.read();

    let n = s.len();
    let mut ans = vec![];
    for i in 0..n {
        let d = s[i] as usize - 'a' as usize;
        let update = 26 - d;
        if d == 0 {
            ans.push(s[i]);
        } else if 26 <= k + d {
            ans.push('a');
            k -= update;
        } else {
            ans.push(s[i]);
        }
    }
    if k > 0 {
        // let n = ans.len();
        // let s_n = ans[n - 1];
        // let d = s_n as usize - 'a' as usize;
        // ans[n - 1] = (((d + k) % 26) as u8 + 'a' as u8) as char;
        ans[n - 1] = ('a' as u8 + (((ans[n - 1] as usize - 'a' as usize) + k) % 26) as u8) as char;
    }
    println!("{}", ans.iter().collect::<String>());
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2436
N = input()
'''
str=''
str_list=list(N)
str_list2= list(reversed(N))
if str.join(str_list)==str.join(str_list2):
    print('Yes')
else:
    print('No')
'''
#スライス操作　逆のステップ指定
if N ==N[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N, K;
uint64_t a[1001];
uint64_t mul[1000100];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> K;
	for (int32_t i = 0; i < N; i++)
	{
		in >> a[i+1];
		a[i + 1] += a[i];
	}
	auto iter = mul;
	for (int32_t i = 1; i <= N; i++)
	{
		for (int32_t j = i+1; j <= N+1; j++)
		{
			*iter++ = a[j - 1] - a[i - 1];
		}
	}

	uint64_t mask = 0;
	for (int32_t d = 45; d >= 0; --d)
	{
		uint64_t next = mask | (uint64_t(1) << d);

		int32_t sum = 0;
		for (size_t i = 0; i < (iter - mul); i++)
		{
			if ((mul[i] & next)==next) {
				++sum;
			}
		}

		if (sum >= K) {
			mask = next;
		}
	}
	out << mask << endl;



	return 0;
}
#endif


Measured memory_bytes: 5240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);



int main(){
	ll N;
	cin >> N;
	ll ans = (N+1)/2;
	cout << ans << endl; 
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] s=sc.next().toCharArray();
            for(int i=0;i<s.length;i++) {
                if(s[i]=='@') {
                    for(int j=0;j<s[i+1]-'0';j++) {
                        System.out.print(s[i+2]);
                    }
                    i+=2;
                    continue;
                }
                System.out.print(s[i]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 26352
#include<stdio.h>
int main(void){
	int n,i,max,min,a[10000];
	long sum;
	sum=0;
	max=-1000000;
	min=1000000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		if(max<a[i]){
			max=a[i];
		}
		if(min>a[i]){
			min=a[i];
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
  int N;
  cin >> N;
  vector <long long> L(N+1);
  L[0] = 2;
  L[1] = 1;
  
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 1] + L[i - 2];
  
  }
  cout << L[N] << endl;
  return 0;
  
  
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  
  vector<int> ans(n);
  rep(i,n) ans.at(a.at(i)-1) = i+1;
  
  rep(i,n) cout << ans.at(i) << " ";
  
  cout << endl;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int max = Math.max(Math.max(a, b), c);
        int[] diff = new int[] { max - a, max - b, max - c };
        int count = 0;
        for (int i = 0; i < 3; i++) {
            count += diff[i] / 2;
            diff[i] %= 2;
        }
        int sum = Arrays.stream(diff).sum();
        count += sum % 2 == 0 ? sum / 2 : sum / 2 + 2;

        int result = count;

        // 出力
        System.out.println(result);
    }
}


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

int main(void) {
	int N;
	cin >> N;
	if (N <= 999) {
		cout << "ABC" << endl;
	}
	else if(N >= 1000 && N <= 1998) {
		cout << "ABD" << endl;
	}

}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    long long res = 0;
    vector<long long> B(N);
    fill(B.begin(), B.end(), 0);

    B[N-1] = A[N-1];
    for(int i = N-2; i >= 0; i--) {
        B[i] += (B[i+1] + A[i]) % MOD;
    }
    // REP(i, N) cout << "," << B[i];
    // cout << endl;
    
    REP(i, N-1) { 
        res += (A[i] * B[i+1])  % MOD;
    }
    
    cout << res % MOD << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll x;
	cin>>x;
	if(x<=6)
		cout<<1;
	else if(x<=11)
		cout<<2;
	else if(x%11>6)
		cout<<(x/11)*2+2;
	else if(x%11==0)
		cout<<(x/11)*2;
	else
		cout<<(x/11)*2+1;
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



Measured memory_bytes: 3640
# SegmentTree
class SegmentTree:
  def __init__(self, n, p, unit, f):
    self.num = 2**((n-1).bit_length())
    self.seg = [unit]*(2*self.num)
    for i in range(n):
      self.seg[i+self.num] = p[i]
    for i in range(self.num-1, 0, -1):
      self.seg[i] = f(self.seg[i << 1], self.seg[(i << 1)+1])
    self.f = f
    self.unit = unit

  def update(self, i, x):
    i += self.num
    self.seg[i] = x
    while i:
      i >>= 1
      self.seg[i] = self.f(self.seg[i << 1], self.seg[(i << 1)+1])

  def query(self, l, r):
    ansl = ansr = self.unit
    l += self.num
    r += self.num-1
    if l == r:
      return self.seg[l]
    while l < r:
      if l & 1:
        ansl = self.f(ansl, self.seg[l])
        l += 1
      if ~r & 1:
        ansr = self.f(self.seg[r], ansr)
        r -= 1
      l >>= 1
      r >>= 1
    if l == r:
      ansl = self.f(ansl, self.seg[l])
    return self.f(ansl, ansr)

n,k=map(int,input().split())
a=[int(input())for _ in range(n)]
m=max(a)
seg=SegmentTree(m,[0]*m,0,lambda x,y: max(x,y))
ans=0
for x in a:
  f=seg.query(max(0,x-k),min(m,x+k)+1)
  seg.update(x,f+1)
  ans=max(ans,f+1)
print(ans)

Measured memory_bytes: 127768
import java.util.Scanner;

public class Main
{
	static int[][] map = new int[12][12];
	static boolean[][] check = new boolean[12][12];
	static int count;
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
			
		for(; scanner.hasNext();)
		{
			for(int i=0; i<12; i++)
			{
				String input = scanner.next();
				for(int j=0; j<12; j++)
				{
					map[i][j] = Integer.parseInt(input.substring(j, j+1));
					check[i][j] = false;
				}
			}
			
			count = 0;
			for(int i=0; i<12; i++)
			{
				for(int j=0; j<12; j++)
				{
					checkMap(i, j);
				}
			}
			
			System.out.println(count);
		}
	}
	
	static void checkMap(int m, int n)
	{
		boolean is_count = false;

		if(m > 0)
		{
			if(map[m-1][n] == 1)
			{
				is_count = true;
			}
		}
		for(int i=m; i<12; i++)
		{
			if(check[i][n] || map[i][n]==0)
			{
				check[i][n] = true;
				break;
			}
			for(int j=n; j>=0; j--)
			{
				if(check[i][j] || map[i][j]==0)
				{
					check[i][j] = true;
					break;
				}		
				else if(map[i][j]==1 && !is_count)
				{
					count ++;
					is_count = true;
				}
				
				check[i][j] = true;
			}
			for(int j=n+1; j<12; j++)
			{			
				if(check[i][j] || map[i][j]==0)
				{
					check[i][j] = true;
					break;
				}		
				else if(map[i][j]==1 && !is_count)
				{
					count ++;
					is_count = true;
				}
				
				check[i][j] = true;
			}
		}
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b)%3 == 0 || a%3 == 0 || b%3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
abcde = list()
ans = 99999
flag = True

for i in range(5):
    abcde.append(int(input()))
    
for i in range(5):
    p_ans = 0
    p_ans += abcde[i]
    for j in range(5):
        if i != j:
            if abcde[j] % 10 == 0: p_ans += abcde[j]
            else:p_ans += abcde[j] + (10 - abcde[j] % 10)
    if ans > p_ans:
        ans = p_ans
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int MOD = 1e9 + 7;
int a, b;
char c;
int main(void) {
	cin >> a>>c>>b;
	if (c == '+')ct(a + b);
	else ct(a - b);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
	int n,d,x;
	cin>>n>>d>>x;
	int a[110]={0};
	int arr[110]={0};
	for(int i=0;i<n;i++)cin>>a[i];

	arr[1] = n;
	for(int i=0;i<n;i++){
		int v = a[i];
		while(v < d){
			arr[v+1] += 1;
			v += a[i];
		}
	}

	int cnt=0;
	for(int i=1;i<=d;i++){
		if(arr[i] != 0) cnt += arr[i];
	}

	cout<< cnt + x <<endl;
	
	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    import scala.io.StdIn._
    val c = readLine()
    val str = ("abcdefghijklmnopqrstuvwxyz")

    println(str(str.indexOf(c) + 1))
  }

}

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

int main(){
    //int p[10];
    int k,array_size=3,x;
    std::vector<int> p;

    int n = array_size;
    while(n--){
        cin >> x;
        p.push_back(x);
    }

    for(int i=0;i<array_size;i++){
        for(int j=array_size-1;j>i;j--){
            if(p[j]<p[j-1]){
              k = p[j];
              p[j] = p[j-1];
              p[j-1] = k;  
            }
        }
    }

    for(int i=0;i<array_size;i++){
        if(i!=array_size-1){
            cout << p[i] << " ";
        }else{
            cout << p[i] << endl;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    string view;
    cin >> view;
    vector<int> area;
    
    stack<int> down;
    stack<pair<int, int>> puddle;
    int total = 0;
    rep(i, view.length()){
        if(view[i]=='\\'){
            down.push(i);
        }else if(view[i]=='/' && !down.empty()){
            total += i - down.top();
            int nowarea = i - down.top();
            if(!puddle.empty() && !down.empty()){
                while(puddle.top().first > down.top()){
                    nowarea += puddle.top().second;
                    puddle.pop();
                    if(puddle.empty() || down.empty()) break;
                }
            }
            puddle.push(make_pair(down.top(), nowarea));
            down.pop();
        }
    }
    
    cout << total << endl;
    cout << puddle.size();
    
    vector<int> temp;
    while(!puddle.empty()){
        temp.push_back(puddle.top().second);
        puddle.pop();
    }
    reverse(all(temp));
    rep(i, temp.size()) cout << " " << temp[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3268
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.chomp.to_i

    if n.even?
      puts "0.5"
    else
      puts "#{((n / 2) + 1).to_f / n}"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

double INF = 2e5;

double dmod(double a, double b) {
    while (a >= b) a -= b;
    return a;
}

double D; int N;
pair<int, int> p[10];

double solve(const int n_bounces) {
    double l = 0, r = INF;

    double itv = D / n_bounces;

    for (int _ = 0; _ < 64; ++_) {
        double v0 = (l + r) / 2.0;
        if (itv > v0 * v0) {
            l = v0;
            continue;
        }

        double theta = (M_PI - asin(itv / v0 / v0))/2;

        double vx = v0 * cos(theta), vy = v0 * sin(theta);

        bool ok = true;
        for (int j = 0; j < N; ++j) {
            double md = dmod(p[j].first, D/n_bounces);
            double height = -(1.0 / 2.0 / vx / vx) * md * md + (vy / vx) * md;
            if (height <= p[j].second) {
                ok = false;
                break;
            }
        }

        (ok ? r : l) = v0;
    }
    return l;
}

int main() {
    int B;
    cin >> D >> N >> B;
    for (int j = 0; j < N; ++j) {
        cin >> p[j].first >> p[j].second;
    }

    double ans = 1e10;
    for (int b = 1; b <= B+1; ++b) {
        ans = min(ans, solve(b));
    }
    cout << setprecision(8) << fixed << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n,d; cin>>n>>d;
    d=d*d;
    int ans=0;
    fi(i,n) {
        int x,y; cin>>x>>y;
        if((x*x+y*y)<=d) ans++;
    } 
    cout<<ans<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15016
#include<bits/stdc++.h>
#define N 110
using namespace std;
bool vis[N][N];
int d[N];
int n;
long long ans;

void dfs(int x,int y){
	if(vis[x][y]||vis[y][x]) return ;
	vis[x][y]=vis[y][x]=1;
	//cout<<ans<<" "<<d[x]<<" "<<d[y]<<endl;
	ans=ans+d[x]*d[y];
	for(int i=1; i<=n; i++){
		if(i!=x){
			dfs(x,i);
			dfs(i,x);
		}
	}
	for(int i=1; i<=n; i++){
		if(i!=y){
			dfs(y,i);
			dfs(i,y);
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&d[i]);
	dfs(1,2);
	printf("%d",ans);
	return 0; 
} 

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

using namespace std;

#define MOD 1000000007

long long n;

template <typename T>
void cross (T &A,T B) {
	T C(n, vector<long long>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			for (int k = 0; k < n; ++k)
				(C[i][j] += A[i][k] * B[k][j]) %= MOD;
	A.swap(C);
}

int main() {
	long long k; cin >> n >> k;
	vector<vector<long long> > mat(n, vector<long long>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) cin >> mat[i][j];
	vector<vector<long long> > tmp(n, vector<long long>(n));
	for (int i = 0; i < n; ++i) tmp[i][i] = 1;
	while (k > 0) {
		if (k & 1) cross(tmp, mat);
		cross(mat, mat);
		k >>= 1;
	}
	mat.swap(tmp);
	long long ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) (ans += mat[i][j]) %= MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384