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

int main(){
	map<string,int> x;
	int n;
	cin>>n;
	string s[n+1];
	for(int i=1;i<=n;i++){
		cin>>s[i];
		x[s[i]]=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(x[s[i]]){
			x[s[i]]--;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25512
n, m = list(map(int, input().split(' ')))

value_list = []
for i in range(m):
    a, b = map(int, input().split(' '))
    value_list.append(a)
    value_list.append(b)
for i in range(1, n + 1):
    print(value_list.count(i))


Measured memory_bytes: 2940
import math
N = int(input())

ans = [0] * (10100)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            if tmp > 10000:
                break
            ans[tmp] += 1

for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 69216
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
using namespace std;
const int N=1e5+5; 
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,k,p,l[N],ans[N];
int main(){
	n=read(),k=read();
	inc(i,1,n) l[i]=read();
	inc(i,1,n-1){
		if(l[i]+l[i+1]>=k){
			p=i;
			break;
		}
	}
	if(!p) return puts("Impossible"),0;
	puts("Possible");
	inc(i,1,p-1) printf("%d\n",i);
	dec(i,n-1,p+1) printf("%d\n",i);
	printf("%d\n",p); 
}

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>


static const double EPS = 1e-9;
using namespace std;

class Vector {
private:

public:
  double x, y;
  Vector():x(0), y(0){}; //Default constructor
  //Constructor
  Vector(double x_, double y_) {
    this->x = x_;
    this->y = y_;
  }
};


int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;

  Vector p(x, y);
  Vector cent(double(W/2.0), double(H/2.0));

  double max_area = (double(W) * double(H)) / 2;
  int has_other = 0;

  if ((fabs(cent.x - p.x) < EPS) && (fabs(cent.y - p.y) < EPS)) {
    has_other = 1;
  }

  cout << max_area << " " << has_other << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a[]=new int[3];
		a[0]=scan.nextInt();
		a[1]=scan.nextInt();
		a[2]=scan.nextInt();
		Arrays.sort(a);
		System.out.println((a[1]-a[0])+(a[2]-a[1]));
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	  public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);
		    int n = Integer.parseInt(sc.next());
		    
		    if (n<1 || n>100000) {
		    	System.out.println("Entrada invalida!!!");
		    	System.exit(0);
		    }
		    
		    int[][] acao = new int[n][3];
		    int[][] feliz = new int[n+1][3];
		    
		    for(int i = 0; i <= n; i++) {
		      for(int j = 0; j < 3; j++) {
		        feliz[i][j] = 0;
		      }
		    }
		    
		    for(int i = 0; i < n; i++) {
		      for(int j = 0; j < 3; j++) {
		        acao[i][j] = Integer.parseInt(sc.next());
		      }
		    }
		    
		    for(int i = 0; i < n; i++) {
		      for(int j = 0; j < 3; j++) {
		        for(int k = 0; k < 3; k++) {
		          if(j == k) continue;
		          feliz[i+1][j] = Math.max(feliz[i+1][j], feliz[i][k] + acao[i][j]);
		        }
		      }
		    }
		    
		    int answer = maxThree(feliz[n][0], feliz[n][1], feliz[n][2]);
		    System.out.println(answer);
		  }
		 
		  public static int maxThree(int a, int b, int c) {
		    int ans = a;
		    if(ans < b) ans = b;
		    if(ans < c) ans = c;
		    return ans;
		  }

}


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

using namespace std;

int main() {
  int n, a;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    ans += a & 1;
  } 
  puts(ans & 1 ? "NO" : "YES");
  return 0;
}

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

const int MX = 1000001;

int main() {
    int n; cin >> n;
    int mn =0;
    vector<int> a(n); rep(i,n) {
        cin >> a[i];
        mn = max(mn, a[i]);
    }

    vector<int> tmp(MX,0);
    rep(i,n) {
        int b = a[i];
        if(tmp[b] > 1) continue;
        for(int j = b; j < mn+1; j+=b) {
            tmp[j]++;
        }
    }
    int ans = 0;
    rep(i,n) {
        if(tmp[a[i]] == 1) ans++;
    }
    cout << ans << endl;
}

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

// a>b
int gcd(int a, int b) {
  if (b==0) {
    return a;
  } else {
    return gcd(b, a%b);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  // left.at(i) => a0...ai
  vector<int> left(n, a.at(0));
  // right.at(i) => an-1,...,a_(n-1-i)
  vector<int> right(n, a.at(n-1));
  for (int i=1;i<n;i++) {
    left.at(i) = gcd(left.at(i-1), a.at(i));
    right.at(i) = gcd(right.at(i-1), a.at(n-1-i));
  }
  int max_gcd=0;
  for (int i=1;i<n-1;i++) {
    int cand = gcd(left.at(i-1), right.at(n-2-i));
    if (cand > max_gcd) {
      max_gcd = cand;
    }
  }
  if (right.at(n-2) > max_gcd) {
    max_gcd = right.at(n-2);
  }
  if (left.at(n-2) > max_gcd) {
    max_gcd = left.at(n-2);
  }
  cout << max_gcd << endl;
  return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}

	answer := 0
	for i := 0; i < n; i++ {
		answer += (A[i] - 1)
	}

	fmt.Println(answer)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    int ci = C-1;
    int ai = A-X;
    int bi = B-Y;

    ll ans = 0;
    while (ai < A || bi < B) {
        // p[ai], q[ai]よりc[ai]の方が美味しいとき
        if (ci >= 0 && ai < A && bi < B && p[ai] < q[bi] && p[ai] < r[ci]) {
            // p[ai]をr[ci]で代わりに
            ans += r[ci];
            // cout << r[ci] << " ";
            ci--;
            ai++;
        } else if (ci >= 0 && ai < A && bi < B && p[ai] >= q[bi] && q[bi] < r[ci]) {
            // q[bi]をr[ci]で代わりに
            ans += r[ci];
            // cout << r[ci] << " ";
            ci--;
            bi++;
        // これ以降はr[ci]で代わりにしない
        } else {
            if (ai < A) {
                if (ci >= 0 && p[ai] < r[ci]) {
                    ans += r[ci];
                    ci--;
                } else {
                    ans += p[ai];
                }
                // cout << p[ai] << " ";
                ai++;
            }
            if (bi < B) {
                if (ci >= 0 && q[bi] < r[ci]) {
                    ans += r[ci];
                    ci--;
                } else {
                    ans += q[bi];
                }
                // cout << q[bi] << " ";
                bi++;
            }
        }
    }
    // cout << endl;
    // cout << ai << " " << bi << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

int main(){
   int a,b;
   std::cin>>a>>b;
   if(a<b) std::cout<<"a < b"<<std::endl;
   else if(a==b) std::cout<<"a == b"<<std::endl;
   else std::cout<<"a > b"<<std::endl;
   return 0;
}

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

int main()
{
	string s;
	cin>>s;
	int n = s.length();
	int cc = 0;

	for(int i=0;i<n/2;i++)
	{

		if(s[i]!= s[n-i-1])
		{
			cc=cc+1;
			if(s[i]<s[n-i-1])
			s[n-i-1]= s[i] ;
		else
			s[i]= s[n-i-1] ;
		}


	}
	cout<<cc;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n';
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
bool cmp(pair<int,int>a,pair<int,int>b){
return a.S<b.S;
}
int main()
{
int a,b;
while(cin>>a>>b){


    pair<int,int>A[100005]={};
    for(int i=0;i<b;i++){
        cin>>A[i].F>>A[i].S;
        A[i].S--;
    }
    sort(A,A+b,cmp);
    int now=A[0].S;
    int ans=1;
    for(int i=1;i<b;i++){
        if(A[i].F<=now&&now<=A[i].S){
            con;
        }
        else{
            ans++;
            now=A[i].S;
        }
    }

    cout<<ans<<endl;





}
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>

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

const int MAX_N = 1000;
const int MAX_M = 2000;
const ll INF = 1LL << 50;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(MAX_M,0),b(MAX_M,0);
    vector<ll> c(MAX_M,0) ,dist(MAX_M,0);

    rep(i,M){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    rep(i,N) dist[i] = INF;
    dist[0] = 0;

    rep(loop,N-1){
        rep(i,M){
            if(dist[a[i]-1]==INF) continue;

            if(dist[b[i]-1] > dist[a[i] - 1] + c[i]){
                dist[b[i]-1] = dist[a[i]-1] + c[i];
            }       
        }
    }

    ll ans = dist[N-1];

    bool negative[MAX_N];

    rep(i,N) negative[i] = false;

    rep(loop,N){
        rep(i,M){
            if(dist[a[i] - 1] == INF) continue;
            if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
                dist[b[i] - 1] = dist[a[i] - 1] + c[i];
                negative[b[i]- 1] = true;//
            }
            if(negative[a[i] - 1] == true) negative[b[i]-1] = true;
        }
    }

    if(negative[N-1]) cout << "inf" << endl;
    else cout << -ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
 
int main(){
  string S,T;
  cin >> S >> T;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(S[i]==T[i])cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC023A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var sum = new long[N + 1];
            for(int i = 1; i <= N; i++)
            {
                sum[i] = sum[i - 1] + Ai[i - 1];
            }
            
            var dislist = sum
                .GroupBy(i => i)
                .Where(g => g.Count() >= 1)
                .Select(g => new { number = g.Key, duplicationCount = g.Count()})
                .ToList();

            long ans = 0;
            foreach (var d in dislist)
            {
                ans += (d.duplicationCount * (long)(d.duplicationCount - 1) / 2);
            }

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


Measured memory_bytes: 53448
object Main {

  def gcd(a: Long, b: Long): Long = if(b!=0) gcd(b,a%b) else a

  def lcm(a: Long, b: Long): Long = a * b / gcd(a,b)

  def loop(s: String):Unit = if(s != null){
    val Array(a,b,_*) = s.split(" ").map(_.toLong)
    println(gcd(a,b)+" "+lcm(a,b))
    loop(scala.io.StdIn.readLine)
  }

  def main(args: Array[String]): Unit = {
    loop(scala.io.StdIn.readLine)
  }
}

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


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

    int n;
    cin >> n;
    vector<int> p(n);
    rep (i, n) cin >> p[i];
    int piv = p[0];
    int cnt=0;
    rep (i, n) {
        if (piv >= p[i]) {
            piv = min(piv, p[i]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3956
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d=collections.Counter(d)
t=collections.Counter(t)
#print(d)
#print(t)
for i in t.keys():
    if d[i]<t[i]:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 55640
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
if N == 1:
    print(1)
    exit()
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)

Measured memory_bytes: 14428
#include<iostream>
   
using namespace std;
   
int main(){
int a,b;
cin>>a>>b;
string op = " == ";
if(a>b){
op = " > ";
}
if(a<b){
op = " < ";
}
   
cout<<'a'<<op<<'b'<<endl;
   
return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> X(N);
  for(int i=0;i<N;i++){
    cin >> X[i];
  }
  ll ans=1e9;
  for(int i=0;i<=N-K;i++){
    if(X[i]*X[i+K-1]<0){
      ans=min(ans,min(2*abs(X[i])+X[i+K-1],abs(X[i])+2*X[i+K-1]));
    }
    else{
      ans=min(ans,max(abs(X[i]),abs(X[i+K-1])));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4040
#include <iostream>

int main(void) {
  std::string S;
  int res = 700;
  std::cin >> S;
  for (int i=0;i < 3;i++) {
    if (S[i] == 'o') res += 100;
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input=sys.stdin.readline
n,x,y=map(int,input().split())
x-=1
y-=1
g=[[] for i in range(n)]
g[x].append(y)
g[y].append(x)
for i in range(n-1):
    g[i].append(i+1)
    g[i+1].append(i)
ans=[0]*n
for i in range(n):
    s=i
    q=deque([s])
    v=[-1]*n
    v[s]=0
    while q:
        p=q.popleft()
        for j in g[p]:
            if v[j]==-1:
                ans[v[p]]+=1
                v[j]=v[p]+1
                q.append(j)
for i in range(n-1):
    print(ans[i]//2)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  int pre = 0;
  int64 ret = 0;
  for(auto &c : A) {
    chmax(pre, c);
    ret += pre - c;
  }
  cout << ret << "\n";
}



Measured memory_bytes: 3984
#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);

    char c[2][3];
    rep (i, 2) rep (j, 3) cin >> c[i][j];

    bool ans = true;
    rep (i, 1)
    {
        rep (j, 3)
        {
            if (c[i][j] != c[1 - i][2 - j])
            {
                ans = false;
            }
        }
    }

    cout << (ans ? "YES\n" : "NO\n");
    return 0;
}



Measured memory_bytes: 764
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        mut ttxxyy: [(isize, isize, isize); n]
    };
    ttxxyy.insert(0, (0, 0, 0));
    for tmp in ttxxyy.windows(2) {
        let a = tmp[0];
        let b = tmp[1];
        let (at, ax, ay) = a;
        let (bt, bx, by) = b;
        let time = bt - at;
        let distance = (bx - ax).abs() + (by - ay).abs();
        if (time < distance) || ((time - distance) % 2 != 0) {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 5844
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<assert.h>
#define gc getchar()
#define lint long long
#define N 200010
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int a[N];
int main()
{
	int n=inn();lint ans=0;
	for(int i=1;i<=n;i++) a[i]=inn();
	for(int i=1,j=1,x=0;i<=n;i++)
	{
		while(x&a[i]) x^=a[j++];
		ans+=i-j+1,x|=a[i];
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

ans = min(R) - max(L)
if ans < 0:
    print(0)
else:
    print(ans + 1)


Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    vector<LL> rui(N+1);
    rui[0] = 0;
    rep(i,N)rui[i+1] = rui[i] + A[i];

    LL ans = INF;

    for(int i = 2;i <= N-2;i++){
        LL ub = i;
        LL lb = 1;
        while(ub - lb > 1){
            LL mid = (ub+lb)/2;
            if(rui[mid] > rui[i] - rui[mid])ub = mid;
            else lb = mid;
        }
        LL p1 = rui[ub]; 
        LL p2 = rui[i] - rui[ub];
        LL q1 = rui[lb];
        LL q2 = rui[i] - rui[lb];
        LL left_min = min(q1,q2);
        LL left_max = max(q1,q2);
        if(abs(p1-p2) < abs(q1-q2)){
            left_min = min(p1,p2);
            left_max = max(p1,p2);
        }

        ub = N;
        lb = i;
        while(ub - lb > 1){
            LL mid = (ub+lb)/2;
            if(rui[mid] - rui[i] > rui[N] - rui[mid])ub = mid;
            else lb = mid;
        }
        LL p3 = rui[lb] - rui[i];
        LL p4 = rui[N] - rui[lb];
        LL q3 = rui[ub] - rui[i];
        LL q4 = rui[N] - rui[ub];
        LL right_min = min(q3,q4);
        LL right_max = max(q3,q4);
        if(abs(p3-p4) < abs(q3-q4)){
            right_min = min(p3,p4);
            right_max = max(p3,p4);
        }

        LL tmp1 = min(right_min,left_min);
        LL tmp2 = max(right_max,left_max);
        LL tmp = abs(tmp1-tmp2);
        ans = min(ans,tmp);

    }
    cout << ans << endl;
}

Measured memory_bytes: 6408
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n,w, a[100007], b[100007], c[100007], dp[105][100005] = {},tmp=0;
	string str, str2[5000];
	cin >> n>>w;

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

	for (int i = 1; i <= n; i++) {
		for (int j = a[i]; j <=w; j++) {
			
			dp[i + 1][j - a[i]] = max(dp[i][j] + b[i], dp[i][j - a[i]]);
			
		}
		for (int j = w-a[i]+1; j <= w; j++) {

			dp[i + 1][j ] = max(dp[i][j],dp[i+1][j]) ;

		}
		for (int j = 0; j <= w; j++) {
			if (tmp < dp[n + 1][i]) { tmp = dp[n + 1][i]; }

		}
	}


	for (int i = 0; i <= w; i++) {
		if (tmp < dp[n + 1][i]) { tmp = dp[n + 1][i]; }

	}
	cout << tmp;
}

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

using namespace std;

// when range [l, r), has property P~notP, want last P.
// when return l-1, means not found.
template <typename T>
T bs_last(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = (l+r)/2;
        if (f(mid)) {
            l = mid + 1;
        }else {
            r = mid;
        }
    }
    return r-1;
}

void solve() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<long long> a(x);
    vector<long long> b(y);
    vector<long long> c(z);
    for (auto& p: a) {
        cin >> p;
    }
    for (auto& p: b) {
        cin >> p;
    }
    for (auto& p: c) {
        cin >> p;
    }
    sort(a.begin(), a.end(), greater<long long>());
    sort(b.begin(), b.end(), greater<long long>());
    sort(c.begin(), c.end(), greater<long long>());
    const long long N = 1e10+10;
    long long p = bs_last<long long>(3, N*3, [&](long long p){
            int cnt = 0;
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < y; j++) {
                    for (int u = 0; u < z; u++) {
                        if (a[i]+b[j]+c[u] < p) break;
                        cnt++;
                        if (cnt >= k) return true;
                    }
                }
            }
            return false;
            });
    vector<long long> res; res.reserve(k);
    auto print = [&](){
        sort(res.begin(), res.end(), greater<long long>());
        for (auto& p: res) {
            cout << p << "\n";
        }
        exit(0);
    };
    int cnt = 0;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int u = 0; u < z; u++) {
                long long tmp = a[i]+b[j]+c[u];
                if (tmp <= p) break;
                res.emplace_back(tmp);
                cnt++;
            }
        }
    }
    for (int _ = 0; _ < k-cnt; _++) {
        res.emplace_back(p);
    }
    print();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)  {
  int S, h, m, s;
  scanf("%d", &S);
  
  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0; 
}

Measured memory_bytes: 1796
N,M=map(int,input().split())
original_paths={}
for n in range(1,N+1):
    original_paths[n]=[]
for m in range(1,M+1):
    s,e=map(int,input().split())
    original_paths[s].append(e)
    original_paths[e].append(s)#以上地図(原本)作り
    
visited=[1]
current_point=1
answer=0
import copy
paths=copy.deepcopy(original_paths)

while len(paths[1])!=0:#すべてのルートを探索済み==点1から動けない
    
    if len(paths[current_point])!=0:
        next_point=paths[current_point][0]
    
        if next_point in visited:#next_pointに行ったことがある

            if len(paths[current_point])!=1:#next_point以外に選択肢がある
                paths[current_point].remove(next_point)#next_pointを選択肢から消す

            else:#next_point以外に選択肢がない(current_pointは行き止まり)
                if len(visited)==N:#すべての点を訪れたかチェック
                    answer+=1
                prior_point=visited[-2]#ひとつ前にいた点をprior_pointとし、
                paths[current_point]=original_paths[current_point].copy()#current_pointからの選択肢を初期化
                paths[prior_point].remove(current_point)#prior_pointの選択肢からcurrent_pointを除く
                visited.remove(current_point)#current_pointをvisitedから除き、
                current_point=prior_point#prior_pointに戻る

        else:#next_pointに行ったことがない
            visited.append(next_point)#next_pointをvisitedに加え、
            current_point=next_point#next_pointに進む

    else:
        prior_point=visited[-2]#ひとつ前にいた点をprior_pointとし、
        paths[current_point]=original_paths[current_point].copy()#current_pointからの選択肢を初期化
        paths[prior_point].remove(current_point)#prior_pointの選択肢からcurrent_pointを除く
        visited.remove(current_point)#current_pointをvisitedから除き、
        current_point=prior_point#prior_pointに戻る
        
print(answer)


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int h[n];
    int m=0;
    int co=0;
    for(int i=0;i<n;i++){
        cin >> h[i];
        if(m<=h[i]){
            co++;
            m=h[i];
        }
    }
    cout <<co<< endl;
    return 0;
}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

vector<int> dp(100010, -1);

int choose(int now){
    if(now <= 0){
        return !!now * 1e9;
    }else if(dp[now] != -1){
        return dp[now];
    }else{
        int ans = 1e9;
        for(int i = 1; i <= now; i *= 6){
            ans = min(ans, choose(now - i));
        }
        for(int i = 1; i <= now; i *= 9){
            ans = min(ans, choose(now - i));
        }
        return dp[now] = ans + 1;
    }
}

int main(){
    int N;
    cin >> N;
    cout << choose(N) << endl;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    set<int>s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s.insert(a[i]);
    }
    
    int current_different = s.size();
    
    if(current_different <= k){
        cout << 0 << endl;
    }else {
        //cout << current_different << endl;
        int result = 0;
        set<pair<int, int>>new_s;
        map<int, int>mp;
        for(int i = 0; i < n; i++){
            mp[a[i]] += 1;
        }
        for(auto v : mp){
            new_s.insert(make_pair(v.second, v.first));
        }
        
        while(current_different > k){
            auto it = new_s.begin();
            current_different -= 1;
            result += it->first;
            new_s.erase(it);
        }
        
        cout << result << endl;
    }
}


Measured memory_bytes: 32304
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second

using namespace std;


ll a[200200];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0) ,cout.tie(0);
    int n; cin >> n;
    for(int i = 1;i <= n;i++)
        cin >> a[i];
    map<ll,ll>m;
    ll ans = 0;
    for(int i = n;i >= 1;i--){
        ans += m[a[i] + i];
        m[i - a[i]]++;
    }
    cout <<ans << '\n';


    return 0;
}


Measured memory_bytes: 27844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  cout<<(int)pow(N,3)<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
np = n

if k == 1:
    n = 0
else:  
    while abs(n - k) < np:
        i = 1
        if k ** i < n:
            while k ** i < n :
                i += 1
            n = n - k ** (i - 1)
        np = n
        n = abs(n - k)
print(n)


Measured memory_bytes: 3060
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

N, K = map(int, input().split())
od = OrderedDict()

for i in range(N):
    a, b = map(int, input().split())
    if a not in od:
        od[a] = b
    else:
        od[a] += b
od = OrderedDict(sorted(od.items(), key=lambda x: x[0]))

for i in od.items():
    K -= i[1]

    if K <= 0:
        print(i[0])
        exit()


Measured memory_bytes: 118612
#include <bits/stdc++.h>
#define MAXN 200000
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    int x[MAXN]={0},b[MAXN]={0};
    for (int i=0;i<N;i++){
	cin >> x[i];
	b[i]=x[i];
    }

    sort(b,b+N);
    for (int i=0;i<N;i++){
	if (x[i] <= b[(N/2)-1]){
	    cout << b[N/2] << endl;
	} else {
	    cout << b[(N/2)-1] << endl;
	}
    }

    return 0;
}

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

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b;
    cin >> a >> b;
    if(a%b==0){
      cout << 0 << endl;
    }else cout << 1 << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
# 二項係数のmod (大量のmod計算が必要なとき)
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r=min(r,n-r)

    return g1[n] * g2[r] * g2[n - r] % mod

def per(n, r, mod):
    if (r < 0 or r > n):
        return 0

    return g1[n] * g2[n-r]  % mod

mod = 10 ** 9 + 7
N = 10 ** 6 # 出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

n,m= map(int, input().split())

# 順列の総数
ans=per(m,n,mod)


cnt=0
for i in range(n+1):
    if i%2==0:
        cnt+=per(m-i,n-i,mod)*cmb(n,i,mod)
    else:
        cnt-=per(m-i,n-i,mod)*cmb(n,i,mod)

    cnt%=mod
print((ans*cnt)%mod)


Measured memory_bytes: 212456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << n << ":";
  for (int i = 2; n > 1; i++) {
    if (i * i > n) break;
    while (n % i == 0) {
      cout << " " << i;
      n /= i;
    }
  }
  if (n > 1) cout << " " << n;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
     
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
const ll MOD2 = 1e9 + 7;
const int MOD = 1e9 + 7;
 
const ull infull = numeric_limits<unsigned long long>::max();
 
void fix(int &x, ll MOD) {
    x = (x % MOD);
    if(x < 0) x += MOD;
    return;
}
 
ll lgput(ll a, ll b, ll MOD) {
    ll ret = 1;
    a %= MOD;
    while(b) {
        if(b&1) ret = ret*a % MOD;
        a = a*a % MOD;
        b >>= 1;
    }
 
    return ret;
}
 
ll inv(ll a, ll MOD) {
    return lgput(a, MOD-2, MOD);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};

using Mint = ModInt<998244353>;

int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));

    ll n, k;
    cin >> n >> k;

    cout << min(n % k, k - n % k);
    return 0; 
}

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

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

    int count = 0;
    int coordinate = 0;
    for(int i = 0; i <= n; i++) {
        if(i > 0) {
            int l;
            cin >> l;
            coordinate += l;
        }
        if(coordinate <= x) count++;
        else break;
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1234567
using namespace std;
typedef long long ll;
int main()
{
    string s,t;
    cin>>s>>t;
    string ans="";
    for(int i=0;i<t.size()-1;i++) ans+=t[i];
    if(ans == s) puts("Yes");
    else puts("No");
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    int sum = 0;

    rep(i, n)
    {
        while (a[i] % 2 == 0)
        {
            sum++;
            a[i] /= 2;
        }
    }

    OP(sum);

    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int N; cin >> N;

	for (int i = 1; i <= N; i++)
	{
		int a = std::to_string(i).length();
		if(a%2==1){ans++;}
	}
	

	cout << ans << endl;
}


Measured memory_bytes: 256
s = list(map(str,input()))
if s[0] != "A":
  print("WA")
elif s[2:-1].count("C") != 1:
  print("WA")
else:
  del s[0]
  s.remove("C")
  if "".join(s).islower():
    print("AC")
  else:
    print("WA")

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,K,C;string S;
    cin>>N>>K>>C>>S;
    vector<bool> work(N);
    vi bk(N,0);
    vi fr(N,0);
    int first_work=99999999,last_work=0;
    for(int i=0;i<N;i++){
        work[i]=(S[i]=='o')?true:false;
        if(work[i]){
            first_work=min(first_work,i);
            last_work=max(last_work,i);
        }
    }
    //cout<<first_work<<" "<<last_work<<endl;

    int checkpoint=first_work;
    bool next_add=true;
    for(int i=checkpoint+1;i<N;i++){
        if(next_add){
            next_add=false;
            bk[i]=bk[i-1]+1;
        }else{
            bk[i]=bk[i-1];
        }
        if(work[i] && checkpoint+C<i){
            checkpoint=i;
            next_add=true;
        }
    }

    reverse(ALL(work));//反転
    checkpoint=N-last_work-1;
    next_add=true;
    for(int i=checkpoint+1;i<N;i++){
        if(next_add){
            next_add=false;
            fr[i]=fr[i-1]+1;
        }else{
            fr[i]=fr[i-1];
        }
        if(work[i] && checkpoint+C<i){
            checkpoint=i;
            next_add=true;
        }
    }
    reverse(ALL(fr));

    // for(int i=0;i<N;i++){
    //     cout<<bk[i]<<" ";
    // }
    // cout<<endl;
    // for(int i=0;i<N;i++){
    //     cout<<fr[i]<<" ";
    // }
    // cout<<endl;

    for(int i=0;i<N;i++){
        if(fr[i]+bk[i]<K){
            cout<<i+1<<endl;
        }
    }
}


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

double avg(int *a, int l) {
  int i, s = 0;

  for (i = 0; i < l; i++) {
    s += a[i];
  }

  return (double) s / l;
}

int main(void) {
  int n, i, s[1000];
  double m, t, a;

  for (;;) {
    scanf("%d", &n);

    if (n == 0) {
      break;
    }

    for (i = 0; i < n; i++) {
      scanf("%d", &s[i]);
    }

    m = avg(s, n);

    for (t = 0, i = 0; i < n; i++) {
      t += pow(s[i] - m, 2);
    }

    a = sqrt(t / n);

    printf("%f\n", a);
  }

  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int n, l, t, w, s[2], u[2];
long long nw[mx], cnt, x;

int main(){
  scanf("%d%d%d", &n, &l, &t);
  s[0] = t % l;
  s[1] = l - s[0];
  u[0] = t / l;
  u[1] = - 1 - u[0];
  for(int i = 0; i < n; i++){
    scanf("%lld%d", &x, &w);
    w--; x += s[w];
    nw[i] = x % l;
    cnt += u[w] + x / l;
  }
  while(cnt < 0) cnt += n;
  sort(nw, nw+n);
  rotate(nw, nw + cnt%n, nw+n);
  for(int i = 0; i < n; i++) {
    printf("%lld\n", nw[i]);
  }
}

Measured memory_bytes: 1920
def main():
    limit, remainder_min = map(int, input().split(" "))
    answer = 0
    if remainder_min:
        for i in range(1, limit + 1):
            answer += max(0, i - remainder_min) * (limit // i) + max(0, limit % i - remainder_min + 1)
    else:
        answer = limit ** 2
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060