akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define upto(a, b, i) for(int i = (a),b_ =(b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a),b_ =(b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a),b_ =(b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a),b_ =(b); i > b_; --i)
#define times(n, i) uptil(0, (n), i)
#define rtimes(n, i) downto((n) - 1,0, i)
#define size(a) ((int)(a).size())
#define ln << endl
#define sp << " "

template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;

void solve() {
  int W,H,X,Y; cin >>W>>H>>X>>Y;
  cout << (W * H / 2.0) sp << (X*2 == W && Y*2 == H ? 1 : 0) ln;
  next_case:;
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
CD = [list(map(int,input().split())) for i in range(N)]

AB.sort()
CD.sort()

#print(AB)
#print(CD)

ans = 0

for i in range(N-1,-1,-1):
    ab = AB[i]
    li = []
    for cd in CD:
        if ab[0] < cd[0] and ab[1] < cd[1]:
            li.append(cd)
    li.sort(key=lambda x: x[1])
    if len(li) != 0:
        CD.remove(li[0])
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int dp[100010];

int		main(void)
{
	dp[0] = 0;
	for (int n = 1; n <= 100000; n++)
	{
		dp[n] = 1e9;
		int power = 1;
		while (power <= n)
		{
			dp[n] = min(dp[n], dp[n-power]+1);
			power *= 6;
		}
		power = 1;
		while (power <= n)
		{
			dp[n] = min(dp[n], dp[n-power]+1);
			power *= 9;
		}
	}
	int n;
	cin >> n;
	cout << dp[n] << endl;
}



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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

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

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<>
void sub(int& a,int b){
	a-=b;
	if(a<0)a+=mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

ll dp[334][334][334];

int main(){
	int n=read(),m=read();
	dp[0][1][1]=1;
	REP(i,m){
		REP(j,n+1){
			REP(k,n+1){
				add(dp[i+1][j+1][k],dp[i][j][k]*(n-j));
				add(dp[i+1][j][j],dp[i][j][k]*k);
				add(dp[i+1][j][k],dp[i][j][k]*(j-k));
			}
		}
	}
	cout<<dp[m][n][n]<<endl;
}


Measured memory_bytes: 237824
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a=0,b=0,x=0,c=0;
scanf("%lld%lld%lld",&a,&b,&x);
if(a>0){
	a-=1;
	c=(b/x)-(a/x);
} 
else{
	c=b/x;
	c++;
}
printf("%lld",c);
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}


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

	ll  d, n, r ,l ,k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) Yes(1);
	else Yes(0);
	return 0;

}


Measured memory_bytes: 256
import math
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 1

idx = A.index(1)
cnt = 1
right = idx
left = idx
while True:
  for i in range(1, K):
    right += 1
    if(right < len(A)):  
      A[right] = 1
    else:
      left -= 1
      if(0 <= left):
        A[left] = 1
      else:
        print(cnt)
        exit()
  if(left <= 0 and len(A)-1 <= right):
    print(cnt)
    exit()
  else:
    cnt += 1


Measured memory_bytes: 13812
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c,d;
   ll mod =1e9+7;
   string s1,s2;
   stack<ll>stck1;
   stack<ll>stck2;

   set<ll>st;
   map<string,ll>mp;
    cin>>n>>a;

    ll sum1=n*500;
    if(sum1>=a){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


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

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

    if ( d == 25 ) {
        cout << "Christmas" << endl;
    }
    else if ( d == 24 ) {
        cout << "Christmas Eve" << endl;
    }
    else if ( d == 23 ) {
        cout << "Christmas Eve Eve" << endl;
    }
    else if ( d == 22 ) {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(r <= x){
    if(x <= W-r){
      if(r <= y){
        if(y <= H-r){
          printf("Yes\n");
          exit(0);}}}}
  printf("No\n");
  return 0;}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {

  int n;
  cin >> n;
  vector<long long int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<long long int> b(n+1, 0);
  map<long long int, long long int> mp;
  mp[0]++;
  for(int i=1; i<=n; i++){
    b[i] = b[i-1] + a[i-1];
    mp[b[i]]++;
  }

  long long int cnt = 0;
  for(auto i=mp.begin(); i!= mp.end(); i++){
    long long int tmp = i->second;
    cnt += (tmp*(tmp-1))/2;
  }

  cout << cnt << endl;

  return 0;
}

//


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());

    if(N%2==1){
        cout << B[N/2]-A[N/2]+1 << endl;
    }else{
        cout << (B[N/2]+B[N/2-1]-(A[N/2]+A[N/2-1]))+1 << endl;
    }

}

Measured memory_bytes: 6428
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc126/tasks/abc126_b

s = input()
a = int(s[:2])
b = int(s[2:4])
if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    x=int(input())
    ans=[0,0]
    m=-500
    M=-m
    for i in range(m,M):
        for j in range(m,M):
            if j**5-i**5==x:
                ans=[j,i]
                break
    print(*ans)






if __name__ == "__main__":

    main()

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

#define int long long
const int _ = 1e5 + 7;
struct Edge{int end , upEd , w;}Ed[_ << 1];
int N , head[_] , sz[_] , minid , minval , ans , cntEd;

void addEd(int a , int b , int c){Ed[++cntEd] = (Edge){b , head[a] , c}; head[a] = cntEd;}

void dfs(int x , int p , bool flg){
	sz[x] = 1; int mx = 0;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(Ed[i].end != p){
			dfs(Ed[i].end , x , flg); mx = max(mx , sz[Ed[i].end]);
			sz[x] += sz[Ed[i].end]; if(flg) ans += sz[Ed[i].end] * Ed[i].w * 2;
		}
	mx = max(mx , N - sz[x]); if(minval > mx){minval = mx; minid = x;}
}

signed main(){
	cin >> N; minval = 1e9;
	for(int i = 1 ; i < N ; ++i){
		int a , b , c; cin >> a >> b >> c;
		addEd(a , b , c); addEd(b , a , c);
	}
	dfs(1 , 0 , 0); int t = minid; dfs(t , 0 , 1); bool sp = 0;
	for(int i = head[t] ; i ; i = Ed[i].upEd)
		if(sz[Ed[i].end] * 2 == N){sp = 1; ans -= Ed[i].w;}
	if(!sp){
		int mn = 1e9;
		for(int i = head[t] ; i ; i = Ed[i].upEd) mn = min(mn , Ed[i].w);
		ans -= mn;
	}
	cout << ans; return 0;
}

Measured memory_bytes: 13184
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

use std::collections::HashMap;
fn count<T>(v: T) -> HashMap<T::Item, u64>
where
    T: Iterator,
    T::Item: std::cmp::Eq + std::hash::Hash,
{
    let mut map = HashMap::new();
    for i in v {
        *map.entry(i).or_insert(0) += 1;
    }
    map
}

fn main() {
    let (_n, m) = input!(u64, u64);
    let a = input!(u64,);
    let mut cumsum: Vec<_> = vec![0];
    cumsum.extend(a.iter().scan(0, |state, &x| {
        *state = *state + x;
        Some(*state % m)
    }));
    let cnt = count(cumsum.iter());
    let ans = cnt.values().fold(0, |s, v| s + v * (v - 1) / 2);
    println!("{}", ans);
}


Measured memory_bytes: 14588
#include<stdio.h>
#include<stdlib.h>

int main(void){
  
  char S[4];
  scanf("%s", S);

  int top , under;           //topが上2二桁　underが下二桁
  under = atoi(S) % 100;
  top = atoi(S) / 100;


  int YYMM = 0;
  int MMYY = 0;
  if(0 < under && under < 13){
    YYMM = 1;
  }

  if(0 < top && top < 13){
    MMYY = 1;
  }



  if(YYMM == 1 && MMYY == 1){
    puts("AMBIGUOUS");
  }else if(YYMM == 1 && MMYY == 0){
    puts("YYMM");
  }else if(YYMM == 0 && MMYY == 1){
    puts("MMYY");
  }else{
    puts("NA");
  }


  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String X = sc.next();

   if(X.charAt(0)==X.charAt(1)&&X.charAt(1)==X.charAt(2)||X.charAt(1)==X.charAt(2)&&X.charAt(2)==X.charAt(3)) System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 20944
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char a[102][103],buf[101];
	int i,j,h,w;
	scanf("%d %d",&h,&w);
	for(i=0;i<=h+1;i++)	{
		for(j=0;j<=w+1;j++)	{
			a[i][j]='#';
		}
		a[i][w+2]='\0';
	}
	for(i=0;i<h;i++)	{
		scanf("%s",buf);
		for(j=0;j<w;j++)	{
			a[i+1][j+1]=buf[j];
		}
	}
	for(i=0;i<=h+1;i++)	printf("%s\n",a[i]);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i=0; i<N;i++){
    cin >> vec.at(i);
  }
  
  int count;
  
  
  int M;
  cin >> M;
  
  
  
  
  for(int j=0; j<M; j++){
    
    count=0;
     for(int i=0; i<N; i++){
    count+=vec.at(i);
  }
  
   
    
    int P,X;
    cin >> P>> X;
    
    count -= vec.at(P-1);
    count += X;
    cout << count<< endl;
  }
    
    
}

Measured memory_bytes: 3572
#include <iostream> 

using namespace std; 

int main()
{
  int N;
  cin >> N; 
  
  // Factors are less than the number
  // so if a number has 8 factors it's greater than or equal to 8
  // only testing for odd numbers 
  int total = 0;
  for (int i = 9; i < N + 1; i+= 2)
  {
    int count = 0; 
    for (int j = 1; j * j < i + 1; j++) 
    {
      if (i % j == 0) 
      {
        if (j * j == i) count++;
        else count += 2;
      }
    }
    if (count == 8) 
      total++;
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int i, j, num;
	int N, M, K;

	cin >> N >> M;

	int *a = new int[M];
	for (i = 0; i < M; i++) {
		a[i] = 0;
	}
	for (i = 0; i < N; i++) {
		cin >> K;
		for (j = 0; j < K; j++) {
			cin >> num;
			a[num - 1]++;
		}
	}
	num = 0;
	for (i = 0; i < M; i++) {
		if (a[i] == N) num++;
	}

	cout << num << endl;

	delete[] a;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder {
  class Program {
    static void Main()
    {
      string[] buf = Console.ReadLine().Split();
      int a = int.Parse(buf[0])%2;
      int b = int.Parse(buf[1])%2;
      if(a*b==1){
        Console.WriteLine("Odd");
      } else {
        Console.WriteLine("Even");
      }
    }
  }
}


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


int main() {

	int q;
	cin >> q;
	
	map<string, long long> mp;
	for(int i = 0; i < q; ++i){
		int order;
		string key;
		cin >> order >> key;
		
		if(order == 0){
			int num;
			cin >> num;
			mp[key] = num;
		}else if(order == 1){
			cout << (mp[key] != 0 ? mp[key] : 0) << endl;
		}else{
			mp[key] = 0;
		}
	}

	return 0;
}


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

int main() {
  int n, t;
  cin >> n >> t;
  int ti[n];
  for (int i = 0; i < n; i++) cin >> ti[i];
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int diff = ti[i] - ti[i-1];
    ans += diff < t ? diff : t;
  }
  cout << ans + t << endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	l := len(a)
	for i := 0; i < l; i++ {
		if a[i] != b[l-1-i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


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

    if(a == b && b == c && a%2 == 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    while(a%2 == 0 && b%2 == 0 && c%2 == 0){
        ll A = a, B = b, C = c;
        a = B/2 + C/2;
        b = C/2 + A/2;
        c = A/2 + B/2;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

const int mod=1000000007;
struct mint{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const{return mint(-x);}
  mint& operator+=(const mint a){
    if((x+=a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x+=mod-a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=mod;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a=pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  // for prime mod
  mint inv() const{
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return (*this)*=a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

map<ll,ll> pfmp; //各素因数の指数を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
  ll n=N;
  if(n<=1) return;
  ll exp;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    exp=0;
    while(n%2==0){
      n/=2;
      exp++;
    }
    if(exp>pfmp[2]) pfmp[2]=exp;
  }
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      exp=0;
      while(n%i==0){
        n/=i;
        exp++;
      }
      if(exp>pfmp[i]) pfmp[i]=exp;
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
  } 
}

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    PF(a[i]);
  }
  mint LCM=1;
  rep(i,pfv.size()){
    rep(j,pfmp[pfv[i]]){
      LCM*=pfv[i];
    }
  }
  mint ans=0;
  rep(i,N){
    ans+=LCM/a[i];
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"

using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	if (abs(X - A) < abs(X - B)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	string S,T;
	cin>>S>>T;
	int ans=0;
	REP(i,S.size()){
		if(S[i]!=T[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3856
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            
            int a,b,c;
            for(int i = n ; i < 1000 ; i++)
            {
                a = i%10;
                b = (i/10)%10;
                c = (i/100)%10;
                if(a==b && b==c)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1<<17];
int n;
main()
{
	for(int i=1;i<1<<17;i++)dp[i]=1e9;cin>>n;
	for(int i=0;i<n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for(int r=6;i+r<=n;r*=6)dp[i+r]=min(dp[i+r],dp[i]+1);
		for(int r=9;i+r<=n;r*=9)dp[i+r]=min(dp[i+r],dp[i]+1);
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a,b,m,x,y,c,i;
    cin >> a >> b >> m;
    ll r[a],w[b],minPrice=INT_MAX;
    for(i=0;i<a;i++) cin >> r[i];
    for(i=0;i<b;i++) cin >> w[i];
    while(m--) {
    	cin >> x >> y >> c;
    	minPrice = min(minPrice, r[x-1]+w[y-1]-c);
    }
    sort(r,r+a);
    sort(w,w+b);
    minPrice = min(r[0]+w[0], minPrice);
    cout << minPrice;
    cout << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll x;
  cin >> x;
  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int N, a[200009];
const int Konst = 40;
int sir[Konst + 10];

bool ok (int sigma)
{
    if (sigma == 1)
    {
        for (int i=1; i<N; i++)
            if (a[i + 1] <= a[i])
                return 0;
        return 1;
    }
    memset (sir, 0, sizeof (sir));
    for (int i=2; i<=N; i++)
    {
        if (a[i] <= a[i - 1])
        {
            int pos = a[i];
            if (pos <= Konst)
            {
                while (sir[pos] == sigma - 1 && pos > 0)
                    sir[pos] = 0, pos --;
                if (pos == 0) return 0;
                sir[pos] ++;
            }
        }
        else
        {
            for (int j=a[i - 1] + 1; j<=Konst; j++)
                sir[j] = 0;
        }
    }
    return 1;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
int p = 1, u = N, mij, ras = 0;
while (p <= u)
{
    mij = (p + u) >> 1;
    if (ok (mij)) ras = mij, u = mij - 1;
    else p = mij + 1;
}
printf ("%d\n", ras);
return 0;
}


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

int ANS[5];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        ANS[i] = -1;
    }
    bool ans = true;
    for(int j = 0; j < m; j++){
        int s, c;
        cin >> s >> c;
        if (s == 1 && c == 0 && n != 1){
            ans = false;
            break;
        }
        if (ANS[s] >= 0 && c != ANS[s]){
            ans = false;
            break;
        }
        ANS[s] = c;
    }
    if (n > 1 && ANS[1] == -1) ANS[1] = 1;
    if (n == 1 && ANS[1] == -1) ANS[1] = 0;
    for(int i = 2; i <= n; i++){
        if (ANS[i] == -1) ANS[i] = 0;
    }
    int D = 1;
    int tot = 0;
    for(int i = n; i > 0; i--){
        tot += ANS[i] * D;
        D *= 10;
    }
    if (ans) cout << tot << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n;

void rec(Array& v, int sum) {
	if (sum > n) return;
	
	int len = size_of(v);
	
	if (sum == n) {
		for_(i,0,len) {
			if (i < len - 1) cout << v[i] << " ";
			else cout << v[i] << endl;
		}
	}

	for_rev(i,n,1) {
		if (len > 0 && v[len - 1] < i) continue;
		v.push_back(i);
		rec(v, sum + i);
		v.pop_back();
	}
}

void solve() {
	Array v;
	rec(v, 0);
}

int main() {
	while (cin >> n, n) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1220
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
t = 0
sa = a.map { t += _1 }
t = 0
sb = b.map { t += _1 }
a_over = sa.bsearch_index { _1 > k }
amax_idx = a_over ? a_over - 1 : n - 1
max = amax_idx + 1
rest = k - sa[amax_idx]
amax_idx.downto(-1) do |ai|
  if ai == -1
    d = sa[amax_idx]
  else
    d = sa[amax_idx] - sa[ai]
  end
  b_over = sb.bsearch_index { _1 > rest + d }
  bidx = b_over ? b_over - 1 : m - 1
  max = [max, ai + 1 + bidx + 1].max
end
puts max

Measured memory_bytes: 45044
N = int(input())
Alist = list(int(x) for x in input().split())

nball = [0] * (N+1)
for i in range(N):
    nball[Alist[i]]+=1

sum=0
for i in range(N):
    sum+=nball[i+1]*(nball[i+1]-1)/2
    
for i in range(N):
    if(nball[Alist[i]] > 2):
        print(int(sum-( ((nball[Alist[i]]-1)*2) /2 )))
    elif(nball[Alist[i]] == 2):
        print(int(sum-1))
    else:
        print(int(sum))

Measured memory_bytes: 26140
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    char alpha[52];
    rep(i,26){alpha[i]=char('a'+i);}
    for(int i=26;i<52;i++){alpha[i]=char('A'+(i-26));}


    int n;
    while(true){
        cin>>n;
        string ans;
        if(n==0)break;
        vector<int> v(n);
        string s;
        rep(i,n)cin>>v[i];
        cin>>s;
        int key=0;
        rep(i,s.size()){
            if(key==n)key=0;
            char x=s[i];
            int ind=0;
            while(true){
                if(x==alpha[ind])break;
                ind++;
            }

            for(int j=0;j<v[key];j++){
                ind--;
                if(ind<0)ind=51;
            }
            ans+=alpha[ind];
            key++;
        }
        cout<<ans<<endl;





    }
    return 0;
}



Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        String S;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            S = sc.next();

        }
        if(N%2 != 0){
            System.out.println("No");
            return;
        }
        char[] c = S.toCharArray();

        for(int i = 0; i < N/2; i++){
            if(c[i] != c[i+N/2]){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/


signed main(){
	ll n,k;
	cin >> n >> k;
	ll h[n] = {};
	ll dp[n] = {};
	
	rep(i,0,n){
		cin >> h[i];
		dp[i] = INF;
	}
	
	dp[0] = 0;
	
	rep(i,0,n){
		rep(j,1,k+1){
			if(i+j >= n) break;
			
		dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
		}
	}
	
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void){
    int N;
    cin >> N; cin.ignore();
    string S1, S2;
    cin >> S1; cin.ignore();
    cin >> S2; cin.ignore();
    
    vector<int> d_type;
    for (int i = 0; i < N; i++) {
        if (S1[i] == S2[i]) {
            d_type.push_back(1);
        } else {
            d_type.push_back(2);
            i++;
        }
    }
    
    long long ans;
    int pre_type = 0;
    for (int type: d_type) {
        if (pre_type == 1) {
            ans *= 2;
        } else if (pre_type == 2) {
            ans *= (type == 1) ? 1 : 3;
        } else {
            ans = (type == 1) ? 3 : 6;
        }
        pre_type = type;
    }
    
    cout << ans % 1000000007 << endl;
} 


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

using namespace std;

const int N = 100005;
char s[N],t[N];
int ps[N],pt[N];

int main(){
    scanf("%s%s",s+1,t+1);
    int n = strlen(s+1),m=strlen(t+1);
    for(int i = 1; i<=n; i++)
        ps[i] = ps[i-1]+1+(s[i]=='B');
    for(int i = 1; i<=m; i++)
        pt[i] = pt[i-1]+1+(t[i]=='B');
    int q;
    scanf("%d",&q);
    while(q--){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int ns = ps[b]-ps[a-1];
        int nt = pt[d]-pt[c-1];
        if(ns%3==nt%3)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	while(1) {
		int n, m, a;
		cin>>n>>m>>a;
		if(n == 0 && m == 0 && a == 0) break;
		vector<pair<ll, P> > l(m);
		REP(i, m) cin>>l[i].first>>l[i].second.first>>l[i].second.second;
		sort(ALL(l), greater<pair<ll, P> >());
		REP(i, m) {
			if(l[i].second.first == a) a = l[i].second.second;
			else if(l[i].second.second == a) a = l[i].second.first;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
using namespace std;
	
const int maxn = 200000+5;

int n;
int a[maxn];
long long ans = 0;

void Merge(int left,int right,int mid){
	int Q[maxn],cnt = 0;
	int i,j;
	for(i = left,j = mid+1;i <= mid && j <= right;){
		if(a[i] <= a[j])Q[++cnt] = a[i],i++;
		else Q[++cnt] = a[j],j++,ans+=mid-i+1;
	}
	while(i <= mid)Q[++cnt] = a[i++];
	while(j <= right)Q[++cnt] = a[j++];
	for(int i = left,j = 1;i <= right;)a[i++] = Q[j++];
}

void Merge_Sort(int left,int right){
	int mid = (left+right)>>1;
	if(left >= right)return;
	Merge_Sort(left,mid);
	Merge_Sort(mid+1,right);
	Merge(left,right,mid);
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n; i++)scanf("%d",&a[i]);
	Merge_Sort(1,n);
	printf("%lld\n",ans);
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	ll n, k;
	cin >> n >> k;
	char s[100000];
	cin >> s;
	vll r(n);
	ll flag = -1, rs = -1;
	if (s[0] == '0') {
		rs = 0; r[0] = 0;
	}
	for (int i = 0; i < n; i++) {
		if (flag != s[i]) {
			flag = s[i];
			rs++;
			r[rs]++;
		}
		else{
			r[rs]++;
		}
	}
	if (s[n - 1] == '0') {
		rs++;r[rs] = 0;
	}
	ll sum = 0, ans = 0;
	for (int i = 0; i <= k * 2 && i <= rs; i++)
		sum += r[i];
	ans = sum;
	for (int i = k * 2 + 1; i <= rs - 1; i += 2) {
		sum += r[i] + r[i + 1];
		sum -= r[i - (k * 2)] + r[i - (k * 2 + 1)];
		ans = max(ans, sum);
	}
	cout << ans;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

LL mypow(LL x,LL n){
    LL ans = 1;
    while(n > 0){
        if(n&1){
            ans = (ans*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ans;
}

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

    LL n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;

    vector<vector<LL>> dp(n+1,vector<LL>(n+1,0));
    dp[a-1][0] = 1;

    vector<LL> kaizyo(n+1,1);
    vector<LL> inverse(n+1,1);
    for(LL i = 1; i < n+1; i++){
        kaizyo[i] = (kaizyo[i-1]*i)%MOD;
        inverse[i] = mypow(kaizyo[i],MOD-2);
    }
    
    vector<vector<LL>> di(n+1,vector<LL>(n+1));
    for(LL i = 0; i < n+1; i++){
        for(LL j = 0; j < n+1; j++){
            di[i][j] = mypow((mypow(kaizyo[i],j)*kaizyo[j])%MOD,MOD-2);
        }
    }

    for(LL i = a; i <= b; i++){
        for(LL j = 0; j < n+1; j++){
            dp[i][j] = dp[i-1][j];
            for(LL k = c; k <= d && j-k*i >= 0; k++){
                dp[i][j] += (((((dp[i-1][j-k*i]*kaizyo[n-j+k*i])%MOD)*inverse[n-j])%MOD)*di[i][k])%MOD;
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[b][n] << endl;
    
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 200100;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = power(fact[b], mod-2);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();
	ll n, k;
	cin >> n >> k;
	for( int i = 1; i <= k; ++i ){
		cout << comb(k-1, i-1) * comb(n-k+1, i) % mod << endl;
	}
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;

}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a,int b){
    return a<b ? a:b;
}

int main(){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head != tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t > 0){
            enqueue(u);
        }
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}









Measured memory_bytes: 11856
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
    int n,m,cnt=0; cin>>n>>m;
    int c[20],t[50001];
    for(int i=0;i<m;++i) cin>>c[i];
    sort(c,c+m);
    t[0]=0;
    for(int j=1;j<=n;++j) t[j]=100000;
    for(int i=0;i<m;++i)
	for(int j=0;j+c[i]<=n;++j) t[j+c[i]]=min(t[j+c[i]],t[j]+1);
    cout<<t[n]<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(c>b&&a+b>=c)
	{
		cout<<"safe"<<endl;
	}
	else if(c<=b)
	{
		cout<<"delicious"<<endl;
	}
	else
	{
		cout<<"dangerous"<<endl;
	}
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
L = [0]*n
R = [0]*n
for i in range(n-1):
    R [i+1] = gcd(R[i], A[i])
    L[i+1] = gcd(L[i], A[-i-1])
print(max(gcd(R[i], L[-i-1]) for i in range(n)))

Measured memory_bytes: 14080
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	
    	double x1 = sc.nextDouble(), y1 = sc.nextDouble(),
    		   x2 = sc.nextDouble(), y2 = sc.nextDouble();
    	
    	double a = x2 - x1;
    	double b = y2 - y1;
    	
    	double c = a * a + b * b;
    	c = Math.sqrt(c);
    	
    	System.out.println(c);
    }
}

Measured memory_bytes: 27932
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll total=0;
    for(ll i=0;i<n;i++)
    {
        total+=a[i];
    }
    sort(a.rbegin(),a.rend());
    ll num=0;
    ll min_reqd=ceil(total/(lf)(4*m));
    for(ll i=0;i<n;i++)
    {
        if(a[i]>=min_reqd)
            num++;
    }
    if(num>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
} 


Measured memory_bytes: 384
#include<stdio.h>
#define CLASSNUMBER 39
int main(void) {
	int a;

	while (scanf("%d", &a)!=EOF) {
		if (a%CLASSNUMBER == 0)
			printf("3C%2d\n", CLASSNUMBER);
		else
			printf("3C%02d\n",a%CLASSNUMBER);
	}
	return 0;
}

Measured memory_bytes: 608
S = input()
N = len(S)

X = [0] * N

k = 0
for i in range(N - 1):
    if S[i + 1] == "L":
        if S[i] == "R":
            k = i + 1
        X[i + 1] = k

k = 0
for i in range(N - 1, -1, -1):
    if S[i] == "R":
        if S[i + 1] == "L":
            k = i + 1
        X[i] = k

result = [0] * N
for i in range(N):
    if (X[i] - i) % 2 == 0:
        result[X[i]] += 1
    else:
        result[X[i] - 1] += 1

print(*result)



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

using namespace std;

int main(){
    int X,A,B;
    cin>>X>>A>>B;

    if(-A+B<=0){
        cout << "delicious" << endl;
    } 
    else if(-A+B<=X){
        cout << "safe" << endl;
    }
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    int n, ans = 0;

    cin >> n;

    n++;

    int a[n], b[n];

    a[0] = 0, b[0] = 0;

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

        cin >> a[i];
        a[i] += a[i-1];
    }

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

        cin >> b[i];
        b[i] += b[i-1];
    }

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

        int tmp = a[i]+(b[n-1]-b[i-1]);
        ans = max(ans, tmp);
    }

    cout << ans;

    return 0;
}


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

const int lim = 2000006;

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

    int n,k;
    cin>>n>>k;
    int cnt0 = 0,cntk2 = 0;
    for(int i=1;i<=n;++i)
    {
    	if(i%k==0)
    		cnt0++;
    	if(k%2==0 && i%k==k/2)
    		cntk2++;
    }
    cout<<1LL*cnt0*cnt0*cnt0 + 1LL*cntk2*cntk2*cntk2;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string s;
	cin>>s;
	if(s.length()==2)cout<<s<<endl;
	else cout<<s[2]<<s[1]<<s[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    REP(x, L, R + 1) {
        if (x % d == 0) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

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

long long INF = 1e18;
int main(){
    long long H, N;
    cin >> H >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<long long> dp(H + 1, INF);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < H; j++){
            if(j + A[i] > H) dp[H] = min(dp[H], dp[j] + B[i]);
            else dp[j + A[i]] = min(dp[j] + B[i], dp[j + A[i]]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384