akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N, A, B, sum = 0;
    int a;

    cin >> N >> A >> B;
    for (int i = 0; i <= N; i++) {
        a=findSumOfDigits(i);
        if (A <= a  && a <= B) {
            sum += i;

        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back()
#define ll long long
#define pi pair<int,int>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  int n;
  cin>>n;
  ll x[n+5];
  ll y[n+5];
  for(int i=0;i<n;i++)
  {
    cin>>x[i]>>y[i];
  }

  ll mx=0,mn = INT_MAX;

  for(int i=0;i<n;i++)
  {
    mx=max(mx,x[i]+y[i]);
    mn=min(mn,x[i]+y[i]);
  }
  ll ans = mx-mn;
  mx=INT_MIN;
  mn=INT_MAX;
  for(int i=0;i<n;i++)
  {
    mx=max(mx,x[i]-y[i]);
    mn=min(mn,x[i]-y[i]);
  }
  ans= max(ans,mx-mn);
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string c;
    cin >> c;
    if (c == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (c != "Y" && i == N-1) {
      cout << "Three" << endl;
      break;
    }
    else continue;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> igarashi(N);
  
  for (int i = 1; i < sqrt(N); i++) {
    for (int j = 1; j < sqrt(N); j++) {
      for (int k = 1; k < sqrt(N); k++) {
        int kyoko = i * i + j * j + k * k + i * j + j * k + k * i;
        if (kyoko <= N) {
          igarashi.at(kyoko - 1)++;
        }
      }
    }
  }
  for (int l = 0; l < N; l++) {
    cout << igarashi.at(l) << endl;
  }
}


Measured memory_bytes: 3732
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n, q;

void Input() {
	cin >> n;
}

void Solve() {
	vll a(n);
	mll mp;
	ll su = 0;
	for (ll i = 0; i < n; i++) cin >> a[i], mp[a[i]]++, su += a[i];
	cin >> q;
	while (q--) {
		ll u, v;
		cin >> u >> v;
		su = su - u * mp[u] + v * mp[u];
		cout << su << endl;
		mp[v] += mp[u];
		mp[u] = 0;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

Measured memory_bytes: 10004
#include <iostream>

using namespace std;

int H, W;
char cell[51][51];

void check(unsigned x, unsigned y);

int main()
{
	cin >> H >> W;

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cin >> cell[j][i];
		}
	}

	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			check(j, i);
			cout << cell[j][i];
		}

		cout << endl;
	}



	return 0;
}

void check(unsigned x, unsigned y)
{
	unsigned count = 0;
	if (cell[x][y] == '#') return;

	for (int i = -1; i <= 1; i++)
	{
		for (int j = -1; j <= 1; j++)
		{
			if (x + j <= 0 || y + i <= 0) continue;

			if (cell[x + j][y + i] == '#') count++;

		}
	}

	cell[x][y] = '0' + count;

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef pair<int,int>P;//bit/コストxy


//ここからbit判定
int bit_data[26];
void bit_set(){
	bit_data[0]=1;
	for(int i=1;i<26;i++)bit_data[i]=bit_data[i-1]*2;
}
bool bit(int base,char check){
	if('A'<=check&&check<='Z'){
		int che=check-'A';
		int res=base&bit_data[che];
		if(!res)return 0;
		else return 1;
	}
	else if(check=='#'){
		return 0;
	}
	else{
		return 1;
	}
}
int bit_change(int base,char change){
	int che=change-'a';
	int res=base^bit_data[che];
	return res;
}
//ここまでbit判定

int xv[]={0,1,0,-1};
int yv[]={1,0,-1,0};

int main(){
	bit_set();
	int W,H;
	
	while(cin>>W>>H,H){
		queue<P>Q;
		map<P,int>flag;
		char land[32][32];
		for(int i=0;i<=W+1||i<=H+1;i++)land[i][0]=land[i][H+1]=land[0][i]=land[W+1][i]='#';
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>land[j][i];
				if(land[j][i]=='@'){
					Q.push(make_pair(0,j*100+i));//どこのフラグも立っていない&0コストxy
					flag[make_pair(0,j*100+i)]=1;
				}
			}
		}
		int end=1;
		for(int b,cost,x,y;!Q.empty();Q.pop()){
			b=Q.front().first;
			cost=Q.front().second/10000;
			x=Q.front().second/100%100;
			y=Q.front().second%100;
			
			//cout<<"#"<<b<<" "<<cost<<" "<<x<<" "<<y<<endl;
			
			if(land[x][y]=='<'){
				cout<<cost<<endl;
				end=0;
				break;
			}
			if('a'<=land[x][y]&&land[x][y]<='z'){
				b=bit_change(b,land[x][y]);
			}
			for(int i=0;i<4;i++){
				x=Q.front().second/100%100+xv[i];
				y=Q.front().second%100+yv[i];
				if(bit(b,land[x][y])&&flag[make_pair(b,x*100+y)]==0){
					flag[make_pair(b,x*100+y)]=1;
					Q.push(make_pair(b,(cost+1)*10000+x*100+y));
				}
				
			}
		}
		if(end)cout<<-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 13772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N;
    cin >> N;
  	if (N == 1) ans = 0;
  	else ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=55;
lint val[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline lint nxi(){
		lint x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	lint q=nxi();
	int n=50;
	for(int i=1; i<=n; ++i){
		val[i]=q/n+i-1;
	}
	for(int i=1; i<=q%n; ++i){
		for(int j=1; j<i; ++j) --val[j];
		val[i]+=n;
		for(int j=i+1; j<=n; ++j) --val[j];
	}
	printf("%d\n",n);
	for(int i=1; i<=n; ++i){
		printf("%lld ",val[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Roc ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define NMAX 200009
using namespace std;
ll n, k, v[NMAX], pd[NMAX];
int main()
{
    Roc;
    cin >> n >> k;
    for(ll i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = 0; i <= k; ++i)
        if(pd[i] == 0)
            for(int j = 1; j <= n; ++j)
                if(i + v[j] <= k)
                    pd[i + v[j] ] = 1;
    if(pd[k] == 1)
        cout << "First";
    else
        cout << "Second";
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, D = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    d2=D**2
    cnt=0
    for x,y in S:
        if x**2+y**2<=d2:
            cnt+=1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 37136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S; 
  ll K; cin>>K;
  ll N=S.size();
  set<string> list;
  vector<string> vec(0);
  rep(i,5){
    rep(j,N-i){
      string s=S.substr(j,i+1);
      if(!list.count(s)) {
        list.insert(s);
        vec.push_back(s);
      }
    }
  }
  sort(vec.begin(),vec.end());
  cout<<vec[K-1]<<endl;
  return 0;
}

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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

int main() {
  ll N;

  cin >> N;
  vector<ll> A(N);

  FOR(i, 0, N) { cin >> A[i]; }

  ll min = *min_element(A.begin(), A.end());
  ll max = *max_element(A.begin(), A.end());

  cout << max - min << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from math import *

lineNumber = 0
coord = [0, 0]
theta = 0.5 * pi
#for line in [ "56,65", "97,54", "64,-4", "55,76", "42,-27", "43,80", "87,-86", "55,-6", "89,34", "95,5", "0,0"]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    List = map(float, line.strip().split(","))

    # set data
    forward = List[0]
    d_theta = - List[1] / 180.0 * pi

    # solve
    coord[0] += forward * cos(theta)
    coord[1] += forward * sin(theta)
    theta += d_theta

print int(coord[0])
print int(coord[1])

Measured memory_bytes: 4428
#include<stdio.h>

int main(void){

   double r,s,l;
   
   scanf("%lf",&r);
   
   s=r*r*3.141592653589;
   l=2*r*3.141592653589;
  
   printf("%f %f\n",s,l);
   
   return 0;
}
   
   

Measured memory_bytes: 648
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

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

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int H, W, N;
vector<PII> black;
vector<PII> square;
int dhs[3] = {-2, -1, 0};
int dws[3] = {-2, -1, 0};
LL ans[10];

void solve() {
    for (auto bl : black) {
        REP(h, 3) {
            REP(w, 3) {
                int nh = bl.first + dhs[h];
                int nw = bl.second + dws[w];
                if (0 <= nh and nh < H - 2 and 0 <= nw and nw < W - 2) {
                    square.PB(make_pair(nh, nw));
                }
            }
        }
    }
    sort(ALL(square));
    if (square.size()) {
        int cnt = 1;
        FOR(i, 0, square.size() - 1) {
            if (square[i] == square[i+1]) {
                cnt += 1;
            } else {
                ans[cnt] += 1;
                cnt = 1;
            }
        }
        ans[cnt] += 1;
    }
    ans[0] = (LL)(H - 2) * (W - 2);
    FOR(i, 1, 10) {
        ans[0] -= ans[i];
    }
    REP(i, 10) {
        cout << ans[i] << endl;
    }
}

int main(int argc, char const* argv[])
{
    cin >> H >> W >> N;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        black.PB(make_pair(a, b));
    }
    solve();
    return 0;
}


Measured memory_bytes: 9324
#include<stdio.h>
int main()
{
    int n,i,r=1;
    char s[100];
    scanf("%d%s",&n,&s);

    if(n%2)
    {
        r=0;
    }
    else{
        for(i=0;i<n/2;i++){
            r*=s[i]==s[n/2+i];
        }
    }
    printf(r?"Yes":"No");
    return 0;
}


Measured memory_bytes: 1724
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=100005;
LL a[N],b[N],sum,cost1,cost2;
int main( )
{
  int i,j,n;
  n=read( );
  for(i=1;i<=n;i++) a[i]=read( );
  for(i=1;i<=n;i++) a[i]+=a[i-1];
  //
  sum=0;
  for(i=1;i<=n;i++) b[i]=a[i];
  for(i=1;i<=n;i++)
    {
      b[i]+=sum;
      if(i&1) 
	{
	  if(b[i]<=0) cost1+=(-b[i]+1),sum+=(-b[i]+1);
	}
      else
	{
	  if(b[i]>=0) cost1+=(b[i]+1),sum-=(b[i]+1);
	}
    }
  //
  sum=0;
  for(i=1;i<=n;i++) b[i]=a[i];
  for(i=1;i<=n;i++)
    {
      b[i]+=sum;
      if(!(i&1)) 
	{
	  if(b[i]<=0) cost2+=(-b[i]+1),sum+=(-b[i]+1);
	}
      else
	{
	  if(b[i]>=0) cost2+=(b[i]+1),sum-=(b[i]+1);
	}
    }
  //
  cout<<min(cost1,cost2);
  return 0;
}


Measured memory_bytes: 1792
package main

import (
  "fmt"
  "math"
)

func main() {
  var N int
  A := [1000001][3]float64{}

  fmt.Scan(&N)

  for i := 0; i < N; i++ {
    fmt.Scan(&A[i+1][0])
    fmt.Scan(&A[i+1][1])
    fmt.Scan(&A[i+1][2])
  }

  flag := true
  for i := 0; i < N; i++ {
    if A[i+1][0] - A[i][0] > math.Abs(A[i+1][1] - A[i][1]) + math.Abs(A[i+1][2] - A[i][2]) {
      if int(A[i+1][0] - A[i][0] - math.Abs(A[i+1][1] - A[i][1]) - math.Abs(A[i+1][2] - A[i][2]))%2 != 0 {
        flag = false
        break
      }
    } else if A[i+1][0] - A[i][0] < math.Abs(A[i+1][1] - A[i][1]) + math.Abs(A[i+1][2] - A[i][2]) {
      flag = false
      break
    }
  }

  if flag {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }

}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char);
long long getKey(char *);
int h1(int);
int h2(int);
int find(char *);
int insert(char *);

int main() {
  int i,n,h;
  char str[L],com[9];

  for(i=0;i<M;i++) H[i][0] = '\0';

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);

    if(com[0] == 'i') {
      insert(str);
    } else {
      if( find(str) ) {
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;

}

int getChar(char ch) {
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]) {

  long long sum = 0,p = 1,i;

  for(i=0;i<strlen(str);i++) {
    sum+=p*(getChar(str[i]));
    p*=5;
  }

  return sum;

}

int h1(int key) { return key%M; }

int h2(int key) { return 1+( key % (M-1) ); }

int find(char str[]) {
  long long key,i,h;
  key = getKey(str);

  for(i=0;;i++) {
    h = ( h1(key) + i * h2(key) ) % M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if( strlen(H[h]) == 0 ) return 0;
  }

  return 0;

}

int insert(char str[]) {
  long long key,i,h;
  key = getKey(str);

  for(i=0;;i++) {
    h = ( h1(key) + i * h2(key) ) % M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if( strlen(H[h]) == 0 ) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 16048
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if v>w and abs(a-b)<=(v-w)*t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61696
# coding = SJIS

sx, sy, tx, ty = map(int, input().split())
way = ""

for i in range(ty - sy):
    way += "U"
for i in range(tx - sx):
    way += "R"
for i in range(ty - sy):
    way += "D"
for i in range(tx - sx):
    way += "L"
way += "L"
for i in range(ty - sy + 1):
    way += "U"
for i in range(tx - sx + 1):
    way += "R"
way += "D"
way += "R"
for i in range(ty - sy + 1):
    way += "D"
for i in range(tx - sx + 1):
    way += "L"
way += "U"

print(way)

Measured memory_bytes: 9212
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


/////////////////////////////////////////////////////////////////

int main(){
    int n,k,q;cin>>n>>k>>q;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    //if(q==1){cout<<0<<endl;return 0;}
    ll ans=inf;
    rep(i,0,n-1){
        ll x=a[i];
        int j=0;
        vector<ll>y;
        vector<ll>v;
        while(j<=n-1){
            if(a[j]<a[i]){
                sort(v.begin(),v.end());
                int t=v.size();
                for(int z=0;z+k-1<=t-1;z++){
                    y.pb(v[z]);
                }
                v.clear();
            }else{
                v.pb(a[j]);
            }
            j++;
        }
        sort(v.begin(),v.end());
        int t=v.size();
        for(int z=0;z+k-1<=t-1;z++){
            y.pb(v[z]);
        }
        sort(y.begin(),y.end());
        if(y.size()>=q){
            ans=min(ans,y[q-1]-a[i]);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
using namespace std;


int main(int argc, char *argv[])
{
    // VARIABLES
    int N;
    string s; int p;
    vector<tuple<string, int, int>> v;

    // INPUT
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> s >> p;
        v.emplace_back(s, p, i+1);
    }

    // PROC
    sort(v.begin(), v.end(), [](tuple<string, int, int> l, tuple<string, int, int> r) {
        if(get<0>(l) != get<0>(r)) return get<0>(l) < get<0>(r);
        else return get<1>(l) >= get<1>(r);
    });

    // OUTPUT
    for(auto x : v){
        cout << get<2>(x) << endl;
    }

    return 0;   
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    sl = [input() for i in range(n)]

    m = int(input())
    tl = [input() for i in range(m)]

    maxcount = 0
    for s in set(sl):
        count = sl.count(s) - tl.count(s)
        if count > maxcount:
            maxcount = count

    print(maxcount)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll H, W, n;
    cin >> H >> W >> n;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    unordered_map<ll, ll> cnt;
    rep(i, n) {
        rep(dy, 3) rep(dx, 3) {
            ll x = -dx + b[i]-1;
            ll y = -dy + a[i]-1;
            if (0 <= x && 0 <= y && x + 2 < W && y + 2 < H) {
                ll ind = x + y * W;
                if (cnt.find(ind) == cnt.end()) cnt[ind] = 0;
                cnt[ind]++;
            }
        }
    }

    vector<ll> res(10);
    ll sum = 0;
    for (auto& kv: cnt) {
        res[kv.second]++;
        sum++;
    }
    res[0] = (H - 2) * (W - 2) - sum;

    rep(i, 10) {
        put(res[i]);
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 41096
#include <iostream>
using namespace std;
int main(){
	int a,c,b;
	cin>>a>>b;
    if(a>0) cout<<"Positive";
    if(a<=0&&b>=0) cout<<"Zero";
    if(a<0&&b<0){
    	c=b-a;
    	if(c%2==0) cout<<"Negative";
    	else cout<<"Positive";
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;

struct edge {
	int a , b , c;
};

signed main() {
	int n , m , p; cin >> n >> m >> p;
	vector<edge> v , vb;
	for(int i = 0 ;i < m ;i ++ ) {
		edge x;
		cin >> x.a >> x.b >> x.c;
		x.c -= p;
		x.c = -x.c;
		v.push_back(x);
		swap(x.a , x.b);
		vb.push_back(x);
		
	}
	long long dd[N] = {} , dd2[N] = {} , dd3[N] = {};
	for(int i = 1; i < n ;i ++ ) dd2[i] = 1e18;
	dd2[n] = 0;
	for(int i = 1 ; i <= n ;i ++ ){
		for(int j = 0; j < m ; j ++ ) {
			long long a = vb[j].a , b = vb[j].b , c = vb[j].c;
			if(dd2[a] == 1e18) continue;
			if(dd2[a] + c < dd2[b]) dd2[b] = dd2[a] + c;
		}
	}
	for(int i = 2 ;i <= n ;i ++ ) dd[i] = 1e18;
	dd[1] = 0;
	for(int i = 1 ; i <= n ;i ++ ){
		for(int j = 0; j < m ; j ++ ) {
			long long a = v[j].a , b = v[j].b , c = v[j].c;
			if(dd[a] == 1e18) continue;
			if(dd[a] + c < dd[b]) dd[b] = dd[a] + c;
		}
	}
	for(int i = 1 ;i <= n ;i ++) dd3[i] = dd[i];
	for(int i = 1 ; i <= 2*n ;i ++ ){
		for(int j = 0; j < m ; j ++ ) {
			long long a = v[j].a , b = v[j].b , c = v[j].c;
			if(dd[a] == 1e18) continue;
			if(dd[a] + c < dd[b]) dd[b] = dd[a] + c;
		}
	}
	
	bool t = false;
	for(int i = 1; i <= n ;i ++ ){
		if(dd[i] < dd3[i] && dd2[i] != 1e18) t = true;
	}
	if(t || dd[n] == 1e18) cout << -1;
	else {
		if(dd[n] < 0) cout << -dd[n];
		else cout << 0;
	}
}
		


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    int n; cin >> n;
    vl l(n);
    rep(i,n)cin>>l[i];
    ll res = 0;
    sort(all(l));
    rep(i,n){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    if(l[i] + l[j] > l[k])res++;
                }
            }
        }
    }
    out(res);
}

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

long long A[100000+100];
long long B[100000+100];

int main()
{
  long n;
  cin >> n;
  for(long i=0;i<n;i++){
    cin >> A[i] >> B[i];
  }
  long max = 0;
  long index = 0;
  for(long i=0;i<n;i++){
    if(A[i] > max){
      max = A[i];
      index = i;
    }
  }
  cout << A[index]+B[index]  << endl;
  return 0;
}

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

int a[51];
int cnt[13];
int vis[25];
int ans = -1;
void dfs(int x){
    if(x==13){
        int tem = 24;
        for(int i=0;i<24;i++)
            for(int j=i+1;j<24;j++)
                if(vis[i]&&vis[j]){
                    tem = min(tem,min(j-i,24-j+i));
                }
        ans = max(ans,tem);
        return ;
    }
    if(cnt[x]==2){
        vis[x]=1;
        vis[24-x]=1;
        dfs(x+1);
    }
    else if(cnt[x]){
        if(x){
            vis[x]=1;
            dfs(x+1);
            vis[x]=0;
            vis[24-x]=1;
            dfs(x+1);
            vis[24-x]=0;
        }
        else{
            vis[x]=1;
            dfs(x+1);
            vis[x]=0;
        }
    }
    else dfs(x+1);
}

int main(){
    memset(a,0,sizeof(a));
    memset(cnt,0,sizeof(cnt));
    memset(vis,0,sizeof(vis));
    int n;
    bool flag = 1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    cnt[0]++;
    for(int i=0;i<12;i++){
        if(cnt[i]>=3){
            flag = 0;
            break;
        }
    }
    if(cnt[0]>=2||cnt[12]>=2){
        flag = 0;
    }
    if(flag)dfs(0);
    if(!flag){
        ans = 0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
g = 0
if N < K:
    #w = 1/(K-1)
    for i in range(1,N+1):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
else:
    f = (N-K+1)
    for i in range(1,K):
        t = i
        gk = 1
        while (t < K):
            gk /= 2
            t *= 2
        #print(i,gk,1/gk)
        g += gk
    g += f
print(g/N)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

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

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	int sum=0;
	rep(i,n)sum+=a[i];
	int min=101*n;
	rep(i,n)chmin(min,abs(a[i]*n-sum));
	rep(i,n)if(abs(a[i]*n-sum)==min){
		cout<<i<<endl;
		return 0;
		}
}

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

   int main(){
    int n=0;

    while(1){
      cin>>n;

      if(n==0){
        break;
      }

      int p[n];
      int total=0;
      for(int i=0;i<n;i++){
        cin>>p[i];
        total=total+p[i];
      }

      int ave;
      ave=total/n;
      int lesspeople=0;
      for(int j=0;j<n;j++){
        if(ave>=p[j]){
          lesspeople++;
        }
      }
      cout<<lesspeople<<"\n";


    }

    return 0;
   }



Measured memory_bytes: 3140
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, A: "List[int]"):
    for i in range(1, N + 1):
        if K * i - (i - 1) >= N:
            ret = i
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;

struct UnionFind{
	vector<int> par;
	UnionFind(int n){
		par.resize(n);
		rep(i, n) par[i] = i;
	}
	int find(int x){
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		par[find(x)] = find(y);
	}
};

int main(){
	int n, m;
	while (cin >> n >> m, n){
		vector<tuple<int, int, int>> v; // w, a, b
		rep(i, m){
			int a, b, w;
			cin >> a >> b >> w;
			v.emplace_back(w, a - 1, b - 1);
		}
		sort(ALL(v));

		int ans = 1e9;
		rep(i, m){
			UnionFind uf(n);
			int cnt = 1, mx;
			FOR(j, i, m){
				int w, a, b;
				tie(w, a, b) = v[j];
				if (uf.find(a) == uf.find(b)) continue;
				uf.unite(a, b);
				mx = w;
				++cnt;
			}
			if (cnt != n) break;
			ans = min(ans, mx - get<0>(v[i]));
		}
		if (ans == 1e9) ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0, mx = a[0];
  for (int i = 1; i < n; i++) {
    ans += max(mx-a[i], 0LL);
    chmax(mx, a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4776
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int D=gi();
	    int a=(int)Math.ceil(((double)N)/ (double)(2*D+1));

        System.out.print(a);
//        if (s.charAt(0)=='0' && N!=1) {
//        	System.out.println(-1);
//        }else {
//        	System.out.println(s);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35600
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
string s="! Khelbe Hogwarts, Jitbe Hogwarts!";
int main ()
{
__

int a,b,arr[3];

cin >> a >> b;

arr[0] = a+b;
arr[1] = a-b;
arr[2] = a*b;

sort(arr,arr+3);

cout << arr[2];


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                  long long int
#define ff                   first
#define ss                   second
#define pb                   push_back
#define mp                   make_pair
#define pii                  pair<int,int>
#define vi                   vector<int>
#define mi                   map<int,int>
#define pqb                  priority_queue<int>
#define pqs                  priority_queue<int,vi,greater<int>>
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define inf                  1e18
#define precise(x,y)         fixed<<setprecision(y)<<x
#define w(x)                 int x;cin>>x;while(x--)
#define endl                 "\n"
#define no_of_digit(n)       floor(log10(n))+1
#define copyarr(a,b,n)       copy_n(a,n,b)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

//*******************to check if all number in array are positive*******************
//all_of(arr,arr+n,[](int x){return x>0;})?cout<<"positive":cout<<"some negative";


//*******************to check if any element in array is negative*******************
//any_of(arr,arr+n,[](int x){return x<0;})?cout<<"Any negative":cout<<"All positive";


int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //*****************Enter the code here*******************//
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=1;i<=10;i++)
    {
    	x=r*x-d;
    	cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)


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

	string str;
	cin >> str;

	if (str.size() % 2 != 0) cout << "No" << endl;
	if (str.size() % 2 == 0) {
		int k = str.size() / 2;
		
		if (str.substr(0, k) == str.substr(k, str.size() - 1)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		
	}



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y))
			return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1)
		return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
bool isOK(int index, string s) {
	unordered_map<string, pair<int,vector<int>>> mp;
	if(index<1)return false;
	rep(i, (int) s.size() - index + 1) {
		mp[s.substr(i, index)].first++;
		mp[s.substr(i,index)].second.push_back(i);
	}
	for (pair<string,pair<int,vector<int>>> it : mp)
		if (it.second.first > 1) {
		    int fi=it.second.second[0];
		    if(lower_bound(it.second.second.begin(),it.second.second.end(),fi+index)!=it.second.second.end())
			return true;
		}
	return false;
}
int my_binary_search(string s) {
	int ng = (int) s.size();
	int ok = 0;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOK(mid, s))
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}
signed main(signed argc, char* argv[]) {
	int n;
	string s;
	cin >> n >> s;
	cout << my_binary_search(s) << endl;
}

Measured memory_bytes: 6832
#include<iostream>

using namespace std;

char prime[9973220];

void make(void);

int main(){
  make();
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;

    if(n >= 9973220) n = 9973219;
    
    for(int i = n; i >= 13; i--){
      if(prime[i] == 1 && prime[i-2] == 1 && prime[i-6] == 1 && prime[i-8] ==1){
	cout << i << endl;
	break;
      }
    }
  }
  return 0;
}

void make(void){
  for(int i = 0; i < 9973220; i++) prime[i] = 1;

  prime[0] == 0;
  prime[1] == 0;

  for(int i = 2; i*i < 9973220; i++){
    if(prime[i] == 1){
      for(int j = i*2; j < 9973220; j+=i) prime[j] = 0;
    }
  }
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    string s;
    cin>>s;
    ll cnt[26]={0};
    for(i=0;i<4;i++)
    cnt[s[i]-'A']++;
    ll pos=0;
    for(i=0;i<26;i++)
    {
        if(cnt[i]==2)
        pos++;
    }
    if(pos==2)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int[] F = new int[N];
		int[][] P = new int[N][11];
		sc.nextLine();
		for (int i = 0; i < N; i++) {
			String[] fi = sc.nextLine().split(" ");
			F[i] = getMask(fi);
		}
		for (int i = 0; i < N; i++) {
			String[] pi = sc.nextLine().split(" ");
			for (int j = 0; j < 11; j++) {
				P[i][j] = Integer.parseInt(pi[j]);
			}
		}

		long maxRev = Long.MIN_VALUE;
		for (int mask = 1; mask < 1024; mask++) {
			long rev = 0;
			for (int i = 0; i < N; i++) {
				rev += P[i][countOnes(mask & F[i])];
			}
			maxRev = Math.max(maxRev, rev);
		}
		System.out.println(maxRev);
		sc.close();
	}

	private int getMask(String[] input) {
		int mask = 0;
		for (String s : input) {
			mask = mask * 2;
			if (Integer.parseInt(s) == 1) {
				mask += 1;
			}
		}
		return mask;
	}

	private int countOnes(int mask) {
		int cnt = 0;
		while (mask > 0) {
			if ((mask & 1) == 1) {
				cnt++;
			}
			mask = mask / 2;
		}
		return cnt;
	}
}

Measured memory_bytes: 22228
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int x,h,i,j;
  double S;
  while(1){
    cin >> x >> h;
    if(x ==0 && h == 0)break;
    S=(x * x)+sqrt( ((x*0.5) * (x*0.5)) + (h*h) ) * x * 0.5 * 4;
    printf("%.6lf\n",S);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> T(N);
  ll ans = 1;
  rep(i, N) {
    cin >> T[i];
    ans = lcm(ans, T[i]);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

// xの次のルンルン数を出力
long int f(long int x){
    long int a = x;
    vector<long int> num;
    while(a > 0){
        num.push_back(a % 10);
        a /= 10;
    }

    if (num.size() == 1){
        return  x + 1;
    }
    
    // rep(i, num.size()) cout << num[i];
    // cout << endl;
    // cout << num.size() << endl;
    for (int i = 0; i < num.size() - 1; i++){
        if (num[i] < num[i+1]){
            num[i]++;
            for (int j = i-1; j >= 0; j--){
                num[j] = max(num[j+1] - 1, (long int)0);
            }
            break;
        }else if(num[i] == num[i+1]){
            if (num[i] < 9){
                num[i]++;
                for (int j = i-1; j >= 0; j--){
                    num[j] = max(num[j+1] - 1, (long int)0);
                }
                break;
            }
        }
        if (i == num.size() - 2){
            if (num[i] > num[i+1]){
                num[i+1]++;
                for (int j = i; j >= 0; j--){
                    num[j] = max(num[j+1] - 1, (long int)0);
                }
                // cout << 1 << endl;
                break;
            }else if(num[i] == num[i+1]){
                num.push_back(1);
                rep(i, num.size()-1) num[i] = 0;
                break;
            }
        }
    }
    long int res;
    res = num[num.size()-1];
    for (int i = num.size() - 2; i >= 0; i--){
        res *= 10;
        res += num[i];
    }
    return res;
}

int main(){
    long int k;
    cin >> k;
    long int ans = 1;
    for (int i = 1; i < k; i++){
        ans = f(ans);
        // cout << ans << endl;
    }
    cout << ans << endl;
    // cout << f((long int) 998) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int m[10],i,j,blank;

  for(i = 0; i < 10; i++) scanf("%d",&m[i]);

  for(i = 0; i < 9; i++){

    for(j = 0; j < 9; j++){

      if(m[j] > m[j+1]){

        blank=m[j];
        m[j]=m[j+1];
        m[j+1]=blank;

      }

    }

  }

  printf("%d\n%d\n%d\n",m[9],m[8],m[7]);

  return 0;

}

Measured memory_bytes: 2672
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():

    s = list(input().rstrip())
    zero = 0
    one = 0
    for i in s:
        if i == "0":
            zero += 1
        else:
            one += 1
    print(2*min(zero,one))

if __name__=="__main__":
    main()


Measured memory_bytes: 77944
/*
* @Author: dnhirapara
* @Date: 2020-04-25 20:07
* @Name: dp_c
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n;
    cin>>n;
    ll dp[n][3]={0};
    ll a[3]={0};
    cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
    for(ll i=1;i<n;i++){
        for(ll k=0;k<3;k++){
            cin>>a[k];
        }
        for(ll j=0;j<3;j++){
            for(ll k=0;k<3;k++){
                if(k!=j){
                    dp[i][j]=max(dp[i-1][k]+a[j],dp[i][j]);
                }
            }
        }
    }
    ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
	int a,b,r,c,d,s;
	scanf("%d%d%d%d%d%d",&a,&b,&r,&c,&d,&s);
	int dist=(a-c)*(a-c)+(b-d)*(b-d);
	int ans;
	if(dist>(r+s)*(r+s))ans=4;
	else if(dist==(r+s)*(r+s))ans=3;
	else if(dist>(r-s)*(r-s))ans=2;
	else if(dist==(r-s)*(r-s))ans=1;
	else ans=0;
	printf("%d\n",ans);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    string s;
    int x=0,y=0,c=0;
    cin>>s;
    rep(i,s.size()) c++;
    rep(i,s.size()){
        if (s.at(i)=='A') {
            x=i+1;
            break;
        }
    }
    rep(i,c){
        if (s.at(s.size()-i-1)=='Z'){
            y= c-i;
            break;
        }
    }
    cout<<y-x+1<<endl;
    return 0;
}

Measured memory_bytes: 640