akhauriyash/Code-Regression huggingface dataset:
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
//  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(n)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)

  val ans = (1 to n).map(_.toString.length).count(_ % 2 != 0)

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

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

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

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

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

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 175988
#include <bits/stdc++.h>
#define ll long long
#define pub push_back
#define mp make_pair
#define MAX 
#define ull unsigned ll
 
using namespace std;

ifstream fin("input.txt");
string str;


int main()
{
  ios :: sync_with_stdio(false);
  
  int k ; 
  cin >> k;
  
  int n = 7  % k ;
  int cnt  = 1 ;
  
  for (int i = 1 ;i < 1e7 ; i++)
  {
     if (n == 0)
     {
       cout<<i<<endl ;
       return 0;
     }
     
     n = ( n * 10  + 7 ) % k ; 
  }
  
  
  cout<<-1<<endl;
  
}

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

int main(){
    string W, T;
    cin >> W;
    transform(W.begin(), W.end(), W.begin(), ::toupper);

    int cnt=0;
    while(true){
        cin >> T;    
        if(T == "END_OF_TEXT") break;
        transform(T.begin(), T.end(), T.begin(), ::toupper);  
        if(W == T) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3216
n = int(input())
w = list(map(int, input().split()))

Min = 10000
for i in range(n+1):
    if i < n:
        w1 = sum(w[:i])
        w2 = sum(w[i:])
        Abs = abs(w1-w2)
    else:
        w1 = sum(w)
        w2 = sum([])
        Abs = abs(w1-w2)

    if Min > Abs:
        Min = Abs

print(Min)

Measured memory_bytes: 38512
n = int(input())
a = list(map(int, input().split()))
a.append(a[0])
m_1 = [0] * (n + 1)
m_1[0] = 1
m_2 = [0] * (n + 1)
m_2[1] = 1

i = 0
while i < n - 1:
    m_1[i + 2] = m_1[i] + (a[i + 1] - a[i]) * 2
    i += 2
i = 1
while i <n - 1:
    m_2[i + 2] = m_2[i] + (a[i + 1] - a[i]) * 2
    i += 2
    
sub = m_1[0] - m_2[-1]
for i in range(len(m_2)):
    if m_2[i] != 0:
        m_2[i] += sub
        m_1[i] = m_2[i]
offset = (sum(a[:-1]) - sum(m_1[:-1])) // n
for i in range(n):
    print(m_1[i] + offset)

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

using namespace std;

int a , b;

int main()
{
    cin >> a >> b;
    if(a>0) cout<<"Positive"<<endl;
    else if(a==0||(a<0&&b>0)) cout<<"Zero"<<endl;
    else if((abs(b)-abs(a))%2!=0) cout<<"Positive"<<endl;
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int w[110][110];
char p[110][110];
int n, m;
int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
	}
	if (p[1][1] == '#')w[1][1]++;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			if (i + j == 2)continue;
			w[i][j] = 1e9;
			if (i != 1)w[i][j] = min(w[i][j], w[i - 1][j] + (p[i][j] != p[i - 1][j]));
			if (j != 1)w[i][j] = min(w[i][j], w[i][j - 1] + (p[i][j] != p[i][j - 1]));
		}
	}
	printf("%d\n", (w[n][m] + 1) / 2);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	cout<<c/a*b;




	cout<<endl;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=307;
typedef long long ll;

int n,m,ans;
int a[maxn][maxn];
int now[maxn];

int f[maxn];
int f1[maxn];
int maxx;

int main()
{
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	  for(j=1;j<=m;++j)
	    scanf("%d",&a[i][j]);
	
	for(i=1;i<=n;++i) now[i]=1;
	
	ans=400;
	
	for(i=1;i<=n;++i)
	{
		f1[a[i][now[i]]]++;
		maxx=max(maxx,f1[a[i][now[i]]]);
	}
	ans=min(maxx,ans);
	
	
	int flag=0;
	for(int t=1;t<=m;++t)
	{
		int maxv=0;
		for(i=1;i<=n;++i)
		{
			if(maxv<f1[a[i][now[i]]])
			{
				maxv=f1[a[i][now[i]]];
				k=a[i][now[i]];
			}
		}
		if(maxv==1) break;
		
		f[k]=1;
		for(i=1;i<=n;++i)
		{
			f1[a[i][now[i]]]--;
			while(now[i]<=m&&f[a[i][now[i]]])
			{
				now[i]++;
			}
			if(now[i]>m)
			{
				flag=1;
				break;
			}
			f1[a[i][now[i]]]++;
		}
		if(flag==1) break;
		
		maxx=0;
		for(i=1;i<=m;++i)
		{
			maxx=max(maxx,f1[i]);
		}
		ans=min(ans,maxx);
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 640
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

A,B=LI()

print((B-1)//(A-1) + (1 if (B-1)%(A-1) else 0))

Measured memory_bytes: 3064
from operator import mul

N, M, C = map(int, input().split())
Bs = list(map(int, input().split()))
Ass = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
for As in Ass:
    if sum(map(mul, As, Bs)) + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
  int scr[5];
  int sum=0;
  int i;

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

  for(i=0;i<5;i++){
    if(scr[i]<40)
      scr[i]=40;
  }

  for(i=0;i<5;i++)
    sum+=scr[i];

  printf("%d\n",sum/5);

  return 0;
}

Measured memory_bytes: 600
n = int(input())

a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

ret = 0
for i in range(n):
    ret += b[a[i] - 1]
    if i > 0:
        if a[i] - a[i - 1] == 1:
            ret += c[a[i - 1] - 1]
print(ret)

Measured memory_bytes: 3064
a = list(input())
b = list(input())
c = list(input())

temp = a.pop(0)
flg = True
while flg:
    if temp == "a":
        if len(a) == 0:
            print("A")
            flg = False
            break
        temp = a.pop(0)
    elif temp == "b":
        if len(b) == 0:
            print("B")
            flg = False
            break
        temp = b.pop(0)
    elif temp == "c":
        if len(c) == 0:
            print("C")
            flg = False
            break
        temp = c.pop(0)

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

signed main() {
  int n;
  cin >> n;
  cout << 180 * (n - 2) << endl;
}

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100001;
int a[N];
int main() {
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	int l = s.length();
	int x,y;
	for(int i = 0; i < l; i++)
		if (s[i] == 'A') {
			x = i;
			break;
		}
	for(int i = l - 1; i >= 0; i--)
		if (s[i] == 'Z') {
			y = i;
			break;
		}
	cout << y - x + 1 << endl;
  	return 0;
}


Measured memory_bytes: 720
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
typedef long long ll;
using namespace std;

int n;
set<string>st;
string w,w2;

int main() {
	cin >> n;
	cin >> w2;
	st.insert(w2);
	lp(n-1) {
		cin >> w;
		if (st.find(w) != st.end()|| w2[w2.size() - 1] != w[0]) {
			cout << "No" << endl;
			return 0;
		}
		st.insert(w);
		w2 = w;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}

signed main(){
    cin>>n;
    dfs("",'a');
}  

Measured memory_bytes: 1536
from collections import deque

def main():
    N, M, *AB = map(int, open(0).read().split())
    C = {}
    for i in range(M):
        a = AB[2 * i + 0] - 1
        b = AB[2 * i + 1] - 1
        if a not in C:
            C[a] = []
        C[a].append(b)
        if b not in C:
            C[b] = []
        C[b].append(a)
    ANS = {i:-1 for i in range(N)}
    D = deque()
    D.append((0, C[0]))
    # print(D)
    while len(D) != 0:
        d = D.popleft()
        v = d[0]
        L = d[1]
        for l in L:
            if ANS[l] == -1:
                ANS[l] = v
                D.append((l, C[l]))
    print('Yes')
    for i in range(1, N):
        print(ANS[i] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68208
#include<bits/stdc++.h>
using namespace std;
bool dp[100005];
vector <int> a;
int N, K, temp;
int main(){
	scanf("%d%d", &N, &K);
	memset(dp, 0, sizeof(dp));
	for(int i = 0 ; i<N ; i++){
		scanf("%d", &temp);
		a.push_back(temp);
		dp[temp] = true;
	}
	for(int i = 1 ; i<=K ; i++){
		bool win = false;
		for(auto j : a){
			if(i - j < 0) continue;
			if(dp[i-j] == false){
				win = true;
				break;
			}
		}
		if(win) dp[i] = true;
	}
	if(dp[K]) cout <<"First"<<endl;
	else cout << "Second"<<endl;


}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    B.at(A.at(i) - 1) = i + 1;
  }
  
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << " " ;
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <sstream>

typedef std::string String;
typedef std::map< String, char > scnd;

int conv[256];
String str, tstr;
scnd data;

String setWidth( String str, int w ){
	std::stringstream ss;
	ss.width(5);
	ss.fill('0');
	ss << str;
	return ss.str();
}

String two_convert( int i ){
	String result;
	while( i != 0 ){
		if( i & 1 ) result += '1';
		else result += '0';
		i >>= 1;
	}

	std::reverse( result.begin(), result.end() );

	return result;
}

int two_re_convert( String str ){
	int a = 1;
	int result;
	for( int i = str.size() - 1; i >= 0; --i ){
		if( str[i] == '1' )result += a;
		a <<= 1;
	}

	return result;
}

int main(){
	conv[' '] = 0;
	conv['.'] = 1;
	conv[','] = 2;
	conv['-'] = 3;
	conv['\''] = 4;
	conv['?'] = 5;

	data["101"] = ' ';
	data["000000"] = '\'';
	data["000011"] = ',';
	data["10010001"] = '-';
	data["010001"] = '.';
	data["000001"] = '?';
	data["100101"] = 'A';
	data["10011010"] = 'B';
	data["0101"] = 'C';
	data["0001"] = 'D';
	data["110"] = 'E';
	data["01001"] = 'F';
	data["10011011"] = 'G';
	data["010000"] = 'H';
	data["0111"] = 'I';
	data["10011000"] = 'J';
	data["0110"] = 'K';
	data["00100"] = 'L';
	data["10011001"] = 'M';
	data["10011110"] = 'N';
	data["00101"] = 'O';
	data["111"] = 'P';
	data["10011111"] = 'Q';
	data["1000"] = 'R';
	data["00110"] = 'S';
	data["00111"] = 'T';
	data["10011100"] = 'U';
	data["10011101"] = 'V';
	data["000010"] = 'W';
	data["10010010"] = 'X';
	data["10010011"] = 'Y';
	data["10010000"] = 'Z';

	while(std::getline(std::cin, str)){

	for( int i = 0; i < str.size(); ++i ){
		if( str[i] >= 'A' && str[i] <= 'Z' ){
				tstr += setWidth(two_convert( str[i] - 'A' ), 5);
			}else{
				tstr += setWidth(two_convert( 26 + conv[str[i]] ), 5);
			}
		}

		String buf;
		for( int  i = 0; i < tstr.size(); ++i ){
			if( data[buf] != NULL ){
				std::cout << data[buf];
				buf = "";
			}
			buf += tstr[i];
		}

		if( data[buf] != NULL ){
			std::cout << data[buf];
			buf = "";	
		}

		std::cout << std::endl;

		str = "", buf = "", tstr = "";
	}
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(){

  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b){
    printf("a < b\n");
  } else if(a > b){
    printf("a > b\n");
  } else{
    printf("a == b\n");
    }
  return 0;
}

Measured memory_bytes: 580
n, k = map(int, input().split())
lis = list(map(int, input().split()))

count = [0]*(n+1)

for i in range(n):
    count[lis[i]] += 1

cnt = sorted(count)
nlis = []
for i in range(n+1):
    if cnt[i] != 0:
        nlis.append(cnt[i])
if len(nlis) <= k:
    print(0)
    exit()

ans = 0
for i in range(len(nlis)-k):
    ans += nlis[i]
    
print(ans)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const ll inf = 1e9;


void solve()
{
  ll R;
  scanf("%lld",&R);
  if (R<1200) cout << "ABC" << endl;
  else if (R<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll a[114514];
signed main() {
	int n, inf = 1e9, ans;
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	rep(i, n - 1) {
		if (abs(a[n - 1] / 2 - a[i]) <= inf) {
			inf = abs(a[n - 1] / 2 - a[i]);
			ans = a[i];
		}
	}
	cout << a[n - 1] << " " << ans << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll M = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size() - 8; ++i) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n;
        try (Scanner cin = new Scanner(System.in)) {
            n = cin.nextInt();
        }
        int sn = Integer.toString(n).chars().map(x -> x - '0').sum();

        System.out.println(n % sn == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 26580
n = int(input())
g = [input().split() + [i+1] for i in range(n)]

for spi in g:
    spi[1] = int(spi[1])

g.sort(key=lambda x:x[1],reverse=True)
g.sort(key=lambda x:x[0])
# print(g)

for spi in g:
    print(spi[2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){

int k,s;
cin>>k>>s;
long long  ans=0;
rep(i,k){
    rep(l,k){
       int p=s-i-l;
            if(0<=p && p<=k){
                ans++;
            }
       }
    }


cout<<ans<<endl;

 return 0;
}
/*
2 2

6

5 15

1

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    int maxv=*max_element(ALL(a)),cnt=0;
    REP(i,n) if(a[i]==maxv) cnt++;

    if(cnt>1){
        REP(i,n) cout<<maxv<<endl;
    }else{
        REP(i,n){
            if(a[i]==maxv){
                a.erase(max_element(ALL(a)));
                cout<<*max_element(ALL(a))<<endl;
            }else{
                cout<<maxv<<endl;
            }
        }
    }
    
	return 0; 
}


Measured memory_bytes: 2432
macro_rules! scan {
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (h, _) = scan!(usize, usize);
    let mut graph = scan!(i64;;10);
    let arr = scan!(i64;;h);

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                let d = graph[i][k] + graph[k][j];
                if d < graph[i][j] {
                    graph[i][j] = d
                }
            }
        }
    }

    let mut ans = 0;
    for row in arr {
        for col in row {
            if col >= 0 {
                ans += graph[col as usize][1]
            }
        }
    }

    println!("{}", ans)
}


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

long long gcd( long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm( long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    
    long long lcmval = lcm( c,d );
    
    long long tmp, ndiv;
    ndiv  = b/c-a/c+1;
    if( a%c != 0 ) ndiv--;

    ndiv += b/d-a/d+1;
    if( a%d != 0 ) ndiv--;

    ndiv -= b/lcmval-a/lcmval+1;
    if( a%lcmval != 0 ) ndiv++;

    /*
    if( b/(c*d) == 0 ){
    }
    else{
        ndiv -= b/(c*d)-a/(c*d)+1;
        if( a%(c*d) != 0 ) ndiv++;
        cout << a/(c*d) << b/(c*d) << endl;
        cout << ndiv << endl;
    }
    */
    
    
    cout << (b-a+1)-ndiv << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <list>
#include <map>

typedef std::pair<double,double> TPoint;

TPoint GetLeft(TPoint Left,TPoint Right)
{
	return std::make_pair((Left.first * 2 + Right.first) / 3,(Left.second * 2 + Right.second) / 3);
}

void Turn(TPoint& Vector)
{
	double X = (Vector.first - (std::sqrt)(3.) * Vector.second) / 2;
	double Y = ((std::sqrt)(3.) * Vector.first + Vector.second) / 2;
	Vector = std::make_pair(X,Y);
}

TPoint GetCenter(const TPoint& Left,const TPoint& Right)
{
	TPoint Vector = std::make_pair(GetLeft(Left,Right).first - Left.first,GetLeft(Left,Right).second - Left.second);
	Turn(Vector);
	return std::make_pair(GetLeft(Left,Right).first + Vector.first,GetLeft(Left,Right).second + Vector.second);
}

TPoint GetRight(const TPoint& Left,const TPoint& Right)
{
	return std::make_pair((Left.first + Right.first * 2) / 3,(Left.second + Right.second * 2) / 3);
}

typedef std::list<TPoint> TPoints;

void Insert(TPoints& Points,const TPoints::iterator Right,int Level)
{
	TPoints::iterator It = Right;
	It--;
	TPoint LeftEdge = *It;
	TPoint RightEdge = *Right;
	It++;
	if(Level)
	{
		Level--;
		Points.insert(It,GetLeft(LeftEdge,RightEdge));
		Points.insert(It,GetCenter(LeftEdge,RightEdge));
		Points.insert(It,GetRight(LeftEdge,RightEdge));
		TPoints::iterator RightSecond = Right;
		RightSecond--;
		TPoints::iterator RightThird = RightSecond;
		RightThird--;
		It = RightThird;
		It--;
		Insert(Points,Right,Level);
		Insert(Points,RightSecond,Level);
		Insert(Points,RightThird,Level);
		Insert(Points,It,Level);
	}
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	
	TPoints Points;
	Points.push_back(std::make_pair(0.,0.));
	Points.push_back(std::make_pair(100.,0.));
	
	TPoints::iterator It = Points.end();
	It--;
	Insert(Points,It,Count);
	
	while(!Points.empty())
	{
		std::cout << Points.front().first << " " << Points.front().second << std::endl;
		Points.pop_front();
	}
	return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define prec fixed << setprecision(20)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	ld n, k;
	cin >> n >> k;
	ld ans = 1 / n;
	ld ans2 = 0;
	for (int i = 1; i <= n; ++i) {
		int x = i;
		int cnt = 0;
		while (x < k)
			x *= 2, cnt++;
		ans2 += pow(0.5, cnt);
	}
	cout << prec << ans * ans2;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

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

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll N, C, K;
Vi T;
int main(){
   cin >> N >> C >> K;
   T.resize(N);
   REP(i, N) cin >> T[i];
   SORT(T);
   ll ans = 0;
   ll i = 0;
   while(i < N){
      REP(j, C + 1){
         if((T[i + j] > T[i] + K) || j == C){
            ans++;
            i += j;
            break;
         }
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 1024
from sys import stdin
N, W = [int(x) for x in stdin.readline().rstrip().split()]
wv = []
for i in range(N):
    wv.append([int(x) for x in stdin.readline().rstrip().split()])
wv.append([0,0])

dp = [[0]*(W+1) for _ in range(N+2)]

for i in range(N+1):
    for sum_w in range(W+1):
        if sum_w - wv[i][0] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[N+1][W])

Measured memory_bytes: 120684
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",24+24-n);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,m,i,l,r;
	cin>>n>>m;
	
	int begin=1,end=n;
	for(i=1;i<=m;i++){
		cin>>l>>r;
		begin=max(begin,l);
		end=min(end,r);
	}
	
	cout<<max(end-begin+1,0);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[20];
int main()
{
    //freopen("t.txt","r",stdin);
    scanf("%s",s);
    printf("2018/01/");
    for(int i=8;i<strlen(s);i++)  printf("%c",s[i]);
    //while(1);
    return 0;
}


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

using namespace std;

typedef long long ll;

ll dp[100][2][2][2];

ll L, R;
int length;
const ll MOD = 1000000007;

int main() {
	cin >> L >> R;
	ll cpyL = L, cpyR = R;
	int cnt = 0;
	while (cpyL > 0)cpyL >>= 1, cnt++;
	length = cnt;
	cnt = 0;
	while (cpyR > 0)cpyR >>= 1, cnt++;
	length = max(length, cnt);

	dp[0][1][1][0] = 1;
	
	for (int i = 0; i < length; i++) {

		int nowRbit = ((R >> (length - i - 1)) & 1), nowLbit = ((L >> (length - i - 1)) & 1);

		for (int j = 0; j < 2; j++)for (int k = 0; k < 2; k++)for (int l = 0; l < 2; l++) {

			ll now = dp[i][j][k][l];
			dp[i][j][k][l] %= MOD;

			for (int x = 0; x < 2; x++)for (int y = 0; y < 2; y++) {
				if (x == 1 && y == 0)continue;

				int nj = j, nk = k, nl = l;
				if (!l && x != y)continue;
				if (!l && x == 1)nl = 1;
				
				if (j && nowLbit == 1 && x == 0)continue;
				if (j && nowLbit == 0 && x == 1)nj = 0;

				if (k && nowRbit == 0 && y == 1)continue;
				if (k && nowRbit == 1 && y == 0)nk = 0;

				dp[i + 1][nj][nk][nl] += now;
				dp[i + 1][nj][nk][nl] %= MOD;
			}

		}
	}

	ll ans = 0;

	for (int j = 0; j < 2; j++)for (int k = 0; k < 2; k++)for (int l = 0; l < 2; l++)
		ans += dp[length][j][k][l];

	cout << ans % MOD << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto x = new int[](N);
    auto y = new int[](N);
    foreach (i ; 0 .. N) {
        scan(x[i], y[i]);
    }

    double s = 0;

    double d(int i, int j) {
        return sqrt(((x[i] - x[j])^^2 + (y[i] - y[j])^^2).to!double);
    }

    foreach (i ; 0 .. N) {
        foreach (j ; i + 1 .. N) {
            s += 2 * d(i, j);
        }
    }

    debug {
        writeln(s);
    }

    s /= N;
    writefln("%.12f", s);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sqr(x) ((x)*(x))
#define pb push_back 
const int N=1000002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}void dec(int &x,int y){x-=y;if(x<0)x+=M;}
void Max(int &x,int y){if(y>x)x=y;}void Min(int &x,int y){if(y<x)x=y;}
struct node{int to,ne;}e[N];
int h[N],x,y,a[N],tot,i,n,m;
void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
void dfs(int u,int fa){
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa) a[v]+=a[u],dfs(v,u);
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for (i=1;i<n;i++) scanf("%lld%lld",&x,&y),add(x,y),add(y,x);
	for (;m--;) scanf("%lld%lld",&x,&y),a[x]+=y;
	dfs(1,0);
	for (i=1;i<=n;i++) printf("%lld ",a[i]);
}

Measured memory_bytes: 22528
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;


int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n;
    vll arr(n, 0);
    rep(i, 0, n) cin>>arr[i];

    vvll dp(n, vll(n, 0));

    rep(L, n-1, 0) {
        rep(R, L+1, n) {
            dp[L][R] = INFLL;
            ll sum = accumulate(arr.begin()+L, arr.begin()+R+1, 0LL);
            rep(k, L, R) {
                dp[L][R] = min(dp[L][R], sum + dp[L][k] + dp[k+1][R]);
            }
//            cout<<(dp[L][R])<<" "<<L<<" "<<R;
//            newl;
        }
    }

    cout<<dp[0][n-1];

    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

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

const int INF = 1e9 + 5;
const int maxi = 1e5 + 5;

int v[maxi][3], dp[maxi][3];

int main() {

	int n; cin >> n;
	memset(dp , 0, sizeof(dp));
	memset(dp , 0, sizeof(v));
	for(int i = 0; i < n; ++i) {
		int a,b,c; cin >> a >> b >> c;
		v[i][0] = a, v[i][1] = b, v[i][2] = c;
	}
	dp[0][0] = v[0][0], dp[0][1] = v[0][1], dp[0][2] = v[0][2];
	for(int i = 1; i < n; ++i) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + v[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + v[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + v[i][2];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    
    n--;
    
    
    for(long long left=-n*d, right=-n*c; left<=n*c; left+=(d+c), right+=(d+c)){
        if(a+left<=b && b<=a+right){
            //cout<<left<<" "<<right<<endl;
            cout<<"YES";
            return 0;
        }
    }
    /*
    if((a-n*d<=b && b<=a-n*c) || (a-(n-1)*d+c<=b && b<=a+(n-1)*d-c) || (a+n*c<=b && b<=a+n*d)){
        cout<<"YES";
    }*/
    cout<<"NO";
    
    
    
    
    return 0;
}

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

string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    int N;
    string S;
    cin >> N >> S;


    for( int i =0; i < S.size(); i++){

        char c = S[i];

        int cIndex= 0;

        for( int j = 0; j < abc.size(); j++){
            if (c == abc[j]){
                cIndex=j;
                break;
            }
        }
    
        S[i] = abc[(cIndex+N)%abc.size()];
    }
   
    cout<<S<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int MAX = 3003, MOD = 998244353;
int dp[MAX][MAX], arr[MAX], n,s;


signed main(){

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

	cin>>n>>s;
	for(int i=1;i<=n;i++) cin>>arr[i];
	int ans = 0;
	for(int i=1;i<=n;i++){
		dp[i][arr[i]] = i;

		for(int j=0; j+arr[i]<=s;j++){
			dp[i][j+arr[i]] += dp[i-1][j];
			dp[i][j+arr[i]] %= MOD;
		}
		ans = (ans + (n-i+1)*dp[i][s]) %MOD;
		for(int j=0;j<=s;j++) dp[i][j] = (dp[i][j] + dp[i-1][j]) %MOD;
	}
	cout<<ans;
	

	return 0;
}

Measured memory_bytes: 70656
def num_divisors_table(n):
    table = [0] * (n + 1)  
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1  
    return table
n=int(input())
ans=0
for i,j in enumerate(num_divisors_table(n)):
  ans+=i*j
print(ans)

Measured memory_bytes: 146040
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int have,a,b,result;
		have = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		have = have - a;
		result = have % b;
		System.out.println(result);
	}
}

Measured memory_bytes: 23764
#!/usr/bin/env python3
from itertools import combinations
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
a = [int(item) for item in input().split()]

rgb = [-1, -1, -1]
ans = 1
for item in a:
    cnt = rgb.count(item - 1)
    if cnt == 0:
        print(0)
        exit()
    rgb[rgb.index(item-1)] = item
    ans *= cnt
    ans %= MOD
print(ans)

Measured memory_bytes: 14100
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
     ll x;
     cin>>x;
     cout<<(x>=30?"Yes":"No");
   }
}

Measured memory_bytes: 3644
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
  print(-1)
else:
  Chk=[[False]*n for _ in range(n)]
  E=[]
  for i in range(2,n+1):
    E.append([1,i])
    Chk[0][i-1]=True
  res=(n-1)*(n-2)//2-k
  
  while res>0:
    for i in range(2,n+1):
      for j in range(i+1,n+1):
        if Chk[i-1][j-1]==False:
          s,g=i,j
          Chk[i-1][j-1]=True
          break
      else:
        continue
      break
    E.append([s,g])
    res-=1
  print(len(E))
  for s,g in E:
    print(s,g)


Measured memory_bytes: 4212
n, m = [int(_) for _ in input().split()]

ball = [1 for i in range(n)]
red = [False for i in range(n)]
red[0] = True

for i in range(m):
    x, y = [int(_)-1 for _ in input().split()]
    ball[x] -= 1
    ball[y] += 1
    if red[x]:
        red[y] = True
    if ball[x] == 0:
        red[x] = False

print(sum(red))


Measured memory_bytes: 4656
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int n, k;
  cin >> n >> k;
  vi H(n);
  rep(i, n) cin >> H[i];

  sort(all(H));
  int ans = INF;
  for (int i = 0; i < n - k + 1; i++) {
    ans = min(ans, H[i + k - 1] - H[i]);
  }

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

Measured memory_bytes: 640
n=int(input())
lst=["1","2","3","4","5","6","7","8","9","10","11","12","13"]
#S_list=lst
#H_list=lst
#C_list=lst
#D_list=lst
S_list=["1","2","3","4","5","6","7","8","9","10","11","12","13"]
H_list=["1","2","3","4","5","6","7","8","9","10","11","12","13"]
C_list=["1","2","3","4","5","6","7","8","9","10","11","12","13"]
D_list=["1","2","3","4","5","6","7","8","9","10","11","12","13"]
for i in range(n):
	Del=map(str,raw_input().split())
	if Del[0]=="S":
		S_list.remove(Del[1])
        elif Del[0]=="H": 
                H_list.remove(Del[1]) 
        elif Del[0]=="C": 
                C_list.remove(Del[1]) 
        elif Del[0]=="D": 
                D_list.remove(Del[1]) 
S=map(int,S_list)
H=map(int,H_list)
C=map(int,C_list)
D=map(int,D_list)
#
for i in range(len(S)):
	print "S "+str(S[i])
for i in range(len(H)):
        print "H "+str(H[i])
for i in range(len(C)):
        print "C "+str(C[i])
for i in range(len(D)):
        print "D "+str(D[i])

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 300
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n;
double px[MAX],py[MAX],pz[MAX],vx[MAX],vy[MAX],vz[MAX],r[MAX],vr[MAX];

class State{
  public:
    int a,b;
    double time;
    State(int a,int b,double time):a(a),b(b),time(time){}
    bool operator<(State s)const{
      return time<s.time;
    }
};

void solve(){
  double res[MAX];
  vector<State> v;

  FOR(i,0,n){
    res[i]=r[i]/vr[i];
    FOR(j,i+1,n){
      double X=px[i]-px[j],Y=py[i]-py[j],Z=pz[i]-pz[j];
      double VX=vx[i]-vx[j],VY=vy[i]-vy[j],VZ=vz[i]-vz[j];
      double R=r[i]+r[j],VR=vr[i]+vr[j];
      double c=X*X+Y*Y+Z*Z-R*R;
      double b=X*VX+Y*VY+Z*VZ+R*VR;
      double a=VX*VX+VY*VY+VZ*VZ-VR*VR;
      if(b*b-a*c<-eps)continue;
      double t1=(-b+sqrt(b*b-a*c))/a;
      if(t1<eps || r[i]<t1*vr[i] || r[j]<t1*vr[j])t1=inf;
      double t2=(-b-sqrt(b*b-a*c))/a;
      if(t2<eps || r[i]<t2*vr[i] || r[j]<t2*vr[j])t2=inf;
      double t=min(t1,t2);
      if(t!=inf)v.pb(State(i,j,t));
    }
  }

  sort(all(v));
  FOR(i,0,v.size()){
    int a=v[i].a,b=v[i].b;
    double t=v[i].time;
    if(t<res[a] && t<res[b])res[a]=res[b]=t;
  }
  FOR(i,0,n)pd(res[i]);
}

int main()
{
  while(cin>>n && n){
    FOR(i,0,n){
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3240
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = N / (A + B) * A;
    ans += min(N % (A + B), A);

    cout << ans << endl;
    
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力データを変数で受け取る
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		//入力データを処理して、結果を出力
		int[] array = {a, b, c};
		Arrays.sort(array);
		
		int count = 0;
		if((array[2] - array[1]) % 2 == (array[2] - array[0]) % 2) {
			count = ((array[2] - array[1]) + (array[2] - array[0])) / 2;
		} else {
			count = ((array[2] - array[1]) + (array[2] - array[0]) + 3) / 2;
		}
		
		System.out.println(count);

	}
}


Measured memory_bytes: 35724
//お前を見ている
#include<stdio.h>
int main(void){
  int a=0;
  int b=0;
  int c=0;
  int x=0;
  int i;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
 
  for(i=1;i<=b;i++){
  
  
  if(c==((a*i)%b)){
    printf("YES");
    x=a%b;
    break;
  }
  }
  if(x==0){
    printf("NO");
  }
  
  return 0;
}

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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  auto check = [&](int b) {
    map<int, int> s;
    for (int i = 0; i < n - 1; ++i) {
      if (a[i] >= a[i + 1]) {
        while (!s.empty() && s.rbegin()->first >= a[i + 1]) {
          s.erase(--s.end());
        }
        for (int j = a[i + 1] - 1; ~j; --j) {
          ++s[j];
          if (s[j] == b) {
            s.erase(j);
          } else {
            break;
          }
          if (!j) {
            return false;
          }
        }
      }
    }
    return true;
  };
  bool flag = true;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] >= a[i + 1]) {
      flag = false;
      break;
    }
  }
  if (flag) {
    puts("1");
    return 0;
  }
  int l = 2, r = n + 1;
  while (l < r) {
    int mid = l + r >> 1;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		
		List<List<Integer>> a = new Vector<List<Integer>>(n);
		for(int i = 0; i < n; ++i) {
			a.add(new LinkedList<Integer>());
		}
		
		int u, v;
		for(int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			u = Integer.parseInt(str[0]);
			v = Integer.parseInt(str[1]);
			
			a.get(u).add(v);
			a.get(v).add(u);
		}

		// classify nodes
		int[] d = new int[n];
		int no = 0;
		ArrayDeque<Integer> st = new ArrayDeque<Integer>(); // stack
		for(int i = 0; i < n; ++i) {
			if(d[i] != 0){
				continue;
			}
			no += 1;
			st.push(i); // first node
			while(st.size() > 0){
				for(Integer node: a.get(st.pop())){
					if(d[node] == 0){
						// push the adjacent nodes
						d[node] = no;
						st.push(node);
						
					}
				}
			}
			
		}
		
		// read Q's
		int q = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			u = Integer.parseInt(str[0]);
			v = Integer.parseInt(str[1]);
			if(d[u] != 0 && d[u] == d[v]){
				sb.append("yes\n");
			}else{
				sb.append("no\n");
			}
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 73728
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	string s;
	cin>>s;
	sort(ALL(s));
	if(s=="abc"){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256