akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
 
const int INF = 1<<29;
 
int dp[150][10][77];
int stones[150][10][2];
int col[150];
 
int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
   
    REP(i, N) {
      cin >> col[i];
      REP(j, col[i]) {
	cin >> stones[i][j][0] >> stones[i][j][1];
      }
    }
 
    REP(i, N) REP(j, col[i]) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, col[0]) dp[0][j][0] = 0;
    REP(j, col[1]) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, col[i+1]) {
	int x_now = stones[i+1][j][0], d_now = stones[i+1][j][1];
	REP(k, col[i]) {
	  int x_prev = stones[i][k][0], d_prev = stones[i][k][1];
	  int safe = (d_now + d_prev) * abs(x_now - x_prev);
	  REP(m, M+1) {
	    dp[i+1][j][m] = min(dp[i+1][j][m], dp[i][k][m] + safe);
	  }
	}
	if (i > 0) {
	  REP(k, col[i-1]) {
	    int x_prev = stones[i-1][k][0], d_prev = stones[i-1][k][1];
	    int safe = (d_now + d_prev) * abs(x_now - x_prev);
	    REP(m, M) {
	      dp[i+1][j][m+1] = min(dp[i+1][j][m+1], dp[i-1][k][m] + safe);
	    }
	  }
	}
      }
    }
 
    int ans = INF;
    REP(j, col[N-1]) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, col[N-2]) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N],cnt;
LL x,s,pp,sum[N],S;
struct uzi
{
	LL a,b;
	uzi operator - (const uzi &t)const{
		return uzi{a-t.a,b-t.b};
	}	
}p[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],s+=a[i];
	LL dem=0;
	p[1]=uzi{0,1};
	for(int i=2;i<=n;i++){
		uzi res={2*a[i-1],0};
		p[i]=res-p[i-1];
	}
	for(int i=1;i<=n;i++){
		cnt+=p[i].b;
		S+=p[i].a;
	}
	x=(s-S)/cnt;
	for(int i=1;i<=n;i++){
		cout<<p[i].a+x*p[i].b<<' ';
	}
	return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
long long S = 0, res;
map<long long, int>Map;
int main() {
	int i, a,n;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		Map[S]++;
		scanf("%d", &a);
		S += a;
		res += Map[S];
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 12672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] N=cin.ArrayInt(2,0);
        int ans=N[1];
        if(6<=N[0]&&12>=N[0])ans=N[1]/2;
        else if(N[0]<6)ans=0;
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


Measured memory_bytes: 11092
N=int(input())
A=list(map(int,input().split()))
T=1
K=10**18

for i in range(N):
    if A[i]==0:
        print(0)
        exit()

for i in range(N):
    T*=A[i]
    if T>K:
        print(-1)
        exit()


print(T)

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

int main() {
    string s;
    cin >> s;

    if (s.at(s.size()-1) == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }

    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a > b) swap (a, b);
    if (b > c) swap (b, c);
    if (a > b) swap (a, b);
    cout << a << " " << b << " " << c << "\n";
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
int main()
{
    io;
    int a,p;
    cin>>a>>p;
    int cnt=p;
    cnt+=3*a;
    cout<<cnt/2;
    return 0;
}


Measured memory_bytes: 256
//Osenbei
#include <stdio.h>
#include <string.h>
int A[10001];

int main(){
  int C, R, tmp, mask, ans, a, b, i, j;
  while(1){
    scanf("%d %d", &C, &R);
    if((C | R) == 0){
      break;
    }
    memset(A, 0, sizeof(A));
    for(i = 0; i < C; ++i){
      for(j = 0; j < R; ++j){
        scanf("%d", &tmp);
        A[j] += tmp << i;
      }
    }
    ans = 0;
    for(mask = 0; mask < (1 << C); ++mask){
      //printf("mask = %d \n", mask);
      a = 0;
      for(i = 0; i < R; ++i){
        tmp = A[i] ^ mask;
        //printf("%d", tmp);
        b = 0;
        while(tmp != 0){
          if((tmp & 1) == 1){
            b++;
          }
          tmp = tmp >> 1;
        }
        a += b > C - b ? b : C - b;
      }
      //printf(" a = %d \n", a);
      if(ans < a){
        ans = a;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1072
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117&lang=jp
//FROYD-WARSHALL

#include <iostream>
#include <cstdio>
using namespace std;

const long inf = 1001001001001;
int n, m, a, b, c;
long K[100][100] = {};

void show()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (K[i][j] == inf)
            {
                cout << "INF";
            }
            else
            {
                cout << K[i][j];
            }
            if (j != n - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            if (i == j)
            {
                K[i][j] = 0;
            }
            else
            {
                K[i][j] = inf;
            }
        }
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        //cerr << "read " << a << " " << b << " " << c << " " << d << endl;
        //cout << a << b << c << endl;
        K[a][b] = c;
        //cout << K[a][b] << endl;
    }
    //show();
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (K[i][j] > K[i][k] + K[k][j] && K[i][k] != inf && K[k][j] != inf)
                {
                    K[i][j] = K[i][k] + K[k][j];
                }
            }
        }
    }
    bool flag = 0;
    for (int i = 0; i < n; i++)
    {
        if (K[i][i] < 0)
        {
            flag = 1;
        }
    }
    if(flag){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        show();}
    //cout << K[s][g] << K[g][s] << endl;
    //cout << v - p - K[s][g] - K[g][s] << endl;
    return 0;
}



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

void swap(int * x, int * y) {
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
    return; 
}

int main(void) {
  vector<int> x;
  vector<int> y;

  while(1) {
    int num1, num2;
    cin >> num1 >> num2;
    if(num1 == 0 && num2 == 0) {
      break;
    } else {
      x.push_back(num1);
      y.push_back(num2);
    }
  }

  for(int i = 0; i < x.size(); i++) {
    if(x[i] > y[i]){
        //swap(&x[i], &y[i]);
        std::swap(x.at(i), y.at(i));
    }
    cout << x[i] << " " << y[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
#![allow(dead_code)]
fn main()
{
    let mut a:u32 = read();
    
    a = a % 10;
    match a {
        2 |4|5|7|9 => println!("hon"),
        0 |1|6|8   => println!("pon"),
        _  => println!("bon")
    }
}

// Rust language references:
//   https://www.rust-lang.org/
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 2092
def main():
    N = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    if N==1:
        print(5)
        return

    m = min([a,b,c,d,e])  # bottle neck

    ans = (N//m) - (N%m==0)
    ans += 5

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

// 素数判定
bool prime (int i) {
  bool can = true;
  for (int j=2; j<=sqrt(i); j++) {
    if (i%j==0) {
      can = false;
      break;
    }
  }
  return can;
}

int main() {
  int Q;
  cin >> Q;
  vector<int> l(Q), r(Q); // 素数テーブル
  for (int i=0; i<Q; i++) cin >> l[i] >> r[i];
  vector<int> memo(100001, 0); // memo[i]:=i(1<=i<=100000)以下の2017に似た数の個数
  for (int i=3; i<=100000; i++) {
    if (prime(i)&&prime((i+1)/2)) memo[i] = memo[i-1]+1;
    else memo[i] = memo[i-1];
  }
  for (int i=0; i<Q; i++) cout << memo[r[i]]-memo[l[i]-1] << endl;
  return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    }
    else
    {
        cout << (a + b) / 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map {|i| i.to_i}
puts a.join(" ")
1.upto(n-1) do |i| 
    v = a[i]
    j = i - 1 
    while j >= 0 && a[j] > v do
        a[j+1] = a[j]
        j -= 1
    end 
    a[j+1] = v 
    puts a.join(" ")
end

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

int main() {
  int n,k;
  int64_t ans=0;
  cin >> n >> k;
  vector<int> mns(n);
  for(int i = 0; i < n; i++) cin >> mns[i];
  sort(mns.begin(), mns.end());
  reverse(mns.begin(), mns.end());
  for(int i = 0; i < n; i++) {
    if(k > 0) {
      k--;
      continue;
    }
    if(k == 0) {
      for(int j = 0; j < mns[i]; j++) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
    double x, y;
    Point(double x=0, double y=0):x(x), y(y){}

    Point operator + (Point p){ return Point(x + p.x, y + p.y); }
    Point operator - (Point p){ return Point(x - p.x, y - p.y); }
    Point operator * (double a){ return Point(a * x, a * y); }
    Point operator / (double a){ return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y;}
    bool operator < (const Point &p) const {
        // first x, second y
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b){
    //|a||b|cos(theta)
    return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
    //|a||b|sin(theta)
    return a.x * b.y - a.y * b.x;
}

Point project(Point p1, Point p2, Point p){
    Vector base = p2 - p1;
    double r = dot(p - p1, base) / base.norm();
    return p1 + base * r;
}

int main() {

    int Q;
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Point p1(x1, y1);
    Point p2(x2, y2);

    cin >> Q;
    rep(i, Q){
        double x, y;
        cin >> x >> y;
        Point p(x, y);
        Point proj = project(p1, p2, p);
        Point ret = proj * 2 - p;
        printf("%.10f %.10f\n", ret.x, ret.y);
    }

}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e5;
int A[N+7][5], mem[N+7][5];

int dp(int i, int j) {
	if(i==0) return 0;
	if(mem[i][j]!=-1) return mem[i][j];
	if(j==1) return mem[i][j] = A[i][j] + max(dp(i-1, 2), dp(i-1, 3));
	if(j==2) return mem[i][j] = A[i][j] + max(dp(i-1, 3), dp(i-1, 1));
	else return mem[i][j] = A[i][j] + max(dp(i-1, 1), dp(i-1, 2));
}
int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,T,cas=0;
	cin>>n;
	for(int i=1;i<=n;++i) {
		cin>>A[i][1]>>A[i][2]>>A[i][3];
	}
	memset(mem, -1, sizeof(mem));
	int res = max(dp(n,1), max(dp(n,2), dp(n,3)));
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8832
N = 2
ARR = [157, 193]

N = 6
ARR = [200, 180, 160, 140, 120, 100]

N = 7
ARR = [100, 130, 130, 130, 115, 115, 150]

N = int(input())
ARR = list(map(int, input().split()))
#

# N = 5
# ARR = [111, 111, 111, 111, 111]

def prepare(n,arr):
    result = []
    for i in range(n):
        if i == 0:
            result.append(arr[0])
        else:
            if arr[i] != arr[i-1]:
                result.append(arr[i])
    return result


def calculate(arr):
    n = len(arr)
    result = []
    for i in range(n):
        if i == n-1:
            if arr[i] > arr[i-1]:
                result.append({'type': 1, 'value': arr[i]})
            continue

        if i == 0:
            if arr[1] > arr[0]:
                result.append({'type': 0, 'value': arr[i]})
            continue

        if (arr[i + 1] > arr[i]) and (arr[i] < arr[i - 1]):
            result.append({'type': 0, 'value': arr[i]})

        if (arr[i + 1] < arr[i]) and (arr[i] > arr[i - 1]):
            result.append({'type': 1, 'value': arr[i]})

    money = 1000
    num = 0
    for index,res in enumerate(result):
        type = res.get('type')
        value = res.get('value')

        if index == (len(result) - 1):
            if value == 1:
                continue

        if type == 0:
            tmpNum = money // value
            num += tmpNum
            money -= value * tmpNum
        else:
            money += num * value
            num = 0

    print(money)


arr = prepare(N, ARR)
calculate(arr)


Measured memory_bytes: 9304
S=str(input())
N=len(S)
if S!=S[::-1]:#Sと反転したSが不一致
    print('No')
else:
    S1=S[0:(N-1)//2]#Sが1文字目～(N-1)/2番目の場合
    S2=S[(N+1)//2:N]#Sが(N+3)/2～N番目の場合
    if S1==S1[::-1] and S2==S2[::-1]:
        print('Yes')
    else:
        print('No')

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(550000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  int ans = 0;
  int N, M;
  cin >> N >> M;
  int L, R, Lmax = 0, Rmin = INF;
  FOR(i, 0, M) {
    cin >> L >> R;
    Lmax = max(Lmax, L);
    Rmin = min(Rmin, R);
  }

  ans = Rmin - Lmax + 1;
  if (ans < 0) {
    ans = 0;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    ll x=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0'),y=(s[5]-'0')*10+(s[6]-'0');
    if (x>2019){
        cout << "TBD" << endl;
    }else if (x==2019 && y>4){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    return 0;
}




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

using namespace std;

int P(int i,vector<int>& p) {
  if(p[i] == i)return i;
  else return p[i] = P(p[i],p);
}

void C(int a,int b,vector<int>& p) {
  p[P(a,p)] = P(b,p);
}

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> p(N);
  int i;
  for(i=0;i<N;i++)p[i] = i;
  int a,b;
  for(i=0;i<M;i++) {
    cin >> a >> b;
    C(a-1,b-1,p);
  }
  vector<bool> f(N,false);
  int cnt = 0;
  for(i=0;i<N;i++) {
    if(!f[P(i,p)]) {
      f[p[i]] = true;
      cnt++;
    }
  }
  cout << cnt-1 << endl;
}

Measured memory_bytes: 3788
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            if(ret != null) Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = long.Parse(input.ReadLine());

        if (n < 2) return 0;

        //long y = 0;

        //for(int i=1; i<=n-1; i++) {
        //    for(int j=1; j+i<=n; j++) {
        //        long x = ModCombination(n, i);
        //        x *= ModCombination(n-i, j);
        //        x %= Mod;

        //        x *= ModPow(8, n-i-j);
        //        y += x % Mod;
        //        y %= Mod;
        //    }
        //}

        //long y = 0;

        ////long x = n - 1; //09の個数
        //for(int i=2; i<=n; i++) {
        //    long x = ModCombination(n, i);
        //    x *= ModSub(ModPow(2, i), 2); //09のパターン
        //    x %= Mod;

        //    x *= ModPow(8, n-i); //18のパターン
        //    x %= Mod;

        //    y += x;
        //    y %= Mod;
        //}

        long y1 = ModPow(10, n); //0-9
        long y2 = ModPow(8, n); //1-8
        long y3 = ModPow(9, n);

        long y4 = ModSub( (y3 * 2) % Mod, y2);

        long y = y1;
        y = ModSub(y, y4);

        return y;
    }

    static long ModSub(long x1, long x2) {
        long v = x1 - x2;
        if(v < 0) v += Mod;
        return v % Mod;
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % Mod;
            }
            x1 = (x1 * x1) % Mod;
            x2 /= 2;
        }
        return ans % Mod;
    }

    static long ModDiv(long x1, long x2) {
        long bb = ModPow(x2, Mod - 2);
        return (x1 * bb) % Mod;
    }

    static long ModCombination(long m, long n) {
        var a = 1L;
        var b = 1L;
        for (long i = 1; i <= n; i++) {
            a = (a * (m - i + 1)) % Mod;
            b = (b * i) % Mod;
        }

        return ModDiv(a, b) % Mod;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27428
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long int ll;

int main(){
  int x, y; cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}


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

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> numList = new ArrayList<>();
		int ans = 0;
		
		for(int i = 0; i < N; i++) {
			numList.add(sc.nextInt());
		}
		
		int min = numList.get(0);
		for(int i = 0; i < N; i++) {
			if(numList.get(i) < min) {
				min = numList.get(i);
			}
			
			if(numList.get(i) <= min) {
				ans++;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 82092
#include <bits/stdc++.h>
using namespace std;
int n,t,x,y,nx=0,ny=0,nt=0,f=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t>>x>>y;
		if(((t-nt)-(max(nx,x)-min(nx,x))-(max(ny,y)-min(ny,y)))%2!=0||(t-nt)-(max(nx,x)-min(nx,x))-(max(ny,y)-min(ny,y))<0){
			f=1;
		}
		nt=t;
		nx=x;
		ny=y;
	}
	if(f==1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

int main(void)
{
  string w;
  cin >> w;

  unordered_map<char, int> count;
  for(auto i : w){
      count[i]++;
  }
  for(auto i=count.begin(); i!=count.end(); i++){
    if(i->second % 2 ==1){
      cout << "No" << endl;
      return 0;
    }
  }
 
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int k,x;
    cin >> k >> x;
    REP(i,k * 2 - 1){
        cout << x - k + 1 + i << " ";
    }
    cout << endl;
}

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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

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


int main()
{
    string s;
    cin >> s;
    int tmp = 0;
    int r = 0, l = 0;
    vector<P> v;
    while(tmp < s.size()){
        if((tmp == s.size() - 1) || (s[tmp] == 'L' && s[tmp+1] == 'R')){
            l++;
            v.push_back(make_pair(r,l));
            r = 0;
            l = 0;
        }else if(s[tmp] == 'L'){
            l++;
        }else{
            r++;
        }
        tmp++;
    }
    vector<int> ans;
    for(auto i : v){
        rep(j,i.first-1) ans.push_back(0);
        int r_cnt = (i.first+1)/2 + i.second/2;
        int l_cnt = i.first/2+ (i.second+1)/2;

        ans.push_back(r_cnt);
        ans.push_back(l_cnt);
        rep(j,i.second-1) ans.push_back(0);
    }
    rep(i,ans.size()){
        cout << ans[i] << ' ';
    }
}


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

# define ll long long

int main() {
	int n;
	cin >> n;
	
	ll lucas[87];
	lucas[0] = 2;
	lucas[1] = 1;
	for(int i = 2; i <= 86; i++) {
		lucas[i] = lucas[i-1] + lucas[i-2];
	}

	cout << lucas[n];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll cnt=0;
  rep(i,n){
    if(s[i]=='R'){
      cnt++;
    }
    else
      cnt--;
  }
  if(cnt>0){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	const int N = 1e6 + 1;
	int b[N] = {0}, e[N] = {0};
	for(int i = 0; i < N; i++)
		b[i] = 0;
	for(int i = 0; i < n; i++)
		b[a[i]]++, e[a[i]]++;
	int ans = 0;
	for(int i = 1; i < N; i++)
	{
		if(e[i] == 1 && b[i] == 1)
			ans++;
		if(b[i] == 0)
			continue;
		for(int j = 2 * i; j < N; j += i)
			b[j] += b[i];
	}
	//for(int i = 0; i < 25; i++)
		//cout << b[i] << " ";
	//cout << endl;
	cout << ans << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

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

#define MAX_W 100005
#define MAX_N 102

long long N, W, w[MAX_W], v[MAX_N];
long long memo[MAX_W][MAX_N];

long long ks(int capacity, int item) {
  if (capacity < 0) {
  	return -1e9;
  }
  if (item == N) {
  	return 0;
  }
  if (memo[capacity][item] != -1) {
  	return memo[capacity][item];
  }
  long long take = v[item] + ks(capacity - w[item], item + 1);
  long long skip = ks(capacity, item + 1);
  return memo[capacity][item] = max(take, skip);
}

int main() {
  scanf("%lli %lli", &N, &W);
  for (int i = 0; i < N; i++) {
  	scanf("%lli %lli", &w[i], &v[i]);
  }
  memset(memo, -1, sizeof memo);
  printf("%lli\n", ks(W, 0));
}

Measured memory_bytes: 80128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

vector<int> G[100005];
int in[100005],dp[100005];
queue<int> q;

int main()
{jizz
	int n,m,a,b;
	cin >> n >> m;
	while(m--)
		cin >> a >> b,G[a].pb(b),++in[b];
	for(int i=1;i<=n;++i)
		if(!in[i]) q.push(i);
	while(!q.empty())
	{
		a=q.front(),q.pop();
		for(int i:G[a])
			if(dp[i]=max(dp[i],dp[a]+1),!--in[i]) q.push(i);
	}
	cout << *max_element(dp+1,dp+n+1) << "\n";
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
  /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P
        
        IT ALWAYS SEEMS IMPOSSIBLE
        UNTIL ITS DONE ->WILLIAM LIN


        */

fast();
//ll t;cin>>t>>while(t--)
{
	long double a,b,c;
	cin>>a>>b>>c;
	if((2*sqrt(a*b))<(c-a-b))
	
		Yes
	
	else
		No
}

    

return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os

# 検索用タグ、10^9+7 組み合わせ、スプレッドシートでのトレース

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)

def cmb(n, r):
    mod = 10 ** 9 + 7
    ans = 1
    for i in range(r):
        ans *= n - i
        ans %= mod
    for i in range(1, r + 1):
        ans *= pow(i, mod - 2, mod)
        ans %= mod
    return ans

def prepare_simple(n, mod=pow(10, 9) + 7):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= mod
    fn = f

    # n!^-1 の計算
    inv = pow(f, mod - 2, mod)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv
    return fn, invs


def prepare(n, mod=pow(10, 9) + 7):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= mod
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, mod - 2, mod)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv

    return factorials, invs


# 実装を行う関数
def resolve(test_def_name=""):
    x, y = map(int, input().split())

    all_move_count = (x + y) // 3

    x_move_count = all_move_count
    y_move_count = 0

    x_now = all_move_count * 2
    y_now = all_move_count

    canMake= False
    for i in range(all_move_count+1):
        if x_now == x and y_now == y:
            canMake = True
            break

        x_move_count -= 1
        y_move_count += 1
        x_now -= 1
        y_now += 1

    if not canMake:
        print(0)
        return


    ans = cmb(all_move_count,x_move_count)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 3"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """2 2"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """999999 999999"""
        output = """151840682"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 77692
def func(D,T,S):
  actualTime = D / S
  if actualTime <= T:
    return "Yes"
  else:
    return "No"


if __name__ == "__main__":
    inputStr = input().split(' ')
    D = int(inputStr[0])
    T = int(inputStr[1])
    S = int(inputStr[2])
    print(func(D,T,S))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int x,n;
    cin >> x >> n;
    vector<int> cnt(105,0);
    rep(i,n){
        int a;
        cin >> a;
        cnt[a] ++;
    }
    int ans = 0;
    int mn = INF;
    rep(i,105){
        if(cnt[i]>0) continue;
        if(mn > abs(x-i)){
            ans = i;
            mn = abs(x-i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 1 ; i < n ; i++){
        int cnt = 0;
        vector<char> x(i);
        vector<char> y(n-i);
        string a = s.substr(0, i);
        string b = s.substr(i, n-i);
        for(int j = 0 ; j < i ; j++){
            x[j] = a[j];
        }
        for(int j = 0 ; j < n-i ; j++){
            y[j] = b[j];
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        int k = 0;
        while(k < x.size()-1){
            if(x[k] == x[k+1]){
                x.erase(x.begin()+k);
                continue;
            }
            k++;
        }
        for(int j = 0 ; j < x.size() ; j++){
            int left = 0, right = y.size(), mid;
            while(left < right){
                mid = (left + right) / 2;
                if(x[j] == y[mid]){
                    cnt++;
                    break;
                }else if(x[j] < y[mid]){
                    right = mid;
                }else{
                    left = mid + 1;
                }
            }
        }
        if(ans < cnt){
            ans = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin


def calc_min_price(a_list, b_list,  pricedown_list):
    # 割引しない場合の最安組み合わせを算出する
    min_a = min(a_list)
    min_b = min(b_list)
    min_price = min_a + min_b

    # 割引したものも含めて一番安い値段を算出する
    for i, j, price in pricedown_list:
        min_price = min(min_price, a_list[i-1]+b_list[j-1]-price)

    return min_price


# 入力
a, b, m = map(int, input().split())

# 商品値段リスト
a_list = [int(x) for x in stdin.readline().rstrip().split()]
b_list = [int(x) for x in stdin.readline().rstrip().split()]

# 値引きリスト
pricedown_list = []
for i in range(m):
    pricedown_list.append([int(x) for x in stdin.readline().rstrip().split()])

# 最小金額を計算する
min_price = calc_min_price(a_list, b_list,  pricedown_list)

# 出力
print(min_price)


Measured memory_bytes: 76476
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
     int a;
     cin >> a;
     cout << a * a * 3 << endl;
}

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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif
using ll=long long ;

void solve() {
    int k,n;
    cin >> k >> n;
    if (k%2==0) {
        cout << (k/2) << ' ';
        for (int _ = 1; _ < n; _++) {
            cout << k << ' ';
        }
        return;
    }
    const ll LIM = 1e6;
    vector<ll> len = {1, k};
    while (len.back()<LIM) {
        ll x = (1+len.back())*k;
        len.emplace_back(x);
    }
    int m = len.size() - 1;
    vector<int> res;
    for (int i = n; i > m; i--) {
        res.emplace_back((k+1)/2);
    }
    int shift = max(0, n-m);
    m = min(n,m);
    ll nth = (len[m]-shift+1)/2;
    assert(nth>0);
    dbg(m, nth);
    dbg(len);
    function<void(int,ll)> calc = [&](int d, ll i){
        assert(i < len[d]);
        res.emplace_back(1 + i/(len[d]/k));
        i %= (len[d]/k);
        assert(i <= len[d-1]);
        if (i == 0) return;
        calc(d-1, i-1);
    };
    calc(m, nth-1);
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 19304
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
 


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    bool flag=1;
    rep(i,n) {
        if (a[i]==0) flag=0;
    }
    ll ans=1;
    if (flag) {
        rep(i,n) {
            if (ans>1000000000000000000/a[i]) {
                ans=-1;
                break;
            }
            ans*=a[i];
        }
    } else {
        ans=0;
    }
    cout << ans << endl;

 
    return 0;   
}

Measured memory_bytes: 4000
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b, c = Is()
print(max(c-a+b, 0))

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> A;
	for(int i = 0; i < n; i ++){
		int x; cin >> x;
		A.push_back(x);
	}
	sort(all(A));
	int ans = 0;
	for(int i = 0; i < k; i ++){
		ans += A[i];
	}
	cout << ans;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    int N;
	    String S;
	    
	    N=sc.nextInt();
	    S=sc.next();
	    
	    int white[]=new int[N+1];
	    int black[]=new int[N+1];
	    
	    white[0]=0;
	    black[0]=0;
	    
	    for(int i=1;i<N+1;i++){
	    	if(S.charAt(i-1)=='.') {
	    		white[i]=white[i-1]+1;
	    		black[i]=black[i-1];
	    	}else if(S.charAt(i-1)=='#') {
	    		white[i]=white[i-1];
	    		black[i]=black[i-1]+1;
	    	}
	    }
	    
	    int ans=1000000000;
	    for(int k=0;k<N+2;k++) {
	    	if(k!=N+1) {
	    	ans=ans<black[k]+(white[N]-white[k])?ans:black[k]+(white[N]-white[k]);
	    	}else {
	    	ans=ans<black[N]?ans:black[N];
	    	}
	    }
	    
	    System.out.println(ans);
	    
	}
 
}

Measured memory_bytes: 29784
import java.util.*;

public class Main {
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) {
		
		int n = scan.nextInt();
		
		if(n==1) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
	
}
 





Measured memory_bytes: 35656
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <numeric>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  vector<int> dp(n+1);
  for (int i = n; i >= 1; i--) {
    if (2*i > n) {
      dp[i] = a[i];
    } else {
      int k = 2;
      while (k*i <= n) {
        dp[i] ^= dp[k*i];
        k++;
      }
      dp[i] ^= a[i];
    }
  }
  int m = accumulate(dp.begin(), dp.end(), 0);
  cout << m << endl;
  for (int i = 1; i <= n; i++) {
    if (dp[i])
      cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.nextLine();
		String s = in.nextLine();

		if(n==1 || n % 2 == 1) {
			System.out.println("No");
			return;
		}
		for(int i = 0; i < n/2; i++) {
			if(s.charAt(i) != s.charAt(n/2 + i)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21844
s = input()
t = "0"
u = "1"
a = 0
b = 0

for i in range(len(s)-1):
    if i%2 == 0:
        t = t + "1"
        u = u + "0"
    else:
        t = t + "0"
        u = u + "1"
x = 0
        
for i in range(len(s)):
    if s[i] != t[i]:
        a = a + 1
    if s[i] != u[i]:
        b = b + 1

print(min(a,b))

Measured memory_bytes: 3316