akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;

void solve()
{
	int n;
	cin >> n;

	loop(i,0,3985)
	{
		for(int j = i; j >= -3985; j--)
		{
			int a = i , b = j;
			loop(k,0,4)
			{
				a = a*i;
				b = b*j;
			}

			if(a-b == n)
			{
				cout << i << " " << j << endl;
				return;
			}
		}
	}
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,r;
    cin>>n;
    int a[n];
    long long dp[n][n];
    long long pref[n];
    
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    pref[0]=a[0];
    for(int j=1;j<n;j++){
        pref[j]=pref[j-1]+a[j];
    }
    
    for(int len=1;len<=n;len++){
        for ( l=0;l<n;l++){
            int r=l+len-1;
            if(r==n){
                break;            }
        if(len==1){
            dp[l][l]=0;
        }
        else{
            dp[l][r]=2e18;
            for (int mid = l;mid<r;mid++){
                if(l==0){
                    long long calc = dp[l][mid] + dp[mid+1][r] +pref[r];
                
                     dp[l][r]=min(dp[l][r],calc);
                }
                else{
                long long calc = dp[l][mid] + dp[mid+1][r]+pref[r]-pref[l-1];
                dp[l][r]=min(dp[l][r],calc);
            }
            }
        }
    }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int count = scanner.nextInt();
    int length = scanner.nextInt();
    
    List<String> strings = new ArrayList<>();
    for (int ix = 0; ix < count; ix++) {
      strings.add(scanner.next());
    }
    
	Collections.sort(strings);
    StringBuilder builder = new StringBuilder();
    for (String string : strings) {
      builder.append(string);
    }
    
    System.out.println(builder);
  }
}

Measured memory_bytes: 21332
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    if n == 1 {
        println!("{}", 0);
        return;
    }
    let mut position: Vec<usize> = vec![0; n + 1];
    for i in 0..n {
        let num: usize = sc.read();
        position[num] = i;
    }

    let mut maximum = 1;
    let mut present = 1;
    for i in 2..(n + 1) {
        if position[i] > position[i - 1] {
            present += 1;
        } else {
            if present > maximum {
                maximum = present;
            }
            present = 1;
        }
    }
    if present > maximum {
        maximum = present;
    }

    println!("{}", n - maximum);
}


struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024 * 10], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }
    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX

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

#define DEBUG false

int main() {
		ll n, m;
		cin >> n >> m;

		vector <bool> check(n);
		vector <bool> used(m);
		map <ll, vector <int> > mp;

		ll k;
		vector <vector<int> > list(n);
		rep(j, n) {
				cin >> k;
				rep(i, k) {
						int tmp;
						cin >> tmp;
            list[j].push_back(tmp);
						mp[tmp].push_back(j);
				}
		}

		queue <int> qu;
		check[0] = true;
		rep(i, list[0].size()) {
				qu.push(list[0][i]);
		}

		while(!qu.empty()) {
				int num = qu.front(); qu.pop();
        if(DEBUG) cout << "num:"<<num<<endl;
				if(used[num]) continue;
        used[num] = true;

        vector<int> vv = mp[num];
        rep(i, vv.size()){
          int id = vv[i];
          if(!check[id]){
            rep(j, list[id].size()){
              if(!used[list[id][j]]) qu.push(list[id][j]);
            }
          }
          check[id] = true;
        }
		}

    bool ans = true;
    rep(i, n) if(!check[i]) ans = false;

    if(DEBUG) rep(i, n) cout << check[i] <<endl;

    if(ans) cout << "YES" <<endl;
    else cout <<"NO" <<endl;

		return 0;
}


Measured memory_bytes: 9208
a, b = map(int,input().split())
l = [[0]*50 for i in range(50)]
m = [0]*50
L = []
def cal(v):
    m[v] = 1
    for i in range(a):
        if l[v][i] == 0:continue
        if m[i]==1 : continue
        cal(i)
for i in range(b):
    ta , tb = map(int,input().split())
    ta-=1
    tb-=1
    L.append([ta,tb])
    l[ta][tb]+=1
    l[tb][ta]+=1
c = 0

for x,y in L:
    l[x][y] = 0
    l[y][x] = 0
    m = [0]*50

    cal(0)

    flag = 0
    for i in range(a): 
        if m[i] == 0:flag=1
    c+=flag
    # print(x,y,flag)
    l[x][y] = 1
    l[y][x] = 1
print(c)

    


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

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

using namespace std;

vector<int> Z_algorithm(const vector<int>& a){
	int n=a.size();
	vector<int> z(n);
	for(int i=1,pre=0;i<n;i++){
		if(z[pre]>(i-pre)+z[i-pre]){
			z[i]=z[i-pre];
		}
		else{
			int j=max(pre+z[pre]-i,0);
			while(i+j<n && a[j]==a[i+j]) j++;
			z[i]=j;
			pre=i;
		}
	}
	z[0]=n;
	return z;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	vector<int> seq(3*n);
	rep(i,n-1) seq[i]=b[i]^b[i+1];
	seq[n-1]=-1;
	rep(i,2*n) seq[n+i]=a[i%n]^a[(i+1)%n];

	auto z=Z_algorithm(seq);

	rep(k,n){
		int x=a[k]^b[0];
		if(z[n+k]==n-1) printf("%d %d\n",k,x);
	}

	return 0;
}


Measured memory_bytes: 9728
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int r;
  cin>>r;
  if(r<1200) cout<<"ABC"<<endl;
  else if(r<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}

Measured memory_bytes: 4352
#include<iostream>        //如果所有的数加起来-正对角线上的数=正对角线上的数*2 就是yes 
using namespace std;
int main()
{
	int c[4][4];
	for(int i=1;i<4;i++)
	{
		for(int j=1;j<4;j++)
		cin>>c[i][j];
	}
	int asum=0;
	int xsum=0;
	for(int i=1;i<4;i++)
	{
		for(int j=1;j<4;j++)
		{
			asum=asum+c[i][j]; 
		}
		xsum=xsum+c[i][i];
	} 
	if(asum-xsum==xsum*2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }

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

	for (uint32_t i = 1; i <= 9; i++) {
		for (uint32_t j = 1; j <= 9; j++) {
			if (n == (i*j)) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	
	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

llong tens[19];

llong getMod(llong x, llong m) {
    return (x % m + m) % m;
}

llong solve(int d, int c) {
    vector<pll> now(1, pll(0, 1));
    for (int i = 0, j = c - 1; i < j; ++i, --j) {
        llong cnt[19] = {};
        for (int x = 0; x < 10; ++x) {
            for (int y = (j == c - 1); y < 10; ++y) {
                ++cnt[x - y + 9];
            }
        }
        vector<pll> nxt;
        for (int k = 0; k < 19; ++k) {
            if (cnt[k] == 0) continue;
            for (pll p : now) {
                llong nx = p.fs + (tens[j] - tens[i]) * (k - 9);
                if (getMod(nx - d, tens[i]) == 0) nxt.emplace_back(nx, p.se * cnt[k]);
            }
        }
        now = nxt;
    }
    llong ret = 0;
    for (pll i : now) if (i.fs == d) ret += i.se;
    if (c & 1) ret *= 10;
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    tens[0] = 1;
    for (int i = 1; i <= 18; ++i) tens[i] = tens[i - 1] * 10;
    int D;
    cin >> D;
    llong ans = 0;
    for (int i = 2; i <= 18; ++i) {
        ans += solve(D, i);
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
	int n,m;
	scanf("%d%d", &n, &m);
	int num[100005];
	memset(num,0,sizeof(num));
	for (int i=0; i<m; i++) {
		int a,b;
		scanf("%d%d", &a, &b);
		num[a-1]++;
		num[b-1]++;
	}
	bool pos=true;
	for (int i=0; i<n; i++) pos &= num[i]%2==0;
	printf("%s\n", pos ? "YES" : "NO");
}


Measured memory_bytes: 640
"use strict"
function Main(input){
 input=input.trim();
 input=input.split(/\s+/);
 for(let i=0;i<input.length;i++)
   input[i]=input[i]-0;
  var A=input[0];
  var B=input[1];
  var C=input[2];
  var M=Math.floor(B/A);
  var result=Math.min(M,C);
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
N,L=map(int,input().split())
apple=[]
total=0
min_effect=0
for i in range(0,N):
    apple.append(L+i)
    total+=(L+i)
if(apple[0]*apple[N-1]<=0):
    min_effect=0
elif(apple[N-1]<0):
    min_effect=apple[N-1]
elif(apple[0]>0):
    min_effect=apple[0]
print(total-min_effect)

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    auto index = [&](int x) {
        if (x <= a) {
            return 0;
        } else if (x <= b) {
            return 1;
        } else {
            return 2;
        }
    };

    vector<int> cnts(3, 0);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        cnts[index(x)] += 1;
    }

    cout << *min_element(cnts.begin(), cnts.end()) << '\n';

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [i for i in map(int,input().split())]

index = 1
ans = 0
flag = 0
for i in range(1,N+1):
  if A[i-1] == index:
    flag = 1
    index += 1
  else:
    ans += 1

print(ans) if flag else print("-1")

Measured memory_bytes: 25768
#include <stdio.h>

double get_bmi(double h, double w){
	return (w / (h * h));
}

int is_dangerous(double h, double w){
	return (get_bmi(h, w) >= 25.0);
}

int main(void)
{
	int sid;
	double weight, height;

	while (~scanf("%d,%lf,%lf", &sid, &weight, &height)){
		if (is_dangerous(height, weight)) printf("%d\n", sid);
	}
	return (0);
}

Measured memory_bytes: 628
s = input()
n = len(s) + 1
ans = 0
l = 0
r = 0
if s[0] == ">":
    p = 0
elif s[0] == "<":
    p = 1
for i in range(n-1):
    if p == 0:
        if s[i] == ">":
            l += 1
        elif s[i] == "<":
            p = 1
            ans += l*(l+1)//2
            if l < r:
                ans -= l
            elif l >= r:
                ans -= r 
            l = 0
            r = 1
    elif p == 1:
        if s[i] == "<":
            r += 1
        elif s[i] == ">":
            l += 1
            p = 0
            ans += r*(r+1)//2
if p == 0:
    ans += l*(l+1)//2
    if l < r:
        ans -= l
    elif l >= r:
        ans -= r
elif p == 1:
    ans += r*(r+1)//2
    
print(ans)

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

int main(void){
  int x,n;
  cin>>x>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int num=0;
  int mn=500;
  sort(p.begin(),p.end());
  if(n==0){
      cout<<x<<endl;
      return 0;
  }
  for(int i=-100;i<=500;i++){
      bool at=true;
      for(int j=0;j<n;j++){
          if(p[j]==i){
              at=false;
          }
      }
      if(at==false){
          continue;
      }
      if(mn>abs(x-i)){
          num=i;
          mn=abs(x-i);
      }
  }
  cout<<num<<endl;
}
  
  
       
      
   
   
    


Measured memory_bytes: 3596
n, k = gets.split.map(&:to_i)
x = {}
y = {}
z = {}
xs = []
ys = []
zs = []
areas = []
n.times do
  area = gets.split.map(&:to_i)
  areas << area
  xs << area[0]; xs << area[3]
  ys << area[1]; ys << area[4]
  zs << area[2]; zs << area[5]
end
xs.sort!
ys.sort!
zs.sort!
xss = xs.size
yss = ys.size
zss = zs.size
xs.each_with_index{ |a, i| x[a] = i }
ys.each_with_index{ |b, i| y[b] = i }
zs.each_with_index{ |c, i| z[c] = i }
sea = Array.new(xss){ Array.new(yss){ Array.new(zss, 0) }}
for area in areas
  x0, y0, z0, x1, y1, z1 = area
  for a in (x[x0]...x[x1])
    for b in (y[y0]...y[y1])
      for c in (z[z0]...z[z1])
        sea[a][b][c] += 1
      end
    end
  end
end

ret = 0
for a in (0...xss-1)
  dx = xs[a+1] - xs[a]
  for b in (0...yss-1)
    dy = ys[b+1] - ys[b]
    for c in (0...zss-1)
      dz = zs[c+1] - zs[c]
      if sea[a][b][c] >= k
        ret += dx * dy * dz
      end
    end
  end
end
p ret

Measured memory_bytes: 16876
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#define eps 0.0000000001
#define maxn 300009
#define inf 0x3f3f3f3f
#define mod 1000000009
#define ll long long
using namespace std;

int main()
{
    //freopen("d:\\in.txt","r",stdin);
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(c>=a&&c<=b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
void main() {
    int[] ab = readln.split.to!(int[]);
    writeln(ab.all!"a & 1" ? "Odd" : "Even");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    int n ;
    long long sum=0;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    map<int, long long> m;
    for(int i=0; i<n; i++){
        m[a[i]]++;
    }
    for(int i=0; i<=200000; i++){
        if(m[i] >=2LL) sum += m[i] * (m[i]-1)/2;
    }
    for(int k=0; k<n; k++){
        long long sum1 = sum;
        long long x = (long long) m[a[k]] * (m[a[k]]-1);
        long long y = (long long) (m[a[k]] - 1) * (m[a[k]]-2);
        if(m[a[k]] == 2LL) sum1 = sum1 -  x/2;
        else if(m[a[k]] >= 3LL) sum1 = sum1 -  x/2 + y/2;
        cout << sum1 << endl;
    }
}

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

using namespace std;

long long MOD = 1e9 + 7;

long long c[2005][2005];
int n, k;

int main(void)
{
    for (int i = 0; i <= 2000; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
    }
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i)
        printf("%lld\n", c[1 + n - k][i] * c[k - 1][i - 1] % MOD);
    return 0;
}

Measured memory_bytes: 30208
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;
Int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}//gcd

Int lcm(Int a, Int b) {
 return a / gcd(a, b)*b;
}//lcm
int main(){
    Int a,b;cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));

    int ans = INF;
    rep(i, n - k + 1) ans = min(ans, h[i + k - 1] - h[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
z = gets
i = 0
ngs = 753
max = 
a = z[i..(i+2)]
while i < z.length - 3 do
    a = z[i..(i+2)]
    hikaku = (a.to_i - 753).abs
    if i == 0 then
        max = hikaku
    elsif i != 0 && max > hikaku then
        max = hikaku
    end
    i += 1
end
puts max



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

int main(){
  int N;
  cin >> N;
  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;
  
  vector<string> judge(N);
  for(int i=0; i<N; i++){
    cin >> judge.at(i);
  }
  for(int i=0; i<N; i++){
    if(judge.at(i) == "AC")
      AC++;
    else if(judge.at(i) == "WA")
      WA++;
    else if(judge.at(i) == "TLE")
      TLE++;
    else if(judge.at(i) == "RE")
      RE++; 
  }
  
  cout << "AC" << " x " << AC << endl;
  cout << "WA" << " x " << WA << endl;
  cout << "TLE" << " x " << TLE << endl;
  cout << "RE" << " x " << RE << endl;
  
}

Measured memory_bytes: 6356
#include<stdio.h>

int main(void){
	
	int a,b;
	b=1;
	while(1){
		a=0;
		
		scanf("%d",&a);
		if(a==0){
			break;
		}
		printf("Case %d: %d\n",b,a);
		b++;
		
		
		
		
	}
	
	
	
	return 0;
	
}

Measured memory_bytes: 600
N,M = map(int, input().split())
li = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ptn = []
for i in range(2 ** N):
    ptn.append(list(str(bin(i))[2:].zfill(N)))

ans = 0
for x in ptn:
    sucflg = True
    for oidx,outval in enumerate(li):
        cnt = 0
        for idx,inval in enumerate(outval):
            if idx == 0:
                continue
            if x[inval - 1] == '1':
                cnt += 1
        else:
            if cnt % 2 != p[oidx]:
                sucflg = False
                break
    else:
        if sucflg:
            ans += 1

print(ans)



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

int main()
{
    ll n;
    int k;
    cin >> n >> k;
    int ans;
    int flag = 0;
    rep(i,100000)
    {
        if (pow(k, i) <= n && pow(k, i + 1) > n)
        {
            ans = i + 1;
            flag = 1;
        }
        if (flag)
            break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int S;
  cin >> S;
  int a, b, c, d;
  a = S / 1000;
  b = (S / 100) % 10;
  c = (S / 10) % 10;
  d = S % 10;
  if (a == b || b == c || c == d){
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def multiple(X, Y, Z):
    # 天井関数math.ceilが誤差でおかしくなってるから組み込み関数を使う
    if X % Z != 0:
        min_z = X // Z + 1
    else:
        min_z = X / Z
    max_z = Y // Z
    num_z = max_z - min_z + 1
    return int(num_z)

def gcd(X, Y):
    while Y!= 0:
        X, Y = Y, X % Y
    return X

if C == 1 or D == 1:
    print(0)
else:
    num_c = multiple(A, B, C)
    num_d = multiple(A, B, D)
    lcm = int((C * D) / gcd(C, D)) 
    num_lcm = multiple(A, B, lcm)
    print(B - A + 1 - num_c - num_d + num_lcm)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int diff = a + b - c - d;
        String result = "Balanced";
        if (diff != 0) {
            boolean judge = 0 < diff;
            result = judge ? "Left" : "Right";
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.WYR", "r", stdin );
	int m, n;
	while (scanf ("%d %d", &m, &n ), m, n ){
		string str = "";
		int x = 0, y = 0, dir = 0;
		while (getline (cin, str ) ){
			stringstream ss(str );
			string com = ""; int arg = 0;
			ss >> com;
			if (com == "STOP" ){
				printf ("%d %d\n", x+1, y+1 );
				break;
			}else
			if (com == "LEFT" ){
				dir = (dir - 1 + 4 )%4;
			}else
			if (com == "RIGHT" ){
				dir = (dir + 1 ) % 4;
			}else{
				ss >> arg;
				if (com == "FORWARD" ){
					y = y + arg*dy[dir];
					x = x + arg*dx[dir];
				}else
				if (com == "BACKWARD" ){
					y = y + arg*dy[(dir+2) % 4];
					x = x + arg*dx[(dir+2) % 4];
				} // end if
				if (x < 0 ) x = 0;
				if (x >= m ) x = m - 1;
				if (y < 0 ) y = 0;
				if (y >= n ) y = n - 1;
			} // end if
//			cout << '(' << x << ',' << y << ") dir: " << dir << endl;
		} // end while
	} // end while		 

		
	return 0;
}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int sum = 0;
    for (int i=0; i<n; i++) {
        sum += s[i] - '0';
        sum %= 9;
    }

    cout << (sum%9==0? "Yes" : "No") << endl;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p;
   cin>>n>>m;
   if(n-m<0)
   {
       cout<<"0"<<endl;
   }
   if(n-m>=0)
   {
       cout<<n-m<<endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll K, X;
    cin >> K >> X;
    if (500 * K >= X) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def solv(n, p):
    count = 0
    for i in range(n-2):
        if p[i] < p[i+1] and p[i+1] < p[i+2]:
            count += 1
        elif p[i] > p[i+1] and p[i+1] > p[i+2]:
            count += 1
    return count


if __name__ == '__main__':

    n = int(input())
    p = [int(x) for x in input().split()]

    ans = solv(n, p)

    print(ans)


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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n],b[m],ans[2000] = {0};
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }

  for(int i = 0; i < m; i++){
    for(int j = 0; j < n; j++){
      if(b[i] >= a[j]){
	ans[j]++;
	break;
      }
    }
  }
  int res = 0;
  int num = 0;
  for(int i = 0; i < n; i++){
    res = max(res, ans[i]);
    if(res == ans[i])num = i + 1;
  }
  cout << num << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> nums(3, 0);

  REP (i, s.size()) {
    nums[s[i] - 'a']++;
  }

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

  if (nums[2] - nums[1] > 1 || nums[2] - nums[0] > 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}


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

int main(){
    int n,l;
    scanf("%d %d",&n,&l);
    vector<string>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    for(auto x:v) cout<<x;
    printf("\n");
    return 0;
}


Measured memory_bytes: 764
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    
    frame = "#" * w
    dots = "#" + "." * (w-2) + "#"
    print(frame)
    for row in range (h-2):
        print(dots)
    print(frame)
    print()



Measured memory_bytes: 5612
object Main {
    def main(args: Array[String]) {
        val sc = new java.util.Scanner(System.in)
        val h, w, n = sc.nextInt
        var a = List[Int]()
        for (i <- 1 to n) {
            val c = sc.nextInt
            for (j <- 1 to c) a = i :: a
        }
        val table = Array.fill(h, w)(-1)
        for (i <- 0 until h) {
            for (j <- 0 until w) {
                val idx = if (i%2 == 0) j else w - j - 1
                table(i)(idx) = a.head
                a = a.tail
            }
        }
        for (i <- 0 until h) {
            for (j <- 0 until w) {
                if (j!=0) print(" ")
                print(table(i)(j))
            }
            println()
        }
    }
}

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

int main() {
  int N; cin >> N;
  string s; cin >> s;
  s += s[0];
  string SSWWS("SSWWS");
  string ans;
  for(int i = 0; i < 4; ++i) {
    string res = SSWWS.substr(i, 2);
    for(int j = 1; j < N; ++j) {
      for(int k = 0; k < 4; ++k) {
        if(res.substr(j-1, 2) == SSWWS.substr(k, 2)) res += (s[j] == 'o') ? "SW"[k%2] : "WS"[k%2];
      }
    }
    if(res.back() != res.front()) continue;

    bool ok = false;
    for(int k = 0; k < 4; ++k) {
      if(res.substr(N-1, 2) == SSWWS.substr(k, 2)) {
        if((s[0] == 'o' && res[1] == "SW"[k%2]) || (s[0] == 'x' && res[1] == "WS"[k%2])) ok = true;
      }
    }
    if(ok) ans = res.substr(0, N);
  }

  cout << ((ans.empty()) ? "-1" : ans) << endl;

  return 0;
}


Measured memory_bytes: 736
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "DEBUG: " << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout << endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }
// -----------------------------------------------------------------------------

const int N = 1E6 + 100;
int n; char s[N];

LL solve(int K) {
    int l = 0, r = 1, mp = 0, cp = 0;
    LL pcount = 0, ans = 0;
    while (l < n) {
        while (r < n && r - l < K) {
            // add r
            if (s[r] == 'M')
                mp++;
            else if (s[r] == 'C') {
                cp++;
                pcount += 1 * mp;
            }
            r++;
        }

        if (s[l] == 'D') ans += pcount;

        l++;
        if (s[l] == 'M') { mp--; pcount -= 1 * cp; }
        else if (s[l] == 'C') cp--;
    }
    return ans;
}

int main() {
    int q;
    cin >> n >> s >> q;
    while (q--) {
        int k; cin >> k;
        cout << solve(k) << endl;
    }
}

Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a, S;
    scanf("%d",&S);
    a = S%100;
    if(S==0){
        printf("NA");
    }else if(a==0 ){
        if(99 <S && S<1201){
        printf("MMYY");
        }else{
            printf("NA");
        }
    }else if(0<a && a< 13){
        if(0<S && S<13){
            printf("YYMM");
        }else if(0101<=S && S<=1212){
            printf("AMBIGUOUS");
        }else
        {
            printf("YYMM");
        }
    }else{
        if(1313<S){
            printf("NA");
        }else if(S>0012 && 0100>S){
            printf("NA");
        }else if(S>0112 && 1300<S){
            printf("MMYY");
        }else{
            printf("MMYY");
        }
    }
   
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  string s1 = "Hoshino", s2 = "Hoshina";
  string::size_type pos;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    string line;
    getline(cin, line);
    for (pos = line.find(s1); pos != string::npos; pos = line.find(s1, s2.length() + pos))
      line.replace(pos, s1.length(), s2);
    cout << line << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	char ch1, ch2;
	cin >> ch1 >> ch2;
	if (ch1 == 'H') {
		cout << ch2 << endl;
	}
	else {
		if (ch2 == 'H')cout << 'D' << endl;
		else cout << 'H' << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N_MAX = 100;
typedef pair<int,int> P;
int main()
{
  int n,i,j,k,res;
  int p[N_MAX];
  string ss;
  string s[N_MAX],s2[N_MAX];
  P pp[N_MAX];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s[i] >> p[i];
    s2[i]=s[i];
  }
  sort(s2,s2+n);
  for(i=0;i<n;){
    ss=s2[i];
    for(j=0,k=0;k<n;k++)
      if(s[k]==ss){
        pp[j].first=p[k];
        pp[j].second=k+1;
        j++;
      }
    sort(pp,pp+j,greater<P>());
    for(k=0;k<j;k++)
      cout << pp[k].second << endl;
    i+=j;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int V = 1000;
	int N,W;
	std::cin >> N >> W;
	std::vector<int> dp(V*N+1,W+1);
	dp[0] = 0;
	rep(i,N) {
		int w,v;
		std::cin >> w >> v;
		for(int j = V*N;j>=0;j--) {
			if(j-v>=0) dp[j] = std::min(dp[j],dp[j-v]+w);
		}
	}
	for(int j = V*N;j>=0;j--) {
		if(dp[j]<=W) {
			print(j);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.conv, std.algorithm, std.array, std.math;

void main()
{
  long a, b, c;
  long d;
  readf("%d %d %d %d", &a, &b, &c, &d);

  if ((c-a).abs <= d || (b-a).abs <= d && (c-b).abs <= d) {
    writeln("Yes");
  }
  else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 









int main()
{
     int k;
     cin>>k;
     if(k<=9)cout<<k;
     else
     {
          int i=9;
          queue<ull> q;
          for(int i=1;i<=9;i++)q.push(i);
          ull ans=0;
          while(true){
               ull p=q.front();q.pop();
               ull d=p%10;
               p*=10;
               
               if(d!=0)
               {i++;
               ans=p+d-1;if(i==k)break;q.push(ans);
               }
               ans=p+d;
               i++;
               if(i==k)break;q.push(ans);
               if(d!=9){
                    i++;
                    ans=p+d+1;
                    if(i==k)break;q.push(ans);
               }
          }
          cout<<ans;
     }
}


























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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

const int oo = 1e18;

int N, M;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> M;

    int sum = 0;

    vector<int> vect;

    for(int i = 0 ; i < N ; i++)
    {
        int n;
        cin >> n;
        vect.push_back(n);
        sum += n;
    }

    sum = ((sum-1)/(4*M))+1;

    int cont = 0;

    for(auto x : vect)if(x >= sum)cont++;

    if(cont >= M)cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<1300;i++){
        if(int(i*0.08)==a&&int(i*0.1)==b){cout<<i<<endl;return 0;}
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,k,total=0,c=0;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);

  for(int i=1; i<1000; i++){
    total=0;
    total=k*i;
    if(total>=a&&total<=b){
      c++;
      break;
    }    
  }
  if(c>=1)puts("OK");
  else puts("NG");
	    
  return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define N 100001
using namespace std;
int n,A[N];

int partition(int p,int r){
  int x=A[r];
  int i=p-1,t;
  for(int j=p;j<r;j++)
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  int r=partition(0,n-1);
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    if(r==i)cout<<'[';
    cout<<A[i];
    if(r==i)cout<<']';
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1548
import sys
from collections import deque
 
def main():
    N, M = map(int, input().split())
    a = deque([int(sys.stdin.readline().strip()) for _ in range(M)])
 
    atmp = -1
    if len(a) != 0:
        atmp = a.popleft()
 
    dp=[0] * (N+1)
    for i in range(0, N+1):
        if i == atmp:
            if len(a) != 0:
                atmp = a.popleft()
            continue
 
        if i == 0 or i == 1:
            dp[i] = 1
            continue
 
        if dp[i-1] == 0 and dp[i-2] == 0:
            break
 
 
        dp[i] = dp[i-1] + dp[i-2]
 
    print(dp[N] % 1000000007)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 460404
#! /usr/bin/python3
# A - キャンディーとN人の子供イージー / Children and Candies (ABC Edit)

"""
問題文
    競プロ幼稚園にはN人の子供がいます。
    えび先生は、子供たちを一列に並べ、
    一人目にはキャンディーを1個,二人目には2個,...,
    N人目にはN個あげることにしました。
    必要なキャンディーの個数の合計は何個でしょう?
制約
    1 ≦ N ≦ 100
入力
    入力は以下の形式で標準入力から与えられる。
    N
出力
    必要なキャンディーの個数の合計を出力せよ。
"""

test_mode = True

N = int(input())    # 人数
candy = 0           # キャンディーの個数

for i in range(N):  # 一人ずつキャンディーの個数を加える
    candy += i+1

print(candy)


Measured memory_bytes: 2940
X, Y, A, B, C = map(int, input().split())

plist = sorted(list(map(int, input().split())))[::-1][:X]
qlist = sorted(list(map(int, input().split())))[::-1][:Y]
rlist = sorted(list(map(int, input().split())))
plist.extend(qlist)
plist.extend(rlist)

print(sum(sorted(plist, reverse=True)[:X + Y]))


Measured memory_bytes: 107756
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 536
#include <iostream>

using namespace std;

int const N = 1e5 + 10;
int a[N];

void swap(int &a, int &b) {
  
  int tmp = a;
  a = b;
  b = tmp;
}

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

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    _, b, c = LS()
    x = int(b[0] + c[0]) % 4
    if not x:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B;
  cin >> A >> B;

  B--;

  if (B % (A - 1) == 0) {
    COUT(B / (A - 1));
  } else {
    COUT(B / (A - 1) + 1);
  }

  return 0;
}

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


int main() {
int H,N;
cin >> H >> N;
vector<int> vec(100000);
bool ans =false;

for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
}
for (int i = 0;i< N;i++) {
    H = H-vec.at(i);
    if (H <= 0) {
        ans = true;
        break;

    }
}

if (ans == true) {
    cout << "Yes" << endl;
} else {
    cout << "No" << endl;
}

return 0;
}


Measured memory_bytes: 640
def mpow(a,b,m):
    ans=1
    while b >0 :
        if b&1:
            ans = (ans*a)%m
        a=(a*a)%m
        b=b>>1

    return ans

def calcmod(X,m,N):
    mod=0
    X=X[::-1]
    # print(X)
    for i in range(N):
        if X[i] == '1':
        # if X & (1<<i) >0:
            mod += mpow(2,i,m)
            mod%=m
    return mod

def popcount(m):
    return bin(m).count("1")


def findsteps(mm):
    cnt=0
    while mm !=0:
        cnt+=1
        mm=mm%popcount(mm)
    return cnt
N=int(input())
x=input()
X=int(x,2)

##we need to find X%(m-1) and X%(m+1)
m=popcount(X)
m1=m+1
m2=m-1
firstmod=calcmod(x,m1,N)
if m2 !=0:
    secondmod=calcmod(x,m2,N)
fans=[0 for i in range(N)]
k=0
for i in range(N-1,-1,-1):
    if X & (1<<i) >0:
        ##the bit was set
        ##we need to find X%(m-1) - (2^i)%(m-1)
        if m2 == 0:
            ans=0
        else:
            mm=secondmod - mpow(2,i,m2)
            if mm < 0:
                mm+=m2
            mm=mm%m2
            ans=1+findsteps(mm)
    else:
        mm = firstmod + mpow(2,i,m1)
        mm=mm%m1
        ans=1+findsteps(mm)
    fans[k] = ans
    k+=1
        ##the bit was not set
for i in fans:
    print(i)

Measured memory_bytes: 88044
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    swap(a, b);
  }
  string small = to_string(a);
  string ans = "";
  rep(i, b) {
    ans += small;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256