akhauriyash/Code-Regression huggingface dataset:
/*
Author: yww
Language: C++
Mail: weeerrr720@qq.com
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
int main()
{
	int n;
	db ans=0,x;
	char str[10];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf%s",&x,str);
		if(str[0]=='J')
			ans+=x;
		else
			ans+=x*380000.0;
	}
	printf("%.20lf\n",ans);
	return 0;
}

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

int main() {
  char S;
  cin >> S;
  if (isupper(S)) cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}

Measured memory_bytes: 3596
import scala.io.StdIn
import scala.collection.mutable._

object Main extends App {

  val Array(n, m) = StdIn.readLine.split(" ").map(_.toInt)
  val graph = Array.fill(n+1)(ListBuffer.empty[Int])
  Iterator.continually(StdIn.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => graph(e(0)) += e(1))

  val visit = Array.ofDim[Boolean](n+1)
  def dfs(pos:Int, cnt:Int):Unit = {
    if(cnt < 0) return
    visit(pos) = true
    // print(pos + " ")
    for(i <- graph(pos)) {
      dfs(i, cnt-1)
    }
  }

  dfs(1,2)
  val ans = if(visit(n)) "POSSIBLE" else "IMPOSSIBLE"
  println(ans)
}

Measured memory_bytes: 81268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  int c[N];
  int t[N];
  for (int i = 0; i < N; i++)
    cin >> c[i] >> t[i];
  int ans = 114514;
  for (int i = 0; i < N; i++)
    if (t[i] <= T)
      ans = min(c[i], ans);
  if (ans != 114514)
    cout << ans << endl;
  else
    cout << "TLE" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;



//重複を含まないようにする

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine().Split(' ');
            int n, l;
            n = int.Parse(s[0]);
            l = int.Parse(s[0]);
            var list = new List<string>();
            
            for (int i = 0; i < n; i++)
            {
                s = ReadLine().Split(' ');
                list.Add(s[0]);
            }
            list.Sort();
            string ans = list[0];


            for (int i = 1; i < n; i++)
            { ans += list[i]; }

            WriteLine(ans);
            Out.Flush();
        }

    }

    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }
}

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  int A[N];
  rep(i, N){
    cin >> A[i];
    A[i] %= K;
  }

  int sum[N+1] = {};
  map<int, int> mp;
  for(int i=1;i<=N;i++){
    sum[i] = sum[i-1] + A[i-1] - 1;
    sum[i] %= K;
    if(sum[i] < 0){
      sum[i]+=K;
    }
  }

  for(int i=1;i<min(K, N+1);i++){
    mp[sum[i]]++;
  }
  int ans = mp[0];
  for(int i=1;i<=N;i++){
    mp[sum[i]]--;
    if(i+K-1 <= N){
      mp[sum[i+K-1]]++;
    }
    ans += mp[sum[i]];
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,c;
  int x[111111],v[111111];
  cin>>n>>c;
  for(int i=0;i<n;i++)
    cin>>x[i]>>v[i];
  int suv[111111]={};
  int sma[111111]={};
  int sm[111111]={};
  int ma=0,iv=0,k;
  
  int suv2[111111]={};
  int sma2[111111]={};
  int sm2[111111]={};
  int ma2=0,iv2=0,k2;
  //cout<<endl;
  
  for(int i=0;i<n;i++){
    int t=ma;
    iv+=v[i];
    suv[i]=iv;
    ma=max(ma,iv-x[i]);
    sma[i]=ma;
    if(t!=ma)k=i;
    sm[i]=x[k];
    int ni=n-1-i;
    int t2=ma2;
    iv2+=v[ni];
    suv2[i]=iv2;
    ma2=max(ma2,iv2-(c-x[ni]));
    sma2[i]=ma2;
    if(t2!=ma2)k2=ni;
    sm2[i]=x[k2];
  }
  int ans=max(ma,ma2);
  // cout<<ans<<endl;
  for(int i=0;i<n-1;i++){
    ans=max(ans,sma[n-2-i]+suv2[i]-2*(c-x[n-1-i]));
    ans=max(ans,sma2[n-i-2]+suv[i]-2*x[i]);
    //cout<<sma[n-i-2]<<" "<<suv2[i]<<" "<<2*(c-x[n-1-i])<<endl;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;
ll A,B;
ll digit = 1;
ll val = 1;
ll ans = 0;

int main(){
    cin >> A >> B;
    A -= 1;
    ll a = 0;
    ll b = 0;
    if(A % 4 == 1 || A % 4 ==2){
        a = 1;
    }
    if(B % 4 == 1 || B % 4 ==2){
        b = 1;
    }
    ans += abs(a-b)*val;
    digit += 1;
    val *= 2;
    while(B >= val){
        a = 0;
        b = 0;
        if((A % (val*2)) >= val && (A%(val*2)) %2 == 0){
            a = 1;
        }
        if((B % (val*2)) >= val && (B%(val*2)) %2 == 0){
            b = 1;
        }
        //cout << a << b << endl;
        ans += abs(a-b)*val;
        digit += 1;
        val *= 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
  
  	if(n % 1000 == 0){
    	cout << 0 << endl;
      	return 0;
    }
  	else{
    	cout << 1000 - (n%1000) << endl;
      	return 0;
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
int c[26];

int main(void) {
    char ch;
    while( scanf( "%c", &ch ) != EOF ) {
        if( 'a' <= ch && ch <= 'z' ){
            c[ ch - 'a' ]++;
        } else if( 'A' <= ch && ch <= 'Z' ) {
            c[ ch - 'A' ]++;
        }
    }
    for( int i = 0; i < 26; i++ ){
        printf( "%c : %d\n", 'a' + i, c[i] );
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  string s,t;cin>>s>>t;
  bool e=true;
  ll k=0;
  rep(i,0,n){
    if(s[i]==t[k]){
      k++;
      e=true;
    }else e=false;
  }
  if(e)out(2*n-k);
  else out(2*n);
  // if(e)out(s+t.substr(k,n-k));
  // else out(s+t);



  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
if n==1:
  print((2*arr[0])%mod)
else:
  table=[1]
  for _ in range(n):
    tmp=table[-1]*2
    tmp%=mod
    table.append(tmp)
  for i in range(n):
    if i==n-1:    
      ans+=(table[i-1]*(n-i+1)*arr[i])%mod
    else:
      ans+=(table[i]*(n-i+1)*table[n-i-2]*arr[i])%mod
  print((ans*table[n])%mod)

Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;
    int p11 = 1;
    int p12 = 1;
    int p2 = 2;
    int p31 = 3;
    int p32 = 3;
    long long P1 = A[0];
    long long Q1 = A[1];
    long long R1 = A[2];
    long long S1 = accumulate(A.begin(), A.end(), 0LL) - P1 - Q1 - R1;
    long long P2 = P1;
    long long Q2 = Q1;
    long long R2 = R1;
    long long S2 = S1;
    long long ans = max(max(P1,Q1),max(R1,S1)) - min(min(P1,Q1),min(R1,S1));
    while (true)
    {
        while (p11<p2-1 && P1<Q1)
        {
            p11++;
            P1 += A[p11-1];
            Q1 -= A[p11-1];
        }
        while (p12<p2-1 && P2<Q2)
        {
            p12++;
            P2 += A[p12-1];
            Q2 -= A[p12-1];
        }
        if (1<p12)
        {
            P2 -= A[p12-1];
            Q2 += A[p12-1];
            p12--;
        }

        while (p31<N-1 && R1<S1)
        {
            p31++;
            R1 += A[p31-1];
            S1 -= A[p31-1];
        }
        while (p32<N-1 && R2<S2)
        {
            p32++;
            R2 += A[p32-1];
            S2 -= A[p32-1];
        }
        if (p32>p2+1)
        {
            R2 -= A[p32-1];
            S2 += A[p32-1];
            p32--;
        }

        ans = min(ans, max(max(P1,Q1),max(R1,S1)) - min(min(P1,Q1),min(R1,S1)));
        ans = min(ans, max(max(P2,Q2),max(R1,S1)) - min(min(P2,Q2),min(R1,S1)));
        ans = min(ans, max(max(P1,Q1),max(R2,S2)) - min(min(P1,Q1),min(R2,S2)));
        ans = min(ans, max(max(P2,Q2),max(R2,S2)) - min(min(P2,Q2),min(R2,S2)));

        p2++;
        if (p2==N-1)
            break;
        Q1 += A[p2-1];
        R1 -= A[p2-1];
        Q2 += A[p2-1];
        R2 -= A[p2-1];
        if (p31==p2)
        {
            p31++;
            R1 += A[p31-1];
            S1 -= A[p31-1];
        }
        if (p32==p2)
        {
            p32++;
            R2 += A[p32-1];
            S2 -= A[p32-1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int r;cin >> r;
  cout << 6.28318530717958623200*r << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3864
#include <stdio.h>

int main(void)
{

	int num;
	long a;
	int ii;
	char c;
	long min, max, total;

	scanf("%ld", &num);

	min = 9999999;
	max = -9999999;
	total = 0;
	for (ii = 0; ii < num; ii++) {
		scanf("%ld", &a);
		if (min > a) {
			min = a;
		}
		if (max < a) {
			max = a;
		}
		total += a;

		if (ii < num - 1) {	//空白読み飛ばし(最後以外)
			scanf("%c", &c);
		}

	}

	printf("%ld %ld %ld\n", min, max, total);

	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

void solve(long long N, long long M, long long K, std::vector<long long> A,
           std::vector<long long> B) {
    vector<long long> X, Y;
    X.push_back(0);
    Y.push_back(0);
    rep(i,N) X.push_back(A[i]);
    rep(i,M) Y.push_back(B[i]);
    loop(i, 1, X.size()) X[i] += X[i-1];
    loop(i, 1, Y.size()) Y[i] += Y[i-1];

    int ans = 0;
    rep(i, X.size()) {
        auto k = K - X[i];
        if (0 <= k) {
            int j = upper_bound(Y.begin(), Y.end(), k) - Y.begin();
            ans = max(ans, i + j - 1);
        }
    }

    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &B[i]);
    }
    solve(N, M, K, std::move(A), std::move(B));
    return 0;
}


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

using namespace std;

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; ++i) {
    cin >> grid[i];
  }

  int max_dst = 0;

  const vector<pair<int, int>> adjs{
      {1, 0},
      {-1, 0},
      {0, 1},
      {0, -1},
  };

  for (int r = 0; r < h; ++r) {
    for (int c = 0; c < w; ++c) {
      if (grid[r][c] == '.') {
        vector<vector<int>> dst(h, vector<int>(w, INT_MAX));
        using Elem = tuple<int, int, int>;
        auto cmp = [](auto&& a, auto&& b) {
          return get<0>(a) > get<0>(b);
        };
        priority_queue<Elem, vector<Elem>, decltype(cmp)> q{cmp};
        // priority_queue<Elem, vector<Elem>, greater<Elem>> q;
        dst[r][c] = 0;
        q.emplace(0, r, c);
        while (!q.empty()) {
          int d, row, col;
          tie(d, row, col) = q.top();
          q.pop();
          if (d != dst[row][col])
            continue;
          max_dst = max(max_dst, d);
          for (auto&& adj : adjs) {
            auto arow = row + adj.first;
            auto acol = col + adj.second;
            if (0 <= arow && 0 <= acol && arow < h && acol < w &&
                grid[arow][acol] == '.' && d + 1 < dst[arow][acol]) {
              dst[arow][acol] = d + 1;
              q.emplace(d + 1, arow, acol);
            }
          }
        }
      }
    }
  }

  cout << max_dst << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> P;

int N, Q;
int father[MAXN];
bool vis[MAXN];

void Init() {
	for (int i = 0; i < MAXN; ++i) {
		father[i] = i;
	}
}
int Find(int x) {
	if (father[x] == x)
		return x;
	return Find(father[x]);
}

int main(int argc, char const *argv[]) {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	while (scanf("%d%d", &N, &Q) != EOF && !(N == 0 && Q == 0)) {
		int a, b;
		LL res = 0;
		char opt[5];
		Init();
		for (int i = 2; i <= N; ++i) {
			scanf("%d", &father[i]);
		}
		for (int i = 0; i < Q; ++i) {
			scanf("%s %d", opt, &b);
			if (opt[0] == 'Q') {
				res += Find(b);
			}
			else
				father[b] = b;
		}
		printf("%lld\n", res);
	}
	//system("pause");
	return 0;
}



Measured memory_bytes: 3516
fun main(args: Array<String>) {
    val S = next()
    val K = nextInt()
    val A = mutableListOf<String>()
        for (n in 0 until S.length) {
        for (m in 0 until Math.min(K, S.length - n)) {
            A.add(S.substring(n .. (n + m)))
        }
    }
    var B = A.sorted().distinct()
    println(B[K - 1])
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }


Measured memory_bytes: 42320
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int a[112345];
signed main() {
	int n, i, t;
	cin >> n;
	for (i = 1; i <= n; ++i) {
		cin >> t;
		a[t] = i;
	}
	for (i = 1; i <= n; ++i)cout << a[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(void) {
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=0;i<n;i++) cin>>a[i+1];
    vector<int> b(n+1);
    for(int i=n;i>=1;i--){
        int sum=0;
        for(int j=i+i;j<=n;j+=i){
            sum^=b[j];
        }
        b[i]=sum^a[i];
    }
    vector<int> ans;
    for(int i=1;i<=n;i++){
        if(b[i]) ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    string s;

    cin >> s;

    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
  }
}

Measured memory_bytes: 3652
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


N = int(input())
if N == 1:
    print(0)
    exit(0)

ar = factorization(N)
ans = 0
for i in range(len(ar)):
    tmp = 0
    for j in range(1, 100):
        tmp += j
        if tmp > ar[i][1]:
            ans += j-1
            break

print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e18 + 5;

ll N, K;
vector<ll> A, B;

bool check(ll m) {
    ll sum = 0;
    //! A*Bの中で数える
    REP(i, A.size()) {
        ll a = A[i];
        ll ok = -1, ng = B.size();
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (a * B[mid] <= m)
                ok = mid;
            else
                ng = mid;
        }
        sum += ok + 1;
    }

    //! A*Aの中で考える
    REP(i, A.size()) {
        ll ok = i, ng = A.size();
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (A[i] * A[mid] <= m)
                ok = mid;
            else
                ng = mid;
        }
        sum += ok - i;
    }

    //! B*B
    REP(i, B.size()) {
        ll ok = B.size(), ng = i;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (B[i] * B[mid] <= m)
                ok = mid;
            else
                ng = mid;
        }
        sum += B.size() - ok;
    }

    return sum >= K;
}

int main() {
    cin >> N >> K;
    REP(i, N) {
        ll a;
        cin >> a;
        if (a > 0)
            A.push_back(a);
        else
            B.push_back(a);
    }
    sort(A.begin(), A.end(), [](ll a, ll b) { return a < b; });
    sort(B.begin(), B.end(), [](ll a, ll b) { return a < b; });
    ll ans = INF, ng = -INF;
    while (abs(ans - ng) > 1) {
        ll mid = (ans + ng) / 2;
        if (check(mid))
            ans = mid;
        else
            ng = mid;
    }
    cout << ans << endl;
    return 0;
}

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>> tu(n);
  for(int i =0; i<n ;i++){
    string s;
    int p;
    cin>>s>>p;
    tu[i] = make_tuple(s,100-p, i+1);
  }
  sort(tu.begin() , tu.end());
  for(int i ; i<n ;i++){
    cout << get<2>(tu[i])<<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

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

typedef pair<int,mp> mmp;
typedef pair<int,mmp> fmp;


int main(void){
	for(;;){
		int w,h;
		scanf("%d%d",&w,&h);
		if(h==0)break;
		int dat[35][35]={};
		memset(dat,-1,sizeof(dat));
		reg(y,1,h){
			reg(x,1,w){
				scanf("%d",&dat[y][x]);
			}
		}
		int cs[4];
		rep(i,4)scanf("%d",&cs[i]);
		
		int dp[35][35][4];
		memset(dp,-1,sizeof(dp));
		
		priority_queue<fmp,vector<fmp>,greater<fmp> > que;
		que.push(fmp(0,mmp(0,mp(1,1))));
		
		while(!que.empty()){
			fmp fpa = que.top(); que.pop();
			int co=fpa.fir,
				nd=fpa.sec.fir,
				y=fpa.sec.sec.fir,
				x=fpa.sec.sec.sec;
			
			//printf("%d %d %d %d\n",co,nd,y,x);
			
			if(dat[y][x]<0)continue;
			if(dp[y][x][nd]!=-1 && dp[y][x][nd]<=co)continue;
			dp[y][x][nd]=co;
			
			if(x==w && y==h){
				printf("%d\n",co);
				break;
			}
			
			
			rep(i,4){
				int tc=co;
				if(dat[y][x]!=i)tc+=cs[i];
				
				int tx=x,ty=y,td=nd;
				if(i!=0)td=(td+i)%4;
				tx+=dx[td];
				ty+=dy[td];
				
				//printf("push_ %d %d %d %d\n",tc,td,ty,tx);
				que.push(fmp(tc,mmp(td,mp(ty,tx))));
			}
		}
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '1')
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
def check_gu(s):
    n = len(s)
    if n%2!=0:
        return False
    return s[:n//2] == s[n//2:]

if __name__ == '__main__':
    s=input()

    for i in range(1,len(s)):
        ss = s[:len(s)-i]
        if(check_gu(ss)):
            print(len(ss))
            break


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

public class Main {

    public static int[] intInputs = new int[4];

    static String combination = "";

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        char[] inputs = reader.readLine().toCharArray();
        for (int i = 0; i < 4; i++) {
            intInputs[i] = Character.getNumericValue(inputs[i]);
        }
        String suffix = "=7";
        solve(1, intInputs[0], 7, "");

        StringBuilder result = new StringBuilder("" + String.valueOf(intInputs[0]));
        for (int i = 0; i < 3; i++) {
            result
                    .append(combination.charAt(i))
                    .append(String.valueOf(intInputs[i + 1]));
        }

        System.out.println(result + suffix);

    }

    public static void solve(int index, int currentValue, int targetValue, String base) {
        if (index == 4 && currentValue == targetValue) {
            combination = base;
        } else if (index < 4) {
            solve(index + 1, currentValue + intInputs[index], targetValue, base + "+");
            solve(index + 1, currentValue - intInputs[index], targetValue, base + "-");
        }
    }


}


Measured memory_bytes: 23124
import Control.Applicative
import Data.List

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve n = minimumBy f ps
  where
    ps = filter isPal [1..9999]
    f a b = compare (abs (a - n)) (abs (b - n))
isPal :: Int -> Bool
isPal n = let ns = unfoldr f n
          in (reverse >>= (==)) ns
  where
    f 0 = Nothing
    f x = Just $ let (q, r) = divMod x 10 in (r, q)



Measured memory_bytes: 4216
#include<stdio.h>
#include<stdlib.h>
#define MAXN 15
n,N,i[MAXN],d[MAXN],w[MAXN],W[1<<MAXN],DP[MAXN][1<<MAXN];
K,k,k0,p;
long long DT[MAXN][1<<MAXN],t,t0,t1,tmin;
P(k,K){
	if(K&(1<<k)){
		K-=1<<k;
		P(DP[k][K],K);
		K+=1<<k;
		printf("%d%c",i[k],K==N-1?'\n':' ');
	}
}
main(){
	scanf("%d",&n);
	N=1<<n;
	for(k=0;k<n;k++)
		scanf("%d%d%d",i+k,d+k,w+k);
	for(K=0;K<N;K++){
		W[K]=70;
		for(k=0;k<n;k++){
			if(K&(1<<k))
				W[K]+=w[k]*20;
		}
	}
	for(K=1;K<N-1;K++){
		for(k=0;k<n;k++){
			if(!(K&(1<<k))){
				tmin=1e18;
				for(k0=0;k0<n;k0++){
					if(K&(1<<k0)){
						t0=DT[k0][K-(1<<k0)];
						t1=(long long)abs(d[k0]-d[k])*W[K];
						t=t1+t0;
						if(t<tmin){
							tmin=t;
							p=k0;
						}
					}
				}
				DT[k][K]=tmin;
				DP[k][K]=p;
			}
		}
	}
	tmin=1e18;
	for(k=0;k<n;k++){
		t=DT[k][N-1-(1<<k)];
		if(t<tmin){
			tmin=t;
			k0=k;
		}
	}
	P(k0,N-1);
	return 0;
}

Measured memory_bytes: 3608
n = gets.chomp.to_i
ar = []
n.times do |num|
  ar << gets.chomp.to_i
end
m = 10000000000000000
d = -10000000000000000000000000
ar.each do |i|
  n = i.to_i
  a = n - m 
  d = a if a > d
  m = n if m > n 
end
p d

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

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,t;
	cin>>n;
	t=n/15;
	cout<<800*n-t*200;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    res = ["AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHABR","KIHBAR","AKIHBR","KIHBR"]
    s = input().rstrip()
    for i in res:
        if i == s:
            print('YES')
            break
    else:
        print('NO')


if __name__ == '__main__':
    main()

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    vector<ll> cum(n+1, 0);
    rep(i, n) {
        cum[i+1] = cum[i] + a[i];
    }

    int l = 1;
    int r = 3;
    ll ans = LINF;
    for (int m = 2; m <= n-2; m++) {
        if (r <= m) r = m+1;
        while (l+1 < m && abs(cum[l+1] - (cum[m] - cum[l+1])) <= abs(cum[l] - (cum[m] - cum[l]))) ++l;
        while (r+1 < n && abs(cum[r+1] - cum[m] - (cum[n] - cum[r+1])) <= abs(cum[r] - cum[m] - (cum[n] - cum[r]))) ++r;
        ll mn = min({cum[l], cum[m]-cum[l], cum[r]-cum[m], cum[n]-cum[r]});
        ll mx = max({cum[l], cum[m]-cum[l], cum[r]-cum[m], cum[n]-cum[r]});
        ans = min(ans, mx - mn);
    }

    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int c[3][3],flag=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
        
    }
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if((c[i][j]-c[i+1][j])!=(c[i][j+1]-c[i+1][j+1]))    flag=1;
            if((c[i][j]-c[i][j+1])!=(c[i+1][j]-c[i+1][j+1]))    flag=1;
        }
    }
    if(flag == 0)   cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 1000000007
#define MAX 100005

typedef long long ll;
//typedef int ll;
typedef double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

/********************************************************/

signed main()
{
    boost;
    #ifndef ONLINE_JUDGE
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    #endif // ONLINE_JUDGE
    
    ll tests = 1LL;
    //cin >> tests; 
    rep(testno,1,tests+1){
       //cout<<"Case #"<<testno<<": ";

       ll n;
       cin >> n;
       cout << (((n+999)/1000)*1000) - n << endl;
    }

    return 0;

}



Measured memory_bytes: 3632
n=int(input())
if(n<10):
  x=n
elif(n<100):
  x=9
elif(n<1000):
  x=n-90
elif(n<10000):
  x=9+900
elif(n<100000):
  x=n-90-9000
elif(n==100000):
  x=90909
print(x)

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  string s;
  cin>>s;
  rep(i,s.size()-1)if(s[i]=='A'&&s[i+1]=='C'){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;



}


Measured memory_bytes: 764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long n = sc.nextLong();
    if(b>n){
      long p =(long)(Math.floor((a*n)/b)-a*Math.floor(n/b));
      System.out.println(p);
    }
    else{
      long x = b-1;
      long p =(long)(Math.floor((a*x)/b)-a*Math.floor(x/b));
      System.out.println(p);
    }
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  
  int count = 0;
  for (int i = 0; i < A+B+1; i++) {
    if (S[i] == '-') count++;
  }
  
  if (count == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='-')cout<<a-b;
	else cout<<a+b;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解答写し
int main(){
	int n;
	long long c, a, b;
	vector <pair<long long, long long>> v;
    vector<long long > A(100001,0);
	vector<long long > B(100001,0);
	cin >> n >> c; 
	for (int i = 0; i<n; i++){
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	} 
	long long res = 0;
	long long sum = 0; 
	for (int i = 0; i < n; i++){//時計回り
		sum += v[i].second;//寿司のカロリーを足す
		if (i == 0){
			B[i] = sum - v[i].first;//消費したカロリーを引く
		}else{
			B[i] = max(B[i - 1], sum - v[i].first);//消費したカロリーを引く
		}
	} 
	sum = 0;
	for (int i = n - 1; i >= 0; i--){//反時計回り
		sum += v[i].second;//寿司のカロリーを足す
		if (i == n - 1){
			A[i] = sum - (c - v[i].first);//消費したカロリーを引く
		}else{
			A[i] = max(A[i + 1], sum - (c - v[i].first));//消費したカロリーを引く          
		}
	} 
	for (int i = 0; i<n; i++){
		res = max(res, B[i]);//時計回りの最大カロリーの値を調べる
		if (i != n - 1){
			res = max(res, B[i] - v[i].first + A[i + 1]);
		}
	} 
	for (int i = n - 1; i >= 0; i--){//反時計回りの最大カロリーも調べる
		res = max(res, A[i]);
		if (i != 0){
			res = max(res, A[i] - (c - v[i].first) + B[i - 1]);
		}
	} 
	cout << res << '\n';//endlは遅いのでこちらを使う習慣をつける
	return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a,b;
int main(){
	cin>>n>>a>>b;
	cout<<min(n,min(a,b))<<' '<<max(0,a+b-n);
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
#define E 0.0000001

int main(){
    long double a, b, c;
    cin >> a >> b >> c;

    if((sqrt(a) + sqrt(b)) + 1.0E-14 < sqrt(c)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import os
import itertools
from math import *
    
pnum = int(input())

ctime = []
for i in range(5):
    ctime.append(int(input()))
    
#最小値をさがす
bneck = min(ctime)
bn_index = ctime.index(bneck)

#ボトルネック到達にかかる時間
bn_start_time = bn_index

#ボトルネックを通過するのにかかる時間
bn_thow_time = ceil(pnum / bneck)

#残りの移動にかかる時間
bn_nokori_time = 5 - bn_index

print(bn_index + bn_thow_time + bn_nokori_time - 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 3e5 + 1;
const char newl = '\n';

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return 0;
}

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

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

  vl a(n);
  rep(i, n) cin >> a[i];

  atcoder::segtree<ll, op, e> dp(MAX);
  ll ans=0;
  rep(i, n) {
    dp.set(a[i], dp.prod(max(a[i]-k, 0LL), min(a[i]+k+1, MAX)) + 1);
    chmax(ans, dp.get(a[i]));
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 16136
import java.util.*;

public class Main{
    public static final long INF = (int)1e9;
    public static int[][][] dp;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        char[] s = sc.next().toCharArray();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(""+s[i]);
        }
        
        dp = new int[n+1][4][1001];
        for(int i=0; i<n; i++){
            for(int j=2; j>=0; j--){
                for(int k=0; k<1000; k++){
                    if(j>0 && dp[i][j-1][k]==1 && k*10+a[i]<1000){
                        dp[i+1][j][k*10+a[i]] = 1;
                    }
                    if(dp[i][j][k]==1){
                        dp[i+1][j][k] = 1;
                    }
                }
            }
            dp[i+1][0][a[i]] = 1;
        }
        
        int ans = 0;
        for(int i=0; i<1000; i++){
            if(dp[n][2][i]>=1){
                //System.out.println(" :" + i);
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}



Measured memory_bytes: 717844
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line;
        Long n=null;
        Long d=null;
        Long currentLine=0L;
        Long count=0L;
        while ((line = stdin.readLine()) != null && currentLine!=n) {
            if (n==null) {
                var splited = line.split(" ");
                n = Long.valueOf(splited[0]);
                d = Long.valueOf(splited[1]);
            } else {
                currentLine++;
                var splited = line.split(" ");
                Long x = Long.valueOf(splited[0]);
                Long y = Long.valueOf(splited[1]);
                if (x*x+y*y<=d*d) {
                    count++;
                }
            }

        }
        System.out.println(count);
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 54704
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
ans = 0

N = int(input())
b = []

for i in range(0, N):
	b_input = int(input())
	b.append(b_input)

for i in range(0, 3):
	for j in range(0, N):
		if A_1[i] == b[j]:
			A_1[i] = True
		if A_2[i] == b[j]:
			A_2[i] = True
		if A_3[i] == b[j]:
			A_3[i] = True

A = [A_1, A_2, A_3]

for i in range(0, 3):
	if A[i][0] == A[i][1] == A[i][2] == True:
		ans = 1
		break
	elif A[0][i] == A[1][i] == A[2][i] == True:
		ans = 1
		break

if A[0][0] == A[1][1] == A[2][2] == True or A[0][2] == A[1][1] == A[2][0]:
	ans = 1

if ans == 1:
	print('Yes')
else:
	print('No')



Measured memory_bytes: 3064
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    val C = Combination(N)
    for (i in 1..K) {
        println(C(N - K + 1, i) * C(K - 1, i - 1))
    }
}

class Combination(n: Int) {
    private val fact = Array<MInt?>(n + 1) { null }
    private val ifact = Array<MInt?>(n + 1) { null }

    init {
        fact[0] = MInt(1)
        (1..n).forEach { i -> fact[i] = fact[i - 1]!! * MInt(i) }
        ifact[n] = fact[n]!!.inv()
        (n downTo 1).forEach { i -> ifact[i - 1] = ifact[i]!! * MInt(i) }
    }

    operator fun invoke(n: Int, k: Int): MInt {
        if (k < 0 || n < k) return MInt(0)
        return (fact[n]!! * ifact[k]!! * ifact[n - k]!!)
    }
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a.v += b.v
        if (a.v >= MOD) a.v -= MOD
        return a
    }

    operator fun plus(b: Int) = plus(MInt(b))
    operator fun plus(b: Long) = plus(MInt(b))

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a.v -= b.v
        if (a.v < 0) a.v += MOD
        return a
    }

    operator fun minus(b: Int) = minus(MInt(b))
    operator fun minus(b: Long) = minus(MInt(b))

    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a.v *= b.v
        a.v %= MOD
        return a
    }

    operator fun div(b: MInt): MInt {
        return MInt(v) * b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(N: Int) = pow(N.toLong())

    fun pow(N: Long): MInt {
        var ans = MInt(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans *= a
            }
            a *= a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 37584
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<int> l(N);
    vec<int> r(N);

    rep(i, N) cin >> l[i] >> r[i];

    sort(all(l));
    sort(all(r));

    ll R, L;
    if (N % 2 == 1) {
        R = r[N / 2];
        L = l[N / 2];
    } else {
        R = (r[(N - 1) / 2] + r[N / 2]);
        L = (l[(N - 1) / 2] + l[N / 2]);
    }
    cout << R - L + 1 << endl;
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
const int maxn = 200100;
struct T {
    int to, nxt, v;
} way[maxn << 4];
int h[maxn], head[maxn], num = 1;
inline void adde(int x,int y,int v) {
    way[++num] = {y, h[x], v}, h[x] = num;
    way[++num] = {x, h[y], 0}, h[y] = num;
}
int dis[maxn];
inline bool bfs(int s,int t) {
    std::queue<int> q;
    for(int i = s;i <= t;++i) dis[i] = - 1, head[i] = h[i];
    for(q.push(s), dis[s] = 0;!q.empty();) {
        int t = q.front(); q.pop();
        for(int i = h[t];i;i = way[i].nxt) if(way[i].v && dis[way[i].to] < 0) 
            dis[way[i].to] = dis[t] + 1, q.push(way[i].to);
    }
    return dis[t] >= 0;
}
inline int dfs(int s,int t,int lim) {
    if(s == t || !lim) return lim;
    int ans = 0, mn;
    for(int & i = head[s];i;i = way[i].nxt)
        if(dis[way[i].to] == dis[s] + 1 && (mn = dfs(way[i].to, t, std::min(lim, way[i].v)))) {
            way[i].v -= mn;
            way[i ^ 1].v += mn;
            ans += mn; lim -= mn;
            if(!lim) break;
        }
    return ans;
}
inline int dinic(int s,int t) {
    int ans = 0;
    for(;bfs(s,t);) ans += dfs(s,t,1e9);
    return ans;
}

int main() {
	int w, h;
	using std::cin; using std::cout;
	cin >> w >> h;
	const int inf = 1e6;
	for(int i = 1;i <= w;++i) {
		for(int j = 1;j <= h;++j) {
			char x; cin >> x;
			if(x == 'o') {
				adde(i, j + w, 1);
				adde(j + w, i, 1);
			}
			if(x == 'S') {
				adde(0, i, inf);
				adde(0, j + w, inf);
			}
			if(x == 'T') {
				adde(i, w + h + 1, inf);
				adde(j + w, w + h + 1, inf);
			}
		}
}
	int ans = dinic(0, w + h + 1);
	cout << (ans < inf ? ans : -1) << '\n';
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<string>
using namespace std;

int main(void) {
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3]&&str[0]!=str[3])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};


int main()
{
    ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector< vector<int> > prefixSum(10, vector<int>(N,0));
    vector<int> earliest(10, N);
    vector<int> latest(10, -1);
    for(int i=0; i<N; i++)
    {
        prefixSum[S[i]-'0'][i]++;
        for(int j=0; j<10; j++)
        {
            if(i-1>=0) prefixSum[j][i]+=prefixSum[j][i-1];
        }
        earliest[S[i]-'0']=min(earliest[S[i]-'0'], i);
        latest[S[i]-'0']=max(latest[S[i]-'0'], i);
    }
    int ans=0;
    for(int a=0; a<=9; a++)
    {
        for(int b=0; b<=9; b++)
        {
            for(int c=0; c<=9; c++)
            {
                if(!(0 <= earliest[a] && earliest[a]<N)) continue;
                if(!(0 <= earliest[b] && earliest[b]<N)) continue;
                if(!(0 <= earliest[c] && earliest[c]<N)) continue;
                if(earliest[a]>=latest[c]) continue;
                int amount=prefixSum[b][latest[c]-1];
                amount-=prefixSum[b][earliest[a]];
                if(amount>0) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664