akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<LL, int> II;

LL Count(int l, int r, LL d) {
	if (l >= r) return (d == 0) ? (l == r ? 10 : 1) : 0;
	if (d % 10 == 0) return (l == 1 ? 9 : 10) * Count(l + 1, r - 1, d / 10);
	LL diff = d % 10 - 10;
	LL powe = 1;
	for (int i = 1; i <= r - l; ++i) powe *= 10;
	LL nd = d - diff + diff * powe; assert(nd % 10 == 0);
	return ((l == 1 ? 9 : 10) + diff) * Count(l + 1, r - 1, abs(nd) / 10);
}

int main() {
	int d; cin >> d;
	LL ans = 0;
	for (int len = 2; len <= 18; ++len) ans += Count(1, len, d);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   long M = sc.nextLong();
   long[] a = new long[N+1];
   for(int i =0;i<N;i++) 
   {
     a[i] =sc.nextLong();
   }
   long tmp = a[0]/2;
   for(int i =0;i<N;i++)
   {
     tmp = lcm(tmp,a[i]/2);
     if(tmp>M) break;
   }
   long ans =0;
   for(int i=0;i<N;i++)
   {
     if(tmp%(a[i])==0)
     {
       System.out.println(0);
       return;
     }
   }
   if(M - tmp>=0)
   { 
     ans++;
     ans+= (M - tmp)/(2*tmp);
   }
   System.out.println(ans);
 }
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
 }
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
 }
}

Measured memory_bytes: 57148
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
//#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch MatchMatching | diff MatchMatching.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address MatchMatching.cpp && ./a.out

/*
 
 2/28/2019
 
 15:42-16:46 WA
 17:00 give up
 17:41 got AC after fixing order of dp index 😡
 
 */

LL cost[10]={0,2,5,5,4,5,6,3,7,6};

const int MAX_N=1e4+1;
int A[10];
int N,M;

int to[10][MAX_N];
int dp[10][MAX_N];
VI ds;
const int Inf=1e5;
void solve() {
  REP(i,M)ds.push_back(A[i]);
  sort(ds.rbegin(),ds.rend());
  MINUS(to);
  REP(i,10)REP(j,MAX_N) dp[i][j]=-Inf;
  dp[M][0]=0;
  for(int j=M-1; j>=0; --j) for(int i=N; i>=0; --i)/*REPE(i,N)*/ {
    int d=ds[j],c=cost[d];
    for(int k=i/c; k>=0; --k) {
      int ii=i-k*c;
      assert(ii>=0);
      if(dp[j+1][ii]>=0&&dp[j+1][ii]+k>dp[j][i]) {
        dp[j][i]=dp[j+1][ii]+k;
        to[j][i]=k;
        dump(j,d,c,i,k,ii,dp[j][i],dp[j+1][ii]);
      }
    }
  }
  string res;
  int i=N;
  REP(j,M) {
    int cnt=to[j][i];
    assert(cnt>=0);
    int d=ds[j];
    string s(cnt,'0'+d);
    res+=s;
    i=i-cnt*cost[d];
  }
  assert(i==0);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,M) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine((nab[2] - nab[1] + 1) % 2 == 0 ? "Borys" : "Alice");
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[200010], b[200010];
int main() {
	int n, m;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> m;
	rep(i, m)cin >> b[i];
	rep(i, n)if (!binary_search(b, b + m, a[i]))cout << a[i] << endl;
	return 0;
}


Measured memory_bytes: 4620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int K, N;
    cin >> K >> N;
    if(K%2 == 0){
        cout << K/2 << ' ';
        rep(i, N-1) cout << K << ' ';
        cout << endl;
        return 0;
    }
    if(K == 1){
        rep(i, (N+1)/2) cout << 1 << ' ';
        cout << endl;
        return 0;
    }
    int ans[N];
    rep(i, N) ans[i] = (K+1)/2;
    int T = N/2;
    while(T--){
        rep3(i, N-1, 1){
            if(ans[i] == 0 && ans[i-1] <= 1) continue;
            if(ans[i] >= 1) ans[i]--;
            else{
                ans[i-1]--;
                rep2(j, i, N-1) ans[j] = K;
            }
            break;
        }
    }
    rep(i, N){
        if(ans[i] > 0) cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 4744
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

#define ar (int)(400+10)

int a[ar];
int b[ar];
int dp[ar][ar];
int sums[ar][ar];

void inc(int& a,int b)
{
    a+=b;
    if (a>=md){
        a-=md;
    }
}

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n,c;
    cin>>n>>c;
    for (int i=0;i<ar;i++){
        int pow_ij=(i>0?1:0);
        for (int j=0;j<ar;j++){
            sums[i][j]=(sums[i-1][j]+pow_ij)%md;
            pow_ij=pow_ij*i%md;
        }
    }
    for (int i=1;i<=n;i++){
        cin>>a[i];
    }
    for (int i=1;i<=n;i++){
        cin>>b[i];
    }
    dp[0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<=c;j++){
            for (int take=0;j+take<=c;take++){
                inc(dp[i+1][j+take],dp[i][j]*(sums[b[i+1]][take]-sums[a[i+1]-1][take]+md)%md);
            }
        }
    }
    cout<<dp[n][c]<<"\n";
}


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

using namespace std;

int main(){
    int N,M;
   
    cin >> N >> M;
     vector<int> count(M) ;
    int K;
    
    for(int i=0;i<N;i++){
        cin >> K;
        
        for(int j=0;j<K;j++){
            int A; cin >> A; A--;
            count.at(A)++;
        }
    }
    int ans=0;
    for(int i=0;i<M;i++){
        if(count.at(i)==N){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(int n){
ll ans = 1 ;
for(int i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    int a , b ;
    cin >> a >> b ;
    if(a == b){
        cout << "Draw" << endl ;
        return 0;
    }
    if(a == 1)
        a += 13 ;
    if(b == 1)
        b += 13 ;
    if(a > b)
       cout << "Alice" << endl ;
    else
        cout << "Bob" << endl ;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)

int main() {
	double d, t, s;
	cin >> d >> t >> s;
	if (d / s <= t) {
		
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int a,b;
  cin >> a >> b;
  cout << max({a+b,a-b,a*b}) << endl;
    
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int t[n];

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

    int m;
    scanf("%d", &m);

    for(int i = 0; i<m; i++){
        int xn, nt;
        scanf("%d %d", &xn, &nt);
        printf("%d\n", total - t[xn-1] + nt);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string o= "CODEFESTIVAL2016";
string s; int wa=0;
int main(){
  cin >> s;
  for (size_t i = 0; i < o.length(); i++) {
    if(o[i] != s[i]) wa++;
  }
  cout << wa << endl; 
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int x,t,n;
	scanf("%d %d %d",&n,&x,&t);
	if(n%x==0){
		printf("%d",(n/x)*t);
		return 0;
	}
	printf("%d",(n/x+1)*t);
	return 0;
} 

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

int main(){
    int n; cin >> n;
    vector<int> a(100000);
    vector<int> cnt(100000);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]==0){
            cnt[0]++; cnt[1]++; 
        }else if(a[i]==100000-1){
            cnt[100000-2]++; cnt[100000-1]++;
        }else{
            cnt[a[i]-1]++; cnt[a[i]]++; cnt[a[i]+1]++;
        }
    }
    int ans = 0;
    for(int i=0; i<100000; i++){
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
x, y = map(int, input().split())

if x >= 0:
	if y >= x:
		print(y - x)
	elif abs(y) < x:
		if y <= 0:
			print(1 + x + y)
		else:
			print(2 + x - y)
	elif -y == x:
		print(1)
	else:
		print(1 - x - y)
else:
	if -x == y:
		print(1)
	elif abs(x) >= abs(y):
		if y <= 0:
			print(y - x)
		else:
			print(1 - x - y)
	elif y > 0:
		print(1 + x + y)
	else:
		print(2 + x - y)

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

A.sort()
A_max = A[-1]

checked = [False] * (A_max+1)
ans = 0
for i in range(N):
    if i < N-1:
        if A[i] == A[i+1]:
            for j in range(A[i], A_max+1, A[i]):
                checked[j] = True
    if checked[A[i]]:
        pass
    else:
        ans += 1
        for j in range(A[i], A_max+1, A[i]):
            checked[j] = True

print(ans)


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

using namespace std;

long long n;

vector <vector <pair <long long, long long> > > g;

vector <long long> d;


void dfs(long long i, long long p = -1, long long dist = 0) {
	d[i] = dist;
	for (auto j : g[i]) {
		if (j.first != p) {
			dfs(j.first, i, dist + j.second);
		}
	}
}


int main () {
	cin >> n;
	d.assign(n, 1e9 + 10);
	
	g = vector <vector <pair <long long, long long> > > (n); 
	
	for (long long i = 0; i < n - 1; i++) {
		long long a, b, c;
		cin >> a >> b >> c;
		g[a - 1].emplace_back(b - 1, c);
		g[b - 1].emplace_back(a - 1, c);
	}
	
	long long q, k; cin >> q >> k;
	k--;
	dfs(k);
	
	for (long long i = 0; i < q; i++) {
		long long x, y; cin >> x >> y;
		cout << d[x - 1] + d[y - 1] << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) {
	n, m, k := sc.getInt3()
	as := sc.getInts(n)
	bs := sc.getInts(m)

	f := func(as []int) []int {
		ret := make([]int, len(as)+1)
		for i, a := range as {
			ret[i+1] = ret[i] + a
		}
		return ret
	}
	ca := f(as)
	cb := f(bs)

	sort.Sort(sort.Reverse(sort.IntSlice(ca)))
	sort.Sort(sort.Reverse(sort.IntSlice(cb)))

	ans := 0
	f1 := func(ca, cb []int) {
		for i, a := range ca {
			if a > k {
				continue
			}

			j := sort.Search(len(cb), func(i int) bool {
				return k >= a+cb[i]
			})

			num := (len(ca) - i - 1) + (len(cb) - j - 1)
			ans = max(ans, num)
		}
	}
	f1(ca, cb)
	f1(cb, ca)
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 9588
n = int(input())
*A, = map(int, input().split())
ans = 0
for i in range(n):
    j = A[i:].index(min(A[i:])) + i
    A[i], A[j] = A[j], A[i]
    if i != j:
        ans += 1
print(*A)
print(ans)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <iomanip>

using namespace std;

int main()
{
	int L;

	cin >> L;

	long double cube;
	long double hen = (long double)L / 3;
	cube = hen * hen*hen;
	cout <<fixed<<setprecision(12)<<cube << endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


void solve(int N, vi& c, vi& s, vi& f) {
    for (int st=0; st<N; ++st) {
        int t = 0;
        for (int i=st; i<N-1; ++i) {
            if (t < s[i]) t = s[i];
            else {
                int qceil = (t + f[i]-1) / f[i];
                t = f[i] * qceil;
            }
            t += c[i];
        }
        cout << t << endl;
    }
}

int main() {
    int N; cin >> N;
    vi c(N-1),s(N-1),f(N-1);
    rep(i,N-1) cin >> c[i] >> s[i] >> f[i];
    solve(N,c,s,f);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[100005];
char t[100005];
int sA[100005];
int tA[100005];
int mem[3][3] = {
        {0, 2, 1},
        {1, 0, 2},
        {2, 1, 0}
};
int main(){
    scanf("%s",s+1);
    scanf("%s",t+1);
    int n = strlen(s+1);
    int m = strlen(t+1);
    for(int i = 1; i <= n; i++){
        sA[i] = sA[i-1] + (s[i] == 'A' ? 1 : 0);
    }
    for(int i = 1; i <= m; i++){
        tA[i] = tA[i-1] + (t[i] == 'A' ? 1 : 0);
    }
    int q;
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int sa = sA[b] - sA[a-1];
        int sb = b-a+1 - sA[b] + sA[a-1];
        int ta = tA[d] - tA[c-1];
        int tb = d-c+1 - tA[d] + tA[c-1];
        sa %= 3;
        sb %= 3;
        ta %= 3;
        tb %= 3;
        if(mem[sa][sb] == mem[ta][tb]){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string k[101][101];
int main(){
	long long i,j,n,m;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>k[i][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(k[i][j][0]=='s'&&k[i][j][1]=='n'&&k[i][j][2]=='u'&&k[i][j][3]=='k'&&k[i][j][4]=='e'){
				cout<<char(64+j)<<i;
				return 0;
			}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line1=sc.nextLine().split(" ");
        int l=Integer.parseInt(line1[0]);
        int r=Integer.parseInt(line1[1]);
        int d=Integer.parseInt(line1[2]);
		
		int count=0;
		for(int a=l;a<=r;a++) {
			if(a%d==0) {
				count++;
			}
		}
        
        System.out.println(count);
        
        
	}
  
}


Measured memory_bytes: 35664
#include<stdio.h>
     
int main(void){
 int h,m,s;
 scanf("%d", &s);
 h = s/3600;
 m = (s%3600)/60;
 s = (s%3600)%60;
 printf("%d:%d:%d\n",h, m, s);
 return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 200000

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX+1];
    fget_array(&arr[1], num);
    static int map[NUM_MAX+1];
    int i;
    // A_i + i = j - A_j
    for(i = 1; i <= num; i++) {
        int val = arr[i]+i;
        if(val <= NUM_MAX) map[val]++;
    }

    int64_t ans = 0;
    for(i = num; i >= 1; i--) {
        int val = arr[i]+i;
        if(val <= NUM_MAX) map[val]--;
        // j > i
        int jval = i-arr[i];
        if(jval >= 0) ans += map[jval];
    }

    printf("%lld\n", ans);
    return 0;
}

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

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

const int N = (int) 2e3;
const int INF = (int) 1e9 + 7;

ii p[N + 7];
ll dp[N + 7][N + 7];
bool sel[N + 7];
int n;

ll f(int i, int l, int r) {
	if (i == 0) return 0;
	if (dp[l][r] != -1) return dp[l][r];

	ll x = f(i - 1, l + 1, r) + (ll) p[i].fs * abs(l - p[i].sc);
	ll y = f(i - 1, l, r - 1) + (ll) p[i].fs * abs(r - p[i].sc);

	return dp[l][r] = max(x, y);
}

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	sf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		sf("%d", &p[i].fs);
		p[i].sc = i;
	}

	sort(p + 1, p + n + 1);

	memset(dp, -1, sizeof(dp));
	printf("%lld", f(n, 1, n));

	return 0;
}


Measured memory_bytes: 35452
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define N 105
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
int a[N], ans = (1 << 30);
int main(){
	int i, j, n, m, sum;
	scanf("%d", &n);
	for(i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(i = -100; i <= 100; i++){
		sum = 0;
		for(j = 1; j <= n; j++) sum += (i - a[j]) * (i - a[j]);
		ans = min(ans, sum);
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 100

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

map<P, int> dp;
int w[MAX_N], v[MAX_N], n;

ll calc(int r, int pos){
  if(dp[{r, pos}]!=0)return dp[{r, pos}];
  if(pos>=n)return 0;
  if(r-w[pos]>=0){
    return dp[{r, pos}]=max(calc(r, pos+1), calc(r-w[pos], pos+1)+v[pos]);
  }else{
    return dp[{r, pos}]=calc(r, pos+1);
  }

}

int main(){
  int W;cin>>n>>W;
  rep(i, n){
    cin>>w[i]>>v[i];
  }
  cout<<calc(W, 0)<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 6400
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5||a==5&&c==5||b==5&&c==5){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;

ll a[maxn];
ll n;

int main(){
    cin >> n;
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout << "NO"<<endl;
            return 0;
        }
        if(i==n-2){
            cout << "YES"<<endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 5148
import sys
sys.setrecursionlimit(1000000)

N=int(input())
n=[[]for i in range(N+1)]

for i in range(N-1):
    a,b,c=map(int,input().split())
    n[a].append([b,c])
    n[b].append([a,c])
    
L=[-1 for i in range(N+1)]

Q,K=map(int,input().split())

L[K]=0

def dfs(x):
    for i in n[x]:
        if L[i[0]]==-1:
            L[i[0]]=L[x]+i[1]
            dfs(i[0])
dfs(K)
#print(n)
#print(L)

for i in range(Q):
    x,y=map(int,input().split())
    print(L[x]+L[y])

Measured memory_bytes: 137992
/*************************************************************************
    > File Name: B.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/4/29 19:57:33
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------
bool vis[333];
int main(){
#ifdef HandsomeHow
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	int a,b,c;
	cin>>a>>b>>c;
	int su = a%b;
	while(true){
		if(su==c){
			puts("YES");
			return 0;
		}
		if(vis[su]){
			puts("NO");
			return 0;
		}
		vis[su]=true;
		su=su+a;
		su%=b;
	}
	return 0;
}



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

int main() {
    int A, B;
    cin >> A >> B;
    if (max(A,B) <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int n;
	string tmp, s = "keyence";

	cin >> tmp;

	n = tmp.size();

	for (int i = 1; i <= 7; i++) {

		if (tmp.substr(0, i) + tmp.substr(n - (7 - i)) == s) {

			cout << "YES";
			return 0;
		}
	}

	cout << "NO";
}


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

int is_kaibun(string a){
    int n = a.length();
    int flag = 1;

    // 前後の一致を確認
    for(int i = 0; i < (n/2); i++){
        if(a[i] != a[n-1-i]) flag = 0; // 一致しなかったら回文でない
    }

    return flag;
}

int main()
{
    //入力
    string s;
    cin >> s;

    //文字列の前半と後半を取り出す
    int n = s.length(); // 長さ取得
    string formar_s = s.substr(0,((n-1)/2));
    string latter_s = s.substr((n+1)/2);

    int flag = is_kaibun(s) && is_kaibun(formar_s) && is_kaibun(latter_s);

    if(flag == 1) cout << "Yes" << endl;
    if(flag == 0) cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	int A,B;
	string trow;
	cin>>a>>b>>A>>B>>trow;
	if(a == trow)
		A--;
	else if(b == trow)
		B--;
		
	cout<<A<<" "<<B<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    K = int(input())
    if K%10:
        if K%7==0:
            K//=7
        L = 9*K
        mod = 10%L
        for i in range(9000001):
            if mod == 1:
                print(i+1)
                exit()
            mod = 10*mod%L
        print(-1)
    else:
        print(-1)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const ll ccc=1000000;
bool prime[ccc+1];
int cnt[ccc+1];
void makeprime(){
	ll iii,jjj;
	for(iii=0;iii<=ccc;iii++){
		prime[iii]=true;
	}
	prime[0]=false;
	prime[1]=false;
	for(iii=2;iii*iii<=ccc;iii++){
		if(prime[iii]){
			for(jjj=2*iii;jjj<=ccc;jjj+=iii){
				prime[jjj]=false;
			}
		}
	}
	for(int i=1;i<ccc;i++){
		cnt[i]=cnt[i-1];
		if(prime[i]) cnt[i]++;
	}
}
int main(){
	makeprime();
	while(true){
		int n;
		scanf("%d",&n);
		if(!n) break;
		printf("%d\n",cnt[2*n]-cnt[n]);
	}
	return 0;
}

Measured memory_bytes: 6068
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		double ans=0.0;
		int [] x=new int [n];
		int [] y=new int [n];
		for(int i=0;i<n;i++)
		{
			x[i]=in.nextInt();
			y[i]=in.nextInt();
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i!=j)
				{
					double q=Math.pow((x[i]-x[j]),2)+Math.pow((y[i]-y[j]),2);
					ans=ans+Math.sqrt(q);
				}
			}
		}
		ans=ans/n;
		System.out.println(ans);
	}
}
	

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

int main() {
  string a,b;
  cin>>a>>b;
  int temp=stoi(a+b);
  if((int)sqrt(temp)*(int)sqrt(temp)==temp) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#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;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 102;

int n;
int p[N];

int calc(int x) {
	int res = 0;
	for (int i = 0; i < n; i++)
		res += (x - p[i]) * (x - p[i]);
	return res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p, p + n);
	int st = 0, en = N;
	while (st < en) {
		int mid = st + (en - st) / 2;
		if (calc(mid) > calc(mid + 1))
			st = mid + 1;
		else
			en = mid;
	}
	cout << calc(st) << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
from collections import deque
import sys
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()

cnt = 0
for left in range(N):
  for right in range(left+1,N):
    if a[left] > a[right]:
      cnt += 1
cnt = (cnt*K) %mod

a.sort()
tmp = 0
for i in range(N-1):
  if a[i+1] > a[i]:
    tmp = i+1
  cnt += ((tmp*K*(K-1))//2) %mod

print(cnt %mod)

"""
2 1000000006
2 1

10 3
10 9 8 7 6 5 4 3 2 1
"""

Measured memory_bytes: 3572
//#define DEBUG
#define MAXN 2000000000
#define ll long long int
#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef DEBUG
    freopen("in.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x;
    cin >> x;
    if (x == 1) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin >> a >> b;
c=a+b;
if(c<a-b)
  {
    c=a-b;
  }
if(c<a*b)
  {
    c=a*b;
  }
cout << c << endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

def main(n):
	if n[0] == "#":
		return
	if (int(n[1]) > 31) or (int(n[1]) == 31 and int(n[2]) > 4):
		n[0] = "?"
		n[1] = str(int(n[1]) - 30)
	print(" ".join(n))
	return main(input().split())

main(input().split())


Measured memory_bytes: 5624
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    writeln(min(C, B / A));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    bool ans = (s*t - d >=0);
    cout << (ans?"Yes":"No") << "\n";
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n;
   cin >> n;
   int x = n;
   int tmp = 0;
   while(n != 0){
      tmp += n % 10;
      n /= 10;
   }
   if(x % tmp == 0)cout << "Yes";
   else cout << "No";
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

vector<int64> Eratosthenes(  int64 N )
{
    N *= 2;
    vector<int64> p;
    vector<bool> is_prime(N+1, true);
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            p.emplace_back( i );
        }
    }
    return p;
}

int main() {
    int64 x;
    cin >> x;
    vector<int64> ans = Eratosthenes(x);
    cout << *lower_bound(ans.begin(), ans.end(), x) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define r0 return 0
using namespace std;

int main()
{
    ll n,m,i,j,k,t,x;

    cin>>x;

    if(x>=400 && x<=599){

        x=8;
    }
    else if(x>=600 && x<=799){

        x=7;
    }
    else if(x>=800 && x<=999){

        x=6;
    }
    else if(x>=1000 && x<=1199){

        x=5;
    }
    else if(x>=1200 && x<=1399){

        x=4;
    }
    else if(x>=1400 && x<=1599){

        x=3;
    }
    else if(x>=1600 && x<=1799){

        x=2;
    }
    else if(x>=1800 && x<=1999){

        x=1;
    }

    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 3632
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto X = nx[1];
    auto LS = readln.split.to!(int[]);

    int d, c;
    foreach (l; LS) {
        ++c;
        d += l;
        if (d > X) break;
    }
    if (d <= X) ++c;
    writeln(c);
}

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

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 dp[110000];

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

    for (int i = 0; i < 110000; i++)dp[i] = i;

    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = 6; j <= n; j *= 6)
        {
            if(i + j > 110000)break;
            chmin(dp[i + j], dp[i] + 1);
        }
        for (int j = 9; j <= n; j *= 9)
        {
            if(i + j > 110000)break;
            chmin(dp[i + j], dp[i] + 1);
        }
    }
    
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    int m, n, i, j, k, l;
    cin>>n>>m;
    vector<string> a(n), b(m);
    for(i = 0; i<n; i++)
    {
        cin>>a[i];
    }
    for(j = 0; j<m; j++)
    {
        cin>>b[j];
    }
    for(i = 0; i<n; i++)
    {
        for(j = 0; j<n; j++)
        {
            if(a[i][j]!= b[0][0]) continue;
            bool x = 1;
            for(k = 0; k<m; k++)
            {
                for(l = 0; l<m; l++)
                {
                    if(i+k>=n || j+l>=n || a[i+k][j+l]!=b[k][l])
                    {
                        x = 0;
                        break;
                    }
                }

            }
             if(x)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }

        }
    }
    cout<<"No"<<endl;
    return 0;
}







Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s; cin >> s;
  int one =0;
  int ans=0;
  rep(i,s.size()) {
    if(s.at(i)!='1'){
      ans = s.at(i)-'0';
      break;
    }
    one++;
  }
  ll k; cin >> k;
  if(one>=k) puts("1");
  else cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int n;
    cin>>n;
    int x = 0;
    for (int i=0; i<n; ++i) {
        int l, r;
        cin>>l>>r;
        int num = r - l + 1;
        x += num;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import random
def isPrime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
ls = []
for i in range(6,55555+1,5):
    if isPrime(i):
        ls.append(i)
N = int(input())
print(*ls[:N])

Measured memory_bytes: 9524
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1316

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int H,W;
vector< vector<char> > matrix;
map<string, int> spell_map;

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

string mystrcmp(string str1, string str2)
{
	if(str1.length() == str2.length()){
		return (str1 <= str2) ? str1 : str2;
	}else{
		return (str1.length() > str2.length()) ? str1 : str2;
	}
}

void dfs(int sx, int sy, int x, int y, int d, string spell)
{
	int nx = (x + dx[d] + W) % W;
	int ny = (y + dy[d] + H) % H;

	spell_map[spell]++;

	if(nx == sx && ny == sy){ 
		 return; 
	}else{
		dfs(sx,sy,nx,ny,d,spell+matrix[ny][nx]);
	}
}

int main()
{
	while(cin >> H >> W && H)
	{
		matrix.assign(H,vector<char>(W));
		spell_map.clear();
		
		rep(h,H){
			rep(w,W){
				cin >> matrix[h][w];
			}
		}

		rep(y,H){
			rep(x,W){
				rep(d,8){
					string str;
					str = str + matrix[y][x];
					dfs( x, y, x, y, d, str);
				}
			}
		}

		string ans;
		for(auto &it : spell_map){
			if(it.second >= 2){
				ans = mystrcmp( ans, it.first );
			}
		}

		cout << ((ans.length() >= 2) ? ans : "0") << endl;
	}
	return 0;
}

Measured memory_bytes: 36160
def nyukokushinsa(a):
  for a_i in a:
    if a_i % 2 == 0 and (a_i % 3 != 0 and a_i % 5 != 0):
      return 'DENIED'

  return 'APPROVED'

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

print(nyukokushinsa(a))

Measured memory_bytes: 3064
#include <stdio.h>

int main (void)
{
	int i,j,k,n,b;
	char S[13],H[13],C[13],D[13],a;
	
	scanf("%d",&n);
	
	for( i=0 ; i<n+1 ; i++){
		scanf("%c %d\n",&a,&b);
		if(a=='S'){S[b-1]=b;}
		else if(a=='H'){H[b-1]=b;}
		else if(a=='C'){C[b-1]=b;}
		else if(a=='D'){D[b-1]=b;}
	}
	
	for( j=0 ; j<4 ; j++ ){
		for( k=0 ; k<13 ; k++ ){
			if(j==0){
				if(S[k]!=k+1){
					printf("S %d\n",k+1);
				}}if(j==1){
				if(H[k]!=k+1){
					printf("H %d\n",k+1);
				}}if(j==2){
				if(C[k]!=k+1){
					printf("C %d\n",k+1);
				}}if(j==3){
				if(D[k]!=k+1){
					printf("D %d\n",k+1);
				}}
			}
		}
		
		return 0;
}

Measured memory_bytes: 600