akhauriyash/Code-Regression huggingface dataset:
import sys
a=0
b=0
c=0
x=3


v,y,z =[int(x) for x in input().split(" ")]

a = v+y
b = y+z
c = z+v

if a<b and a<c:
	print (a)

if b<c and b<a:
	print (b)

if c<b and c<a:
	print (c)

if a == b and b == c:
	print (a)

if a == b and b<c:
	print (a)

if a ==c and a<b:
	print (a)

if c==b and b<a:
	print (c)

Measured memory_bytes: 3064
#!/usr/bin/ruby
# encoding: utf-8

# ABC 110 D  Factorization

require "prime"

def calcComb a,b
  if b > a-b 
    return calcComb(a,a-b)
  end

  ansMul = 1 
  ansDiv = 1
  
  i = 0
  while i < b
    ansMul *= (a-i)
    ansDiv *= (i+1)
    i += 1
  end
  return ansMul/ansDiv
end

# main
N,M = gets.split.map(&:to_i)
C = 1000000007
factors = M.prime_division
ans = 1
j = 0

while j < factors.size
 ans *= calcComb factors[j][1]+N-1,factors[j][1]
 j += 1
end

p ans %= C


Measured memory_bytes: 3964
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
map<long long,int>num;
long long ans,sum;
int n;
int main()
{
	num[0]=1;
	scanf("%d",&n);
	for (int x,i=1;i<=n;i++)
	{
		scanf("%d",&x);
		sum+=x;
		ans+=num[sum]; 
		num[sum]++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 12800
# B
s = input()
a = int(s[:2])
b = int(s[2:])

def f(x):
        if x >= 13 or x == 0:
                return False
        else:
                return True

if f(a) and f(b):
        print('AMBIGUOUS')
elif not f(a) and not f(b):
        print('NA')
elif f(a):
        print('MMYY')
else:
        print('YYMM')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,d,data[12][12];
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>data[i][j];
        }
    }
    int cnt=0,tmp=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            tmp=0;
            for(int k=0;k<d;k++){
                tmp+=(abs(data[i][k]-data[j][k])*abs(data[i][k]-data[j][k]));
            }
            if(ceil(sqrt(tmp))==floor(sqrt(tmp))) cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()[::-1]
n = len(s)
counts = [0] * 2019
counts[0] = 1
current = 0
d = 1

for c in s:
    current += int(c) * d
    d *= 10
    current %= 2019
    d %= 2019
    counts[current] += 1

ans = 0
for count in counts:
    if count > 1:
        # print(i)
        ans += count * (count-1) //2
print(ans)


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

int main(){
  string S;
  long long int ans;
  cin>>S;
  vector<long long int> A(S.size()+1,-1);
if(S.size()>1){
    for(long long int i = 0;i<S.size()-1;i++){
        if(i==0&&S.at(i)=='<'){A.at(i)=0;}
        else if(S.at(i)=='>'&&S.at(i+1)=='<'){
          A.at(i+1)=0;
          if(i+1==S.size()-1)A.at(S.size())=1;
      }
    }

  for(long long int i = 1;i<S.size();i++){
    if(S.at(i-1)=='<'){
      A.at(i)=A.at(i-1)+1;
    }
  }
  if(S.at(S.size()-1)=='>'){
    A.at(S.size())=0;
    if(S.at(S.size()-2)=='>')A.at(S.size()-1)=1;
  }

  for(long long int i = S.size()-2;i>-1;i--){
    if(S.at(i)=='>'){
      if(A.at(i)<A.at(i+1)+1) A.at(i)=A.at(i+1)+1;
    }
  }

  if(A.at(S.size())==-1){
    if(S.at(S.size()-1)=='<')A.at(S.size())=A.at(S.size()-1)+1;
  }
}else{
  A.at(0)=1;
  A.at(1)=0;
}

  ans = 0;
  for(long long int i = 0;i< A.size();i++){
    ans+=A.at(i);
  }

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


Measured memory_bytes: 4740
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;


int main(){

  int n;
  cin >> n;
  int * x = new int[n];
  
  for(int i=0;i<n;i++){
    cin >> x[i];
  }

  int c=0;
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=i+1;j--){
      if(x[j] < x[j-1]){
        int tmp = x[j];
        x[j] = x[j-1];
        x[j-1] = tmp;
        c++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << x[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }
  cout << c << endl;


}



Measured memory_bytes: 3100
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, k);
    cout << n - k + 1 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int n, K;
    cin >> n >> K;
    int v[n];
    rep(i, n) cin >> v[i];
    int mx = min(n, K);
    int ans = 0;
    for (int i = 0; i <= mx; i++){
        for (int j = 0; j <= i; j++){
            vec v_s;
            for (int k = 0; k < j; k++){
                v_s.push_back(v[k]);
            }
            for (int k = n - 1; k > (n - 1) - (i - j); k--){
                v_s.push_back(v[k]);
            }
            sort(v_s.begin(), v_s.end());
            // for (int k = 0; k < v_s.size(); k++){
            //     cout << v_s[k] << " ";
            // }cout << endl;
            
            int sm = 0;
            rep(k, v_s.size()){
                if(k < K - i && v_s[k] < 0) continue;
                sm += v_s[k];
            }
            // cout << sm << endl;
            ans = max(sm, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int a[200010],n,k;
bool check(int x)
{
	int p=0;
	if(x==0)return false;
	for(int i=1;i<=n;i++)
	{
		p+=a[i]/x;
		if(a[i]%x==0)p--;
		if(k<p)return false;
	}
	return true;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	int l=1,r=1e9,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)){ ans=mid;r=mid-1;}
		   else l=mid+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;

    cin >> N;
    int need = 0;
    
    if(N % 2 == 0){
        need = N / 2;
    }

    else{
        need = N / 2 + 1;
    }
    cout << need << endl;

    return 0;
}

Measured memory_bytes: 256
const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[0].split(' ')[0])
  const K = parseInt(tmp[0].split(' ')[1])

  const sunuke = {}

  for (let i = 1; i <= N; ++i) {
    sunuke[i] = ''
  }

  for (let j = 1; j <= K; j++) {
    const sweets = (j * 2 - 1).toString()
    const sunukeNum = tmp[j * 2].split(' ').map(n => n.toString())
    sunukeNum.forEach(elem => {
      sunuke[elem] += sweets
    })
  }

  let result = 0

  for (let i = 1; i <= N; ++i) {
    if (sunuke[i].length === 0) {
      result += 1
    }
  }

  console.log(result)
  return result
}

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

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    n = sqrt(n);
    cout << n*n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)if(a[i]!=i+1)k++;
  cout << ((k<=2)?"YES":"NO") << endl;
}
  

Measured memory_bytes: 3604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string S;
  cin>>S;
  if(S=="ABC"){
    cout<<"ARC"<<endl;
  }
  else{
cout<<"ABC"<<endl;
  }
}

Measured memory_bytes: 3628
// C++ program to Find Number of digits 
// in base b. 
#include <iostream> 
#include <math.h> 
using namespace std; 

// function to print number of 
// digits 
void findNumberOfDigits(long n, int base) 
{ 
	// Calculating log using base 
	// changing property and then 
	// taking it floor and then 
	// adding 1. 
	int dig = (int)(floor( log(n) / 
						log(base)) + 1); 
	
	// printing output 
	cout <<dig<<endl; 
} 

// Driver method 
int main() 
{ 
	// taking inputs 
	long n ;
	int base ;
	cin>>n>>base;
	
	// calling the method 
	findNumberOfDigits(n, base); 
	return 0; 
} 

// This code is contributed by Manish Shaw 
// (manishshaw1) 
   

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

#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                      \
  cout << #v << ":";                                      \
  for (int i = 0; i < v.size(); i++) cout << " " << v[i]; \
  cout << endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >
#define vll vector<vector<ll> >
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
  ll i,j;
  pair<ll,ll> zahyou1,zahyou2;
  cin>>zahyou1.first>>zahyou1.second>>zahyou2.first>>zahyou2.second;
  ll n;
  cin>>n;
  vector< pair<ll,ll> > zahyou;
  for(i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    if(((zahyou1.first<=x && x<=zahyou2.first) || (zahyou2.first<=x && x<=zahyou1.first)) && ((zahyou1.second<=y && y<=zahyou2.second) || (zahyou2.second<=y && y<=zahyou1.second)))
      zahyou.push_back(make_pair(x,y));
  }
  n = zahyou.size();
  for(i=0;i<n;i++){
    zahyou[i].first -= zahyou1.first;
    zahyou[i].second -= zahyou1.second;
  }
  zahyou2.first -= zahyou1.first;
  zahyou2.second -= zahyou1.second;
  if(zahyou2.first < 0){
    for(i=0;i<n;i++){
      zahyou[i].first *= (-1);
    }
    zahyou2.first *= (-1);
  }
  if(zahyou2.second < 0){
    for(i=0;i<n;i++){
      zahyou[i].second *= (-1);
    }
    zahyou2.second *= (-1);
  }
  zahyou1.first = zahyou1.second = 0;
  sort(zahyou.begin(),zahyou.end());
  /*for(i=0;i<n;i++){
    cout<<zahyou[i].first<<" "<<zahyou[i].second<<endl;
    }*/
  vl dp(n+1,INF);
  dp[0] = -1;
  for(i=0;i<n;i++){
    auto it = lower_bound(dp.begin(),dp.end(),zahyou[i].second);
    *it = zahyou[i].second;
    //    DEBUG_VEC(dp);
  }
  for(i=n;i>=0;i--){
    if(dp[i]!=INF)
      break;
  }
  //cout<<i<<endl;
  double kyori;
  bool flag = (i == min(zahyou2.second,zahyou2.first)+1)? true:false;
  // cout<<flag<<endl;
  kyori = (zahyou2.first + zahyou2.second)*100 - 20*i + 5*i*pi;
  if(flag)
    kyori += 5*pi;
  Sp(kyori);
}


Measured memory_bytes: 6512
#include <iostream>
#include <queue>
#define MAX 1005
#define INF 100000000

using namespace std;

typedef struct{
    int x;
    int y;
    int state;
} Mouse;

int H,W,N;
int start_x,start_y;
char ar[MAX][MAX];
int offset_x[4] = {1,0,-1,0};
int offset_y[4] = {0,1,0,-1};
int ans[MAX][MAX];

void init(){
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            ans[i][j] = -INF;
}

int bfs(int state){

    Mouse m;
    m.x = start_x;
    m.y = start_y;
    m.state = state;

    init();

    ans[start_y][start_x] = 0;

    queue<Mouse> q;
    q.push(m);

    while(q.size()){
        Mouse m1 = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int dx = m1.x + offset_x[i];
            int dy = m1.y + offset_y[i];
            if(dx >= 0 && dx < W && dy >= 0 && dy < H && ar[dy][dx] != 'X' && ans[dy][dx] == -INF){
                Mouse m2;
                m2.x = dx;
                m2.y = dy;

                ans[dy][dx] = ans[m1.y][m1.x] + 1;

                if(m1.state == (ar[dy][dx] - '0')){
                    ar[dy][dx] == '.';
                    start_x = dx;
                    start_y = dy;
                    return ans[dy][dx];
                }else{
                    m2.state = m1.state;
                }
                q.push(m2);
            }
        }
    }




}

int main(){

    while(cin >> H >> W >> N){
        for(int i = 0; i < H; i++){
            cin >> ar[i];
            for(int j = 0; j < W; j++){
                if(ar[i][j] == 'S'){
                    start_y = i;
                    start_x = j;
                }
            }
        }
        int res = 0;
        for(int i = 1; i <= N; i++)
            res += bfs(i);
        cout << res << endl;
    }

 return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<int,long long> ps,ms;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    ps[i+1+a]++;
    ms[i+1-a]++;
  }

  long long ans=0;
  for(auto p:ps){
    int pi=p.first;
    long long v = p.second * ms[pi];
    ans+=v;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 37920
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    ans = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            c=x-i-j
            if c>j and c<=n:
                ans+=1
    print (ans)

Measured memory_bytes: 6720
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	for {
		ok := true
		v := N
		d := v % 10
		for v > 0 {
			if d != v%10 {
				ok = false
				break
			}
			v /= 10
		}
		if ok {
			fmt.Println(N)
			return
		}
		N++
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
const int BUF = 100005;


int nNode, s, t;
vector<int> adj[BUF];

void read() {
    for (int i = 0; i < BUF; ++i) adj[i].clear();

    cin >> nNode >> s >> t;
    --s;
    --t;
    for (int i = 0; i < nNode - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
}


void bfs(int bgn, int cost[BUF]) {
    queue<int> Q;
    
    cost[bgn] = 0;
    Q.push(bgn);

    while (!Q.empty()) {
        int cur = Q.front();
        Q.pop();

        for (int i = 0; i < adj[cur].size(); ++i) {
            int nex = adj[cur][i];
            if (cost[nex] == -1) {
                cost[nex] = cost[cur] + 1;
                Q.push(nex);
            }
        }
    }
}


void work() {
    int costS[BUF];
    int costT[BUF];
    memset(costS, -1, sizeof(costS));
    memset(costT, -1, sizeof(costT));
    bfs(s, costS);
    bfs(t, costT);

    int ans = 0;
    for (int i = 0; i < nNode; ++i) {
        if (costS[i] > costT[i]) continue;
        if (adj[i].size() == 1) continue;

        ans = max(ans, costT[i]);
    }
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,k;
    cin>>n>>k;
    VL arr(n);
    ll start=0,end=k;
    fr(i,0,n)
        cin>>arr[i];
    while(end<n)
    {
        if(arr[end]>arr[start])
            cout<<"Yes\n";
        else
            cout<<"No\n";
        end++;
        start++;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N, 0);
  int D, A;
  for(int i=0; i<K; i++){
    cin >> D;
    for(int i=0; i<D; i++){
      cin >> A;
      P.at(A-1)++;
    }
  }
  int Ans=0;
  for(int i=0; i<N; i++){
    if(P.at(i)==0){
      Ans++;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll l, r;
  cin >> l >> r;
  if (2019 <= r - l) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2018;
  // l <= i < j <= r
  for (ll i = l; i < r; ++i) {         // l <= i < r
    for (ll j = i + 1; j <= r; ++j) {  // i < j <= r
      ll tmp = i * j % 2019;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while((line = Console.ReadLine()) != null)
            {
                var cards = line.Split(',').Select(int.Parse).ToLookup(x => x);
                if (cards.Any(x => x.Count() == 4))
                {
                    Console.WriteLine("four card");
                }
                else if (cards.Any(x => x.Count() == 3) && cards.Any(x => x.Count() == 2))
                {
                    Console.WriteLine("full house");
                }
                else if (IsStraight(cards))
                {
                    Console.WriteLine("straight");
                }
                else if (cards.Any(x => x.Count() == 3))
                {
                    Console.WriteLine("three card");
                }
                else if (cards.Any(x => x.Count() == 2))
                {
                    if (cards.ToLookup(x => x.Count())[2].Count() == 2) Console.WriteLine("two pair");
                    else Console.WriteLine("one pair");
                }
                else
                {
                    Console.WriteLine("null");
                }
            }
        }

        private static bool IsStraight(ILookup<int, int> cards)
        {
            if (cards.Count != 5) return false;
            var c = cards.Select(x => x.Key).ToArray();
            var min = c.Min();
            if ((min + min + 4) * 5 / 2 == c.Sum()) return true;
            if (!c.Contains(1)) return false;
            c = c.Where(x => x != 1).Concat(new[] { 14 }).ToArray();
            min = c.Min();
            return (min + min + 4) * 5 / 2 == c.Sum();
        }
    }
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int w = 1;
  while (true) {
    if (w * (w + 1) == n * 2) {
      break;
    } else if (w * (w + 1) > n * 2) {
      cout << "No" << endl;
      return 0;
    }
    w++;
  }
  auto ans = vector<vector<int>>(w + 1);
  int s = 1;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < w - i; j++) {
      ans[i].push_back(s + j);
      ans[i + j + 1].push_back(s + j);
    }
    s += w - i;
  }
  cout << "Yes" << endl;
  cout << w + 1 << endl;
  for (int i = 0; i < w + 1; i++) {
    cout << w << " ";
    for (int j = 0; j < w; j++) {
      if (j == w - 1) {
        cout << ans[i][j] << endl;
      } else {
        cout << ans[i][j] << " ";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>

main()
{
  int num1, num2, amari;

  scanf("%d %d", &num1, &num2);

  while((amari = num1 % num2) != 0)
    {
      num1 = num2;
      num2 = amari;
    }

  printf("%d\n", num2);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int water[3100]={0},sugar[3100]={0};

void dp(int v[],int a,int b,int f){
    v[0]=1;
    v[a]=1;
    v[b]=1;
    for(int i=a;i<=f;i++){
        if(v[i]==1&&i+a<3100){
            v[i+a]=1;
            if(i+b<3100){
                v[i+b]=1;
            }
        }
    }
}

int main(){
    int A,B,C,D,E,F;
    int ans_a=0,ans_b=0;
    long double no=-1.0;
    cin>>A>>B>>C>>D>>E>>F;
    dp(water,100*A,100*B,F);
    dp(sugar,C,D,F);
    for(int i=100*A;i<=F;i++){
        for(int j=0;j+i<=F;j++){
            if(water[i]==1 && sugar[j]==1){
                int tmp=E*(i/100);//tmp(g)砂糖が溶ける
                tmp=j-tmp;//tmp(g)砂糖が溶け残っている
                if(tmp<=0){
                    long double tmp_no=(j*100.0)/(i+j);
                    if(tmp_no>no){
                        no=tmp_no;
                        ans_a=i+j;
                        ans_b=j;
                    }
                }
            }
        }
    }
    cout<<ans_a<<' '<<ans_b<<endl;
    return 0;
}

Measured memory_bytes: 256
l = list(map(int,input().split()))

l[0] = l[0] - l[2]

if l[0] < 0:
  l[1] = l[1] + l[0]
  l[0] = 0
  if l[1] < 0:
    l[1] = 0

print(str(l[0]) + " " + str(l[1])) 

Measured memory_bytes: 3060
from pprint import pprint
H, W = map(int, input().split())
s = ["-1"]
dp = [[1000] * (W + 1) for _ in range(H + 1)]
for _ in range(H):
    s.append(input())
s = list(map(lambda x: " " + x, s))
for y in range(1, H + 1):
    for x in range(1, W + 1):
        if y == 1 and x == 1:
            if s[y][x] == "#":
                dp[y][x] = 1
            else:
                dp[y][x] = 0
            continue
        if x == 1:
            if s[y][x] == "#":
                if s[y - 1][x] == "#":
                    dp[y][x] = dp[y - 1][x]
                else:
                    dp[y][x] = dp[y - 1][x] + 1
            else:
                dp[y][x] = dp[y - 1][x]
        elif y == 1:
            if s[y][x] == "#":
                if s[y][x - 1] == "#":
                    dp[y][x] = dp[y][x - 1]
                else:
                    dp[y][x] = dp[y][x - 1] + 1
            else:
                dp[y][x] = dp[y][x - 1]
        else:
            if s[y][x] == "#":
                if s[y][x - 1] == "#":
                    dp[y][x] = dp[y][x - 1]
                if s[y - 1][x] == "#":
                    dp[y][x] = min(dp[y][x], dp[y - 1][x])
                if s[y][x - 1] != "#" and s[y - 1][x] != "#":
                    dp[y][x] = min(dp[y][x - 1], dp[y - 1][x]) + 1
            else:
                dp[y][x] = min(dp[y][x - 1], dp[y - 1][x])
#pprint(dp)
print(dp[H][W])




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


using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
#define fin "\n"
void chmin(LL &a,LL b){a=min(a,b);}
#define REP(i, n) for(LL i = 0; i < (n); ++i)

LL f(LL a,LL b){return (a+b-1)/b;}
int main(){
    LL n, m, a, b;
    cin >>n>>m>>a>>b;
    vector<LL> d(n);
    REP(i, n) cin >> d[i];

    vector<LL> trash;
    REP(i, n){
        if(d[i] < a) break;
        trash.push_back(d[i]);
    }

    LL cnt = trash.size();
    reverse(trash.begin(), trash.end());
    if(n - cnt < m) {
        for(LL dd : trash){
            if(dd > b) break;
            cnt--;
        }
    }

    cout << cnt << fin;
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long 

int32_t main() {
	boost;

	int l,r;
	cin>>l>>r;
	int ans = 2019;
	for(int i=l;i<=min(l+2019,r);i++){
		for(int j = i+1;j<=min(l+2019,r);j++){
			ans = min(ans,(i*j)%2019);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3540
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;

int loop(int x,int a,int b);

int main(){

    int i,a,b,n;
    cin >> a >> b;

    int ans=0,ans1,ans2;
    int judge=0;

    ans1 = b*10;
    ans2 = b*10+10;

    ans = loop(a,ans1,ans2);


    if (ans ==0)
    {
        cout << "-1" << endl;
    }else
    {
        cout << ans << endl;
    }

}

int loop(int x, int a,int b){
        int i,n;
        rep(i,a,b){
            n = i*8/100;

            if (n == x){
                return i;
                break;
            }
            if(i==b){
                return 0;
            }
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
 
 
void solve(){
    char c;
    cin>>c;
    if(c=='a' || c=='i' || c=='e' || c=='u' || c=='o'){
        cout<<"vowel"<<endl;
    }   else{
        cout<<"consonant"<<endl;
    }
}
 
signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
/*
http://soj.acmm.club/show_problem.php?pid=1005&cid=2828
*/
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
vector<int> dao[2];
int cmp(int a,int b){
    return b < a;
}
int main(){
    int n, H;
    scanf("%d%d", &n, &H);
    for (int i = 0; i < n;i++){
        int t, y;
        scanf("%d%d", &t, &y);
        dao[0].push_back(t);
        dao[1].push_back(y);
    }
    sort(dao[0].begin(), dao[0].end(), cmp);
    sort(dao[1].begin(), dao[1].end(), cmp);
    int ans = 0,mb=0;
    while(H>0){
        if(mb<dao[1].size() && dao[1][mb]>dao[0][0]){
            H -= dao[1][mb++];
            ans++;
        }
        else{
            H -= dao[0][0];
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

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

int n,a[105],b[105],ans=0;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while(c>'9'||c<'0')c=getchar();
   	if(c=='-')t=-1,c=getchar();
   	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
   	return s*t;
}

int main(void){
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	scanf("%d",&b[i]);
	b[0]=0x3f3f3f3f;
	b[n]=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	a[i]=min(b[i],b[i-1]);
	for(int i=1;i<=n;i++)
	ans+=a[i];
	printf("%d\n",ans);
}



Measured memory_bytes: 128
#include <stdio.h>
 
int main(void)
{
    int i, j;
    int in_num;
    int row, column;
    int all_sum = 0;
 
    scanf("%d %d", &row, &column);
    int in_spread[row][column];
    int row_sum[row];
    int column_sum[column];
    int out_spread[row + 1][column + 1];
 
    for (i = 0; i < row; i++){
        for (j = 0; j < column; j++){
            scanf("%d", &in_num);
            in_spread[i][j] = in_num;
            all_sum += in_num;
        }
    }
 
    for (i = 0; i < row; i++){
        row_sum[i] = 0;
        for (j = 0; j < column; j++){
            row_sum[i] += in_spread[i][j];
        }
    }
 
    for (j = 0; j < column; j++){
        column_sum[j] = 0;
        for (i = 0; i < row; i++){
            column_sum[j] += in_spread[i][j];
        }
    }
 
    for (i = 0; i < row; i++){
        for (j = 0; j < column; j++){
            out_spread[i][j] = in_spread[i][j];
        }
    }
    for (i = 0; i < row; i++){
        out_spread[i][column] = row_sum[i];
    }
    for (j = 0; j < column; j++){
        out_spread[row][j] = column_sum[j];
    }
    out_spread[row][column] = all_sum;
 
    for (i = 0; i < row + 1; i++){
        for (j = 0; j < column + 1; j++){
            if (j){
                printf(" ");
            }
            printf("%d", out_spread[i][j]);
        }
        printf("\n");
    }
 
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	
	int ans = 0;
	for (int i = 0; i < 2; i++){
		if(A > B){
			ans += A;
			A--;
		}else{
			ans += B;
			B--;
		}
	}

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


Measured memory_bytes: 256
N, M = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(N)]
ab_list.sort(key=lambda i: i[0])
count = 0
money = 0
for a, b in ab_list:
    buy = min(b, M - count)
    count += buy
    money += buy * a
    if count == M:
        break
print(money)


Measured memory_bytes: 29028
n,m = map(int,input().split())
A = [int(i) for i in input().split()]
BC = []
for i in range(m):
        b,c = map(int,input().split())
        BC.append([b,c])
BC.sort(key=lambda x:x[1],reverse = True)
A.sort()
point_end = []
k = 0
for i in range(n-1,-1,-1):
        while A[i] <= BC[k][1]:
                k += 1
                point_end.append(i)
                if k == m:
                        break
        if k==m:
                break
point_start = 0
for i in range(len(point_end)):
        for j in range(point_start,min(point_start+BC[i][0],point_end[i]+1)):
                A[j] = BC[i][1]
                point_start += 1
print(sum(A))

Measured memory_bytes: 27172
while True:
    p = input()
    c = 0
    d = 0
    if p == '0':
        break
    a = len(p)
    for i in range(1,a):
        if p[i] == 'A':
            c += 1
        else:
            d += 1
    if c > d:
        c += 1
    else:
        d += 1
    print(c,d)


Measured memory_bytes: 5552
N = int(input())
from heapq import heapify, heappush, heappop

inf = float("inf")
def dijkstra(graph, start):  # graphは隣接リスト(繋がっている先, コスト)
    vsize = len(graph)
    dist = [inf] * vsize
    seen = [False] * vsize
    prev = [None] * vsize
    pq = []
    heapify(pq)

    dist[start] = 0
    heappush(pq, (0, start))  # heapではtuple[0]で比較されるのでこの順番で追加する
    while pq:
        cost, u = heappop(pq)
        seen[u] = True
        if dist[u] < cost:
            continue
        for v, w in graph[u]:
            temp_cost = dist[u] + w
            if not seen[v] and temp_cost < dist[v]:
                dist[v] = temp_cost
                prev[v] = u
                heappush(pq, (dist[v], v))
    return dist
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))
Q, K = map(int, input().split())
shortest_path_K = dijkstra(graph, K-1)
for _ in range(Q):
    x, y = map(int, input().split())
    print(shortest_path_K[x-1]+shortest_path_K[y-1])


Measured memory_bytes: 94112
N,M = [int(x) for x in input().split()]
from collections import deque
l = [[] for i in range(N+1)]
d = deque()
for i in range(M):
    p,q = [int(x) for x in input().split()]
    l[p].append(q)
    l[q].append(p)
dist = [-1] * (N+1)
dist[1] = 0
d.append(1)
ans = [0]*(N+1)
while d:
    v = d.popleft()
    for i in l[v]:
        if dist[i] != -1:
            continue
        dist[i] = dist[v] + 1
        ans[i] = v
        d.append(i)
if dist.count(-1) != 1:
    print("No")
else:
    print("Yes")
    for i in range(2,N+1):
        print(ans[i])

Measured memory_bytes: 35232
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=100007;
int n,m,hd[N],nt[N<<1],to[N<<1],C[N<<1],D[N<<1],A[N],B[N],Qx[N],Qy[N],Qz[N],Qc[N],Qd[N],Dx[N],Dy[N],Dz[N],fa[N],son[N],sz[N],tp[N],de[N];
vector<int> V[N];
void walk(int u) {
	sz[u]=1,de[u]=de[fa[u]]+1;
	for(int i=hd[u];i;i=nt[i])
	if(to[i]!=fa[u]) {
		fa[to[i]]=u;
		walk(to[i]);
		sz[u]+=sz[to[i]];
		if(sz[to[i]]>sz[son[u]]) son[u]=to[i];
	}
}
void run(int u) {
	if(son[u]) tp[son[u]]=tp[u],run(son[u]);
	for(int i=hd[u];i;i=nt[i])
	if(to[i]!=fa[u]&&to[i]!=son[u]) tp[to[i]]=to[i],run(to[i]);
}
int lca(int x,int y) {
	while(tp[x]!=tp[y]) {
		if(de[tp[x]]>de[tp[y]]) x=fa[tp[x]];
		else y=fa[tp[y]];
	}
	return de[x]<de[y]?x:y;
}
void fly(int u,int d) {
	For(i,0,(int)V[u].size()-1) {
		int q=V[u][i];
		if(u==Qx[q]) Dx[q]=d-B[Qc[q]]+A[Qc[q]]*Qd[q];
		if(u==Qy[q]) Dy[q]=d-B[Qc[q]]+A[Qc[q]]*Qd[q];
		if(u==Qz[q]) Dz[q]=d-B[Qc[q]]+A[Qc[q]]*Qd[q];
	}
	for(int i=hd[u];i;i=nt[i])
	if(to[i]!=fa[u]) {
		++A[C[i]],B[C[i]]+=D[i];
		fly(to[i],d+D[i]);
		--A[C[i]],B[C[i]]-=D[i];
	}
}
int main() {
	scanf("%d%d",&n,&m);
	For(i,1,n-1) {
		int x,y,c,d;
		scanf("%d%d%d%d",&x,&y,&c,&d);
		nt[i*2-1]=hd[x],hd[x]=i*2-1,to[i*2-1]=y,C[i*2-1]=c,D[i*2-1]=d;
		nt[i*2]=hd[y],hd[y]=i*2,to[i*2]=x,C[i*2]=c,D[i*2]=d;
	}
	walk(1),tp[1]=1,run(1);
	For(i,1,m) {
		scanf("%d%d%d%d",&Qc[i],&Qd[i],&Qx[i],&Qy[i]);
		Qz[i]=lca(Qx[i],Qy[i]);
		V[Qx[i]].push_back(i);
		V[Qy[i]].push_back(i);
		V[Qz[i]].push_back(i);
	}
	fly(1,0);
	For(i,1,m) printf("%d\n",Dx[i]+Dy[i]-2*Dz[i]);
	return 0;
}

Measured memory_bytes: 18172
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];

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

int main(){
    int n; cin >> n;
    ll sum = 0;
    ll ans1, ans2;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            for(int k = 1; k <= n; ++k){
                ans1 = gcd(i, j);
                ans2 = gcd(ans1, k);
                sum += ans2;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3572
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int A[] = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		double sum = 0;
		for(int i=0;i<N;i++) {
			sum+= 1.0/A[i];
		}
		out.println(1.0/sum);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());
    cout << nums.back() << " ";
    int mn = nums[0];
    double mid = nums.back() / 2.0;
    for (int i = 1; i < n; i++) {
        if (abs(1.0 * mn - mid) > abs(1.0*nums[i]-mid)) {
            mn = nums[i];
        }
    }
    cout << mn << "\n";
    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val t = (1..h).map { readLine()!! }
    val dp = Array(h + 1) { Array(w + 1) { Array(2) { Int.MAX_VALUE } } }

    dp[0][0][0] = 0
    dp[0][0][1] = 1

    for (i in 0 until h) {
        for (j in 0 until w) {
            for (use in 0..1) {
                if (dp[i][j][use] == Int.MAX_VALUE) continue
                val nextUse =
                        if (t[i][j] == '#' && use == 0) {
                            1
                        } else if (t[i][j] == '.' && use == 1) {
                            0
                        } else {
                            use
                        }
                val addCost = if (use == 0 && nextUse == 1) 1 else 0
                dp[i + 1][j][nextUse] = Math.min(dp[i + 1][j][nextUse], dp[i][j][use] + addCost)
                dp[i][j + 1][nextUse] = Math.min(dp[i][j + 1][nextUse], dp[i][j][use] + addCost)
            }
        }
    }
    var ans = dp[h][w - 1][0]
    ans = Math.min(ans, dp[h][w - 1][1])
    ans = Math.min(ans, dp[h - 1][w][0])
    ans = Math.min(ans, dp[h - 1][w][1])
    println(ans)
}


Measured memory_bytes: 38168
def enqueue(x, queue):
    queue.append(x)
    return queue
def dequeue(queue):
    val = queue.pop(0)
    return val, queue

def isEmpty(queue):
    return queue!=[]
        
def work(q, process):
    process[1] = process[1] - q
    return process
    
n, q = map(int, input().split())
process = [input().split() for _ in range(n)]
process = [[one[0], int(one[1])] for one in process]
queue = process.copy()

time = 0
while isEmpty(queue):
    process, queue = dequeue(queue)
    process = work(q, process)
    if process[1]<=0:
        worktime = q+process[1]
        print(process[0]+ ' ' +str(time+worktime))
        time += worktime
    else:
        queue = enqueue(process, queue)
        time += q


Measured memory_bytes: 21032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if (S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi"){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
mod = 10 ** 9 + 7
n, m, k = map(int, input().split())
nm = n * m
fact = [1] * (nm + 1)

for i in range(1, nm + 1):
    fact[i] = fact[i - 1] * i % mod


def C(n, k):
    x = fact[n]
    x *= pow(fact[n-k], mod - 2, mod)
    x %= mod
    x *= pow(fact[k], mod - 2, mod)
    x %= mod
    return x


def F(x):
    s1 = x * x * (x + 1) // 2
    s2 = x * (x + 1) * (2 * x + 1) // 6
    return (s1 - s2) % mod


res = (m ** 2 % mod * F(n) % mod + n ** 2 * F(m) % mod) % mod
res *= C(n * m - 2, k - 2)
res %= mod
print(res)


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

// dp[i][x] = last elem x, len = i
// dp[1][x] = 1
// dp[i][x] = sum(dp[i-1][j]) where j<=floor(n/x)

ll dp[105][100005], dp2[105][100005];
const ll mod = 1'000'000'007;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	// calculate groups
	int gc = 0;

	int n, k; read(n, k);

	deque<int> gsl, gsr, gs;

	for (int i = 1; i * i <= n; i++) {
		gsl.push_back(1);
		int lo = n / (i + 1) + 1;
		int hi = n / i;
		//printf("%d: %d - %d\n", i, lo, hi);
		if (n / i != i) gsr.push_front(hi - lo + 1);
	}

	for (int g : gsl) gs.push_back(g);
	for (int g : gsr) gs.push_back(g);
	gc = sz(gs);

	//for (int c : gs) write("G:", c);

	//sort(gs, gs + gc);
	//sort(all(gs));
	rep(i, 0, gc) dp[1][i] = gs[i];
	rep(i, 0, gc) dp2[1][i] = dp[1][i] + (i ? dp2[1][i - 1] : 0);
	rep(g, 2, k + 1) {
		rep(j, 0, gc) {
			(dp[g][j] += dp2[g - 1][gc - 1 - j] * gs[j] % mod) %= mod;
		}
		rep(i, 0, gc) dp2[g][i] = (dp[g][i] + (i ? dp2[g][i - 1] : 0)) % mod;
	}

	ll ans = 0;
	rep(i, 0, gc) ans += dp[k][i];
	die(ans % mod);
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  int count = 0;
  for(int i = 0;i < n;i++) cin>>a[i];
  for(int i = 1;i+1 < n;i++){
    if((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1]))
       count++;
  }
  cout<<count;
}

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

int main(){
    int a;
    cin>>a;
    cout<<a*(1+a+a*a)<<endl;
    return 0;
}

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

string f[2],b[2];

int main(){
    int m;
    cin >> m;
    while(m--){
        set<string> st;
        string s;
        cin >> s;
        for(int i=1;i<s.size();i++){
            f[0] = s.substr(0,i);
            b[0] = s.substr(i,s.size()-i);
            string p = f[0],q = b[0];
            reverse(p.begin(),p.end());
            reverse(q.begin(),q.end());
            f[1] = p;
            b[1] = q;
            rep(i,2)rep(j,2){
                st.insert(f[i]+b[j]);
                st.insert(b[i]+f[j]);
            }
        }
        cout << st.size() << endl;
    }
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    string s, sReverse;
    for(int i = a; i <= b; i++){
        s = to_string(i);
        reverse(s.begin(), s.end());
        sReverse = s;
        s = to_string(i);
        if(s == sReverse) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    vector<int> vec; vec.pb(111); vec.pb(222); vec.pb(333);
    vec.pb(444); vec.pb(555); vec.pb(666); vec.pb(777); vec.pb(888); vec.pb(999);
    int n; cin >> n;
    int t = *lower_bound(vec.begin(), vec.end(), n);
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3624
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := ""
    for i:=0; i<3; i++{
        if s[i]=='1'{
            ans+="9"
        } else {
            ans+="1"
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,a,b,i,p,e=0,m=0,h=0;
    cin >> n>>a>>b;
    for(i=0;i<n;i++){
        cin>>p;
        if(p<=a) e++;
        else if(p<=b) m++;
        else h++;
    }
    cout << min(e,min(m,h))<<endl;
    return 0;
}

Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>

int main(void){
   int A,P;
	scanf("%d", &A);
	scanf("%d", &P);
  	int sumk = 0;
    int ans = 0;
  	sumk = sumk + P;
  	sumk = sumk + (A *3);
  	
   ans = sumk /2;
  

    printf("%d",ans);

    //int max = max(a, N);
    return 0;   
}

Measured memory_bytes: 128
use std::io;

fn main() {
    let mut s = String::new();
    let mut A = String::new();
    let mut B = String::new();

    io::stdin().read_line(&mut s).expect("aa");

    let mut iter = s.split_whitespace();

    let A:usize  = iter.next().unwrap().parse().unwrap();
    let B:usize  = iter.next().unwrap().parse().unwrap();

    println!("{}", (A-1)*(B-1));
}

Measured memory_bytes: 4352
main = do
  [n,m] <- (map read . words) <$> getLine
  as <- (map read . words) <$> getLine
  let thr = fromIntegral (sum as) / fromIntegral (4 * m)
  putStrLn $ if length [0 | a <- as , fromIntegral a >= thr] >= m
    then "Yes"
    else "No"


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include "boost/multiprecision/cpp_int.hpp"
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int N, A; std::cin >> N >> A;

	int ans = N * N - A;
	std::cout << ans;

	return 0;

}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int x,y;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> x >> y;
    if(x%y) cout << x;
    else cout << -1;
}


Measured memory_bytes: 256