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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

struct ConvexHullTrick{
    using Line = std::tuple<ll, ll>;
    std::vector<Line> lines;

    void addLine(ll a, ll b){
        while(lines.size() >= 2){
            ll a1, b1, a2, b2;
            std::tie(a1, b1) = *(lines.rbegin() + 1);
            std::tie(a2, b2) = *lines.rbegin();

            if(-(b - b1) * (a - a2) < -(b - b2) * (a - a1)){
                break;
            }else{
                lines.pop_back();
            }
        }

        lines.emplace_back(a, b);
    }

    ll maximum(ll x){
        int n = lines.size();
        int lb = 0, ub = n;

        auto at = [](ll x, Line l) -> ll {
                      ll a, b;
                      std::tie(a, b) = l;

                      return a * x + b;
                  };

        while(ub - lb > 2){
            int m1 = (2 * lb + 1 * ub) / 3, m2 = (1 * lb + 2 * ub) / 3;

            ll y1 = at(x, lines[m1]), y2 = at(x, lines[m2]);
            if(y1 < y2){
                lb = m1;
            }else{
                ub = m2;
            }
        }

        ll y = at(x, lines[lb]);

        if(ub - lb == 2){
            y = std::max(y, at(x, lines[lb + 1]));
        }

        return y;
    }
};

int N;
ll C;
ll h[200100];
ll dp[200100];
ConvexHullTrick cht;

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

    std::cin >> N >> C;

    for(int i=0;i<N;++i){
        std::cin >> h[i];
    }

    cht.addLine(h[0] * 2, - h[0] * h[0]);

    for(int i=1;i<N;++i){
        dp[i] = h[i] * h[i] + C - cht.maximum(h[i]);
        cht.addLine(h[i] * 2, - (h[i] * h[i] + dp[i]));
    }

    ll mn = dp[N-1];
    std::cout << mn << std::endl;
}


Measured memory_bytes: 9328
/*  ex3_2
    supercomputerjoi    */

#include <stdio.h>

int main(void){

    int num;
    int firstDigit;

    // input N
    scanf("%d", &num);

    // calculate first digit
    firstDigit = num % 10;

    // conditional branch
    switch (firstDigit) {
        case 0:     // if num = 0
            printf("pon\n");
            break;
        case 1:     // if num = 1
            printf("pon\n");
            break;
        case 2:     // if num = 2
            printf("hon\n");
            break;
        case 3:     // if num = 3
            printf("bon\n");
            break;
        case 4:     // if num = 4
            printf("hon\n");
            break;
        case 5:     // if num = 5
            printf("hon\n");
            break;
        case 6:     // if num = 6
            printf("pon\n");
            break;
        case 7:     // if num = 7
            printf("hon\n");
            break;
        case 8:     // if num = 8
            printf("pon\n");
            break;
        case 9:     // if num = 9
            printf("hon\n");
            break;
    }

    return 0;
}

Measured memory_bytes: 1652
import java.util.Scanner;

public class Main {
	public static int ceil(int a, int b){
		int x = (a + (b - 1))/b;
		return x;
	}

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N+1];
		int ans = 0;
		
		B[0] = (int)Math.pow(10, 6);
		B[N] = (int)Math.pow(10, 6);
		
		for(int i=1; i < N; i++) {
			B[i] = sc.nextInt();
	    }
		for(int i=0; i < N; i++) {
			ans += Math.min(B[i], B[i+1]);
	    }
		System.out.println(ans);
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}


Measured memory_bytes: 256
//q4.cpp

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

#define MAX_N 1010

int n,m,d[MAX_N],c[MAX_N];
long long dp[MAX_N][MAX_N];

int main(){
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<=1000;i++)
        for(int j=0;j<=1000;j++)
            dp[i][j]=1000000000000;
    
    for(int i=0;i<n;i++)
        scanf("%d",&d[i]);
    
    for(int i=1;i<=m;i++)
        scanf("%d",&c[i]);
    
    dp[0][0]=0;
    
    
    for(int i=1;i<=m;i++){
        for(int j=0;j<=n;j++){
            dp[i][j+1]=min(dp[i][j+1],dp[i-1][j]+c[i]*d[j]);
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    
    printf("%lld\n",dp[m][n]);
    
    return 0;
}

Measured memory_bytes: 9100
n = gets.chop.to_i
l = gets.chop.split.map(&:to_i)

max_l = l.max


# n.times { |i| sum_l += l[i] unless l[i] == max_l}
sum = 0


sum_l =  l.inject(:+) - max_l

if max_l < sum_l then
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
package main

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

type Query struct {
	p int
	q int
}

var N int
var M int
var Q int
var train [][]int
var query []Query
var dp [][]int

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	M = nextInt()
	Q = nextInt()

	train = make([][]int, N+1)
	dp = make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		train[i] = make([]int, N+1)
		dp[i] = make([]int, N+1)
		for j := 0; j < N+1; j++ {
			train[i][j] = 0
			dp[i][j] = -1
		}
	}
	for i := 0; i < M; i++ {
		L := nextInt()
		R := nextInt()
		train[L][R]++
	}
	query = make([]Query, Q)
	for i := 0; i < Q; i++ {
		query[i] = Query{
			p: nextInt(),
			q: nextInt(),
		}
	}

	for i := 0; i < Q; i++ {
		ans := query[i].run()
		fmt.Println(ans)
	}
}

// queryを実行し、p,qに含まれる区間のtrainの数を返す
func (qu Query) run() int {
	return subQuery(qu.q, qu.q) - subQuery(qu.q, qu.p-1) - subQuery(qu.p-1, qu.q) + subQuery(qu.p-1, qu.p-1)
}

// Lがl以下、Rがr以下の個数を返す
func subQuery(l int, r int) int {
	if l == 0 || r == 0 {
		return 0
	}
	if dp[l][r] != -1 {
		return dp[l][r]
	}
	ans := subQuery(l-1, r) + subQuery(l, r-1) - subQuery(l-1, r-1) + train[l][r]
	dp[l][r] = ans
	return ans
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >>h2 >> m2 >> k;
    cout << (h2-h1)*60 + (m2-m1) - k <<"\n";
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  int r[n+1];
  for(int i=1;i<=n;i++)
  {
    r[a[i]]=i;
   
  }
  for(int i=1;i<=n;i++)
  {
    
    cout<<r[i]<<" ";
  }
  return 0;
}
  

Measured memory_bytes: 1536
import sys
k = int(input())
if k < 10:
    print(k)
    sys.exit()

total = 9
lunluns = []
for i in range(10, 100):
    if abs(i // 10 - i % 10) <= 1:
        lunluns.append('{:02d}'.format(i))
if k < 10 + len(lunluns):
    print(lunluns[k - 10])
    sys.exit()
total = 9 + len(lunluns)

while True:
    new = []
    for lunlun in lunluns:
        if lunlun[-1] == '0':
            new.append(lunlun + '0')
            new.append(lunlun + '1')
        elif lunlun[-1] == '9':
            new.append(lunlun + '8')
            new.append(lunlun + '9')
        else:
            new.append(lunlun + str(int(lunlun[-1])-1))
            new.append(lunlun + lunlun[-1])
            new.append(lunlun + str(int(lunlun[-1])+1))

    lunluns = new
    if total + len(lunluns) >= k:
        print(lunluns[k - total - 1])
        break
    total += len(lunluns)


Measured memory_bytes: 15636
def main():
    N, M = map(int, input().split())
    pre = set()
    wa = [0] * N
    ans, ans2 = 0, 0
    for _ in range(M):
        p, s = input().split()

        if int(p) in pre:
            continue

        if s == 'AC':
            pre.add(int(p))
            ans += 1
        else:
            wa[int(p)-1] += 1

    for i in range(N):
        if (i+1) in pre:
            ans2 += wa[i]
    print(ans, ans2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 12668
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
vector<int> K[2];
vector<P> T[2];
int main(){
  char buf[256];
  int k,t;
  while(1){
    fgets(buf,sizeof(buf),stdin);
    if(buf[0]=='\n') break;
    sscanf(buf,"%d,%d",&k,&t);
    K[0].push_back(k);
  }
  while(~scanf("%d,%d",&k,&t)){
    K[1].push_back(k);
  }
  for(int i=0;i<2;i++){
    sort(K[i].begin(),K[i].end());
    int tmp = K[i][0]-1;
    for(int j=0;j<(int)K[i].size();j++){
      if(tmp != K[i][j]){
	tmp = K[i][j];
	T[i].push_back(P(tmp,1));
      }
      else{
	T[i].back().S++;
      }
    }
  }
  for(int i=0,j=0;i<(int)T[0].size() && j<(int)T[1].size();){
    if(T[0][i].F==T[1][j].F){
      printf("%d %d\n",T[0][i].F,T[0][i].S+T[1][j].S);
      i++; j++;
    } else if (T[0][i].F < T[1][j].F){
      i++;
    } else {
      j++;
    }
  }
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n, m;
	map<string, int> id;
	cin >> n;
	for(int i=0; i<n; i++){
		string t;
		cin >> t;
		id[t] = 1;
	}
	cin >> m;
	int state = 1;
	for(int i=0; i<m; i++){
		string t;
		cin >> t;
		if(id.find(t) == id.end()){
			cout << "Unknown " << t << endl;
		}else if(state == 1){
			cout << "Opened by " << t << endl;
			state = 0;
		}else if(state == 0){
			cout << "Closed by " << t << endl;
			state = 1;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1236
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

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

        if(a == b){
            System.out.println("Draw");
        }else if(a == 1 || (a > b && b != 1)){
            System.out.println("Alice");
        }else{
            System.out.println("Bob");
        }





    } // mainMethod



} // MainClass


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  long long X;
  cin>>X;
  if(X%11==0){
    cout<<X/11*2<<endl;
  }else if(X%11<=6){
    cout<<X/11*2+1<<endl;
  }else{
    cout<<X/11*2+2<<endl;
  }
  return 0;
}


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


int main() {
  long long K,N;
  cin >> N >> K;
  long long p[N];
  for(int i=0;i<N;++i) cin >> p[i];

  double Values[N];
  for(int i=0;i<N;++i){
    Values[i] = (1.0 + p[i])/2.0;
  }

  vector<double> SumValues(N,0);
  double sum = 0;
  for(int i=0;i<N;++i){
    SumValues[i] = Values[i] + sum;
    sum += Values[i];
  }

  vector<double> RangeValues(N,0);
  for(int i=0;i+K<=N;++i){
    if(i==0){
      RangeValues[i] = SumValues[i+K-1];
    }else{
      RangeValues[i] = SumValues[i+K-1] - SumValues[i-1];
    }
  }

  double ans = *max_element(RangeValues.begin(),RangeValues.end());
  // cout << max_val << endl;
  printf("%.10f\n", ans);
  // int dump;
  // cin >> dump;
  return 0;
}



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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename T>
T gcd(T a, T b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//use ll or int for gcd

//---------------------------------------------------------------

int main(){
  int N;
  ll maxA = 0;
  cin>>N;
  vector<bool> S(1000000000,0);
  rep(i,N){
    ll A;
    cin>>A;
    S.at(A-1)=!S.at(A-1);
    maxA = max(A,maxA);
  }
  ll ans = 0;
  llrep(i,maxA){
    ans+=S.at(i);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 122368
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007LL;
in p2(in a){
  return (1LL<<a);
}
in pw(in a, in b, in lm=62){
  a%=mdl;
  if(a<0)
    a+=mdl;
  in r=1;
  for(in i=lm;i>=0;--i){
    r=r*r%mdl;
    if(b&p2(i))
      r=r*a%mdl;
  }
  return r;
}
in inv(in a){
  a%=mdl;
  if(a<0)
    a+=mdl;
  assert(a!=0);
  return pw(a,mdl-2,30);
}
VI fc,invfc;
in ncr(in a, in b){
  if(b==0 || b==a)
    return 1;//even if a<0
  if(b<0 || b>a)
    return 0;
  return fc[a]*invfc[b]%mdl*invfc[a-b]%mdl;
}
void inifc(){
  const in mxfc=1001000;
  fc.resize(mxfc);
  invfc.resize(mxfc);
  fc[0]=fc[1]=invfc[0]=invfc[1]=1;
  for(in i=2;i<mxfc;++i){
    fc[i]=fc[i-1]*i%mdl;
    invfc[i]=invfc[mdl%i]*(mdl-mdl/i)%mdl;
  }
  for(in i=2;i<mxfc;++i){
    invfc[i]*=invfc[i-1];
    invfc[i]%=mdl;
  }
}
void fl(){
  cout<<0<<endl;
  exit(0);
}
in tw(in cnt, in wmix, in wsing){
  in sm=0;
  in cmix=0;
  in wsl=1;
  while(cmix<=cnt){
    if(wsing)
      sm+=pw(wmix,cmix/2)*pw(2,cnt-cmix)%mdl*wsl%mdl*invfc[cmix/2]%mdl;
    else
      sm+=pw(wmix,cmix/2)*wsl%mdl*invfc[cmix/2]%mdl;
    wsl*=cnt-cmix;
    wsl%=mdl;
    ++cmix;
    wsl*=cnt-cmix;
    wsl%=mdl;
    ++cmix;
    wsl*=inv(2);
    wsl%=mdl;
  }
  sm%=mdl;
  return sm;
}
VI pcyc;
VI a;
VI dg;
VI itsz;
VI vis;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  inifc();
  in n;
  cin>>n;
  a.resize(n);
  pcyc.resize(n+1);
  dg.resize(n);
  forn(i,n){
    cin>>a[i];
    --a[i];
    ++dg[a[i]];
    if(dg[a[i]]>2)
      fl();
  }
  itsz.resize(n);
  vis.resize(n);
  queue<in> q;
  forn(i,n){
    if(dg[i]==0){
      vis[i]=1;
      q.push(i);
    }
  }
  while(!q.empty()){
    in u=q.front();
    q.pop();
    if(itsz[a[u]])
      fl();
    itsz[a[u]]=itsz[u]+1;
    if(dg[a[u]]==1){
      vis[a[u]]=1;
      q.push(a[u]);
    }
  }
  VI tit;
  in wys=1;
  forn(i,n){
    tit.clear();
    if(vis[i])
      continue;
    in u=i;
    in ft=-1;
    do{
      vis[u]=1;
      tit.PB(itsz[u]);
      if(itsz[u])
	ft=sz(tit)-1;
      u=a[u];
    }while(u!=i);
    if(ft==-1){
      ++pcyc[sz(tit)];
      continue;
    }
    in cf=ft;
    do{
      in cnt=0;
      do{
	++cnt;
	cf=(cf+1)%sz(tit);
      }while(tit[cf]==0);
      if(cnt<tit[cf])
	fl();
      if(cnt>tit[cf])
	wys=wys*2%mdl;
    }while(cf!=ft);
  }
  forn(i,n+1){
    if(pcyc[i]){
      wys=wys*tw(pcyc[i],i,((i%2==1 && i!=1)?1:0))%mdl;
    }
  }
  cout<<wys<<endl;
  return 0;
}


Measured memory_bytes: 20984
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
 
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;
 


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)cin >> a[i];
  sort(ALL(a));
  ll res = 1, now = 0;
  rep(i, n - 1){
    now += a[i];
    if(a[i + 1] <= 2 * now){
      res++;
    }
    else res = 1;
  }
  cout << res << endl;
}
 

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }
    else if (a >=6 && a <=12){
        cout << b/2 <<endl;
    }
    else{
        cout << 0 <<endl;
    }

    
    
}

Measured memory_bytes: 256
import Data.Char
 
main :: IO ()
main = do
    [n, a, b] <- (map read) . words <$> getLine
    let results = (\i -> (i, (sum . (map digitToInt) . show) i)) <$> [1..n]
    print . sum $ map fst $ filter (\i -> (snd i)>=a && (snd i)<=b) results

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

int main() {
 string S,T,U;
 int A,B;
 cin >> S >> T;
 cin >> A >> B;
 cin >> U;
   if(S==U){
   cout<< A-1<<" " << B;
  }else{
   cout<< A <<" "<< B-1; 
 }
 

}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  unordered_map<int64_t, int64_t> hist;
  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    result += a;
    if (hist.find(a) == hist.end()) {
      hist[a] = 1;
    } else {
      ++hist[a];
    }
  }

  int64_t Q;
  cin >> Q;
  for (int64_t q = 0; q < Q; ++q) {
    int64_t from, to;
    cin >> from >> to;
    if (hist.find(from) != hist.end()) {
      result += (to - from) * hist[from];
      if (hist.find(to) == hist.end()) {
        hist[to] = hist[from];
      } else {
        hist[to] += hist[from];
      }
      hist.erase(hist.find(from));
    }
    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 6596
import queue

h,w=map(int,input().split())

s=[]
for _ in range(h):
    s.append(input())

ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            seen=[[0 for _ in range(w)] for _ in range(h)]
            length=[[0 for _ in range(w)] for _ in range(h)]
            q=queue.Queue()
            q.put([i,j])
            seen[i][j]=1
            while not q.empty():
                ci,cj=q.get()
                for ni,nj in [[ci-1,cj],[ci+1,cj],[ci,cj-1],[ci,cj+1]]:
                    if 0<=ni<h and 0<=nj<w and s[ni][nj]=="." and seen[ni][nj]==0:
                        q.put([ni,nj])
                        length[ni][nj]=length[ci][cj]+1
                        seen[ni][nj]=1
            ans=max(ans,length[ci][cj])

print(ans)

Measured memory_bytes: 9716
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
    int n, k, t, u, v, l; cin >> n >> k >> t >> u >> v >> l;
    int d[n];
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    int h[11000] = {0};
    for (int i = 0; i < n; ++i) {
        h[d[i]] = 1;
    }
    int last = 0; //加速状態のlast
    double ret = 0; //答え 何秒
    int now = 0; //今加速状態か and 人参何本持ってる
    for (int i = 1; i <= l; ++i) {
        if (now) ret += 1.0 / v;
        else ret += 1.0 / u;
        if (now && last + t * v == i) { //今加速状態で効果切れる
            now--;
            last = i;
        }
        if (h[i]) {
            now++;
            if (now == 1) last = i; //人参なしの加速状態なら
            if (now > k + 1) { //now = 1 は人参なし
                now--;
                last = i;
            }
        }
    }
    cout << setprecision(10) << ret << endl;
    return 0;
}




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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
 	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b, c, x, y;
	cin >>a >>b >>c >>x >>y;
	
	ll ans = 1LL<<60;
	rep(i, max(x+1, y+1)){
		ll w = 2LL* i * c + max(x-i, 0) * (ll)a + max(y-i, 0) * (ll)b;
		ans = min(ans, w);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
max_X = 0
count_X = [s.count(i) - t.count(i) for i in s]
max_X = max(count_X)
if max_X < 0:
	print(0)
else:
	print(max_X)

Measured memory_bytes: 3064
n = int(input())
array_s = []
for i in range(n):
    array_s.append(input())

m = int(input())
array_t = []
for i in range(m):
    array_t.append(input())

sums = {}
for s in array_s:
    if not s in sums:
        sums[s] = 1
    else:
        sums[s] += 1

for t in array_t:
    if t in sums:
        sums[t] -= 1

max_x = 0
for key in sums.keys():
    if max_x < sums[key]:
        max_x = sums[key]

print(max_x)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  if(s[2] == s[3] ){
    if(s[4] == s[5] ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a, b, x; cin >> a >> b >> x;
	if (a > x){
		print("NO");
	}else if (a + b >= x){
		print("YES");
	}else{
		print("NO");
	}
}

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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

signed main()
{
	int n=read(),k=read();
	if (k==1) print(0);
		 else print(n-k);

	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  int64_t p=1000000007;
  int n=s.size();
  vector<int64_t> k(n,0);
  vector<int64_t> w(n,0);
  w[0]=1;
  k[0]=2;
  rep(i,n-1){
    int64_t y=i+1;
    if(s[y]=='0'){
      w[y]=(w[i]*3)%p;
      k[y]=k[i];
    }
    else{
      w[y]=(w[i]*3+k[i])%p;
      k[y]=(k[i]*2)%p;
    }
  }
  cout << (k[n-1]+w[n-1])%p << endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int x;  //変更前の消費税率(%)
    int y;  //変更後の消費税率(%)
    int s;  //消費税率変更前の２商品の税込合計価格
    int newpricemax;  //消費税率変更後の２商品の税込合計価格の最大値

    while(true){
        cin >> x >> y >> s;
        if(x == 0 && y == 0 && s == 0) break;

        int newpricemax = 0;

        for(int i = 1; i < s; i++){
            for(int j = 1; j < s; j++){
                int S = i * (100 + x) / 100 + j * (100 + x) / 100; //Sは２商品の価格の変動による消費税率変更前の２商品の税込合計価格
                if(S == s)
                    newpricemax = max(newpricemax, i * (100 + y) / 100 + j * (100 + y) / 100);
            }
        }

        cout << newpricemax << endl;
    }
}


Measured memory_bytes: 3080
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    vector<int>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int ll
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 10;
int n , m;
int a[N] , b[N] , fr[N] , k[N];
set < pii > st;
void upd(int i){
	if(a[i] == b[i])
		return;
	st.erase({k[i] , i});
	fr[i] = ((b[(i + 1)%n] + b[(i - 1 + n)%n]));
	k[i] = (b[i] - a[i]) / fr[i];
	while(b[i] - k[i] * fr[i] < a[i])
		k[i]--;
	while(b[i] - (k[i] + 1) * fr[i] >= a[i])
		k[i]++;				
    st.insert({k[i] , i});
}
main(){
	cin >> n;
	rep(i , 0 , n - 1)
		cin >> a[i];	
	rep(i , 0 , n - 1)
		cin >> b[i];

	rep(i , 0 , n - 1){
		if(a[i] > b[i])ret(-1);

		fr[i] = ((b[(i + 1)%n] + b[(i - 1 + n)%n]));

		k[i] = (b[i] - a[i]) / fr[i];
        while(b[i] - k[i] * fr[i] < a[i])
			k[i]--;
		while(b[i] - (k[i] + 1) * fr[i] >= a[i])
			k[i]++;
		st.insert({k[i] , i});
	}
	int ans = 0;
	while(sz(st) != 0){
		int i = (*st.rbegin()).se;
		st.erase({k[i] , i});
		if(a[i] == b[i])continue;
		if(k[i] == 0)ret(-1);
		b[i] -= fr[i] * k[i];
		ans += k[i];
		k[i] = 0;
		upd((i + 1)%n);upd((i - 1 + n)%n);
		st.insert({0 , i});
	}
	cout << ans;
				

}

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

int main(){
    char s[100000];
    scanf("%s",s);
    int len=strlen(s);

    int i=0;
    while(1){
        if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'){
            if(s[i+5]=='e'&&s[i+6]=='r'){
                if(s[i+7]=='a'&&s[i+8]=='s'&&s[i+9]=='e'){
                    i+=5;
                }else if(s[i+7]=='a'&&s[i+8]=='s'&&s[i+9]=='e'&&s[i+10]=='r'){
                    i+=5;
                }else{
                    i+=7;
                }
            }else{
                i+=5;
            }
        }else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'){
            if(s[i+5]=='r'){
                if(s[i+6]=='a'&&s[i+7]=='s'&&s[i+8]=='e'){
                    i+=5;
                }else if(s[i+6]=='a'&&s[i+7]=='s'&&s[i+8]=='e'&&s[i+9]=='r'){
                    i+=5;
                }else{
                    i+=6;
                }
            }else{
                i+=5;
            }
        }else{
            break;
        }
    }

    if(i==len){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1736
while 1:

	n, x = map(int, raw_input().split())
	if n == 0 and x == 0:
		break

	count = 0
	for i in xrange(1, n-1):
		for j in xrange(i+1, n):
			for k in xrange(j+1, n+1):
				if i+j+k > x:
					break
				if i+j+k == x:
					count += 1
	print count

Measured memory_bytes: 6420
#include <iostream>
#include <cmath>
 
int main()
{
    int64_t n,k;
  	std::cin >> n >> k;

  	int64_t x = n % k;
  
  	while (true)
    {
      const int64_t new_x = std::abs(x - k);
      if (x < new_x)
      {
        break;
      }
      
      x = new_x;
    }

  	std::cout << x << std::endl;
    return 0;
}

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

using namespace std;

#define N 300000

int n,f[N][3];
char s[N];

bool check(int i,int j,int k){
	if (i-j-k<0) return 0;
	if (j!=k) return 1;
	for (int t=0;t<j;++t)
		if (s[i-t]!=s[i-j-t]) return 1;
	return 0;
}

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	memset(f,0xcf,sizeof f); f[0][0]=0;
	for (int i=1;i<=n;++i){
		for (int j=1;j<=2;++j)
			for (int k=0;k<=2;++k)
				if (check(i,j,k)) f[i][j]=max(f[i][j],f[i-j][k]+1);
	}
	printf("%d\n",max(f[n][1],f[n][2]));
	
	return 0;
}


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

const double M_PI = 3.14159265358979323846;

int main(){

	double r;

	cin >> r;

	printf("%.6f %.6f\n", r * r * M_PI, 2 * r * M_PI);

	return 0;
}

Measured memory_bytes: 1240
// Solution to https://atcoder.jp/contests/dp/tasks/dp_v
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int N, MOD;
vector<vector<int>> adj;

// up[node] = number of ways to color the subtree of node that its parent is responsible for, empty coloring included.
// down[node] = number of ways to paint node's subtree where node must be painted black.
vector<int> up, down;

void solve_down(int node, int parent) {
    down[node] = 1;

    // Erase the edge from node to parent.
    if (parent >= 0)
        adj[node].erase(find(adj[node].begin(), adj[node].end(), parent));

    for (int child : adj[node]) {
        solve_down(child, node);
        down[node] = (long long) down[node] * (down[child] + 1) % MOD;
    }
}

void solve_up(int node) {
    int n = adj[node].size();
    vector<int> prefix(n, 1), suffix(n, 1);

    for (int i = 0; i + 1 < n; i++)
        prefix[i + 1] = (long long) prefix[i] * (down[adj[node][i]] + 1) % MOD;

    for (int i = n - 1; i > 0; i--)
        suffix[i - 1] = (long long) suffix[i] * (down[adj[node][i]] + 1) % MOD;

    // Note that both prefix[i] and suffix[i] exclude i.
    for (int i = 0; i < n; i++)
        up[adj[node][i]] = (1 + (long long) prefix[i] * suffix[i] % MOD * up[node]) % MOD;

    for (int child : adj[node])
        solve_up(child);
}

int main() {
    scanf("%d %d", &N, &MOD);
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    up.assign(N, 1);
    down.assign(N, 1);
    solve_down(0, -1);
    solve_up(0);

    for (int i = 0; i < N; i++)
        printf("%lld\n", (long long) up[i] * down[i] % MOD);
}


Measured memory_bytes: 17536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		long s[] = new long[1000100];
		long sum = 0;

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(str[i]);
			s[a]++;
			sum += a;
		}

		int q = Integer.parseInt(br.readLine());

		for (int i = 0; i < q; i++) {
			str = br.readLine().split(" ");
			int b = Integer.parseInt(str[0]);
			int c = Integer.parseInt(str[1]);

			long size = s[b];
			s[c] += s[b];
			s[b] = 0;
			long sumDiff = (c - b) * size;
			sum += sumDiff;

			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 76740
n=int(input())
dp=[[0]*3 for _ in range(n)]
dp[0]=list(map(int,input().split()))
for i in range(1,n):
    l=list(map(int,input().split()))
    dp[i][0]=l[0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=l[1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=l[2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))

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

int main()
{
	int a[10],k,i,j,s=0,x,y;
	
	for(i=0;i<5;i++){
		cin>>a[i];
	}
	for(i=0;i<5;i++){
		for(j=0;j<5-i-1;j++){
			if(a[j]%10==0){
				x=0;
			}
			else{
				x=10-a[j]%10;
			}
			if(a[j+1]%10==0){
				y=0;
			}
			else{
				y=10-a[j+1]%10;
			}
			if(x>y){
				k=a[j];
				a[j]=a[j+1];
				a[j+1]=k;
			}
		}
	}
	for(i=0;i<4;i++){
		s=s+a[i];
		if(a[i]%10!=0){
			s=s+(10-a[i]%10);
		}
	}
	s=s+a[4];
	
	cout<<s<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		try(BufferedReader input = new BufferedReader(new InputStreamReader(System.in))){

			String[] l1 = input.readLine().split(" ");
			int N = Integer.parseInt(l1[0]);
			int M = Integer.parseInt(l1[1]);
			int C = Integer.parseInt(l1[2]);

			String[] l2 = input.readLine().split(" ");
			int[] B = new int[M];
			for(int i = 0; i < M; i++) {
				B[i] = Integer.parseInt(l2[i]);
			}

			int cnt = 0;

			for(int i=0; i < N; i++) {
				int calc = 0;
				String[] lines = input.readLine().split(" ");
				for(int j = 0; j < M; j++) {
					calc += Integer.parseInt(lines[j]) * B[j];
				}
				if(calc + C > 0) cnt++;
			}

			System.out.println(cnt);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
  int h,a;
  cin>>h>>a;
  if(h%a)
    cout<<h/a+1;
  else
    cout<<h/a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    for (int i = 0; i < T.length(); i++) {
      boolean found = true;
      for (int j = 0; j < S.length(); j++) {
        if (S.charAt(j) != T.charAt((i+j) % T.length())) {
          found = false;
          break;
        }          
      }
      if (found) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
ll N;
string s;
bool b[100001];

vector<ll> calc(ll x,ll y){
  vector<ll> v;
  v.pb(x);
  v.pb(y);
  rep1(i,N-2){
    v.pb(v[i] ^ b[i] ^ v[i-1] );
  }
  if (! ( ( (v[0]==v[v.size()-2]) ^ b[v.size()-1] ^ v[v.size()-1] ) && ((v[1]==v[v.size()-1]) ^ b[0] ^ v[0] ) ) ){
    v.clear();
  }
  return v;
}

int main(){
  cin>>N;
  cin>>s;
  rep(i,N){
    if(s[i]=='o') b[i]=0;
    else b[i]=1;
  }
  string a;
  rep(i,2) rep(j,2){
    vector<ll> ans = calc(i,j);
    if(ans.size()){
      rep(i,N){
        if(ans[i]) a+="W";
        else a+="S";
      }
      cout<<a<<endl;
      return 0;
    }
  }
  puts("-1");
  return 0;
}


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

int main() {
  int N, K, S; cin >> N >> K >> S;
  vector<int> ans;
  if (S == 1000000000) {
    for (int i = 0; i < K; i++) ans.push_back(1000000000);
    for (int i = 0; i < N-K; i++) ans.push_back(999999999);
  }
  else {
    for (int i = 0; i < K; i++) ans.push_back(S);
    for (int i = 0; i < N-K; i++) ans.push_back(1000000000);
  }
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int a, b, i=0;
    char op = NULL;
    int *r = malloc(sizeof(int)*10000);
    while (op != '?'){
        scanf("%d %c %d",&a,&op,&b);
        if (op=='+') r[i]=a+b;
        if (op=='-') r[i]=a-b;
        if (op=='*') r[i]=a*b;
        if (op=='/') r[i]=a/b;
        i++;
    }
    for(int j=0;j<i-1;j++) printf("%d\n",r[j]);
    return 0;
}    



Measured memory_bytes: 2048
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
      int n,k;cin>>n>>k;
      int cnt = 0;
      while(n){
          cnt++;
          n /= k;
      }
      cout<<cnt;
    }
    


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N;
  ll count=0;
  cin >> N;
  vector<string> S;
  string a;
  for(int i=0;i<N;++i) {
    cin >> a;
    S.push_back(a);
  }
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  cout << S.size();
}

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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli n,x;

  while(1){
    cin>>n>>x;
    if(n==0 and x==0)break;
    lli ans=0;
    FOR(i,1,n+1){
      FOR(j,1,n+1){
	FOR(k,1,n+1){
	  if(i==j or i==k or j==k)continue;
	  if(i+j+k==x)ans++;
	}
      }
    }
    cout<<ans/6<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
n,a,b,c=map(int,input().split())
s=[int(input())for i in range(n)]
q=5000
def f(X):
    if (int(X/4)):
        return f(int(X/4))+str(X%4)
    return str(X%4)
for i in range(4**n):
    p=f(i)
    p="0"*(n-len(p))+p
    d=[0,0,0]
    for j in range(n):
        if p[j]!="3":
            d[int(p[j])]+=s[j]
    else:
        if not 0 in d:
            q=min(q,abs(d[0]-a)+abs(d[1]-b)+abs(d[2]-c)+10*(p.count("0")+p.count("1")+p.count("2")-3))
            if q==7:
            	print(d)
print(q)

Measured memory_bytes: 3064
x,n = map(int,input().split())
p = list(map(int,input().split()))
if x not in p:
    print(x)
    exit()
a,b = x,x
while True:
    a+=1
    b-=1
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break

Measured memory_bytes: 9116
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
        int H,W,mod=1000000007;
        Scanner in=new Scanner(System.in);
        H=in.nextInt();
        W=in.nextInt();
        char[][]grid=new char[H][W];
        int[][]dp=new int[H][W];
        String s=new String();
        for(int i=0;i<H;i++){
          s=in.next();
          for(int j=0;j<W;j++){
            grid[i][j]=s.charAt(j);
          }
        }
        dp[0][0]=grid[0][0]=='#'?0:1;
        for(int i=1;i<H;i++){
          if(grid[i][0]=='#')dp[i][0]=0;
          else dp[i][0]=dp[i-1][0];
        }
        for(int i=1;i<W;i++){
          if(grid[0][i]=='#')dp[0][i]=0;
          else dp[0][i]=dp[0][i-1];
        }
        for(int i=1;i<H;i++){
          for(int j=1;j<W;j++){
            if(grid[i][j]=='#')dp[i][j]=0;
            else dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
          }
        }
        System.out.println(dp[H-1][W-1]);
    }
}



Measured memory_bytes: 37160
#include <iostream>

using namespace std;

int main()
{
    int month,day;
    cin>>month>>day;
    int cnt=0;
    for(int i=1;i<=month;i++)
    {
        for(int j=1;j<=12;j++)
        {
            if(i==j) cnt++;
            if(i==month&&j==day) break;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

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

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;

void solve(){
  int K,A,B;
  cin>>K>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout<<"OK";
      return;
    }
  }
  cout<<"NG";
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "


ll mod = 1e9 + 7;
ll dp[200000][4];
vi g[200000];

ll dfs(ll s, ll p ,ll c)
{
  if(dp[s][c])return dp[s][c];

  ll ret = 1;

  for(ll i=0;i<g[s].size();i++)
  {
    if(g[s][i] == p)continue;

    ll temp=dfs(g[s][i],s,0);
    
    if(c == 0)
    {
      temp+=dfs(g[s][i],s,1);
    }
    temp%=mod;
    ret*=temp;
    ret%=mod;
  }

  dp[s][c]=ret;
  return dp[s][c];
}


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

  ll n;
  cin>>n;
  for(ll i=1;i<n;i++)
  {
    ll x,y;
    cin>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
  }

  ll ans = dfs(1,-1,0)+dfs(1,-1,1);
  ans%=mod;
  cout<<ans<<"\n";


  return 0;
}


Measured memory_bytes: 19968
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    H, W = map(int, input().split())
    a = []
    white = '.' * W
    for i in range(H):
        s = input()
        if s == white:
            pass
        else:
            a.append(s)

    black = []
    for w in range(W):
        for h in range(len(a)):
            if a[h][w] == '#':
                black.append(w)

    black = sorted(list(set(black)))
    for h in range(len(a)):
        t = ''
        for b in black:
            t += a[h][b]
        print(t)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196