akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int n, m;
int a[100000];
int imos[100000];

signed main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 1; i < n; i++) {
        int cur = a[i - 1], next = a[i];
        if (cur + 2 < m) {
            imos[cur + 2]++;
        }
        if (cur < next) {
            if (next + 1 < m)
                imos[next + 1]--;
        } else {
            imos[1]++;
            imos[next + 1]--;
        }
    }
    for (int i = 0; i < m; i++) {
        // cout << imos[i] << endl;
    }
    for (int i = 1; i < m; i++) {
        imos[i] += imos[i - 1];
    }
    for (int i = 1; i < n; i++) {
        int cur = a[i - 1], next = a[i];
        if (cur < next) {
            if (next + 1 < m)
                imos[next + 1] -= next - cur - 1;
        } else {
            imos[next + 1] -= m - cur + next - 1;
        }
    }
    for (int i = 1; i < n; i++) {
        int cur = a[i - 1], next = a[i];
        if (cur > next) {
            imos[0] += m - cur - 1;
        }
    }
    int otk = imos[0];
    for (int i = 1; i < m; i++) {
        imos[i] += imos[i - 1];
        otk = max(otk, imos[i]);
    }
    for (int i = 0; i < m; i++) {
        // cout << imos[i] << endl;
    }
    int ans = 0;
    for (int i = 1; i < n; i++) {
        int cur = a[i - 1], next = a[i];
        if (cur < next) {
            ans += next - cur;
        } else {
            ans += m - cur + next;
        }
    }
    cout << ans - otk << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b,c = gets.split(' ').map(&:to_i)
ans = 0

if (a == b) && (b == c)
	if a.even?
	puts "-1"
else
	puts "0"
end
	else
	while a.even? && b.even? && c.even?
		a1 = a
		b1 = b
		c1 = c

		a = (b1/2) + (c1/2)
		b = (a1/2) + (c1/2)
		c = (a1/2) + (b1/2)
		ans += 1
	end
	puts ans
end

Measured memory_bytes: 1788
lis = []
while True:
    xy = [int(i) for i in input().split()]
    if xy[0] == 0 and xy[1] == 0:
        break
    else:
        lis.append(xy)

for i in lis:
    if i[0] > i[1]:
        print(i[1], i[0])
    else:
        print(i[0], i[1])


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  int a;
  vi c(8);
  int over=0,count=0;
  rep(i,n){
    cin >> a;
    a /= 400;
    if(a < 8) c[a]++;
    else over++;
  }
  rep(i,8) if(c[i]) count++;
  if(count || !over) cout << count;
  else cout << 1;
  cout << " " << count + over << endl;
}


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

int main(void){
  int a;
  cin >> a;
  int num = a / 111;
  if (a%111 != 0)
   	num++;
  for(int i= 0; i < 3; i++)
  cout << (char)((int)'0'+num);
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <queue>
#include <numeric>
#include <stack>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N;
  cin >> N;
  vector<long> as(N);
  rep (i,N) cin>>as[i];
  long ans=0;
  rep (i,N) rep(j,N) {
    if (i==j)continue;
    ans = max(ans, abs(as[i]-as[j]));
  }
  cout << ans <<endl;
  
  return 0;
}








Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
pair<int,int>ar[30000005];
pair<pair<int,int>,int>pr[4005];
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1,n,num=-1;ll ans=0;
    string s;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        scanf("%d",&n);
        cin>>s;
        ll r=0,g=0,b=0;ll rm=-1,gm=-1,bm=-1;
        for(int i=0; i<n; i++) {
            if(s[i]=='R') {
                r++;
            } else if(s[i]=='G') {
                g++;
            } else if(s[i]=='B') {
                b++;
            }
            pr[i]= {{r,g},b};
            //cout<<i+1<<" "<<
            rm=max(rm,r);
            gm=max(gm,g);
            bm=max(bm,b);
        }
        for(int i=0; i<n-2; i++) {
            for(int j=i+1; j<n-1; j++) {
                if(s[i]!=s[j]) {
                    num++;
                    ar[num]= {i,j};
                }
            }
        }
        for(int i=0; i<=num; i++) {
            int f=ar[i].ff;
            int sn=ar[i].ss;
            int ck1=0,ck2=0,ck3=0;
            if(s[f]=='R'||s[sn]=='R')ck1=1;
            if(s[sn]=='G'||s[f]=='G')ck2=1;
            if(s[f]=='B'||s[sn]=='B')ck3=1;
            if(ck1==1&&ck2==1) {
                ll v=pr[sn].ss;
                if(bm-v>=1) {
                    ans+=(bm-v);
                    if(s[sn+(sn-f)]=='B') {
                        ans--;//cout<<i<<" ";
                    }
                    //cout<<i<<" ";
                }
            } else if(ck2==1&&ck3==1) {
                ll v=pr[sn].ff.ff;
                if(rm-v>=1) {
                    ans+=(rm-v);
                    if(s[sn+(sn-f)]=='R') {
                        ans--;  //cout<<i<<" ";
                    }  //cout<<i<<" ";
                }
            } else if(ck1==1&&ck3==1) {
                ll v=pr[sn].ff.ss;
                if(gm-v>=1) {
                    ans+=(gm-v);
                    if(s[sn+(sn-f)]=='G') {
                        ans--;
                    }  //cout<<i<<" ";
                }
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 45432
#include <stdio.h>

int make_bucket(const char *puzzle, int *bucket);
int is_solve(int *bucket);

int main()
{
    char puzzle[13];

    while (~scanf("%s", puzzle)){
        int bucket[9] = {};
        int add_n, isnt_first;
        make_bucket(puzzle, bucket);
        for (add_n = isnt_first = 0; add_n < 9; add_n++){
            if (bucket[add_n] == 4) continue;
            bucket[add_n]++;
            if (is_solve(bucket)){
                if (isnt_first) printf(" ");
                isnt_first = 1;
                printf("%d", add_n + 1);
            }
            bucket[add_n]--;
        }
        puts("0" + isnt_first);
    }
    return (0);
}

int make_bucket(const char *puzzle, int *bucket)
{
    int i;
    for (i = 0; i < 13; i++){
        bucket[puzzle[i] - '1']++;
    }
    return (0);
}

int is_solve(int *bucket)
{
    int i;
    int res, maxi, total;
    res = 0;
    for (i = 0; i < 9; i++){
        if (bucket[i] >= 3){
            bucket[i] -= 3;
            res = is_solve(bucket);
            bucket[i] += 3;
        }
        if (res) return res;
        if (i < 7 && bucket[i]){
            bucket[i]--;
            bucket[i + 1]--;
            bucket[i + 2]--;
            if (bucket[i + 1] >= 0 && bucket[i + 2] >= 0){
                res = is_solve(bucket);
            }
            bucket[i]++;
            bucket[i + 1]++;
            bucket[i + 2]++;
        }
        if (res) return res;
    }

    maxi = total = 0;
    for (i = 0; i < 9; i++){
        if (maxi < bucket[i]) maxi = bucket[i];
        total += bucket[i];
    }
    return (total == 2 && maxi == 2);
}

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

#define int long long

signed main() {
	int n; cin >> n;
	vector<int> b;
	for(int i = 1; i <= n-1; i++) {
		int t; cin >> t;
		b.push_back(t);
	}
	int ans = 0;
	ans += (b[0]+b[n-2]);
	for(int i = 0; i < n-2; i++) ans += min(b[i],b[i+1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# 書き方を少し変えたver

packs = [int(candies) for candies in input().split()]
N = int(len(packs))
if sum(packs) % 2 == 0:
    half = int(sum(packs) / 2)
else: 
    print('No')
    exit()

dp = [[False] * (half + 1)] * (N + 1)
dp[0][0] = True

for i in range(N):
    for j in range(half+1):
        if dp[i][j]:
            dp[i+1][j] = dp[i][j]
        elif j >= packs[i]:
            dp[i+1][j] = dp[i][j - packs[i]]

if dp[N][half]:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 3064
t=$<.map{a,b=_1.split.map &:to_r
b ?a*b==0?1[a]-1[b]:a/b:0}.tally
M=10**9+7
z=1
t.map{w=t[_1==0?0:-1/_1]||0
w>0&&_1<=0||z=z*(2.pow(_2,M)+2.pow(w,M)-1)%M}
p (t[0]-2+z)%M

Measured memory_bytes: 39692
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    int in = 0;
    int over = 0;
    rep(i,n){
        if(s[i] == 'a'){
            if(in < a+b){
                in++;
                cout << "Yes\n";
            }else{
                cout << "No\n";
            }
        }else if(s[i] == 'b'){
            if(over < b && in < a+b){
                over++;
                in++;
                cout << "Yes\n";
            }else cout << "No\n";
        }else cout << "No\n";
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 896
// 解説見た
#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)
#define rrep(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
const int MOD = 1000000007;
int main() {
    string s; cin >> s;
    int dp[100001][13] = {0};
    dp[0][0] = 1;

    rrep(i,s.size()+1) {
        if (s[i-1] == '?') {
            rep(num,10) {
                rep(j,13) {
                    dp[i][(j*10+num) % 13] += dp[i-1][j];
                    dp[i][(j*10+num) % 13] %= MOD;
                }
            }
        }
        else {
            int num = s[i-1] - '0';
            rep(j,13) {
                dp[i][(j*10+num) % 13] += dp[i-1][j];
                dp[i][(j*10+num) % 13] %= MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 8820
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Input-Values.
                     05 x      BINARY-SHORT.
                     05 a      BINARY-SHORT.
                     05 b      BINARY-SHORT.
              01 Calc-Values.
                     05 ans    PIC Z(10)9.
                     05 tmp    BINARY-SHORT.
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT x.
              ACCEPT a.
              ACCEPT b.
              
              SUBTRACT a FROM x.
              MOVE x TO tmp.
              DIVIDE b INTO tmp.
              MULTIPLY b BY tmp.
              SUBTRACT tmp FROM x.
              MOVE x TO ans.
              DISPLAY TRIM(ans).
       END PROGRAM Answer.


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str1,str2;
  cin >> str1>>str2;
  bool f = true;
  int n = str1.size();
  for ( int i = 0 ; i < n ; i++ ) {
     if(str1.at(i)!=str2.at(i)){
       f = false;
     }
  }
  
  if (f){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int c = in.nextInt();

        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
        }
        int x = 0;
        for (int i = 0; i < n; i++) {
            int r = 0;
            for (int j = 0; j < m; j++) {
                r += in.nextInt() * b[j];
            }
            r += c;
            if (r > 0) {
                x++;
            }
        }

        out.println(x);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22740
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    s: chars,
    }
    let l: Vec<usize> = (0..n).map(|x| s[x].to_digit(10).unwrap() as usize).collect();
    let mut used = vec![vec![vec![false; 11]; 11]; 11];
    let mut ans = 0;
    for i in 0..n {
        let c1 = l[i];
        if used[c1][10][10]{continue};
        for j in i + 1..n{
            let c2 = l[j];
            if used[c1][c2][10]{continue};
            for k in j+1..n{
                let c3 = l[k];
                if used[c1][c2][c3]{continue};
                used[c1][c2][c3] = true;
                ans += 1;
            }
            used[c1][c2][10] = true;
        }
        used[c1][10][10] = true;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, A, x;
  
  cin >> N;
  cin >> A;
  
  x = N % 500;
  
  if(A >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
ll L,n,X[MAX],nX[MAX];
//ll f[MAX][MAX][2],ans;
ll ans,Sl[MAX],Sr[MAX];
ll S1(int l,int r){return Sl[r]-Sl[l-1];}
ll S2(int l,int r){return Sr[r]-Sr[l-1];}
void Calc()
{
	for(int i=1;i<=n/2;++i)
	{
		int L=i,R=i,pos=n-L-R;
		ans=max(ans,S1(pos+1,pos+R)*2+S2(pos+R+2,n)*2+nX[pos+R+1]);
		ans=max(ans,2*X[pos]+S1(pos+1,pos+R-1)*2+X[pos+R]+S2(pos+R+1,n)*2);
		if(i+i<n)
		{
			L=i+1,R=i,pos=n-L-R;
			ans=max(ans,2*X[pos]+S1(pos+1,pos+R)*2+S2(pos+R+2,n)*2+nX[pos+R+1]);
			L=i,R=i+1,pos=n-L-R;
			ans=max(ans,S1(pos+1,pos+R-1)*2+X[pos+R]+S2(pos+R+1,n)*2);
		}
	}
}
int main()
{
	L=read();n=read();
	for(int i=1;i<=n;++i)X[i]=read(),nX[i]=L-X[i];
	//memset(f,-63,sizeof(f));f[0][0][0]=f[0][0][1]=0;
	ans=max(ans,max(L-X[1],X[n]));
	/*for(int i=0;i<=n;++i)
		for(int j=0;i+j<=n;++j)
		{
			if(i==0&&j==0)continue;
			if(i)
			{
				f[i][j][0]=max(f[i][j][0],f[i-1][j][0]+X[i]-X[i-1]);
				f[i][j][0]=max(f[i][j][0],f[i-1][j][1]+(L-X[n-j+1])+X[i]);
			}
			if(j)
			{
				f[i][j][1]=max(f[i][j][1],f[i][j-1][1]+X[n-j+2]-X[n-j+1]);
				f[i][j][1]=max(f[i][j][1],f[i][j-1][0]+X[i]+(L-X[n-j+1]));
			}
			if(i+j==n)
			{
				ans=max(ans,f[i][j][0]);
				ans=max(ans,f[i][j][1]);
			}
			}*/
	for(int i=1;i<=n;++i)Sl[i]=Sl[i-1]+X[i];
	for(int i=1;i<=n;++i)Sr[i]=Sr[i-1]+nX[i];
	Calc();
	swap(X,nX);reverse(&X[1],&X[n+1]);reverse(&nX[1],&nX[n+1]);
	for(int i=1;i<=n;++i)Sl[i]=Sl[i-1]+X[i];
	for(int i=1;i<=n;++i)Sr[i]=Sr[i-1]+nX[i];
	Calc();
	cout<<ans<<endl;
	return 0;
}


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

int n, k;
double ans; 

int main(){
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    double p = (double)1/n;
    int score = i;
    while(score < k){
      score *= 2;
      p *= 0.500000000;
    }
    ans += p;
  }
  
  printf("%.13f\n", ans);
}

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

def GCM(m,n):
    while n>0:
        m,n = n,m%n
    return m

fGCM = [0 for i in range(N)]
bGCM = [0 for i in range(N)]

fGCM[0]=A[0]
bGCM[N-1]=A[N-1]

for i in range(N-1):
    j = N-1-i
    fGCM[i+1]=GCM(fGCM[i],A[i+1])
    bGCM[j-1]=GCM(bGCM[j],A[j-1])

eGCM=[0 for i in range(N)]
eGCM[0]=bGCM[1]
eGCM[N-1]=fGCM[N-2]
for i in range(1,N-1):
    eGCM[i] = GCM(fGCM[i-1],bGCM[i+1])

ans = max(eGCM)
print(ans)



Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;

int main(){
    ll l[4] = {8, 4, 2, 1};
    ll v[4];
    vector<P> vs;
    for(int i=0;i<4;i++){
        cin >> v[i];
        vs.emplace_back(v[i] * l[i], i);
    }
    sort(vs.begin(), vs.end());

    int N;
    cin >> N;
    if(N % 2 == 1){
        if(vs[0].second == 3){
            cout << (N / 2) * v[3] + vs[1].first / 2 << endl;
        }else{
            cout << (vs[0].first / 2) * N << endl;
        }
    }else{
        cout << (N / 2) * vs[0].first << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())

    f = [0] * (N+1)
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                tmp = x*x + y*y + z*z + x*y + y*z + z*x
                if tmp > N:
                    break
                f[tmp] += 1
    
    print("\n".join(map(str, f[1:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string S;
int ans[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    int l = 0;
    int N = S.size();
    S.push_back('R');
    while(l < N) {
        int r = l;
        while(S[r] == 'R') r++;
        int ansl = r - 1;
        int ansr = r;
        while(S[r+1] == 'L') r++;
        for(int i = l; i <= r; i++) {
            if(i % 2 == ansl % 2) ans[ansl]++;
            else ans[ansr]++;
        }
        l = r + 1;
    }
    for(int i = 0; i < N; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1104
n,m,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from itertools import accumulate
import bisect

A = [0] + list(accumulate(a))
B = list(accumulate(b))

ans = 0
for ac in range(n+1):
    if A[ac] > k:
        break
    bc = bisect.bisect_right(B, k-A[ac])
    ans = max(ans, ac+bc)

print(ans)

Measured memory_bytes: 49040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin a(n);
    vvin x(n,vin(n-1));
    vvin y(n,vin(n-1));
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    priority_queue<int> pq;
    pq.push(0);
    rep(i,1<<n){
        bitset<15> tmp(i);
        bool can=true;
        rep(j,n){
            if(tmp.test(j)){
                rep(k,a[j]){
                    if(y[j][k]!=tmp[x[j][k]-1]){
                        can=false;
                        goto out;
                    }
                }
            }
        }
        out:
        if(can){
            int m=tmp.count();
            pq.push(m);
        }
    }
    cout<<pq.top()<<endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	cnt := make([][10]int, 10)

	for i := 1; i < n+1; i++ {
		s := strconv.Itoa(i)
		a, _ := strconv.Atoi(s[:1])
		b, _ := strconv.Atoi(s[len(s)-1:])
		cnt[a][b]++
	}

	ans := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			ans += cnt[i][j] * cnt[j][i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
// const ll mod = 1000000007;
const ll mod = 998244353;
const ll INF = 1LL<<60;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i=2; i<MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main()
{
  ll n,a,b,k; cin>>n>>a>>b>>k;
  cominit();
  ll ans = 0;
  for (ll i=0; i<=n; i++) {
    ll t = k - a*i;
    if (t%b != 0) continue;
    ll j = t/b;
    ans = (ans + (com(n,i)*com(n,j)%mod)) % mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12160
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	int m;
	cin >> n >> m >> x;
	vint a(m);
	rep(i, m)cin >> a[i];
	rep(i, m) {
		if (a[i] < x)c++;
		else d++;
	}
	sec(c, d, c < d);
	please AC;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll a;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include<iostream>
using namespace std;
#define int long long



#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


string s[2];


signed main() {
  cin>>s[0]>>s[1];
  bool can=true;
  rep(i,0,3){
      
      if(s[0][i]!=s[1][2-i])can=false;
      
  }
  if(can)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (N==1&&A!=B) {
			System.out.println(0);
			return ;
		}
		
		if (A>B) {
			System.out.println(0);
			return ;
		}
		
		long ans = N-2;
		
		System.out.println(ans*B-ans*A+1);
	}
	
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

vector <i64> g[maxn] , c[maxn] ;

bool Set[maxn] ;
i64 dis[maxn] ;

bool bfs(i64 n)
{
    i64 i , j , k , l , m , u ,v ;

    memset(Set,0,sizeof(Set)) ;

    for(i=1 ; i<=n ; i++)
    {
        if( Set[i]==true ) continue ;
        Set[i] = true ; dis[i] = 0 ;

        queue<i64> q ;
        q.push(i) ;

        while(!q.empty())
        {
            u = q.front() ;
            q.pop() ;

            for(j=0 ; j<g[u].size() ; j++)
            {
                v = g[u][j] ;
                if(Set[v]==false)
                {
                    dis[v] = dis[u] + c[u][j] ;
                    Set[v] = true ;
                    q.push(v) ;
                }
            }
        }
    }
    i64 mn = 0 ;
    for(i=1 ; i<=n ; i++) mn = min(mn,dis[i]) ;

    for(i=1 ; i<=n ; i++) dis[i] -= mn ;

    for(i=1 ; i<=n ; i++)
    {
        if(dis[i]<0 || dis[i]>1000000000) return false ;
    }

    for(i=1 ; i<=n ; i++)
    {
        for(j=0 ; j<g[i].size() ; j++)
        {
            k = g[i][j] ;
            if( dis[i]+c[i][j]!=dis[k] ) return false ;
        }
    }
    return true ;
}

int main()
{
    i64 i , j , k , l , m , n , r ;

    scanf("%lld %lld",&n,&m) ;

    for(i=1 ; i<=m ; i++)
    {
        i64 d ;
        scanf("%lld %lld %lld",&l,&r,&d) ;
        g[l].pb(r) ; c[l].pb(d) ;
        g[r].pb(l) ; c[r].pb(-d) ;
    }

    bool ans = bfs(n) ;

    if(ans==true) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}


Measured memory_bytes: 18432
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, a, b; rd(n, a, b);

  writeln(min(a*n, b));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N,i;
    int a[4];
    scanf("%d",&N);
    
    for (i=0; i<4; i++) {
        a[i] = N%10;
        N = N/10;
    }
    if (((a[0] == a[1])&&(a[0]==a[2]))||((a[1] == a[2])&&(a[2]==a[3]))) {
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> list = new ArrayList<>();
        
        for (int i = 0; i < n; i++) {
            list.add( sc.nextLong());
        }
        Collections.sort(list, Collections.reverseOrder());
        long sum = list.get(0);
        if(n%2==0){
        for (int i = 1; i < n/2; i++)
           sum+=list.get(i) * 2;
        }
        else{
            for (int i = 1; i <= n/2-1; i++)
           sum+=list.get(i) * 2;
           sum+=list.get(n/2);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 66244
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

struct Node {
  int64_t parent{-1};
  // vector<int64_t> children;
  vector<int64_t> neighbours;
  int64_t offset{0};
  int64_t value{-1};
};

void SetParent(const int64_t cnode, vector<Node> &nodes) {
  for (const int64_t neighbour : nodes[cnode].neighbours) {
    if (nodes[neighbour].parent < 1) {
      nodes[neighbour].parent = cnode;
      SetParent(neighbour, nodes);
    }
  }
}

int64_t GetValue(const int64_t cnode, vector<Node> &nodes) {
  if (nodes[cnode].value >= 0) {
    return nodes[cnode].value;
  }
  if (nodes[cnode].parent == cnode) {
    return nodes[cnode].offset;
  }
  const int64_t temp = GetValue(nodes[cnode].parent, nodes);
  nodes[cnode].value = nodes[cnode].offset + temp;
  return nodes[cnode].value;
}

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

  constexpr int64_t kRoot = 1;
  int64_t N, Q;
  cin >> N >> Q;
  vector<Node> nodes(N + 1);
  nodes[kRoot].parent = kRoot;
  for (int64_t i = 0; i < N - 1; ++i) {
    int64_t a, b;
    cin >> a >> b;
    nodes[a].neighbours.push_back(b);
    nodes[b].neighbours.push_back(a);
  }

  SetParent(kRoot, nodes);

  for (int64_t i = 0; i < Q; ++i) {
    int64_t p, x;
    cin >> p >> x;
    nodes[p].offset += x;
  }

  for (int64_t i = 1; i <= N; ++i) {
    if (i != 1) {
      cout << " ";
    }
    const int64_t result = GetValue(i, nodes);
    cout << result;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 27392
from sys import stdin

def ten(x):
    return 10 - x

lst = []
for i in range(5):
    a = int(stdin.readline().rstrip())
    lst.append(a)

minv = 9
flag = False
for x in lst:
    s = str(x)
    tmp = int(s[-1])
    if tmp <= minv and tmp != 0:
        flag = True
        minv = tmp

sum = 0

for x in lst:
    s = str(x)
    tmp = int(s[-1])
    if tmp >= 1:
        tmp2 = ten(tmp)
        sum = sum + x + tmp2
    else:
        sum = sum + x

if minv != 0 and flag:
    sum = sum - (ten(minv))

print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<ll>());
  ll result = pow(10, 9) + 1;
  for (int i = 0; i < N - K + 1; ++i) {
    result = min(result, h[i] - h[i + K - 1]);
  }
  cout << result << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int p=0,q=0;
    
    cin>>s;
    int a=s.size();
    for(int i=0;i<a;i++){
        if(s[i]=='1') p++;
        else if(s[i]=='0') q++;
    }
    
    int b=min(p,q);
    cout<<b*2<<endl;
    return 0;
}


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

using namespace std;

int v[100005];
int ans[100005];
int n, k;

int main () {
  cin>>n>>k;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    v[i] = a;
  }

  memset(ans, -1, sizeof(ans));
  ans[0]=0;
  
  for (int i=0; i<n; i++) {
    for (int j = 1; j <= k; j++) {
      int valorNovo = ans[i] + abs(v[i]-v[i+j]);
      
      if (ans[i+j]==-1)
        ans[i+j] = valorNovo;
      else if (ans[i+j]>=valorNovo)
        ans[i+j] = valorNovo;

    }
  }
  cout<<ans[n-1]<<endl;

}



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

#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int x,k,d;cin>>x>>k>>d;
  x=abs(x);
  if(x/d>k)fin(x-d*k);
  if((x/d+k)&1)fin(d-x%d);
  fin(x%d);
}


Measured memory_bytes: 3608
def f(x, y, z):
    return (x+y+z)**2 - x*y - y*z - z*x


N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, int(i**0.5)+2):
        for y in range(x, int(i**0.5)+2):
            if f(x, y, y-1) >= i:
                break
            l = y - 1
            r = int(i**0.5) + 1
            while r >= l:
                z = (r+l) // 2
                if f(x, y, z) == i:
                    if x < y:
                        if x == z or y == z:
                            ans += 3
                        else:
                            ans += 6
                    else:
                        if z == y:
                            ans += 1
                        else:
                            ans += 3
                if f(x, y, z) > i:
                    r = z - 1
                else:
                    l = z + 1

    print(ans)


Measured memory_bytes: 70144
import sys

n = int(input())

a = []

for _ in range(n):
    A = list(map(int, input().split( )))
    a.append(A)

b = [[a[i][j] for j in range(n)] for i in range(n)]

#三角不等式(等号可)を満たしてなかったら無理
#満たしてた場合、どの迂回路とも真の不等号ならば保持

for k in range(n):
    for i in range(n):
        for j in range(n):
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                sys.exit()
            if i!=k and j!=k and a[i][k] + a[k][j] == a[i][j]:

                b[i][j] = 0
ans = 0
for i in range(n):
    ans += sum(b[i])

print(ans//2)




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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    string S;
    cin >> S;
    ll K;
    cin >> K;


    vector<ll> c;
    c.push_back(1);

    for (int i = 1; i < S.size(); i++) {
        if (S[i - 1] == S[i]) 
            c[c.size() - 1]++;
        else
            c.push_back(1);
    }

    cerr << join(c) << endl;

    ll ans = 0;
    if (c.size() == 1) {
        if(S.size()%2==0){
           ans += (c[0]/2)*K;
        }else{
            ans += (c[0] * 2 / 2) * (K / 2);
            if(K%2==1)
                ans += c[0] / 2;
        }
    } else {
        if(S[0] == S[S.size()-1]){
            ans += c[0]/2;
            ans += c[c.size() - 1]/2;
            for (int i = 1; i < c.size() - 1;i++){
                ans += (c[i]/2)*K;
            }
            ans += ((c[0] + c[c.size() - 1])/2) * (K - 1);

        }else{
            for(auto a : c){
                ans += (a / 2) * K;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int w,n,c[30],a,b,x;
	
	cin>>w>>n;
	
	for(int i=0;i<w;i++)c[i]=i+1;
	
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		x=c[a-1];c[a-1]=c[b-1];c[b-1]=x;
	}
	for(int i=0;i<w;i++)cout<<c[i]<<endl;
	return 0;
}

Measured memory_bytes: 868
lines = $<.readlines.map {|l| l.split(",").map(&:to_i)}
ln = lines.size / 2 + 1

up = ->(n, sums) {
  return sums if n == ln
  nxt = Array.new(n + 1, 0)
  sums.each_with_index do |s, i|
    nxt[i] = lines[n][i] + s if i.zero?
    nxt[i + 1] = sums[i, 2].max + lines[n][i + 1]
  end
  up.(n + 1, nxt)
}
mid = up.(1, lines.first)

down = ->(n, sums) {
  return sums.first if sums.size == 1
  nxt = sums.each_cons(2).map.with_index do |pair, i|
    lines[n][i] + pair.max
  end
  down.(n + 1, nxt)
}
puts down.(ln, mid)


Measured memory_bytes: 7000
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int i;
  int N, C, K;
  int T[100010];
  scanf("%d %d %d", &N, &C, &K);
  for (i = 0; i < N; i++) {
    scanf("%d", &T[i]);
  }
  sort(T, T+N);
  int ans = 0;
  int now = 0;
  int pos = 0;
  while (pos < N) {
    now = T[pos]+K;
    int pos_1 = pos+C;
    int* pos_2star = upper_bound(T, T+N, now);
    int pos_2 = (int)(pos_2star - T);
    pos = min(pos_1, pos_2);
    ans += 1;
    //printf("pos1=%d pos2=%d pos=%d, bus time=%d\n", pos_1, pos_2, pos, now);
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
#include<cstdio>      // scanf, printf.
#include<algorithm>   // sort.
#include<utility>     // pair.

typedef pair<int, pair<int, int> > Point;

inline int pos_x(Point p){ return p.second.first; }
inline int pos_y(Point p){ return p.second.second; }

bool cmp_x(const Point &p1, const Point &p2){ return pos_x(p1) < pos_x(p2); }
bool cmp_y(const Point &p1, const Point &p2){ return pos_y(p1) < pos_y(p2); }

class Node
{
public:
    Point *mark;
    Node *less, *more;
    int depth;
    Node() : mark(NULL), less(NULL), more(NULL), depth(0) {};
    Node(Point* pos, Node* l, Node* m, int d) : mark(pos), less(l), more(m), depth(d) {};
};

Node* make_tree(Point S[], int left, int right, int d)
{
    if(left > right) return NULL;
    if(left == right){
        Node* leaf = new Node;
        *leaf = Node(&S[left], NULL, NULL, d);
        return leaf;
    }

    if(d & 1){
        sort(S + left, S + right + 1, cmp_x);
    }else{
        sort(S + left, S + right + 1, cmp_y);
    }
    int mid = (left + right) / 2;

    Node* kd_n = new Node;
    kd_n->mark = &S[mid];
    kd_n->less = make_tree(S, left, mid - 1, d + 1);
    kd_n->more = make_tree(S, mid + 1, right, d + 1);
    kd_n->depth = d;

    return kd_n;
}

int cnt;

void search_points(Point S[], int sx, int tx, int sy, int ty, Node* kd_n)
{
    if(kd_n == NULL) return;
    int a = pos_x(*(kd_n->mark)), b = pos_y(*(kd_n->mark));

    if(sx <= a && a <= tx && sy <= b && b <= ty){
        S[cnt] = *(kd_n->mark);
        cnt++;
    }
    int d = kd_n->depth;

    if(d & 1){
        if(sx <= a){ search_points(S, sx, tx, sy, ty, kd_n->less); }
        if(a <= tx){ search_points(S, sx, tx, sy, ty, kd_n->more); }
    }else{ 
        if(sy <= b){ search_points(S, sx, tx, sy, ty, kd_n->less); }
        if(b <= ty){ search_points(S, sx, tx, sy, ty, kd_n->more); }
    }
    return;
}

int main()
{
    int i, a, b, n;
    Point P[500000], Q[100];

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &a, &b);
        P[i] = make_pair(i, make_pair(a, b));
    }
    Node* root;
    root = make_tree(P, 0, n - 1, 0);

    int q, sx, tx, sy, ty;
    scanf("%d", &q);
    while(q){
        cnt = 0;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        search_points(Q, sx, tx, sy, ty, root);
        sort(Q, Q + cnt);
        for(i = 0; i < cnt; i++){ printf("%d\n", Q[i].first); }
        printf("\n");
        q--;
    }
    return 0;
}

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

#define MAX 1000

int lcs(string X, string Y) {
    int c[MAX+1][MAX+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for(int i = 1; i <= n; i++) {
        c[0][i] = 0;
    }
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++) {
            if(X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(c[i][j], maxl);
        }
    }
    return maxl;
}

int main() {
    int n;
    string X, Y; 
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> X >> Y;
        cout << lcs(X, Y) << endl;
    }
    return 0;
}


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

int main() {
	int n,a,b,c;
	cin >> n >> a >> b;
	if(a<b) swap(a,b);
	if((a-b)%2==1){
		cout << "Borys";
	}else{
		cout << "Alice";
	}
	
}

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

int main() {
    int n, m; cin >> n >> m;
    
    int max_units = m;
    int cur_units = m;
    for (int minite = 1; minite <= n; ++minite) {
        int enter, exit; cin >> enter >> exit;
        cur_units += enter - exit;
        if (cur_units < 0) {
            max_units = 0;
            break;
        }
        max_units = max(max_units, cur_units);
    }
    cout << max_units << endl;
    return 0;
}


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

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    int ans=0;
    vector<vector<char>> c(h,vector<char>(w));

    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            cin>>c.at(i).at(j);
        }
    }
    for (int bit=0;bit<(1<<h+w);++bit){
        vector<vector<char>> t=c;
        int cnt=0;
        for (int i=0;i<h;++i){
            if ((bit>>i)%2==0){
                continue;
            }
            else{
                t.at(i).assign(w,'r');
            }
        }
        for (int j=h;j<h+w;++j){
            if((bit>>j)%2==1){
                continue;
            }
            else{
                for(int i=0;i<h;++i){
                    if(t.at(i).at(j-h)=='#'){
                        cnt++;
                    }
                }
            }
        }
        if(cnt==k){
            ans++;
        }
    }
    cout<<ans<<endl;

}

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

int main(){

    int n;
    while(cin>>n){
        int binary_tree[255];
        for(int i=1;i<=n;i++)
            cin>>binary_tree[i];
        
        int parent_key,left_key,right_key;
        for(int i=1;i<=n;i++){
            printf("node %d: key = %d, ",i,binary_tree[i]);
            if(i/2>0){
                parent_key=binary_tree[i/2];
                printf("parent key = %d, ",parent_key);
            
            }
            if(i*2<=n){
                left_key=binary_tree[i*2];
                printf("left key = %d, ",left_key);
            }
            if(i*2+1<=n){
                right_key=binary_tree[i*2+1];
                printf("right key = %d, ",right_key);
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

class Solver {
};
int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;


		char dum;
		cin >> dum;
		map<string, int> mp;
		for (int i = 0; i < n; i++) {
			string line;
			getline(cin, line);
			string ss = "";
			if (i == 0)ss += dum;
			for (int j = 0; j < line.size(); j++) {
				if (line[j] == ' ') {
					if (mp.find(ss) == mp.end()) {
						mp.emplace(ss, 0);
					}
					mp[ss]++;
					ss = "";
				}
				else {
					ss += line[j];
				}
			}
			if (mp.find(ss) == mp.end()) {
				mp.emplace(ss, 0);
			}
			mp[ss]++;
		}

		char c;
		cin >> c;
		vector<tuple<int, string>> strs;
		for (auto pair : mp) {
			if (pair.first[0] == c) {
				strs.emplace_back(make_tuple(-pair.second, pair.first));
			}
		}

		if (strs.size() == 0) {
			cout << "NA" << endl;
		}
		else {
			sort(strs.begin(), strs.end());
			int cnt = 5;
			if (strs.size() < cnt)cnt = strs.size();
			for (int i = 0; i < cnt; i++) {
				cout << get<1>(strs[i]);
				if (i+1 < cnt)cout << " ";
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3216