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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;
const int maxn = 4010;

ll comb[maxn][maxn];
ll p2[maxn];
ll fac[maxn];

ll nhr(int a, int b) {
	if (b < 1) return 0;
	return comb[a+b-1][b-1];
}

ll solve(int pr, int fr, int num) {
	ll res = 0;
	for (int i = 0; i <= pr; ++i) {
		ll way = nhr(num - i, i + fr) * comb[pr][i] % MOD * p2[i] % MOD;
		res = (res + way) % MOD;
	}
	return res;
}

int main() {
	int K, N;

	rep(i, maxn) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
		}
	}

	p2[0] = fac[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		p2[i] = p2[i-1] * 2 % MOD;
		fac[i] = fac[i-1] * i % MOD;
	}

	cin >> K >> N;
	for (int t = 2; t <= K * 2; ++t) {
		int f = (t % 2 == 0);
		int pr = 0;
		for (int p = 1; p * 2 < t; ++p) {
			if (t - p <= K) ++pr;
		}
		int fr = K - pr * 2 - f;
		ll ret = solve(pr, fr, N);
		if (f) {
			ret = (ret + solve(pr, fr, N-1)) % MOD;
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 124288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll i,j,k,dp[3010][3010][4],g[3010][3010];
int main(){
  ll r,c,l;
  cin >> r >> c >> l;
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      g[i][j]=0;
    }
  }
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      for(k=0;k<=3;k++){
        dp[i][j][k]=0;
      }
    }
  }
  for(i=0;i<l;i++){
    ll x,y,z;
    cin >> x >> y >> z;
    g[x][y]=z;
  }
  for(i=1;i<=r;i++){
    for(j=1;j<=c;j++){
      for(k=0;k<=3;k++){
        if(g[i][j]>0){
          dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+g[i][j]);
          if(k!=0){
            dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+g[i][j]);
          }
        }
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
        dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
      }
    }
  }
  ll ans=0;
  for(i=0;i<=3;i++){
    ans=max(ans,dp[r][c][i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 356436
N = int(input())
W = list(map(int, input().split()))

import numpy as np
# Q = np.cumsum(W)

min_ = np.inf
for i in range(len(W)):
  diff = abs(sum(W[:i]) - sum(W[i:]))
  if diff < min_:
    min_ = diff

print(min_)

Measured memory_bytes: 21416
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D, T, S = MAP()

if T * S >= D:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10624
function Main(input: string) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const args = input.split("\n");
  // const N: number = parseInt(args[0], 10);
  const A: number[] = args[1].split(" ").map(s => parseInt(s, 10));
  A.sort((a, b) => a - b);

  let result = (A[0] + A[1]) / 2;
  for (let i = 2; i < A.length; i++) {
    const v = A[i];
    result = (result + v) / 2;
  }
  console.log(result);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
// Main(require("fs").readFileSync("./input", "utf8"));
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main()
{
   //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long N;cin>>N;
    map<long long int ,long long int> Hash;
    long long arr[N];
    for(long long i=0;i<N;i++)
    {
        long long int x;
        cin>>x;
        arr[i]=x;
        Hash[x]++;
    }
    long long int Total=0;
    for(auto it:Hash)
    {
        Total+=((it.second)*(it.second-1))/2;
    }
    for(long long int i=0;i<N;i++)
    {
        long long int z=Hash[arr[i]];
        cout<<Total-((z)*(z-1))/2+((z-1)*(z-2))/2<<endl;
    }
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 1000000007
int main ()
{
    int a;
    int b;
    cin>>a>>b;
    if(a*b%2==0)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = [[int(i) for i in input().split(" ")] for j in range(n)]
mi = 10**7

for i in range(1, 2**n):
    te = [0]*m
    bi = bin(i+2**n)[3:]
    c = 0
    for j in range(n):
        if bi[j] == "0":
            continue
        te = [x+y for x, y in zip(te, a[j][1:])]
        c += a[j][0]
    if sum([1 for i in te if i >= x]) == m:
        mi = min(mi, c)
if mi == 10**7:
    print(-1)
else:
    print(mi)

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

using ll = long long;

struct UF {
    int n;
    vector<int> par;
    UF(int n) : n(n) {
        for(int i = 0; i < n; i++) par.push_back(i);
    }
    int find(int a){
        if(a != par[a]) par[a] = find(par[a]);
        return par[a];
    }
    void join(int a, int b){
        par[find(a)] = find(b);
    }
};

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	ll m;
	int q;
	cin >> n >> m >> q;
	UF uf(n);
	vector<pair<int,int> > bp;
	for(int i = 0; i < q; i++){
		int a, b, c;
		cin >> a >> b >> c;
		if(c == 0){
			uf.join(a, b);
		} else {
			bp.push_back({a, b});
		}
	}
	for(pair<int,int> x : bp){
		if(uf.find(x.first) == uf.find(x.second)){
			cout << "No" << '\n';
			return 0;
		}
	}
	if(m == n-1){
		if(bp.empty()){
			cout << "Yes" << '\n';
		} else {
			cout << "No" << '\n';
		}
		return 0;
	}
	ll ncc = 0;
	for(int i = 0; i < n; i++){
		if(uf.find(i) == i) ncc++;
	}
	ll g = n-1 + ncc * (ncc - 1) / 2 - (ncc - 1);
	if(m <= g){
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 1784
/* author   : mpily :-()
title : Competing.cpp
time :Sat Apr 18 13:22:36 2020

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>arr(m);
	long long sum = 0;
	for(int i = 0; i < m; ++i){
		cin>>arr[i];
		sum += (long long)arr[i];
	}
	cout<<max((long long)(n-sum),-1LL)<<"\n";
	return 0;
}

Measured memory_bytes: 3628
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 52;
int A, B;
char s[maxn << 1][maxn << 1];

int main(void) {
  scanf("%d%d", &B, &A);
  int n = 50;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n << 1; ++j)
      s[i][j] = '.';
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n << 1; ++j)
      s[i + n][j] = '#';

  for (int i = 1; A > 1; i += 2)
    for (int j = 1; j <= n << 1 && A > 1; j += 2)
      s[i][j] = '#', --A;

  for (int i = n << 1; B > 1; i -= 2)
    for (int j = 1; j <= n << 1 && B > 1; j += 2)
      s[i][j] = '.', --B;

  printf("%d %d\n", n << 1, n << 1);
  for (int i = 1; i <= n << 1; ++i) {
    for (int j = 1; j <= n << 1; ++j)
      printf("%c", s[i][j]);
    putchar('\n');
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

 

using namespace std;

 

int main() 

{
    int i, a, b, c;
    for (i = 1; i<=3000; i++)
    {
    cin >> a >> b;
    if(a== 0 && b== 0 )
        break;
         
         
    if (a>b)
    {
        c = a;
        a = b;
        b = c;
    }
   
    cout << a << " " << b << endl;
    }

}


Measured memory_bytes: 3076
# coding: utf-8
# Your code here!
N = int(input())

ans = 0
for i in range(1,N+1,2):
    cnt = 0
    for j in range(1, i+1):
        if i % int(j) == 0:
            cnt = cnt + 1
    
    if cnt == 8:
        ans = ans + 1
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=210000;
const int inf=0x3f3f3f3f;

int n,w,tot;
ll f[Maxn],v;

signed main() {
//	freopen("test.in","r",stdin);
	read(n,tot);
	memset(f,0x3f,sizeof(f));f[0]=0;
	int now=0;
	for(int i=1;i<=n;i++) {
		read(w,v);
		for(int j=now+v;j>=v;j--) f[j]=min(f[j],f[j-v]+w);
		now+=v;
	}
	for(int i=now;i>=0;i--) f[i]=min(f[i],f[i+1]);
	int ans=0;
	while(f[ans]<=tot) ans++;
	printf("%d\n",ans-1);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d=0;
    cin>>a>>b>>c;
    while(1){
        if(c%a==0){
            d++;
        }
        
        if(a==b){
            break;
        }
        a++;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3096
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {b: char};

    if b == 'C' {
        println!("G")
    } else if b == 'G' {
        println!("C")
    } else if b == 'A' {
        println!("T")
    } else {
        println!("A")
    }
}


Measured memory_bytes: 2108
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int N;
int A[200005];

long long int w[1000006];
long long int MOD = 998244353;

long long int POW(long long int a, long long int k) {
	if (k == 0) { return 1; }
	else if (k == 1) { return a; }
	if (k % 2 == 1) { return (POW(a, k - 1)*a) % MOD; }

	long long int ret = POW(a, k / 2);
	return (ret*ret) % MOD;
}
long long int INV(long long int a) {
	return POW(a, MOD - 2);
}

long long int inv[1000006];
long long int sum[1000006];

long long int p[1000006];

vector<long long int> V;

long long int S[1000006], T[1000006];
long long int VAL[1000006];

long long int c[1000006];

int max_A = 0;

int main(void) {

	cin >> N;

	for (int i = 0; i <= N - 1; i++) { cin >> A[i];  max_A = max(max_A, A[i]); }

	/*for (int i = 1; i <= 1000000; i++) {
		p[i] = 1;
	}

	p[1] = 0;

	for (int i = 2; i <= 1000000; i++) {
		for (int j = 2; j*i <= 1000000; j++) {
			p[j*i] = 0;
		}
	}

	for (int i = 1; i <= 1000000; i++) {
		if (p[i] == 1) { V.push_back(i); }
	}

	*/
	
	for (int i = 1; i <= max_A; i++) {
		inv[i] = INV(i);
	}

	//====== w
	for (int i = 1; i <= max_A; i++) {
		w[i] = (inv[i] - sum[i] + MOD) % MOD;

		for (int j = 2; j*i <= max_A; j++) {
			sum[j*i] += w[i]; sum[j*i] %= MOD;
		}
	}
	
	//=======

	for (int i = 0; i <= N-1; i++) {
		c[A[i]]++;
	}



	
	for (long long int i = 1; i <= (long long int) max_A; i++) {
		for (long long int j = 1; j*i <= (long long int) max_A; j++) {
			S[i] += (c[j*i] * j*i); S[i] %= MOD;
			T[i] += c[j*i] * (j*i)*(j*i); T[i] %= MOD;
		}
	}

	for (int i = 1; i <= max_A; i++) {
		VAL[i] = (S[i] * S[i] - T[i] + MOD)%MOD;
		VAL[i]*=inv[2]; 
		VAL[i] %= MOD;
	}
	
	long long int ans = 0;

	for (int i = 1; i <= max_A; i++) {
		ans += w[i] * VAL[i]; ans %= MOD;
	}

	cout << ans << endl;

	/*for (int i = 1; i <= 5; i++) {
		cout << "S[" << i << "]=  " << S[i] << endl;
	}*/

	return 0;
}

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


int main() {
  int N;
  cin >> N;
  
  vector<int64_t> data(87);
  data.at(0) = 2;
  data.at(1) = 1;
  
  for(int i = 2; i < N + 1; i++){
    data.at(i) = data.at(i-1) + data.at(i-2);
  }
  cout << data.at(N) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long i,n,a,b,sum,A[1234567],ans=1e18;
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&A[i]);
		sum+=A[i];
	}
	for(i=1;i<n;i++)
	{
		a+=A[i];b=abs(sum-a-a);
		if(b<ans)ans=b;
	}
	cout<<ans;
}


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

const int MAXN = 2e6+10;
const int P = 1e9+7;

LL fac[MAXN];
LL invf[MAXN];

LL fp(LL a, LL n){
    if(n==0)
        return 1;

    LL h = fp(a, n/2);
    h *= h;
    h %= P;
    if(n&1){
        h = h*a %P;
    }

    return h;
}


LL C(LL a, LL b){
    return fac[a] * invf[a-b] % P * invf[b];
}
int main(){
    int r1, c1, r2, c2;
    cin >>r1>>c1>>r2>>c2;

    fac[0] = 1;
    fac[1] = 1;
    invf[0] = 1;
    invf[1] = 1;

    for(int i=2;i<=(int)2e6;i++){
        fac[i] = fac[i-1] * i %P;
        invf[i] = fp(fac[i], P-2);
    }

    LL ans = 0;
    LL tmp = C(r1+c1, r1);

    for(int i=r1+c1;i<=r2+c2;i++){
        ans = (ans + tmp) % P;
        tmp = tmp * 2 % P;
        if(i <=r2+c1-1){
            tmp += C(i, c1-1);
        }
        else{
            tmp -= C(i, r2);
        }

        if(i<=r1+c2-1){
            tmp+=C(i, r1-1);
        }
        else{
            tmp-=C(i, c2);
        }
        tmp%=P;
    }
    if(ans<0)
        ans+=P;
    cout<<ans;

}


Measured memory_bytes: 31488
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var ret = 0L;
        for (int i = 1; i <= n; i++)
            ret += getAns(n, i, k);
        Console.WriteLine(ret);
    }
    public static int getAns (int n , int b , int k)
    {
        var c = n / b;
        var d = n % b;
        var w = Math.Max(0, b - k);
        if (k == 0) return w -1 +w * (c-1) + Math.Max(0, d - k + 1 );
        else  return w * c + Math.Max(0, d - k + 1);
    }
}


Measured memory_bytes: 13140
integer N
integer(16),allocatable,dimension(:)::A
integer(16) tmp,cnt,ans
read*,N
allocate(A(N))
read*,A
call heapsort(N,A)
ans=0
tmp=A(1);cnt=0
do i=1,N
  if(tmp==A(i))then
    cnt=cnt+1
  else
    if(cnt>=tmp)cnt=cnt-tmp
    ans=ans+cnt
    
    cnt=1;tmp=A(i)
  endif
end do
if(cnt>=tmp)cnt=cnt-tmp
ans=ans+cnt

print"(i0)",ans
contains

subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer(16)::i,k,j,l
  integer(16):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);
    int money = 0;
    for (int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < K; i++){
        money += vec.at(i);
    }
    cout << money << endl;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

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

    int A[3][3]={{0,0,0},{0,0,0},{0,0,0}};
    int res[3][3]={{0,0,0},{0,0,0},{0,0,0}};

    rep(i, 3) { cin >> A[i][0] >> A[i][1] >> A[i][2]; }
    int N;
    cin >> N;
    vector<int> b(N);

    rep(i, N) { cin >> b[i]; }

    rep(bp, N) {
        rep(j, 3) {
            rep(i, 3) {
                if (A[i][j] == b[bp]) {
                    res[i][j] = 1;
                }
            }
        }
    }

    // debug
    /*
    rep(i, 3) {
        rep(j, 3) { cout << res[j][i] << ","; }
        cout << endl;
    }
    */

    // tate
    if (res[0][0] + res[0][1] + res[0][2] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[1][0] + res[1][1] + res[1][2] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[2][0] + res[2][1] + res[2][2] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[0][0] + res[1][0] + res[2][0] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[0][1] + res[1][1] + res[2][1] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[0][2] + res[1][2] + res[2][2] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[0][0] + res[1][1] + res[2][2] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (res[0][2] + res[1][1] + res[2][0] == 3) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
def compute(n, hs):
    max_len = 0
    cur_len = 1
    for i in range(1, n):
        if hs[i - 1] >= hs[i]:
            # print(i, cur_len, file=sys.stderr)
            cur_len += 1
        else:
            # print(i, cur_len, max_len, file=sys.stderr)
            max_len = max(cur_len, max_len)
            cur_len = 1
    max_len = max(cur_len, max_len)
    return max_len - 1


def main():
    n = int(input())
    hs = [int(h) for h in input().split()]
    res = compute(n, hs)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
N = int(input())
listA = list(map(int, input().split()))
listB = list(map(int, input().split()))

def exc(n):
    if n == 0:
        return 1
    return n*exc(n-1)


def hatena(list_data, N):
    new_list = []
    index = 0
    for i in range(0, N):
        count = 0
        if list_data[i] == 1:
            new_list.append(1)
            continue
        else:
            for list_el in new_list:
                if list_data[i] > list_el:
                    count += 1
#             print(count)
            index += (list_data[i]-1-count)*exc(N-1-i)
            new_list.append(list_data[i])
    return index

answer = hatena(listA, N) - hatena(listB, N)

# print(hatena(listA, N))
# print(hatena(listB, N))

if answer < 0:
    answer = -answer

print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int l, r, d;
 cin >> l >> r >> d;
 cout<< (r/d)-(l-1)/d;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  ll fib[50];
  fib[0]=fib[1]=1;
  rep(i,2,50){
    fib[i]=fib[i-1]+fib[i-2];
  }

  out(fib[n]);

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main(){
  string s;
  lint K;
  cin>>s>>K;
  for(lint t=0;t<K;t++){
    if(s[t]!='1'){
      cout<<s[t]<<endl;
      return 0;
    }
  }
  cout<<'1'<<endl;
  return 0;
}


Measured memory_bytes: 256
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	ll k,n;cin>>k>>n;
	if(k*500>=n)
		cout<<"Yes";
	else cout<<"No";
}

int main()
{
	//fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

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

int main()
{
    long long a,b,c,d,ans=0;
    cin>>a>>b;
    cin>>c;
    cin>>d;
        long long sum1 = b/c + b/d;
        long long sum2 = a/c +a/d;

    long long x = __gcd(c,d);

    x = x*(c/x)*(d/x);

    sum1 -= b/(x);
    sum2 -= a/(x);
    if(b>a)
    {
          ans += b-a - sum1 + sum2;
        if(a%c != 0 && a%d != 0)
            ans++;

         cout<<ans<<endl;
    }
     else
     {
         ans += -b+ a + sum1 - sum2;

 if(a%c != 0 && a%d != 0)
            ans++;
         cout<<ans<<endl;
     }

}


Measured memory_bytes: 256
a,b = map(int,input().split())
if 0<a and a<=b:
    print("Positive")
elif a<=b and b<0:
    if (b-a+1)%2==0:
        print("Positive")
    else:
        print("Negative")
elif a<=0 and 0<=b:
    print("Zero")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;cin >> n;
  vector<string> S(n);
  string ans="Yes";
  cin >> S[0];
  for (int i=1;i<n;i++) {
    cin >> S[i];
    string S2=S[i-1];
	if (S[i][0]!=S[i-1][S2.size()-1]) ans="No";
  }
  sort(S.begin(),S.end());
  for (int i=1;i<n;i++) {
    if (S[i]==S[i-1]) ans="No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  string s;
  cin >> n >> s >> k;
  char c = s[k-1];
  for(int i = 0; i < n; i++){
    if(s[i] != c) cout << "*";
    else cout << c;
  }
  cout << endl;
  return 0;
}

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

import sys
import os

N = int(input())
A = list(map(int, input().split()))

B = [0] * 8
any_color = 0

for a in A:
    if a <= 399:
        B[0] += 1
    elif a <= 799:
        B[1] += 1
    elif a <= 1199:
        B[2] += 1
    elif a <= 1599:
        B[3] += 1
    elif a <= 1999:
        B[4] += 1
    elif a <= 2399:
        B[5] += 1
    elif a <= 2799:
        B[6] += 1
    elif a <= 3199:
        B[7] += 1
    else:
        any_color += 1

if any_color == N:
    print(1, any_color)
else:
    colored_num = len([b for b in B if b > 0])
    zero_num = len([b for b in B if b == 0])
    max_num = colored_num + any_color
    print(colored_num, max_num)

Measured memory_bytes: 3064
object Main extends App {
  val s =  scala.io.StdIn.readLine()
  if(s.length % 2 == 0) {
    var tempS = s
    var yesFlag = true
    while(tempS.length > 0) {
      if (tempS.substring(0, 2) != "hi") {
        yesFlag = false
        tempS = ""
      } else {
        if(tempS.length > 3) {
          tempS = tempS.substring(2)
        } else {
          tempS = ""
        }
      }
    }
    if (yesFlag) println("Yes") else println("No")
  } else {
    println("No")
  }

}

Measured memory_bytes: 25528
import java.util.Scanner;
public class Main {
    public static void main(String[] aargs){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = n - n / 1000 * 1000;
        if(p != 0){
            p = 1000 - p;
        }
        sc.close();
        System.out.println(p);
    }
}

Measured memory_bytes: 35620
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void){
    // Here your code !
    int a[10];
    for(int i = 0; i<10; i++){
        scanf("%d\n", &(a[i]));
    }
    
    sort(a,a+10);
    printf("%d\n%d\n%d\n", a[9],a[8],a[7]);
}


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

s = input()
s_len = len(s)

odd = s[::2] #スライスを利用してsの奇数番目を取り出す
even = s[1::2]

if "L" in odd:
    print("No")
elif "R" in even:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 210000
#define mmod 1000000007
using namespace std;
struct node{int x,v,l,r;}a[N];
int n,f[N];
bool cmpv(node x,node y)
{
	if(x.v<y.v) return 1;
	return 0;
}
bool cmpx(node x,node y)
{
	if(x.x<y.x) return 1;
	return 0;
}
bool cmp(node x,node y)
{
	if(x.l<y.l) return 1;
	if(x.l>y.l) return 0;
	if(x.r<y.r) return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].v);
	sort(a+1,a+n+1,cmpv);
	for(int i=1;i<=n;i++) a[i].v=i;
	sort(a+1,a+n+1,cmpx);
	int t=0;
	for(int i=1;i<=n;i++)
	{
		t=max(t,a[i].v);
		a[i].r=t;
	}
	t=n;
	for(int i=n;i>=1;i--)
	{
		t=min(t,a[i].v);
		a[i].l=t;
	}
	sort(a+1,a+n+1,cmp);
	int mx=0;
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		int now=max(mx,a[i].r);
		for(int j=mx+1;j<=now;j++) f[j]=f[j-1];
		mx=now;
		t=0;
		if(a[i].l>1) t=f[a[i].l-2];
		f[a[i].r]=(2*f[a[i].r]-t)%mmod;
		f[a[i].r]=(f[a[i].r]+mmod)%mmod;
	}
	printf("%d\n",(f[n]-f[n-1]+mmod)%mmod);
	return 0;
}

Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int ans = 0;
		for(int i=L;i<=R;i++) if(i % D == 0) ans++;
		Console.WriteLine(ans);
		
	}
	int L,R,D;
	public Sol(){
		var d = ria();
		L = d[0]; R = d[1]; D = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27408
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI 3.141592653589793238

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

long double angle(int a,int b)
{
	long double ma=(b)*6;
	long double ha=(a+(long double)(b/(long double)60))*30;

	long double Min=min(abs(ma-ha),360-abs(ma-ha));

	long double rad=(Min*PI)/(long double)180;

	return rad;
}

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;

	int a,b,c,d;

	cin>>a>>b>>c>>d;

	long double ang=angle(c,d);

	long double ans;

	d(ang);

	ans = (long double)((long double)(a*a+b*b)-(long double)(2*a*b*cosl(ang)));

	ans = sqrtl(ans);

	cout<<fixed<<setprecision(12)<<ans;
	

}

Measured memory_bytes: 4116
a=gets.chomp.to_i
b=gets.chomp.split.map(&:to_i)

x=[]
b.each do |i|
  x << Rational(1,i)
end

#p x
z = Rational(1,(x.inject(:+)))
up = z.numerator.to_f
down = z.denominator.to_f
p up / down

Measured memory_bytes: 3836
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.next().toInt()
    val pList = (0 until n).map { sc.nextInt() }
    println(problem135b(n, pList))
}

fun problem135b(a: Int, pList: List<Int>): String {
    val sorted = pList.sorted()
    var count = 0
    sorted.forEachIndexed { index, num ->
        if (sorted[index] != pList[index]) {
            count++
        }
    }
    return if (count == 0 || count == 2) {
        "YES"
    } else {
        "NO"
    }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B; cin >> A >> B;
    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

bool contains(vector<int> v, int target){
    return find(v.begin(), v.end(), target) != v.end();
}

int main(){
    int a, b;
    cin >> a >> b;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    if(!contains(v, 1)){
        cout << 1 << endl;
    }
    if(!contains(v, 2)){
        cout << 2 << endl;
    }
    if(!contains(v, 3)){
        cout << 3 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// from https://atcoder.jp/contests/dp/submissions/11338932
#include<bits/stdc++.h>

#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 > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXHW 220000

ll facs[MAXHW], invfacs[MAXHW], inv[MAXHW];

void init(){
  facs[0]=1;
  rep(i, MAXHW-1)facs[i+1] = (facs[i]*(i+1))%MOD;
  inv[1]=1;
  for(int i=2;i<MAXHW-1; i++){
    inv[i] = -inv[MOD%i] * (MOD / i)%MOD;
    inv[i] +=MOD;
    inv[i] %=MOD;
  }
  invfacs[0]=1;
  rep1(i, MAXHW)invfacs[i] = invfacs[i-1] * inv[i] % MOD;
//  rep1(i, MAXHW)cout<<invfacs[i]<<' ';
}

ll comb(ll n, ll k){
  return facs[n] * invfacs[k] % MOD * invfacs[n-k] % MOD;
}

ll h,w,n;
vector<pll> walls;

ll dp[3300][2];

ll route(pll from, pll to){
  ll height = to.first-from.first;
  ll width = to.second-from.second;
  if(height<0 || width<0)return 0;
  return comb(height+width, height);
}

int main(){
  init();
  cin>>h>>w>>n;
  walls.push_back({1, 1});
  rep(i,n){
    ll y,x;cin>>y>>x;
    walls.push_back({y, x});
  }
  sort(walls.begin(), walls.end());


  dp[0][0]=1;
  rep1(i, n)rep(j, i){
    dp[i][0] += dp[j][1] * route(walls[j], walls[i]);
    dp[i][0] %= MOD;
    dp[i][1] += dp[j][0] * route(walls[j], walls[i]);
    dp[i][1] %= MOD;
  }

  pll g = {h,w};
  ll ngc = 0;
  rep1(i, n){
    ngc -= dp[i][0] * route(walls[i], g) % MOD;
    ngc += dp[i][1] * route(walls[i], g) % MOD;
    ngc %= MOD;
  }
  ll ans = (comb(h+w-2, w-1) - ngc + MOD*3LL) % MOD;
  cout<<ans<<endl;

//cout<<comb(h+w-2, w-1) <<' '<< ngc<<endl;
//cout<<comb(h+w-2, w-1) - ngc<<endl;

  return 0;
}


Measured memory_bytes: 8948
// HEADERS //
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <bits/stdc++.h>
 
// MISCELLANEOUS //
#define fast_IO() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define gcd __gcd
#define cnt_1s __buitlin_popcount
#define ll long long
#define endl "\n"
#define test(t) cin>>t; while(t--)
#define mem(v,x) memset(v,x,sizeof(v))

// LOOPS //
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define irep(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define srep(i,v) for(decltype(v.begin())i=v.begin();i!=v.end();i++)
 
// CONTAINERS //
//i #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define all(v) (v).begin(),(v).end()
#define present(v,x) (v).find(x)!=(v).end()
 
// DEBUGGING //
#define dbg() printf("\n**DEBUG**\n") 
#define chk(a) cerr<<endl<<#a<<":"<<a<<endl
#define chk2(a,b) cerr<<endl<<#a<<":"<<a<<"\t"<<#b<<":"<<b<<endl
 
// CONSTANTS //
#define M 1000000007
 
// MAIN //
// using namespace __gnu_pbds; 
using namespace std;
long double dp[3005][3005];
int main()
{
  int n; cin>>n; n++;
  long double p[n+1],ans=0.0;
  mem(dp,0.0); dp[0][0]=1.0; p[1]=0.0;
  rep(i,2,n+1) cin>>p[i];
  rep(i,1,n+1) rep(j,0,i+1)
  {
    if(!j) dp[i][j]=dp[i-1][j]*(1.0-p[i]);
    else dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
  }
  rep(i,ceil(1.0*n/2),n)  ans+=dp[n][i];
  printf("%0.10Lf",ans);
}

Measured memory_bytes: 141440
import numpy as np

n = int(input())
table,ans = np.zeros((9,9)),0

for k in range(n):
    num = str(k+1)
    if int(num[0])!=0 and int(num[-1])!=0:
        table[int(num[0])-1][int(num[-1])-1]+=1

for i in range(9):
    for j in range(9):
        ans += table[i][j]*table[j][i]
print(int(ans))

Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int h,n;
int a[2000],b[2000];
int dp[20000];
int ans=INF;
signed main(){
    cin>>h>>n;
    rep(i,15000)dp[i]=INF;
    dp[0]=0;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<h;i++){
        if(dp[i]==INF)continue;
        rep(j,n){
            dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
            
        }
    }
    for(int i=h;i<11451;i++){
        if(dp[i]<INF){
            ans=min(ans,dp[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
int main ()
{
    int H,W,N,a[10005],b[10005],n;
    scanf("%d%d",&H,&W);
    scanf("%d",&N);
    n=1;
    for (int ni=1;ni<=N;ni++) {scanf("%d",&a[ni]);for (int ai=1;ai<=a[ni];ai++) {b[n]=ni;n++;}}
    for (int hi=1;hi<=H;hi++)
    {
        if (hi%2==1)  {for (int wi=1;wi<=W;wi++) printf ("%d ",b[(hi-1)*W+wi]);printf("\n");}
        if (hi%2==0)  {for (int wi=1;wi<=W;wi++) printf ("%d ",b[(hi-1)*W+W-wi+1]);printf("\n");}
    }
    return 0;
}


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

using namespace std;

int main() {
    int n;  cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int a;  cin >> a;
        v.push_back(a);
    }

    sort(v.begin(), v.end());

    int ret = 0;
    for (int i = 1; i < n; i++) ret += v[i] - v[i - 1];

    cout << ret << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int sum, multi, diff;
    sum = a+b;
    multi = a*b;
    diff = a-b;
    int max = 0;

    max = sum;
    if (max<multi)
    {
        max = multi;
    }
    if (max < diff)
    {
        max = diff;
    }
    
    cout << max << endl;

}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<ll,ll>
/*********VARIABLE****************/
using namespace std;
ll i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
    vector<ll> v(n);
    for(i=0;i<n;i++) cin>>v[i];
    stack<ll> st;
    bool flag=0;
    while(v.size()){
        flag=0;
        for(i=v.size()-1;i>=0;i--){
            if(v[i]==i+1){
                flag=1;
                st.push(i+1);
                v.erase(v.begin()+i);
                break;
            }
        }
        if(flag==0){
            cout<<-1;
            return 0;
        }
    }
    while(!st.empty()){
        cout<<st.top()<<"\n";
        st.pop();
    }
    return 0;
}
//.........

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll x, a;
	cin >> x >> a;
	dump(x < a ? 0 : 10);
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a: A) cin >> a;

    multiset<int> B;
    B.insert(-1);

    for (auto &a: A) {
        auto p = B.lower_bound(a);
        p--;
        if (*p >= 0)
            B.erase(p);
        B.insert(a);
    }

    cout << B.size() - 1 << endl;
}

Measured memory_bytes: 5376
fun main(args: Array<String>) = yorukatsu11a()

fun yorukatsu11a() {
    val o = readLine()!!
    val e = readLine()!!

    val sb = StringBuilder()

    for (i in o.indices) {
        sb.append(o[i])
        if (i in e.indices) sb.append(e[i])
    }

    val answer = sb.toString()

    println(answer)
}


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

int main(void) {
  int n; cin >> n;
  vector<bool> k(101, false);
  for (int i = 0; i < n; ++i) {
    int d; cin >> d;
    k[d] = true;
  }
  int ans = 0;
  for (int i = 0; i <= 100; ++i) {
    if (k[i]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int gcd(int a,int b)
{
    if(!b)return a;
    else return gcd(b,a%b);
}
int main()
{
    int n,i,j,k;
     int gc=0,g;
    cin>>n;
    if(n==1)cout<<1;
    else if(n==2)cout<<9;
    else{
    for(int i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                    int m=gcd(i,j);
                if(m==1)
                gc+=1;
            else gc+=gcd(m,k);
            }
        }
    }
    cout<<gc;
}
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
open Printf
open Scanf

let id x = x

let (s, k) = scanf "%s %Ld" (fun s k -> s, k)

let () =
    let r = ref k in
    String.iteri (fun i c ->
        if c <> '1' then (printf "%c\n" c; exit 0);
        if !r = 1L then (printf "%c\n" c; exit 0);
        r := Int64.pred !r
    ) s


Measured memory_bytes: 384
s = input()
k = int(input())
n = len(s)

S = list(s)

import string
A = [chr(i) for i in range(ord("a"), ord("z")+1)]
B = {}
for i in range(26):
    B[A[i]] = i

for i in range(n):
    if S[i] != "a" and 26 - B[S[i]] <= k:
        k -= 26 - B[S[i]]
        S[i] = "a"
        
# print(k)
if k > 0:
    S[-1] = A[(B[S[-1]] + k) % 26]

# print(S)

print("".join(S))

Measured memory_bytes: 49392
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	println(c << " " << a << " " << b);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextDouble()){
			int N = sc.nextInt();
			int M = sc.nextInt();
			int P = sc.nextInt();
			if(N==0 && M==0 && P==0)break;
			
			double sum = 0;
			int set = 0;
			int X = 0;
			for(int i = 1; i <= N; i++){
				X = sc.nextInt();
				sum += X * (100 - P);
			if(i == M)set = X;
			}
			sum = sum / set;
			if(set == 0)
				System.out.println(0);
			else
				System.out.println((int)Math.floor(sum));
		}
		}
}

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


long long N, A[100000];


int main(){
    cin >> N;
    long long A_sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A_sum += A[i];
    }
    bool flag = true;
    if(A_sum % (N*(N+1)/2) != 0){
        flag = false;
    }
    long long k = A_sum * 2 / (N*(N+1));
    long long d[100000];
    for(int i = 0; i < N; i++){
        d[i] = A[(i+1)%N] - A[i] - k;
    }
    for(int i = 0; i < N; i++){
        if(d[i] > 0 || d[i] % N != 0){
            flag = false;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

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

using namespace std;

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

  int n, t;
  cin >> n >> t;
  int64_t time;
  int64_t ans = 0;
  int64_t bef;
  cin >> bef;
  for (int i = 0; i < n - 1; ++i) {
    cin >> time;
    if (t < time - bef) {
      ans += t;
    } else {
      ans += time - bef;
    }
    bef = time;
  }
  cout << ans + t << "\n";
}


Measured memory_bytes: 256