akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, BufRead, BufReader};

fn main() {
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let values: Vec<u32> = line.unwrap()
            .split(' ')
            .filter_map(|x| x.parse::<u32>().ok())
            .collect();
        let sum = (values[0] + values[1]).to_string();
        println!("{}", sum.len());
    }
}



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

int main() {
    char c; cin>>c;
    for(char i='a'; i<='z'; i++) {
        if(c == i) {
            cout<< 'a' << endl;
            return 0;
        }
    }
    for(char i='A'; i<='Z'; i++) {
        if(c == i) {
            cout << 'A' << endl;
            return 0;
        }
    }
}

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

int main(){
    int N;
    // 2乗の和と和
    int sum2=0,sum=0;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i< N; i++) {
        cin >> a.at(i);
        sum2 += a.at(i)*a.at(i);
        sum += a.at(i);
    }
    int p = floor((double)sum/N);
    if((double)sum/N-p > 0.5) p++;
    cout << sum2+p*p*N-2*p*sum << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main(){
    int n; cin>>n;
    vector<int>S(n);
    rep(i,n) cin>>S[i];
    sort(S.begin(), S.end());
    int sum = 0;
    int mini = 1000; //10の倍数でない最も小さい値を格納する用
    rep(i,n){
        sum += S[i];
        if (S[i]%10 != 0) mini = min(S[i], mini);
    }
  
    rep(i,n){
        if (sum%10 != 0){
            cout << sum << endl;
            return 0;
        }
    }
    sum -= mini;
    if (sum%10 != 0) cout << sum << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

void solve()
{
int n,x,t;
cin>>n>>x>>t;
if(n%x==0)
	cout<<(n/x)*t;
else
	cout<<((n/x)+1)*t;
}
int main()
{	
	fast;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
}	


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	ull a, b;
	cin >> a >> b;
	
	cout << min(a%b, max(a%b,b)-min(a%b,b)) << endl;
  return 0;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

A_dic = dict()
for i in range(N):
    if A[i] in A_dic:
        A_dic[A[i]] += 1
    else:
        A_dic[A[i]] = 1

ans = sum(A)
for i in range(Q):
    B, C = map(int, input().split())
    
    if B in A_dic:
        if C in A_dic:
            A_dic[C] += A_dic[B]
        else:
            A_dic[C] = A_dic[B]
        if B > C:
            ans += (C-B) * A_dic[B]
        else:
            ans -= (B-C) * A_dic[B]
        A_dic.pop(B)
    else:
        pass
    
    print(ans)

Measured memory_bytes: 20712
#include<iostream>
 
using namespace std;
int main(){
  string s;
  cin >> s;
  int counter=0;
  if(s[0]=='o')++counter;
  if(s[1]=='o')++counter;
  if(s[2]=='o')++counter;
  cout << counter*100+700 << endl;
  return 0;
}

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

using namespace std;

#define mod 1000000007
#define int int64_t
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

const int maxn=1e6+5;
int pr[maxn];
vector<int> prs[maxn];
int ar[maxn];
int vis[maxn];

void solve()
{
    for(int i=2;i<maxn;i++)
    {
        if(pr[i]==0)
        {
            for(int j=i;j<maxn;j+=i)
            {
                prs[j].push_back(i);
                pr[j]=1;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>ar[i];
    int g=ar[1],flag=0;
    for(int i=2;i<=n;i++)
    {
        g=__gcd(g,ar[i]);
        for(int p:prs[ar[i]])
        {
            if(vis[p])
            {
                flag=1;
                break;
            }
            vis[p]=1;
        }
    }
    if(flag)
    {
        if(g==1)
            cout<<"setwise coprime"<<endl;
        else
            cout<<"not coprime"<<endl;
    }
    else
        cout<<"pairwise coprime"<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 96992
A= list(map(int, input().split()))
flg = True
cnt = 0
for a in A:
  if a != 7 and a != 5:
    flg = False
  if a == 5:
    cnt += 1
if cnt != 2:
  flg = False
if flg is True:
  print('YES')
else:
  print('NO')

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	string ans;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '0')
			ans += "0";
		else if (s[i] == '1')
			ans += "1";
		else if (ans.size() != 0)
			ans.pop_back();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    sort(all(v));
    int cnt = 0, tmp = 0;
    for(int i=0; i<N; i++){
        if(v[i] > tmp){cnt++; tmp=v[i];}
    }
    print(cnt);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main()
{
string s;
cin>>s;
for(int i=0; i<s.size(); i++){

    if(s[i]==','){
        s[i]=' ';
    }
}
cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{  
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> sales = new HashMap<>();
        
        int n = sc.nextInt();
        
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            
            switch(a){
                case 0:
                    sales.put(sc.next(),sc.nextInt());
                    break;
                case 1:
                    System.out.println(sales.getOrDefault(sc.next(),0));
                    break;
                case 2:
                    sales.remove(sc.next());
                    break;
            }
        }
    }
}


Measured memory_bytes: 192708
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
x,y,z = 0,0,0 # 最後に特定アクションを行った場合の最大幸福度
for _ in range(N):
    a,b,c = map(int,input().split())
    x,y,z = max(y,z) + a, max(x,z) + b, max(x,y) + c
answer = max(x,y,z)
print(answer)

Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>

char string[100001];
bool letters[100001];

int main()
{
  std::cin >> string;
  int n = strlen(string);

  for(int i = 0; i < n; i++)
    letters[string[i]] = true;

  for(char i = 'a'; i < '{'; i++)
  {
    if(!letters[i])
    {
      printf("%c", i);
      return 0;
    }
  }
  printf("None");
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> p[i];
  }
  int result = 0;
  for (i = 1; i < n - 1; i++) {
    int p_max = max(p[i - 1], max(p[i], p[i + 1]));
    int p_min = min(p[i - 1], min(p[i], p[i + 1]));
    if (p[i] != p_max && p[i] != p_min) {
      result++;
    }
  }
  cout << result << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string a[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s; cin >> s;
    for (int i = 0; i < 7; i++) {
        if (a[i] == s) {
            for (int j = 1; j <= 7; j++) {
                if (a[(i + j) % 7] == "SUN") {
                    cout << j << "\n";
                    exit(0);
                }
            }
        }
    }
}


Measured memory_bytes: 256
N, M = map(int,input().split())
graph = [[] for n in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
# 入力例 1の場合
# graph : [[], [2], [1, 3, 4], [2, 4], [3, 2]] graphのインデックスが部屋名
# graph[2] : 部屋2は、1,3,4と繋がっている
# graph[4] : 部屋4は、3,2と繋がっている

#次に探索をする部屋番号をストックしておく。まずは部屋番号1から探索を始めるので、１を入れておく
q = [1]
#ans[部屋番号]=道標が指す部屋番号とする。探索していない部屋を'No'として表す。
ans = ['No' for n in range(N+1)]
ans[1] = 1 #ans[1]
while q: #qの中身がなくなったらbreak
    # 現在地を指定（キューの先頭）するとともに、qから先頭を削除する。　一番最初の現在地は1になる。
    now = q.pop(0)
    for edge in graph[now]:
        if ans[edge] != 'No':
            continue
        ans[edge] = now
        q.append(edge)

print('Yes')
for n in range(2,N+1):
    print(ans[n])





Measured memory_bytes: 33776
from collections import deque
s=deque(input())
q=int(input())
cnt=0
for i in range(q):
  t=input().split()
  if t[0]=="1":
    cnt+=1
  else:
    if (int(t[1])+cnt)%2==1:
      s.appendleft(t[2])
    else:
      s.append(t[2])
      
if cnt%2==1:
  s.reverse()
print("".join(s))


Measured memory_bytes: 74756
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool pair_comp(const pair<ll, ll> & p1, const pair<ll, ll> & p2)
{
	// sort(item.begin(), item.end(), throw_comp)のように使う
	if (p1.first != p2.first) {
		return p1.first < p2.first;
	}
	else {
		return p1.second > p2.second;
	}
}

ll gcd(ll a, ll b)
{
	// a >= b
	if (b > a) swap(a, b);
	if (b == 0) return a;
	return gcd(a % b, b);
}

// main function
int main()
{
	ll N = 0;
	ll ans = 0;

	cin >> N;
	vector< ll > v(N, 0);
	map< ll, ll > v0;
	map< ll, ll > v1;
	ll v0_num = 0;
	ll v1_num = 0;

	Rep(i, N) {
		cin >> v[i];
		if (i % 2 == 0) {
			v0[v[i]]++;
			v0_num++;
		}
		else {
			v1[v[i]]++;
			v1_num++;
		}
	}

	map< ll, ll >::iterator itr0;
	map< ll, ll >::iterator itr1;
	vector< pair<ll, ll> > vec0;
	vector< pair<ll, ll> > vec1;

	for (itr0 = v0.begin(); itr0 != v0.end(); itr0++) {
		vec0.push_back( make_pair(v0_num - itr0->second, itr0->first) );
	}
	for (itr1 = v1.begin(); itr1 != v1.end(); itr1++) {
		vec1.push_back(make_pair(v1_num - itr1->second, itr1->first));
	}

	sort(vec0.begin(), vec0.end());
	sort(vec1.begin(), vec1.end());

	if (vec0[0].second != vec1[0].second) {
		// そのまま
		ans = vec0[0].first + vec1[0].first;
	}
	else {
		if (vec0.size() == 1) {
			vec0.push_back(make_pair(v0_num, -1));
		}
		if (vec1.size() == 1) {
			vec1.push_back(make_pair(v1_num, -1));
		}
		ans = min(vec0[1].first + vec1[0].first, vec1[1].first + vec0[0].first);
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
     while(1){
	  string temp;
	  getline(cin,temp);
	  //cout<<temp;
	  if(cin.eof()||temp=="END OF INPUT")break;
	  int sum=0;
	  for(int i=0;i<temp.size();i++){
	       if(temp[i]==' '){
		    cout<<sum;
		    sum=0;
	       }
	       else sum++;
	  }
	  cout<<sum<<endl;
     }
}

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

int main(){
    int n,l=0;cin>>n;
    for(int k=0;k<8;k++){
        if(pow(2,k)>n){
            l=k-1;
            break;
        }
    }
    cout<<pow(2,l)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,d,x;
    cin>>n>>d>>x;
    ll a[100010];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        ll s=d-1;
        x+=s/a[i]+1;
    }
    cout<<x<<endl;
    return 0;
}

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

#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

std::vector<int> weights(300, 0);
std::vector<std::vector<uint>> dp(302, std::vector<uint>(302, 0));

int solve(int num_daruma)
{
    for (uint i = 0; i < num_daruma; i++)
    {
        std::cin >> weights[i];
    }

    for (uint i = 0; i <= num_daruma; i++)
    {
        std::fill(dp[i].begin(), dp[i].begin() + num_daruma + 1, 0);
    }

    for (uint width = 1; width <= num_daruma; width++)
    {
        for (uint l = 0; l <= num_daruma - width; l++)
        {
            auto r = l + width;

            if (width >= 2 && dp[l + 1][r - 1] == r - l - 2 && abs(weights[l] - weights[r - 1]) < 2)
            {
                dp[l][r] = std::max({dp[l][r], r - l});
                continue;
            }

            for (uint mid = l + 1; mid < r; mid++)
            {
                dp[l][r] = std::max({dp[l][r], dp[l][mid] + dp[mid][r]});
            }
        }
    }

    return dp[0][num_daruma];
}

int main()
{
    int num_daruma = -1;

    while (true)
    {
        std::cin >> num_daruma;
        if (num_daruma == 0)
        {
            break;
        }
        std::cout << solve(num_daruma) << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3248
package main

import "fmt"

func main() {
	var X int
	fmt.Scan(&X)

	dp := make([]bool, X+1)
	dp[0] = true
	for i := 0; i <= X; i++ {
		for j := 100; j <= 105; j++ {
			p := i - j
			if p >= 0 && dp[p] {
				dp[i] = true
			}
		}
	}

	if dp[X] {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
int n, u, v, w, ans[100010];
vector<P> road[100010];

void dfs(int x, int y)
{
	ans[x] = y;
	for (int i = 0; i < road[x].size(); i++)
	{
		if (ans[road[x][i].first] != 0)
		{
			continue;
		}
		else if (road[x][i].second % 2 == 0)
		{
			dfs(road[x][i].first, y);
		}
		else
		{
			dfs(road[x][i].first, (y == 1 ? 2 : 1));
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> u >> v >> w;
		road[u].push_back(P(v, w));
		road[v].push_back(P(u, w));
	}
	dfs(1, 1);
	for (int i = 1; i <= n; i++)
	{
		cout << ans[i] % 2 << endl;
	}
	cin >> n;
}

Measured memory_bytes: 8320
// Aizu Vol-5 0577: Unique number
// 2017.8.30 bal4u@uu

#include <stdio.h>

char c[102][3];
int p[202][3];

int main()
{
	int N, i, j, s;

	for (i = 1; i <= 100; i++) for (j = 0; j < 3; j++) c[i][j] = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
		for (j = 0; j < 3; j++) scanf("%d", &p[i][j]), c[p[i][j]][j]++;
	for (i = 0; i < N; i++) {
		for (s = j = 0; j < 3; j++) if (c[p[i][j]][j] == 1) s += p[i][j];
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    
    int n;
    cin>>n;
    
    vector<int> han(4);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;    
        if(s=="AC") han[0]++;
        else if(s=="WA") han[1]++;
        else if(s=="TLE") han[2]++;
        else if(s=="RE") han[3]++;
    }
    
    for(int i=0;i<4;i++){
        if(i==0) cout<<"AC x "<<han[0]<<endl;
        else if(i==1) cout<<"WA x "<<han[1]<<endl;
        else if(i==2) cout<<"TLE x "<<han[2]<<endl;
        else if(i==3) cout<<"RE x "<<han[3]<<endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (ll i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
ll arr[100005];
ll a, b, c, n, q;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> a;
		arr[a]++;
	}
	cin >> q;
	ll tot = 0;
	REP(i, 1, 100001){
		tot += arr[i]*i;
	}
	REP(i, 0, q){
		cin >> b >> c;
		tot += (arr[b])*(c - b);
		arr[c] += arr[b];
		arr[b] = 0;
		cout << tot << endl;
	}
	
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

vector<int> divisor(int n)
{
  vector<int> ret;
  for (int i = 1; i*i <= n; ++i)
  {
    if(n%i==0&&i*i!=n) 
    {
      ret.push_back(i);
      ret.push_back(n/i);
    }
    else if(n%i==0)
    {
      ret.push_back(i);
    }
  }
  sort(ret.begin(), ret.end());
  reverse(ret.begin(), ret.end());
  return ret;
}

int main()
{
  int n;
  cin>>n;
  multiset<int> st;
  vector<int> vec;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    st.insert(tmp);
    vec.push_back(tmp);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ans=0;
  for (int i = 0; i < vec.size(); ++i)
  {
    vector<int> div=divisor(vec[i]);
    bool flag=true;
    for(const auto& e: div) 
    {
      if(e==vec[i])
      {
        st.erase(st.find(e));
        if(st.find(e)!=st.end()) flag=false;
        st.insert(e);
      }
      else if(st.find(e)!=st.end()) flag=false;
    }
    if(flag) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13436
#include <iostream>
//#include <math.h>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 2000;

int n,k;
ll fac[maxn+1];
ll rfac[maxn+1];
ll mod = INF;

ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll s=pow(x,y/2);
        return (s*s)%mod;
    }else{
        ll s=pow(x,(y-1)/2);
        return s*s%mod*x%mod;
    }
}

int main(){
    
    cin >> n>>k;
    
    fac[0]=fac[1]=rfac[0]=rfac[1]=1;
    
    for(ll i=1;i<=n;i++){
        fac[i]=fac[i-1]*i%mod;
    }
    
    rfac[n]=pow(fac[n],INF-2);
    
    for(ll i=n;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }
    
    for(ll i=1;i<=k;i++){
        if(n-k+1<i){
            cout << 0<<endl;
            continue;
        }
        ll Vp = fac[n-k+1]*rfac[i]%mod*rfac[n-k+1-i]%mod;
        ll ans = Vp*(fac[k-1]*rfac[i-1]%mod*rfac[k-i]%mod)%mod;
        cout << ans << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(min(b, d) - max(a, c), 0ll) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3556
def solve(s):
    for i, j in zip(range(0, len(s) - 1), range(1, len(s))):
        if s[i] == s[j]:
            return "%d %d" % (i + 1, j + 1)

    for i, j in zip(range(0, len(s) - 2), range(2, len(s))):
        if s[i] == s[j]:
            return "%d %d" % (i + 1, j + 1)

    return "%d %d" % (-1, -1)



print(solve(input()))


Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int main(){
int n;
cin >> n;
	cout << fib(n) << endl;

	return 0;
	
}

int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main (){
	char huruf[10];
	scanf ("%c", &huruf );
	
	int i=0;
 	if(huruf[i] >= 'A'&& huruf[i]<= 'Z') {
    puts ("A");
  }
   else {
    puts ("a");
  }
	
	return 0;
}

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

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

	long res = 0;
	unordered_map<string, int> count;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		res += count[s];
		count[s]++;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 10660
#include <iostream>

using namespace std;

int main(){
  int h1, h2, k1, k2, a, b, c, d;
  cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
  int ans1=0,ans2=0;
  ans1=h1*a+h2*b+(h1/10)*c+(h2/20)*d;
  ans2=k1*a+k2*b+(k1/10)*c+(k2/20)*d;
  string str;
  if(ans1>ans2){
    str = "hiroshi";
  }else if(ans1<ans2){
    str = "kenjiro";
  }else{
    str = "even";
  }
  cout<<str<<endl;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string S;
    cin>>S;
    int a=0;
    for(int i = 0;i < 4;i++){
        if(S[i] == S[i+1]){
            a+=1;
        }else{
            a+=0;
        }
    }
    if(a == 0){
        cout<<"Good"<<endl;
    }else {
        cout<<"Bad"<<endl;
}
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	ll N;
	cin >> N;
	vector<ll> xs = {3, 5, 7};
	vector<ll> ys;

	for(int k=0; k<9; k++){
		vector<ll> next;
		int n=xs.size();
		for(int i=0; i<n; i++){
			next.push_back(10*xs[i]+3);
			next.push_back(10*xs[i]+5);
			next.push_back(10*xs[i]+7);
		}
		if(k>0){
			for(int x: next) ys.push_back(x);
		}
		xs = next;
	}
	debug(any{(int)xs.size()});

	int ans = 0;
	for(ll x: ys){
		if(x<100||N<x) continue;
		bool p3 = false, p5 = false, p7 = false;
		ll y = x;
		while(x>0){
			p3 = p3 || x%10==3;
			p5 = p5 || x%10==5;
			p7 = p7 || x%10==7;
			x /= 10;
		}
		if(p3&&p5&&p7){
			ans++;
			debug(any{y});
		}
	}
	cout << ans << endl;


	return 0;
}


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

const long long MOD = (long long)1e9 + 7;

int main() {
  std::string L;
  std::cin >> L;
  int N = L.size();
  std::vector<int> A(N);
  int dp[101010][3][2];
  for (int i = 0; i < 101010; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 2; ++k)
	dp[i][j][k] = 0;
  for (int i = 0; i < N; ++i) {
    A[N - 1 - i] = L[i] - '0';
  }

  for (int i = 0; i < N; ++i) {
    for (int comp = -1; comp <= 1; ++comp) {
      for (int pending = 0; pending < 2; ++pending) {
	for (int a = 0; a <= 1; ++a) {
	  for (int b =0; b <= 1; ++b) {
	    if ((pending + a + b) % 2 != (a ^ b)) {
	      continue;
	    }
	    int npending = (pending + a + b) / 2;
	    int ncomp;
	    if ((pending + a + b) % 2 == A[i] && comp == 0) {
	      ncomp = 0;
	    } else if ((pending + a + b) % 2 > A[i] || ((pending + a + b) % 2 == A[i] && comp == 1)) {
	      ncomp = 1;
	    } else {
	      ncomp = -1;
	    }
	    if (i > 0)
	      dp[i][ncomp + 1][npending] += dp[i - 1][comp + 1][pending];
	    else if (comp == 0 && pending == 0)
	      dp[i][ncomp + 1][npending] += 1;
	    dp[i][ncomp+1][npending] %= MOD;
	  }
	}
      }
    }
  }
  std::cout << (dp[N - 1][0][0] + dp[N - 1][1][0]) % MOD << std::endl;
  
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    VI s(n);
    rep(i,n){
        cin >> s[i];
    }

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

    int sum = 0;
    rep(i,n) sum += s[i];

    if(sum % 10 != 0){
        cout << sum << endl;
    }else{
        rep(i,n){
            if(s[i]%10 != 0){
                cout << (sum - s[i]) << endl;
                break;
            }
            if(i == n-1){
                cout << 0 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long x = Long.parseLong(st.nextToken());
        long ways = (x / 11)*2;
        long left = x % 11;
        if(left <= 6 && left > 0)++ways;
        else if(left > 6 && left <= 10)
            ways += 2;
        System.out.println(ways);
    }
}

Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,K;
  cin>>n>>K;
  
  vector<int>T(n);
  cin>>T;

  vector<int> L;
  for(int i=0;i<n-1;i++){
    int l = T[i+1] - T[i];
    L.push_back(l-1);
  }
  sort(L.begin(),L.end());

  int ans = n;
  for(int i=0;i<n - K;i++) ans += L[i];
  cout<<ans<<endl;     
  
  return 0;
}



Measured memory_bytes: 4728
eval"N,*A="+`dd`.split*?,;p (0..2*N).bsearch{|x,*y|N.times{|i|[-1,1].map{|s|A[j=N-1+i*s]>x==A[j+s]&.>(x)&&y<<=A[j]<=x}};y[0]}

Measured memory_bytes: 57856
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A1 = LI()
A2 = LI()
ans = 0
for i in range(N):
    tmp = sum(A1[0:i+1]) + sum(A2[i:])
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 38768
n, k = map(int, input().split())
l = []
for _ in range(n):
  l.append(int(input()))
l.sort()
ans = l[k-1] - l[0]
for i in range(n-k+1):
  if ans > l[i+k-1] - l[i]:
    ans = l[i+k-1] - l[i]
print(ans)

Measured memory_bytes: 7384
import heapq


class PriorityQueue:
    def __init__(self):
        self.__heap = []
        self.__count = 0

    def empty(self) -> bool:
        return self.__count == 0

    def dequeue(self):
        if self.empty():
            raise Exception('empty')
        self.__count -= 1
        return heapq.heappop(self.__heap)

    def enqueue(self, v):
        self.__count += 1
        heapq.heappush(self.__heap, v)

    def __len__(self):
        return self.__count


def dijkstra(s: int, t: int, V: int, edges: list) -> int:
    '''dijkstra method
    :param s: start
    :param t: finish
    :param V: number of vertexes
    :param edges: collection of edges
    :return: minimum distance from u to v
    '''
    d = [float('inf')] * V
    d[s] = 0

    q = PriorityQueue()
    q.enqueue((d[s], s))

    while not q.empty():
        _, u = q.dequeue()
        for v, cost in edges[u]:
            alt = d[u] + cost

            if alt < d[v]:
                d[v] = alt
                q.enqueue((d[v], v))

    return d[t]


def wall(H: int, W: int, C: list, A: list) -> int:
    # 1 から各数字への最短距離を計算する
    edges = [[(v, C[u][v]) for v in range(10)] for u in range(10)]
    min_dist = [dijkstra(i, 1, 10, edges) for i in range(10)]

    return sum(
        min_dist[a]
        for row in A
        for a in row if a >= 0)


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    C = [[int(s) for s in input().split()] for _ in range(10)]
    A = [[int(s) for s in input().split()] for _ in range(H)]
    ans = wall(H, W, C, A)
    print(ans)


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

int cnt;

void insertionSort(int A[], int n, int g) {
  for(int i = g; i <= n-1; ++i) {
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  cnt = 0;
  int g[] = {797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1};

  int M = sizeof(g)/sizeof(int);
  vector<int> G;
  for(int i = M-1; i >= 0; --i) G.push_back(g[i]);
  int m = 0;
  while(m < M && G[m] <= n) ++m;
  G.resize(m);
  reverse(G.begin(), G.end());

  cout << m << endl;
  for(int i = 0; i < m; ++i) {
    if(i) cout << " ";
    cout << G[i];
  }
  cout << endl;

  for(int i = 0; i <= m-1; ++i) {
    insertionSort(A, n, G[i]);
  }
  cout << cnt << endl;
  for(int i = 0; i < n; ++i) {
    cout << A[i] << endl;
  }
}

int n;
int A[1000000];

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> A[i];
  shellSort(A, n);
  return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
	int n;
	while(1){
cin>>n;
if(n==0)break;
int u=5,m=1,d=2,r=3,l=4;
int temp,sum=1;
string w;
for(int i=0;i<n;i++){
cin>>w;
if(w=="North"){
temp=d;
d=7-m;
u=m;
m=temp;
sum+=m;
}else if(w=="East"){
temp=l;
l=7-m;
r=m;
m=temp;
sum+=m;
}else if(w=="South"){
temp=u;
u=7-m;
d=m;
m=temp;
sum+=m;
}else if(w=="West"){
temp=r;
r=7-m;
l=m;
m=temp;
sum+=m;
}else if(w=="Right"){
temp=d;
d=r;
r=u;
u=l;
l=temp;
sum+=m;
}else if(w=="Left"){
temp=d;
d=l;
l=u;
u=r;
r=temp;
sum+=m;
}

}
cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3052
MOD = 1000000007
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
is_broken = [False for _ in range(N+1)]
for a in A:
  is_broken[a] = True

# dp[i] = (i段目に辿り着くルートの総数)

# init 
dp = [0]*(N+1)
dp[0] = 1

# DP
for i in range(N):
  if not is_broken[i+1]:
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
  if i+2 <= N:
    if not is_broken[i+2]:
      dp[i+2] += dp[i]
      dp[i+2] %= MOD

print(dp[N])

Measured memory_bytes: 8624
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  i := 1
  for {
   x := nextInt()
   if x == 0 { 
       break
   }   
   fmt.Println("Case "+ strconv.Itoa(i) +": " + strconv.Itoa(x))
   i++ 
  }
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll kazu = 0;
  cin >> kazu;
  /*vector<string> str(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> str[i];
  }*/
  map<string,int> dic;
  ll kotae = 0;
  for(int i = 0;i <= kazu - 1;i++){
    string str;
    cin >> str;
    sort(str.begin(),str.end());
    //cout << str << endl;
    dic[str]++;
    if(dic[str] >= 2){
      kotae += dic[str] - 1;
    }
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

/*
int n,k;
int dp[2222];

signed main(){
	cin>>n>>k;

	for(int i=1;i<=k;i++){
		memset(dp,0,sizeof(dp));
		dp[0]
	}

}
*/

int n,m;
vector<int>v[100009];
int dp[100009][4];
int s,t;

signed main(){
	r(i,100009)r(j,4)dp[i][j]=1e9;
	cin>>n>>m;
	r(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
	}
	cin>>s>>t; s--;t--;
	priority_queue<P2,vector<P2>,greater<P2> >q;
	q.push(P2(0,P(s,0)));
	dp[s][0]=0;

	while(!q.empty()){
		P2 p=q.top();q.pop();
		int cost=p.F;
		int now=p.S.F;
		int X=p.S.S;

		//cout<<now<<' '<<X<<endl;

		r(i,v[now].size()){
			int nex=v[now][i];
			int nx=(X-1+3)%3;
			int ncos=cost;
			if(X==0)ncos++;
			//cout<<nex<<' '<<nx<<endl;
			if(dp[nex][nx] <= ncos)continue;
			dp[nex][nx] = ncos;
			q.push(P2(ncos,P(nex,nx)));
		}
	}

	if(dp[t][0]==1e9)cout<<-1<<endl;
	else cout<<dp[t][0]<<endl;
}

Measured memory_bytes: 11120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll a,b; cin >> a >> b;
    string sa,sb;
    for(int i = 0; i < b;i++){
        sa += to_string(a);
    }
    for(int i = 0; i < a;i++){
        sb += to_string(b);
    }
    res = min(sa,sb);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

char GetNext(char c, char p, char s) {
  static constexpr char var[][2][2] = {
    {{'S', 'W'}, {'W', 'S'}}, {{'W', 'S'}, {'S', 'W'}},
  };
  c = (c == 'S') ? 0 : 1;
  p = (p == 'S') ? 0 : 1;
  s = (s == 'o') ? 0 : 1;
  return var[c][p][s];
}

string Solve(const string& s) {
  const int N = s.size();

  for (string r : {"SS", "SW", "WS", "WW"}) {
    for (int i = 1; i < N; ++i) {
      r.push_back(GetNext(r[i], r[i - 1], s[i]));
    }
    r.push_back(GetNext(r[N], r[N - 1], s[0]));
    if (r[N] == r[0] && r[N + 1] == r[1])
      return r.substr(0, N);
  }
  return "-1";
}

int main() {
  int N;
  string s;
  cin >> N >> s;
  cout << Solve(s) << "\n";
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] arg) {

        string tmp = Console.ReadLine();
        char[] s = new char[3]; 
        s = tmp.ToCharArray();
        bool isConnected = false;
        
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (s[i] != s[j])
                {
                    isConnected = true;
                    break;
                }
            }
            if (isConnected)
            {
                break;
            }
        }

        if (isConnected)
        {  
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
        
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, K; cin >> N >> K;
    map<int, ll> cnts;
    ll ans = 0;
    cnts.insert({0, 1});
    ll pre = 0;
    ll prefs[N+1]; prefs[0] = 0;
    F0R(i, N) {
        int A; cin >> A; A--;
        pre += A; pre %= K;
        prefs[i+1] = pre;
        if (i >= K-1) {
            cnts[prefs[i-K+1]]--;
        }
        if (cnts.count(pre)) {
            ans += cnts[pre]; cnts[pre]++;
        } else {
            cnts.insert({pre, 1});
        }
    }

    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 14336
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    cout << n/3 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static int N;
    static int[] A;
    static int[] anser;

    static void Main(string[] args)
    {
         N = GetInputInt();
         A = GetInputsInt();
         anser = new int[N+1];

        List<int> aList = new List<int>();

        int n2 = N / 2 +1;
        for (int i = N; i >= n2; i--)
        {
            anser[i] = A[i-1];
            if (anser[i] == 1) aList.Add(i);
        }
        for (int i = n2-1; i > 0; i--)
        {
            anser[i] = A[i-1];

            int total = 0;
            int numTotal = i + i;

            while(numTotal <= N)
            {
                total += anser[numTotal];
                numTotal += i;
            }
            
            if(A[i-1] != total % 2)
            {
                anser[i] = 1;
            }
            else
            {
                anser[i] = 0;
            }
            if (anser[i] == 1) aList.Add(i);
        }

        Console.WriteLine(aList.Count);
        if (aList.Count > 0) {
            for (int i = 0; i < aList.Count-1; i++)
            {
                Console.Write(aList[i] + " ");
            }
            Console.Write(aList[aList.Count-1]);
        }
    }

    

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

int n ,m;
vector <pair<int ,int>> ps;

int main()
{
    scanf("%d%d",&n,&m);
    for(int a,b,i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        ps.push_back({m-a ,b});
    }

    sort(ps.begin() ,ps.end());
    multiset <int> best;
    int ans = 0;
    for(int ps_ptr=ps.size()-1 ,d=n-1; ~d; d--){
        while(~ps_ptr && ps[ps_ptr].first >= d)
            best.insert(ps[ps_ptr--].second);
        if(!best.empty()){
            ans += *prev(best.end());
            best.erase(prev(best.end()));
        }
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 5620
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

long long solve(string &s, int left, int right) {
    if (left >= right)
        return 0;

    if (s[left] != 'x' && s[right] != 'x' && s[left] != s[right])
        return -1;
    else if (s[left] == 'x' && s[right] != 'x') {
        long long res = solve(s, left + 1, right);
        if (res == -1)
            return -1;
        return res + 1;
    }
    else if (s[left] != 'x' && s[right] == 'x') {
        long long res = solve(s, left, right -1);
        if (res == -1)
            return -1;
        return res + 1;
    }
    else {
        return solve(s, left + 1, right - 1);
    }
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    cout << solve(s, 0, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 6784
#coding:utf-8
#1_11_C

class Dice:
    def __init__(self, ary):
        self.top, self.south, self.east, self.west, self.north, self.bottom = ary

    def roll_n(self):
        self.top, self.north, self.bottom, self.south = self.south, self.top, self.north, self.bottom

    def roll_e(self):
        self.top, self.east, self.bottom, self.west = self.west, self.top, self.east, self.bottom

    def twist(self):
        self.north, self.east, self.south, self.west = self.west, self.north, self.east, self.south

    def isEqual(self, dice):
        if self.top == dice.top and self.south == dice.south and self.east == dice.east and self.west == dice.west and self.north == dice.north and self.bottom == dice.bottom:
            return True
        else:
            return False

def isSame(diceX,diceY):
    flag = False
    
    for i in range(6):
        if i % 2 == 0:
            diceX.roll_n()
        else:
            diceX.roll_e()
    
        for j in range(4):
            if diceX.isEqual(diceY):
                flag = True
                break
            else:
                diceX.twist()
    
        if flag:
            break
    
    if flag:
        return True
    else:
        return False

n = int(input())
dices = [Dice(map(int,input().split())) for i in range(n)]

flag = False
for i in range(len(dices)):
    for j in range(i+1, len(dices)):
        if isSame(dices[i],dices[j]):
            flag = True

if not flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6776