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 IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
const ll N = 100005; 
vll adj[N];
bool done[N];
ll dp[N][2];

void dfs(ll u){
    done[u] = 1;
    ll p1 = 1,p2 = 1;

    for(auto v : adj[u]){
        if(done[v]) continue;
        dfs(v);
        p1 = p1 * dp[v][0];
        p2 = p2 * ((dp[v][0] + dp[v][1])%md);
        p1 %= md;
        p2 %= md;
    }

    dp[u][0] = p2;
    dp[u][1] = p1;
}


int32_t main(){
    IOS;
    ll i,j,k,n,m,p,q;
    cin >> n;
    fori(n-1){
        cin >> p >> q;
        adj[p].pb(q);
        adj[q].pb(p);
    }
    dfs(1);
    cout << (dp[1][0] + dp[1][1] + md)%md <<"\n";
} 

Measured memory_bytes: 14336
#include<stdio.h>

int main(){
    char s1[1000],s2[1000],s3[1000];
    scanf("%s%s%s",s1,s2,s3);
    printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);


    return 0;
}


Measured memory_bytes: 128
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var t = o.a(1);
  var ans = "";
  for(var i = 0; i < n; i++)ans += s[i]+t[i];
  return ans;
}

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

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


int main(){
    
    long long S = 1;
    int n;

    cin >> n;
    vector<long long> A(n);
    

    rep(i,n){
        cin >> A.at(i);
    }

    rep(i,n){
        if(A.at(i)==0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){       
        if(A.at(i)<=1000000000000000000/S){
            S *= A.at(i);
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << S << endl;
 
}



Measured memory_bytes: 4056
#include <iostream>

using namespace std;

/*
 * great common divider
 */
int gcd(int x, int y){
    int tmp;
    
    if(y == 0) return x;
    
    if(x < y){
        tmp = y;
        y = x;
        x = tmp;
    }
    
    return gcd(y, x%y);
    
}

/*
 * lowest common multiplyer
 */
int lcm(int x, int y){
    if(x == 0 || y == 0) return 0;
    
    return x*y / gcd(x, y);
}

int main(){
    
    int n, ans = 1;
    int A[10];
    cin >> n;
    
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) ans = lcm(ans, A[i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<cstdio>

using namespace std;

char s[10];
int n,cnt[10];

int main()
{
//	freopen("in.in","r",stdin);
	
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s);
		switch(s[0])
		{
			case 'A':++cnt[1];break;
			case 'W':++cnt[2];break;
			case 'T':++cnt[3];break;
			case 'R':++cnt[4];break;
		}
	}
	
	printf("AC x %d\n",cnt[1]);
	printf("WA x %d\n",cnt[2]);
	printf("TLE x %d\n",cnt[3]);
	printf("RE x %d\n",cnt[4]);
	
	return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int a1 = scanner.nextInt();
        int a2 = scanner.nextInt();
        int a3 = scanner.nextInt();
        int d1 = Math.abs(a1 - a2);
        int d2 = Math.abs(a3 - a2);
        int d3 = Math.abs(a1 - a3);
        int[] d = new int[]{d1,d2,d3};
        Arrays.sort(d);
        System.out.println(d[0] + d[1]);
    }
}

Measured memory_bytes: 21844
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

const ll max_n = 2000;
const ll mod = 1e9 + 7;


ll extgcd(ll a, ll b, ll&x, ll&y)
{
  if (b == 0)
  {
    x = 1;
    y = 0;
    return a;
  }
  else
  {
    ll q = a / b;
    ll g = extgcd(b, a - q * b, x, y);
    ll z = x - q * y;
    x = y;
    y = z;
    return g;
  }
}

//modp逆元
ll inversemod(ll a, ll p)
{
  ll x, y;
  extgcd(a, p, x, y);
  x %= p;
  if (x < 0)
  {
    x += p;
  }
  return x;
}

ll power_ll_p(ll a, ll b, ll p)	//F_pでのべき
{
  if (b > p)
  {
    b %= (p - 1);//位数p-1
  }
  if (b == 0)
  {
    return 1;
  }
  if (b % 2 == 0)
  {
    ll t = power_ll_p(a, b / 2, p);
    return t * t % p;
  }
  else
  {
    return a * power_ll_p(a, b - 1, p) % p;
  }
}

ll combination_p(ll n, ll r, ll p)	//コンビネーション
{
  if (r > n - r)
  {
    r = n - r;
  }
  ll ans = 1;
  for (ll i = 0; i < r; i++)
  {
    ans *= n - i;
    ans %= p;
  }
  ll subans = 1;
  for (ll i = 0; i < r; i++)
  {
    subans *= i + 1;
    subans %= p;
  }
  ans *= power_ll_p(subans, p - 2, p);		//逆元は^(p-2)
  ans %= p;
  return ans;
}


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

  ll combi[max_n + 1];
  combi[0] = 1;
  for (int i = 0; i < max_n; i++)
  {
    combi[i + 1] = combi[i] * (n - k - i + 1);
    combi[i + 1] %= mod;
    combi[i + 1] *= inversemod(i + 1, mod);
    combi[i + 1] %= mod;
  }
  ll combi2[max_n + 1];
  combi2[0] = 1;
  for (int i = 0; i < max_n; i++)
  {
    combi2[i + 1] = combi2[i] * (k - i - 1);
    combi2[i + 1] %= mod;
    combi2[i + 1] *= inversemod(i + 1, mod);
    combi2[i + 1] %= mod;
  }
  for (int i = 1; i <= k; i++)
  {
    cout << (combi[i] * combi2[i - 1]) % mod << "\n";
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		final String EOT = "END_OF_TEXT";
		String w, t;
		int count = 0;
		
		w = sc.next();
		while(true){
			t = sc.next();
			
			if(t.equals(EOT)){
				break;
			}
			
			if(t.equalsIgnoreCase(w)){
				count ++;
			}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 26092
import io.StdIn._
 
object Main extends App {
  val Array(k, x) = readLine().split(" ").map(_.toInt)
 
  require(1 <= k && k <= 100)
  require(0 <= x && x <= 100)
  val excludeK = k - 1
  println((x - excludeK to x + excludeK).mkString(" "))
}

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

using namespace std;

int cnt;
long long n;

void check(long long x){
	bool flag_1, flag_2, flag_3;
	flag_1 = flag_2 = flag_3 = false;

	do{
		int temp = x % 10;
		if(temp == 3){
			flag_1 = true;
		}
		if(temp == 5){
			flag_2 = true;
		}
		if(temp == 7){
			flag_3 = true;
		}
		if(flag_1 && flag_2 && flag_3){
		
			cnt++;
			
			break;
		}
		x = x / 10;
	}while(x != 0);
}

void dfs(long long x){
	if(n < x) return;
	check(x);
	dfs(x * 10 + 3);
	dfs(x * 10 + 5);
	dfs(x * 10 + 7);
}

int main(){

	cin >> n;
	dfs(0);	

	cout << cnt << endl;
}

Measured memory_bytes: 256
import kotlin.math.floor

fun main(){
    val x = readLine()!!.split(" ").map { it.toLong() }[0]
    var a = 100.toDouble()
    for (i in 0 until 1000000000000){
        a *= 1.01
        if (a >= x){
            println(i+1)
            break
        }
        a = floor(a)
    }
}

Measured memory_bytes: 36492
w, h, n = map(int, input().split())
min_x, min_y = 0, 0
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        min_y = max(min_y, y)
    elif a == 4:
        h = min(h, y)

print( (w-min_x)*(h-min_y) if min_x < w and min_y < h else 0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  int x=7%K;
  set<int>st;
  for(int i=1;i<=K;i++){
   if(x==0){
    cout<<i<<endl;
     break;
   } 
   else if(st.count(x)){
    cout<<"-1"<<endl;
     break;
    }
   else{
    st.insert(x);
    x=(x*10+7)%K;
   }
  }
}

Measured memory_bytes: 50504
n,x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()

if sum(a)==x:
    print(n)
elif sum(a)<x:
    print(n-1)
else:
    total=0
    cnt=0
    for a_i in a:
        if total+a_i<=x:
            total+=a_i
            cnt+=1
        else:
            break
    print(cnt)


Measured memory_bytes: 9172
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  def del(a:Array[Array[Int]],i:Int,j:Int):Unit  = {
    if(i<0 || j < 0 || i > 11 || j > 11 || a(i)(j) == 0) return
    else {
      a(i)(j) = 0
      del(a,i,j+1);del(a,i,j-1);del(a,i+1,j);del(a,i-1,j)
    }
  }

  Iterator.continually(readLine).takeWhile( _ != null ).foreach { s=>
    val b = new ArrayBuffer[Array[Int]]

    if(s=="") b+= readLine.map(_.asDigit).toArray else b+= s.map(_.asDigit).toArray
    for( i<- 1 to 11)
      b += readLine.map(_.asDigit).toArray

    val a = b.toArray
    for(i <- 0 until 12;j<- 0 until 12)  {
      if(a(i)(j) == 1) {
        del(a,i,j)
        a(i)(j) = 1
      }
    }
    println(a.map{ _.count{_==1} }.sum)
  }
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    vector<char> abc = {'a','b','c'};
    auto all = all_of(abc.begin(), abc.end(), [S](char c){return std::count(S.begin(), S.end(), c)==1;});
    cout << (all ? YES : NO) << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b = input().strip().split()
a = int(a)
for _ in range(len(b)):
    a = a*10
ab = a+int(b)
for i in range(ab):
    if i * i == ab:
        print("Yes")
        break
    elif i * i < ab:
        continue
    else:
        print("No")
        break

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

int main()
{
    int n = 0;
    int tmp = 0;
    int max = 0, min = 1001;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        if (min >= tmp)
            min = tmp;
        if (max <= tmp)
            max = tmp;
    }
    cout << max - min << endl;

    return 0;
}

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

int main() {
  int N  ; 
  cin >> N ; 
  int cnt = 0 ; 
  
  
  for(int i = 1 ; i <= N ; i++){
    string S = to_string(i) ; 
    if( S.size() % 2 == 1 ){
      cnt++ ; 
    }
     
  }
  cout << cnt << endl ; 
}

Measured memory_bytes: 3736
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <unordered_set>
#include <cctype>
#include <cassert>


using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("angle2.in", "r", stdin);
	//freopen("angle2.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, W;
	cin >> n >> W;
	vector<ll>dp(W + 1);

	for (int i = 0; i < n; i++) {
		int x, c;
		cin >> x >> c;
		for (int j = W - x; j >= 0; j--) {
			dp[j + x] = max(dp[j + x], dp[j] + c);
		}
	}

	cout << *max_element(begin(dp), end(dp));
 	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>
int fun(long long int x)
{
    for(long long int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int x=sqrt(n);
    if(fun(n)==1)
    {
        printf("%lld",n-1);

    }
    else
    for(long long int i=x,j=x;;i++)
    {
        if(i*(long long int)(n/i)==n)
        {
            printf("%lld",i+(long long int)(n/i)-2);
            break;
        }
        if(j*(long long int)(n/j)==n)
        {
            printf("%lld",j+(long long int)(n/j)-2);
            break;
        }
        j--;
    }


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
unordered_map <long long ,long long> m;
long long wynik,a,s,n;
int main() {
    m[0]++;
cin>>n;
for(int i=0;n>i;i++)
{
    cin>>a;
    s+=a;
    wynik+=m[s];
    m[s]++;
}
cout<<wynik;

return 0;
}


Measured memory_bytes: 8520
import queue
k = int(input())

q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(k):
    x = q.get()
    if i == k-1:
        break
    else:
        if not x % 10 == 0:
            q.put(10*x + (x % 10) -1)
        q.put(10*x + (x % 10))
        if not x % 10 == 9:
            q.put(10*x + (x % 10) +1)

print(x)

Measured memory_bytes: 12452
M, K = map(int,input().split())

if K >= 2**M:
    print(-1)
    exit()
elif M == 0:
    print("0 0")
elif M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    A = [i for i in range(2**M) if i != K]
    B = A[::-1]

    for a in A: print(a, end = " ")
    print(K, end=" ")
    for b in B: print(b, end=" ")
    print(K)


Measured memory_bytes: 15224
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N,H,W;
  cin >> N >> H >> W;

  int ans = 0;
  for(int i = 0;i < N;i++) {
    int a,b;
    cin >> a >> b;
    if(a >= H && b >= W) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int h,w;
int n;

vector<pi> row[100005],col[100005];

lint rbase[100005],cbase[100005];

vector<pi> g[100005];

bool vis[100005];

lint wei[100005];
struct uf{
  static const int MAXN=100005;
  int par[MAXN];
  int size[MAXN];
  void init(){
    memset(par,-1,sizeof(par));
    REP(i,MAXN) size[i]=1;
  }
  int root(int a){
    if(par[a]==-1) return a;
    return par[a]=root(par[a]);
  }
  void unite(int a,int b){
    a=root(a);b=root(b);
    if(a==b) return;
    if(size[a]<size[b]) swap(a,b);

    par[b]=a;
    size[a]+=size[b];
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }
};


bool dfs(int v){
  vis[v]=1;
  for(auto e:g[v]){
    if(!vis[e.fr]){
      wei[e.fr]=wei[v]+e.sc;
      if(dfs(e.fr)) return true;
    }else if(wei[e.fr]!=wei[v]+e.sc) return true;
  }
  return false;
}
uf u;
lint con_min[100005];
bool ok(vector<pi> clue[100005],lint base[100005],int h,int w){
  //clue: h
  //base: w
  REP(i,w) g[i].clear();
  CLR(vis);
  u.init();
  REP(i,h){
    sort(ALL(clue[i]));
    for(int j=0;j<((int)clue[i].size())-1;++j){
      int d=clue[i][j+1].sc-clue[i][j].sc;
      int a=clue[i][j].fr,b=clue[i][j+1].fr;

      g[a].pb(mp(b,d));
      g[b].pb(mp(a,-d));
      u.unite(a,b);
    }
  }

  REP(i,w) if(!vis[i]){
    wei[i]=0;
    if(dfs(i)) return false;
  }

  CLR(con_min);
  REP(i,w){
    int r=u.root(i);
    chmin(con_min[r],wei[i]);
  }

  REP(i,w){
    int r=u.root(i);
    wei[i]-=con_min[r];

    base[i]=wei[i];
  }
  return true;
}

pair<pi,int> spec[100005];
int main(){
  cin>>h>>w>>n;
  REP(i,n){
    int r,c,a;scanf("%d%d%d",&r,&c,&a);
    --r;--c;
    row[r].pb(mp(c,a));
    col[c].pb(mp(r,a));

    spec[i]=mp(mp(r,c),a);
  }
  if(ok(row,cbase,h,w) && ok(col,rbase,w,h)){
    REP(i,n){
      int r=spec[i].fr.fr,c=spec[i].fr.sc;
      if(rbase[r]+cbase[c]>spec[i].sc){
        puts("No");
        return 0;
      }
    }
    puts("Yes");
  }else puts("No");
  return 0;
}




Measured memory_bytes: 19456
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())
    S = readline().strip()

    COM_MAX = 2 * 10 ** 6

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def mod_com(n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0
        return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

    N = len(S)
    L = K + N

    ans = 0
    p25 = pow(25, K, MOD)
    inv25 = pow(25, MOD - 2, MOD)
    p26 = 1
    for i in range(K + 1):
        ans = (ans + mod_com(L - i - 1, N - 1) * p25 * p26) % MOD
        p25 = p25 * inv25 % MOD
        p26 = p26 * 26 % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 117544
#include<iostream>
using namespace std;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
int H,h,m,s;
bool check(long H,long h,long m,long s)
{
    for(int r=-1;r<=1;r++)
    {
        long A=r*360*10*H+60*m*(H+1)+3600*h;
        long B=119*H-1;
        long d=gcd(A,B);
        A/=d;
        B/=d;
        if(!(A>=60*B||s*B>A)&&!(h==0&&m==0&&A==0))
        {
            cout<<h<<" "<<m<<" "<<A<<" "<<B<<endl;
            return true;
        }
    }
    return false;
}
main()
{
    while(cin>>H>>h>>m>>s,H)
    {
        while(!check(H,h,m,s))
        {
            s++;
            if(s==60)m++,s=0;
            if(m==60)h++,m=0;
            if(h==H)h=0;
        }
    }
}


Measured memory_bytes: 3096
from collections import Counter
S = list(input())
S.reverse()
MOD = 2019

t = [0]
r = 1
for i in range(len(S)):
    q = (t[-1] + (int(S[i]) * r) % MOD) % MOD
    t.append(q)
    r *= 10
    r %= MOD

cnt = Counter(t)
cnt_mc = cnt.most_common()

ans = 0
for _, j in cnt_mc:
    if j >= 2:
        ans += j * (j - 1) // 2
        
print(ans)

Measured memory_bytes: 18208
# AOJ 0527: Setting Go Stones
# Python3 2018.7.1 bal4u

while True:
	n = int(input())
	if n == 0: break
	a, c = [0]*100005, [0]*100005
	sz, a[0], c[0] = 0, 1, int(input())
	for i in range(n-1):
		color = int(input())
		if c[sz] == color: a[sz] += 1
		elif i & 1:
			sz += 1
			a[sz] = 1
		else:
			if sz == 0: a[sz] += 1
			else:
				a[sz-1] += a[sz]+1
				sz -= 1
		c[sz] = color;
	ans = 0
	for i in range(sz+1):
		if c[i] == 0: ans += a[i]
	print(ans)


Measured memory_bytes: 8616
fun main(args: Array<String>) {
    // 全体一括ソートは遅いはずだが，StringBuilder を使っている部分で実行速度が上がっている？？

    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    // 各県の初期ランクを定義
    var rank = IntArray(n + 1) { 1 }


    // 全ての市を year で一括並び替え
    val cities=(1..m).map {
        // map の中で複数の式を定義している
        val (p, y) = readLine()!!.split(" ").map { it.toInt() }

        // map の lambda式でのローカルリターンを定義（@map が付いていないと main でのリターンになってしまう)
        // Kotlinのラムダでreturnする : https://qiita.com/MasanoriMT/items/f5e814737479ff8d6fec
        // return が明示的に書かれているとわかりやすいが， return を書かなくても最後の式の評価結果が戻り値となる
        return@map Triple(it, p, y)
    }.sortedBy { it.third }

//    val sb=StringBuilder()
//
//    // 各市に県内で何番目かの情報を付与した後に，入力順にソート
//    cities.map {
//        // 同じ県内で何番目かの情報付与
//        Pair(it,rank[it.second]++)
//    }.sortedBy {
//        // データの入力順にソート
//        it.first.first
//    }.forEach {
//        // 出力文字列を StringBuilder に格納
//        sb.append(it.first.second.toString().padStart(6,'0'))
//        sb.append(it.second.toString().padStart(6,'0'))
//        sb.append("\n")
//    }
//
//    // まとめて出力
//    println(sb)

    // 仮にStringBuilder を使わなかった場合

    // 各市に県内で何番目かの情報を付与した後に，入力順にソート
    val ans = cities.map {
        // 同じ県内で何番目かの情報付与
        Pair(it,rank[it.second]++)
    }.sortedBy {
        // データの入力順にソート
        it.first.first
    }.map {
        // 出力文字列を StringBuilder に格納
        it.first.second.toString().padStart(6,'0') + it.second.toString().padStart(6,'0')
    }

    println(ans.joinToString("\n"))
}


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

using namespace std;

#define endl '\n'

typedef long long ll;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define _rep3(i,p,n) for(int i=(p),i##_counter=(n); i<i##_counter;++i)
#define _rep2(i,n,_) _rep3(i,0,n)
#define _rep_call(a, b, c, name, ...) name(a, b, c)
#define rep(...) _rep_call(__VA_ARGS__, _rep3, _rep2)

#define dump(x)  cerr << #x << " = " << (x) << '\n'
#define debug(x) cerr << #x << " = " << (x) << " (at line " << __LINE__ << ")" << " " << __FILE__ << '\n'

void Main() {
    int N, A; cin >> N >> A;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    ll d[N + 1][N + 1][N * A + 1];
    memset(d, 0, sizeof(d));
    rep(i, N + 1) d[i][0][0] = 1;
    rep(i, N) rep(j, 1, N + 1) rep(k, A * N + 1) {
        d[i + 1][j][k] = d[i][j][k];
        if (0 <= k - x[i]) {
            d[i + 1][j][k] += d[i][j - 1][k - x[i]];
        }
    }
    ll total = 0;
    rep(j, 1, N + 1) {
        total += d[N][j][j * A];
    }
    cout << total << endl;
}

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

Measured memory_bytes: 51072
// ABC178C.cpp :
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
#include <iostream>

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


using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


//const int mod = 1000000000 + 7;

ll pow_mod(ll n, ll k) {
    if (k == 0) {
        return 1; // 0乗は1
    }
    else if(k%2==1){ // 乗数が奇数
        return pow_mod(n, k - 1) * n % mod;
    }
    else { // 乗数が偶数
        ll t = pow_mod(n, k / 2);
        return t * t % mod;
    }
}
int main()
{
    ll n;
    cin >> n;

    ll n10 = pow_mod(10, n);
    ll n9 = pow_mod(9, n);
    ll n8 = pow_mod(8, n);
    mint ans = n10 - (n9 * 2) + n8;

    cout << ans << endl;
}


Measured memory_bytes: 3136
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (long long i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  ll N;
  cin >> N;
  ll ans = INF<ll>;
  FOR(i, 1, sqrt(N) + 1) {
    ll j = N / i;
    if (i * j == N) {
      chmin(ans, i + j);
    }
  }
  cout << ans - 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,A[100010];
double ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)ans+=1.0/A[i];
	ans=1.0/ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int D, N;

int main() {

	scanf("%d%d", &D, &N);

	if (N == 100) N++;
	printf("%d", N);
	rep(i, D) printf("00");
	printf("\n");

	return 0;
}


Measured memory_bytes: 768
N = int(input())

two_fives = []
mapping = [[0] * 19 for _ in range(19)]
ans = 0
for _ in range(N):
    s = input()
    if '.' in s:
        m, x = s.split('.')
        A = int(m) * 10 ** 9 + int(x.ljust(9, '0'))
    else:
        A = int(s) * 10 ** 9

    for two in range(19):
        if A % 2 == 0:
            A //= 2
        else:
            break
    for five in range(19):
        if A % 5 == 0:
            A //= 5
        else:
            break
        
    two_fives.append((two, five))
    mapping[18 - two][18 - five] += 1
    if two >= 9 and five >= 9:
        ans -= 1 # excluding ai * ai

for i in range(18):
    for j in range(19):
        mapping[i+1][j] += mapping[i][j]

for i in range(19):
    for j in range(18):
        mapping[i][j+1] += mapping[i][j]


for two, five in two_fives:
    ans += mapping[two][five]

#print(ans)
ans //= 2
print(ans)


Measured memory_bytes: 90600
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
A.sort()
fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % mod
rfact[N] = r = pow(fact[N], mod-2, mod)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % mod
def perm(n, k):
  return fact[n] * rfact[n-k] % mod
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod
ans = 0
#choice as max
for i in range(K-1,N):
    ans += comb(i,K-1)*A[i]%mod
#choice as min
for i in range(N-K+1):
    ans -= comb(N-i-1,K-1)*A[i]%mod
print(ans%mod)

Measured memory_bytes: 15184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int k, a, b;

int main() {
    cin.tie(0);ios::sync_with_stdio(0);
    cin >> k >> a >> b;
    bool ok = false;
  
    for (int i = a; i <= b; i++)
        if (i % k == 0)
            ok = true;
  
    if (ok)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long int
#define INF 1000000005
#define MOD 1000000007
#define FF first
#define SS second
#define int long long int

using namespace std;
typedef long long ll;

ll gcd(ll loc, ll b)
{
    if(loc == 0LL)
        return b;
    if(b == 0LL)
        return loc;
    return gcd(b, loc%b);
}

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll modx(ll Base, ll exponent)
{
  ll ans = 1;
  if(Base == 1)
    return Base;
  while(exponent)
  {
    if(exponent & 1)
      ans = (ans * Base)%MOD;
    Base = (Base * Base)%MOD;
    exponent = exponent >> 1;
  }
  return ans;
}

ll inmodx(ll num)
{
  return (modx(num, MOD-2LL));
}

bool cmp(pii loc, pii b)//true for loc before b
{
  if(loc.SS < b.SS)
    return 1;
  if(loc.SS > b.SS)
    return 0;
  if(loc.FF <= b.FF)
    return 1;
  return 0;
}

char grid[5001][5001];
int tmp[5001][5001];
signed main()
{   
    
  
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); 
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>m>>n;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>grid[i][j];
            if(grid[i][j]=='.')
                tmp[i][j]=0;
            else tmp[i][j]=-1;
        }
    }
    for(int i=1;i<=m;i++)
    {
        if(tmp[i][1]==0)
        {
            tmp[i][1]=1LL;

        }
        else break;
    }
    for(int i=2;i<=n;i++)
    {
        if(tmp[1][i]==0)
        {
            tmp[1][i]=1LL;
        }
        else break;
    }

    for(int i=2;i<=m;i++)
    {
        for(int j=2;j<=n;j++)
        {
            if(tmp[i][j]==-1)
            {
                continue;
            }
            if(tmp[i-1][j]>0)
            {
                tmp[i][j]=(tmp[i][j]+tmp[i-1][j]+MOD)%MOD;
            }
            if(tmp[i][j-1]>0)
            {
                tmp[i][j]=(tmp[i][j]+tmp[i][j-1]+MOD)%MOD;
            }

        }
    }
    cout<<tmp[m][n]<<endl;
    return 0;


   
}

    


Measured memory_bytes: 45952
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int N;
i64 a[50];

bool done() {
    for (int j = 0; j < N; ++j) {
        if (a[j] >= N) return false;
    }
    return true;
}

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> a[j];
    }

    i64 ans = 0;
    while (!done()) {
        int idx = 0;
        for (int j = 1; j < N; ++j) {
            if (a[j] > a[idx]) idx = j;
        }

        i64 inc = a[idx] / N;
        for (int j = 0; j < N; ++j) {
            a[j] += inc;
        }
        a[idx] = (a[idx] - inc) % N;

        ans += inc;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//Yazar: Mehmet Kutay Bozkurt
//Auther: Mehmet Kutay bozkurt
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long int lo;
#define pb push_back
#define st first
#define nd second
lo a,b,c,d,e,n,m,x,y,z,a1[100005],a2[100005],k,t;
char c1,c2,c3,c4;
string s1,s2,s3,s4,den[3];
bool av=false;
map <char,lo> mp;
vector <lo> v;
vector <lo> v1;
int main() {
    // freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
	cin>>n>>m;
    for(lo i=0;i<m;i++){
        cin>>a;
        x+=a;
    }
    if(n<=x){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(){
    ll N, M; cin >> N >> M ;
    ll res = 1;

    COMinit();
    for(auto itr : prime_factor(M)){
        ll tmp = COM(itr.second + N - 1, N - 1);
        res = (res * tmp) % MOD;
    }

    cout << res << endl;
}

Measured memory_bytes: 12160
#include<iostream>
using namespace std;
int main() {
    int n, a;
    cin >> n;
    int num[n];
    for (int i=0; i<n; i++) {
        cin >> a;
        num[n-i-1] = a;
    }
    for (int j=0; j<n; j++) {
        if (j == n-1) {
            cout << num[j] << endl;
        } else {
            cout << num[j] << " ";
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
         n%=10;
        if(n==2||n==4||n==5||n==7||n==9)cout<<"hon";
        else if(n==3)cout<<"bon";
        else cout<<"pon";
    }
    return 0;
}


Measured memory_bytes: 3640
require 'prime'

N = gets.to_i
a = []
a = gets.split.map(&:to_i)
a = a.sort
max = a.max
# a内での登場回数を数える配列
count = []
count = count.fill(0,1..max)
a.each do |num|
  count[num] += 1
end

hurui = []
hurui = hurui.fill(false, 1..max)

ans = 0
a.uniq.each do |num|
  # 2回以上登場するものは条件を満たさないのでふるいにかける
  # hurui[num] = true if count[num] >= 2
  # すでにふるいにかけた値が来たらcoutinue
  next if hurui[num]
  # ふるいにかけられていない中で，a内で1回だけ登場するならans+=1
  ans += 1 if count[num] == 1
  
  # numの倍数をふるいにかけていく
  (num*2).step(max, num) do |i|
    hurui[i] = true
  end
end

puts ans

Measured memory_bytes: 50788
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        printf("a > b\n");
        
    } else if(a<b){
        printf("a < b\n");
        
    } else {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<P> V(N);
    //マンハッタン距離の偶奇が一致しない場合 false

    rep(i,0,N){
        cin >> V[i].first >> V[i].second;
    }
    int dif = abs(V[0].first) + abs(V[0].second);
    rep(i,1,N){
        int d = abs(V[i].first) + abs(V[i].second);
        if(dif % 2 != d % 2){
            cout << -1 << endl;
            return 0;
        }
    }

    ll m = 33;
    vector<ll> dist(m);

    rep(i,0,m){
        dist[i] = 1LL << i;
    }    
    if(dif % 2 == 0){
        dist.insert(dist.begin(), 1);
    }
    //cout << dist.size() - m << endl;
    cout << m + (1-dif%2) << endl;
        
    rep(i,0,dist.size())cout << dist[i] << " ";cout << endl;

    rep(j,0,N){
        string ans;
        string sub;
        ll x = V[j].first, y = V[j].second;
        if(dif % 2 == 0){
            //cout << "even" << endl;
            y--;
            sub = "U";
        }
        
        for(int i = dist.size()-1;i >= (int)dist.size()-m;i--){
            bool a = (-x + y >= 0),b = (x + y >= 0);
            //cout << a << b << endl;
            if(a && b)  {
                //cout << "U" << endl;
                ans += "U";
                y -= dist[i];
            }
            if(a && !b) { 
                //cout << "L" << endl;
                ans += "L";
                x += dist[i];
            }
            if(!a && b) { 
                //cout << "R" << endl;
                ans += "R";
                x -= dist[i];
            }
            if(!a && !b){
                //cout << "D" << endl;
                ans += "D";
                y += dist[i];
            }
        }
        reverse(ans.begin(), ans.end());
        cout << sub + ans << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll h, w, k, dp[110][10];
int main() {
	dp[0][0] = 1;
	cin >> h >> w >> k;
	REP(i, h) {
		REP(j, 1 << (w - 1)) {
			bool ok = true;
			REP(k, w - 2)if (j & (1ll << k) and j & (1ll << (k + 1))) ok = false;
			if (ok) {
				REP(k, w - 1) {
					if (j & (1ll << k)) {
						dp[i + 1][k] += dp[i][k + 1];
						dp[i + 1][k + 1] += dp[i][k];
					}
				}
				REP(k, w) {
					if (!(j & (1ll << k) or j & (1ll << k - 1)))dp[i + 1][k] += dp[i][k];
				}
			}
		}
		REP(j, w)dp[i + 1][j] %= MOD;
	}
	cout << dp[h][k - 1] << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string S) {
  if (S.size()==3) {
    reverse(ALL(S));
  }
  cout << S << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] X = new int[M];

		for (int i = 0; i < M; i++) {
			X[i] = sc.nextInt();
		}

		Arrays.sort(X);

		Integer[] XX = new Integer[M];
		int prev = X[0];
		int now = 0;
		for (int i = 0; i < M; i++) {
			now = X[i];
			XX[i] = Math.abs(now - prev);
			prev = now;
		}

		Arrays.sort(XX, Collections.reverseOrder());

		int result = 0;
		for (int i = N - 1; i < XX.length; i++) {
			result += Math.abs(XX[i]);
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 51436
#include <bits/stdc++.h>
using namespace std;
//long long int i,j,k,n,m,a,b,c,d,p,q,r,l,t=1;
//long long int sum,counted,ans;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void sample()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
long long int* read(long long int n)
{
    long long int* arr=new long long int[n];

    for(int i=0;i<n;i++)
        cin>>arr[i];

    return arr;
}
long long int countDivisors(long long int n) 
{ 
    long long int cnt = 0; 
    for (long long int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 


void solve()
{
    long long int n,i,j,k,ans,m,o;

    cin>>n;

    //long long int ar[n];

    //long long int* ar=read(n);

    ans=0;

    for(i=1;i<n;i++)
    {
        ans+=(n/i);
        if(n%i==0)
            ans--;

    }

    cout<<ans;

    



    return;
}





int main()
{
    fast();
    sample();
    long long int i, j, k, n, m, a, b, c, d, p, q, r, l, t = 1;
    long long int sum, count = 0, ans = 0;

    //cin >> t;
    while (t--)
    {
        solve();

    }

    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ri register int
using namespace std;
int n,m,mod=1e9+7;
long long ans,f[305][305][305];
struct node{int l,r,x;}e[305];
inline int read()
{
	char ch=getchar();int x=0,f=1;while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();return x*f;
}
inline int cmp(node a,node b){return a.r<b.r;}
int main()
{
	n=read();m=read();for(ri i=1;i<=m;++i)e[i]=(node){read(),read(),read()};
	sort(e+1,e+1+m,cmp);f[0][0][0]=1;int c=1;
	for(ri i=0;i<=n;++i)
	{
		for(;e[c].r==i;++c)for(ri j=0;j<i;++j)for(ri k=0;k<max(1,j);++k)
		{
			if(e[c].x==1&&e[c].l<=j)f[i][j][k]=0;
			else if(e[c].x==2&&(e[c].l>j||e[c].l<=k))f[i][j][k]=0;
			else if(e[c].x==3&&e[c].l>k)f[i][j][k]=0;
		}if(i==n)break;
		for(ri j=0;j<max(1,i);++j)for(ri k=0;k<max(1,j);++k)if(f[i][j][k])
		{
			f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
			f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%mod;
			f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%mod;
		}
	}
	//for(ri i=0;i<=n;++i,cout<<endl)for(ri j=0;j<max(1,i);++j,cout<<endl)for(ri k=0;k<max(1,j);++k)
	//cout<<f[i][j][k]<<" ";
	//cout<<c<<endl;
	for(ri i=0;i<n;++i)for(ri j=0;j<max(1,i);++j)
	ans+=f[n][i][j],ans%=mod;printf("%lld",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
	int a,b,c,d; std::cin >> a >> b >> c >> d;
	while (a > 0) {
		c -= b;
		if (c <= 0) {
			std::cout << "Yes" << '\n';
			break;
		}
		a -= d;
		if (a <= 0) {
			std::cout << "No" << '\n';
			break;
		}

	}
	return 0;
}


Measured memory_bytes: 3592
n, k = map(int, input().split())
log = list(map(int, input().split()))

left = 0
right = 10**9

while right - left > 1:
  
  mid = (left + right) // 2
  
  cut = 0
  for i in range(n):
    cut += -(log[i]//-mid)-1

  if cut > k:
    left = mid
  else:
    right = mid
    
print(right)

Measured memory_bytes: 104008
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,m;
    long long int ans=1,x;

    scanf("%d %d",&n,&m);

    if(abs(n-m)>1){
        printf("0\n");
    }else{
        if(n==m){
            for(int i=1;i<=n;i++){
                ans*=i;
                ans%=1000000007;
            }
            for(int i=1;i<=m;i++){
                ans*=i;
                ans%=1000000007;
            }
            printf("%lld\n",(ans*2)%1000000007);
        }else{
            for(int i=1;i<=n;i++){
                ans*=i;
                ans%=1000000007;
            }
            for(int i=1;i<=m;i++){
                ans*=i;
                ans%=1000000007;
            }
            printf("%lld\n",ans%1000000007);
        }
        
        //ans+=x;
    }
   
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int n, in, min_d, max_d;

  cin >> n;   // n???
  cin >> in;  // ???????????????
  min_d = in; // ?????????
  max_d = INT_MIN; // ?????????

  for (int i = 1; i < n; ++i) {
    cin >> in;
    max_d = max(max_d, in - min_d);
    min_d = min(min_d, in);
  }

  cout << max_d << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

struct vec {
	int to;
	int cost;
};

int main()
{
	int n, m;
	cin >> n >> m;
	int tmpr, tmpl;
	int lmax = 0, rmin = MOD_P;

	for (int i = 0; i < m; i++) {
		cin >> tmpl >> tmpr;
		if (tmpl > lmax) {
			lmax = tmpl;
		}
		if (tmpr < rmin) {
			rmin = tmpr;
		}
	}

	if (rmin < lmax) {
		printf("0");
	} else {
		printf("%d", rmin - lmax + 1);
	}
	
	return 0;
}

Measured memory_bytes: 256