akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
 
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define reps(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
 
string n, a, b, c;
long long int i, j, k;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> i >> j >> k;

    int cnt = 0;
    if (i == 0) {
        ++cnt;
    }

    if(i<=k){
        cout << cnt + (j/k) << '\n';
    } else {
        if (i%k == 0) {
            cout << cnt + (j/k - i/k) + 1 << '\n';
        } else {
            cout << cnt + (j/k - i/k) << '\n';            
        }
    }

    return 0;
}

Measured memory_bytes: 384
N,L=map(int,input().split())
all = sum([L+i-1 for i in range(1, N+1)])
anss = []
for j in range(1, N+1):
    tmp = sum([L+i-1 for i in range(1, N+1) if i != j])
    anss.append((abs(all-tmp), tmp))
anss.sort()
print(anss[0][1])


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

int main() {
  int N;
  int D;

  cin >> N >> D;

  int total = 0;

  for(int i=0;;i++) {
    total++;
    if((2 * D + 1) * total >= N) {
      break;
    }
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}

int f10to753(int n, int digit) {
	int n753 = 0;
	bool flag[3] = {false, false, false};
	for (int i=0; i<digit; i++) {
		flag[n%3] = true;
		int tmp = 3 + (n%3)*2;
		n753 += tmp*pow(10,i);
		n /= 3;
	}

	bool flag_and = (flag[0] && flag[1] && flag[2]);
	if (flag_and) {
		return n753;
	} else {
		return pow(10,9);
	}
}

int main(int argc, char *argv[]){
	int N;
	cin >> N;

	int ans = 0;
    for (int j=3; j<=9; j++) {
    	for (int i=0; i<=pow(3,j)-1; i++) {
    		if (f10to753(i,j) <= N) {
    			ans++;
    		}
    	}
    }

	cout << ans << endl;
}

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

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

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

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 888
#include <cstdio>
long double calc(int n,long double d,long double x){
	if (!n) return 0;
	return d+0.5*x*(n-1)+calc(n-2,d+(2*d+5*x)/n,x+4*x/n);
}
int main(){
	int n,d,x;
	scanf("%d%d%d",&n,&d,&x);
	double ans=calc(2*n,d,x);
	printf("%.10f\n",ans);
}

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    //int v;
    if(((n % 10) == 2) || ((n % 10) == 4) || ((n % 10) == 5) || ((n % 10) == 7) || ((n % 10) == 9)){
        cout << "hon" << endl;
    }
    else if(((n % 10) == 0) || ((n % 10) == 1) || ((n % 10) == 6) || ((n % 10) == 8)){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll inf=1e18;
const ld pai=acos(-1);
ll n;
string s;
ll dp[3009][3009];
ll sum[3009][3009];
int main(){
	cin>>n>>s;
	s=' '+s;
	dp[0][1]=1;
	for(ll i=1;i<=n;i++)sum[0][i]=1;
	for(ll i=1;i<s.size();i++){
		for(ll j=1;j<=i+1;j++){
			if(s[i]=='>')dp[i][j]=sum[i-1][n]-sum[i-1][j-1]+mod;
			else dp[i][j]=sum[i-1][j-1];
			dp[i][j]%=mod;
		}
		for(ll j=1;j<=n;j++)sum[i][j]=dp[i][j]+sum[i][j-1],sum[i][j]%=mod;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)ans+=dp[n-1][i],ans%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 141568
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

string s;
cin>>s;
long long k;
cin>>k;

for(int i=0;i<s.size()-1;i++){

    if(s[i]=='a')continue;
    if(26-(s[i]-'a')<=k){
        k-=26-(s[i]-'a');
        s[i]='a';
    }
}
k%=26;
s[s.size()-1]='a'+((s[s.size()-1]-'a')+k)%26;

rep(i,s.size()){
    cout<<s[i];
}


return 0;

}
/*
xyz
4

aya

a
25

z

codefestival
100

aaaafeaaivap
*/


Measured memory_bytes: 512
#include<cstdio>  
#include<string>  
#include<iostream>  
#include<cstring>  
#include<algorithm>  
using namespace std;  
typedef long long LL;  
const int INF = 0x7FFFFFFF;  
const int maxn = 1e5 + 10;  
   
int a[11],vis[11],flag;  
  
void dfs(int x,int l,int r)  
{  
    int i;  
    if(x==11)return;   
    if(flag)return;  
    if(a[x]>l)dfs(x+1,a[x],r);  
    else if(a[x]>r)dfs(x+1,l,a[x]);  
    else{flag=1;return;}  
}  
  
int main()  
{  
  int T,i,j,k;  
  scanf("%d",&T);  
  while(T--)  
  {  
    flag=0;  
    for(i=1;i<=10;i++)  
      scanf("%d",&a[i]);  
    memset(vis,0,sizeof(vis));  
    dfs(1,0,0);  
    if(flag)printf("NO\n");  
    else printf("YES\n");  
  }  
 return 0;  
}  

Measured memory_bytes: 3024
import itertools

N,Q = map(int,input().split())
S = input()

b = [S[i]=='A' and S[i+1]=='C' for i in range(N-1)]
b.insert(0,0)
b = list(itertools.accumulate(b))

for _ in range(Q):
    l,r = map(int,input().split())
    print(b[r-1]-b[l-1])

Measured memory_bytes: 52240
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]a = new int[N];
			for(int i = 0;i<N;i++)a[i] = scan.nextInt();
			int saisyou = N;
			int count = 1;
			int nokosu = 0;
			
			
			for(int i=0;i<N;i++) {
				if(a[i]==count) {
					saisyou--;
					count++;
				}
			}
			
			System.out.println(saisyou==N?-1:saisyou);
			
		}
		
		
	}
		

}


Measured memory_bytes: 80400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main() {
	string S;
	int K;
	int d;
	cin >> K >> S;
	
	if( (int)(S.length()) <= K ){
		cout << S;
	}
	else {
		cout << S.substr(0,K) +"...";
	}

	return 0;
}

Measured memory_bytes: 3628
rating=int(input())



if rating>=400 and rating <=599:
  print('8')
elif rating>=600 and rating <=799:
  print('7')
elif rating>=800 and rating <=999:
  print('6')
elif rating>=1000 and rating <=1199:
  print('5')
elif rating>=1200 and rating <=1399:
  print('4')
elif rating>=1400 and rating <=1599:
  print('3')
elif rating>=1600 and rating <=1799:
  print('2')
elif rating>=1800 and rating <=1999:
  print('1')



Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define int ll
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define mkp make_pair
#define INF (ll)(1e17)
#define MOD (ll)(998244353)

int app[100010];
int sum[100010];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	//I won't misunderstand the problem statement anymore.
	memset(app,-1,sizeof(app));
	memset(sum,0,sizeof(sum));
	int n,x,m; cin>>n>>x>>m;
	int now=x;
	app[now]=1;
	sum[1]=x;
	int end=-1;
	int len=-1;
	For(i,2,m+5){
		now=(now*now)%m;
		if(app[now]!=-1){
			end=i;
			len=i-app[now];
			break;
		}
		sum[i]=now+sum[i-1];
		app[now]=i;
	}
	if(n<=len){
		cout<<sum[n]<<"\n";
		return 0;
	}
	int k=(n-end+1)/len+1;
	int s=sum[end-1]-sum[end-len-1];
	int left=(n-end+1)%len;
	int ans=(k*s+sum[left+end-len-1]);
	cout<<ans<<"\n";
	return 0;
}























Measured memory_bytes: 5208
x = int(input())
maxi = 0
for i in range(2,x+1):
  p = 2
  while True:
    if i ** p <= x:
      if maxi < i ** p:
        maxi = i ** p
      p += 1
    else:
      break
if x <= 3:
  print(1)
else:
  print(maxi)

Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

/**
 * AOJ id = 2021
 * @author scache
 *
 */
public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}
	
	private final int MAX = 1000000;

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)
				break;
			int m = sc.nextInt();
			int l = sc.nextInt();
			int k = sc.nextInt();
			int a = sc.nextInt();
			int h = sc.nextInt();
			
			boolean[] cold = new boolean[n];
			cold[a] = cold[h] = true;
			for(int i=0;i<l;i++)
				cold[sc.nextInt()] = true;
				
			int[][] map = new int[n][n];
			for(int i=0;i<n;i++)
				Arrays.fill(map[i], MAX);
			for(int i=0;i<k;i++){
				int ac = sc.nextInt();
				int bc = sc.nextInt();
				int cc = sc.nextInt();
				map[ac][bc] = cc;
				map[bc][ac] = cc;
			}
			
			solve(n, m, cold, k, map, a, h);
		}
	}

	
	public void solve(int n, int m, boolean[] cold, int k, int[][] map, int a, int h) {
		
		for(int kk=0;kk<n;kk++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[i][j] = Math.min(map[i][j], map[i][kk]+map[kk][j]);
				}
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
//				int mm = i==h || j==h ? m : m+1;
				map[i][j] = (cold[i] && cold[j] && map[i][j]<=m )? map[i][j] : MAX;
			}
		}
		for(int kk=0;kk<n;kk++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					map[i][j] = Math.min(map[i][j], map[i][kk]+map[kk][j]);
				}
			}
		}
		int res = map[a][h]+Math.max(0, map[a][h]-m);
		System.out.println(res >= MAX ? "Help!" : res);
	}

}

Measured memory_bytes: 63808
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
  color[v] = cur;

  for (auto next_v : G[v]) {
    // 隣接頂点の色がすでに確定していた場合
    if (color[next_v] != -1) {
      if (color[next_v] == cur) return false; // 同色が隣接したらNG
      continue;
    }

    // 隣接頂点の色を変えて、再帰的に探索
    // (一度でも false が帰ってきたら false で終了)
    if (!dfs(G, next_v, 1 - cur)) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // 頂点数と辺数
  ll N, M; cin >> N >> M;

  // グラフ入力受取
  Graph G(N);
  for (ll i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // 探索
  color.assign(N, -1);
  bool is_bipartite = dfs(G, 0);

  if (is_bipartite) {
    ll B = 0, W = 0;
    for (ll i = 0; i < N; i++) {
      color[i] == 0 ? B++ : W++;
    }
    cout << B * W - M << endl;
  } else {
    cout << N * (N - 1) / 2 - M << endl;
  }
}


Measured memory_bytes: 6528
N = int(input())
A = list(sorted(map(int, input().split())))

setA = set(A)

if A.count(0) == N:
    print('Yes')
elif len(setA) == 2 and A.count(0) == N / 3:
    print('Yes')
elif len(setA) == 3:
    setA = list(setA)
    x = setA[0]
    y = setA[1]
    z = setA[2]
    if x ^ y ^ z == 0 and A.count(x) == N / 3 and A.count(y) == N / 3:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 14836
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int A=0;
		int last=0;
		for(int i=2;i*i<=a;i++){
			if(a%i==0){
				A-=i;
				last=i;
				while(a%i==0)a/=i;
			}
		}
		if(a!=1){
			A-=a;
			last=a;
		}
		A+=last*2;
		int B=0;
		last=0;
		for(int i=2;i*i<=b;i++){
			if(b%i==0){
				B-=i;last=i;while(b%i==0)b/=i;
			}
		}
		if(b!=1){
			B-=b;last=b;
		}
		B+=last*2;
		if(A>B)printf("a\n");else printf("b\n");
	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    rep(i, K){
        if(C<=B) C*=2;
        else if(B<=A) B*=2;
    }
    if(A<B&&B<C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}


Measured memory_bytes: 3632
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 5001

int n, k;
char s[MAXN];

int input() {
	if (scanf("%s %d", s, &k) < 0) return 0;
	return 1;
}

void init() {
}

string solve() {
	n = strlen(s);
	set<string> ss;
	for (int i=0; i<n; i++) {
		for (int j=1; j<=k && j<=n-i; j++) {
			ss.insert(string(s+i, s+i+j));
		}
	}
	vector<string> a(ss.begin(), ss.end());
	return a[k-1];
}

void output(string ans) {
	printf("%s\n", ans.c_str());
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

int main(){
	while(1){
		long n, ans=0;
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		while(n!=1){
			if(n%2==0) n/=2;
			else n=3*n+1;
			++ans;
		}
		
		printf("%ld\n", ans);
	}
	return 0;
}
		

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int ans=0;
  for(Int i=0;i<n;i++){
    string s;
    cin>>s;
    ans+=s=="E869120";
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}



int mo(int a,int b){
  int g = gcd(a, b);
  return a / g;
}

int d[10000];
vector<int> c;
int all = 0;
int N;
vector<vector<int> > tp(10000);
void dfs(int parent,int idx){
  d[idx] = c[all];
  all++;
  REP(i, 0, tp[idx].size())
  {
    
    if(tp[idx][i]!=parent){
      dfs(idx, tp[idx][i]);
    }
  }
}

int main()
{
  cin >> N;
  tp.resize(N);
  REP(i, 0, N-1)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tp[a].push_back(b);
    tp[b].push_back(a);
  }
  REP(i,0,N){
    int cc;
    cin >> cc;
    c.push_back(cc);
  }

  sort(c.begin(), c.end(), greater<int>());

  dfs(-1, 0);

  int ans = 0;
  REP(i,1,N){
    ans += c[i];
  }
  cout << ans << endl;
  REP(i,0,N){
    if(i!=N-1){
    cout << d[i] << " ";
    }else{
      cout << d[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, K, ans=0;
    in2(N, K);
    rep(i, N){
        if(!i) ans += K;
        else ans *= K-1;
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
const LL MOD = 1e9 + 7;
const int MXN = 100005;
LL comb[MXN], invcomb[MXN];

LL extgcd(LL a, LL b, LL &x, LL &y)
{
    LL d = a;
    if (b)
    {
        d = extgcd(b, a % b, y, x), y -= (a / b) * x;
    }
    else
        x = 1, y = 0;
    return d;
} // ax+by=1 ax同餘 1 mod b

LL inv(LL a)
{
    LL x, y, b = MOD;
    extgcd(a, b, x, y);
    while(x >= MOD)
    {
        x -= MOD;
    }
    while(x < 0)
    {
        x += MOD;
    }
    return x;
}

void pre()
{
    comb[0] = 1;
    invcomb[0] = 1;
    for(int i = 1; i < MXN; ++i)
    {
        comb[i] = (comb[i - 1] * i) % MOD;
        invcomb[i] = inv(comb[i]);
    }
}

LL choose(int m, int n)
{
    LL ans = comb[m];
    ans = (ans * invcomb[m - n]) % MOD;
    ans = (ans * invcomb[n]) % MOD;
    return ans;
}

int main()
{
    IOS;
    int n, k;
    vector<int> v;
    pre();

    cin >> n >> k;
    v.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    LL ans = 0;

    for (int i = k - 1; i < n; ++i)
    {
        LL cnt = choose(i, k - 1);
        // cout << i << ' ' << k - 1 << ' ' << cnt << ' ' << v[i] << '\n';
        LL tmp = ((v[i] % MOD) * cnt) % MOD;
        ans = (ans + tmp) % MOD;
    }

    for (int i = n - k; i >= 0; --i)
    {
        LL cnt = choose(n - i - 1, k - 1);
        // cout << n - i - 1 << ' ' << k - 1 << ' ' << cnt << ' ' << v[i] << '\n';
        LL tmp = ((v[i] % MOD) * cnt) % MOD;
        ans = (ans - tmp + MOD) % MOD;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	int co=0;
	rep(i,n){
		int a;cin>>a;
		if(a%4==0)co+=2;
		else if(a%2==0)co++;
	}
	if(co>=n/2*2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}









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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        std::string S;
        std::cin >> S;

        if(S == "Y"){
            std::cout << "Four" << std::endl;
            return 0;
        }
    }

    std::cout << "Three" << std::endl;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string str;
	int k;
	cin >> str >> k;
	int n=(int)str.size();
	long long mod=998244353;
	
	k=min(k,303);
	
	vector<int> a;
	int cccc=0;
	for(int i=0;i<n;i++){
		if(str[i]=='0'){
			a.push_back(cccc);
			cccc=0;
		}else{
			cccc++;
		}
	}
	a.push_back(cccc);
	n=(int)a.size();
	
	vector<vector<vector<long long>>> dp(n+1,vector<vector<long long>>(k+1,vector<long long>(k+1)));
	
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		//subtract or nothing
		for(int j=0;j<=a[i];j++){
			for(int h=j;h<=k;h++){
				for(int s=0;s<=k;s++){
					if((h-j)>=0) dp[i+1][h-j][s]=(dp[i+1][h-j][s]+dp[i][h][s]);
					if(dp[i+1][h-j][s]>=mod) dp[i+1][h-j][s]-=mod;
				}
			}
		}
		//add
		for(int j=1;j<=k;j++){
			for(int h=0;h<=k;h++){
				if((h+j)>k) break;
				for(int s=0;s<=k;s++){
					if((s+j)>k) break;
					dp[i+1][h+j][s+j]+=dp[i][h][s];
					if(dp[i+1][h+j][s+j]>=mod) dp[i+1][h+j][s+j]-=mod;
				}
			}
		}
	}
	
	long long res=0;
	for(int i=0;i<=k;i++){
		res=(res+dp[n][0][i])%mod;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 115248
#include<bits/stdc++.h>
using namespace std;
int a,b,c,sum;
int main()
{
    cin>>a>>b>>c; 
    sum=a; 
    while(sum%b!=c && sum<=a*1000) 
        sum+=a;
    if(sum%b==c)
        cout<<"YES"<<endl; 
        else
        cout<<"NO"<<endl; 
    return 0;
}

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

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

const int lbd[9]={1,400,800,1200,1600,2000,2400,2800,3200};

int eval(int x) {
	for (int i=8; i>=0; i--)
		if(x>=lbd[i])
			return i;
	return -1;
}

int getmin(int x, int y) {
	if(!x) {
		if(!y) return 0;
		else return 1;
	} else return x;
}

int getmax(int x, int y) {
	return x+y;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<int,int> ct;
	for (int i=0; i<n; i++) {
		int x; cin>>x; 
		ct[eval(x)]++;
	}
	int cur=0, add=0;
	for (int i=0; i<8; i++)
		if(ct[i])
			cur++;
	add=ct[8];
	cout<<getmin(cur,add)<<" "<<getmax(cur,add)<<"\n";
	return 0;
}

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

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

    vector<int> two = {1, 2, 4, 8, 16, 32, 64};
    int max = 64;
    for (int i=1; i < two.size(); i++){
        if (two.at(i) > N){
            max = two.at(i-1);
            break;

        } 
    }
    
    cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

LL a[2000];
LL b[2000];

int main(void){
    int N;LL x;
    cin>>N>>x;
    REP(i,N){
        cin>>a[i];
        b[i]=a[i];
    }
    LL ans=LLMAX;
    REP(i,N+1){
        LL r=0;
        REP(j,N)
            r+=b[j];
        ans=min(r+x*(LL)i,ans);
        REP(j,N)
            b[j]=min(b[j],a[(j-i-1+N)%N]);
    }
    cout<<ans<<endl;
     return 0;
}

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

struct Answer
{
	int m;
	vector<int> G;
	int cnt;
};

void insertionSort(vector<int> &A, int &g, int &cnt)
{
	for(int i = g; i < A.size(); 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;
	}
}

vector<int> FindShellSortNumber(int n)
{
	int g = 1;
	vector<int> G;
	while(g <= n){
		G.push_back(g);
		g = 3 * g + 1;
	}
	int size = G.size();
	for(int i = 1; i <= size / 2; i++){
		swap(G[i-1], G[size-i]);
	}
	return G;
}

Answer shellSort(vector<int> &A)
{
	Answer Result;
	Result.cnt = 0;
	Result.G   = FindShellSortNumber(A.size());
	Result.m   = Result.G.size();
	for(int i = 0; i < Result.m; i++){
		insertionSort(A, Result.G[i], Result.cnt);
	}
	return Result;
}

int main()
{
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	Answer Result = shellSort(A);
	cout << Result.m << endl;
	for(int i = 0; i < Result.G.size() - 1; i++){
		cout << Result.G[i] << ' ';
	}
	cout << Result.G[Result.G.size() - 1] << endl;
	cout << Result.cnt << endl;
	for(int i = 0; i < A.size(); i++){
		cout << A[i] << endl;
	}
	return 0;
}

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

#define MAXN 200005

int s[MAXN];

int main(void)
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>s[i];
    for(int i=k+1;i<=n;++i){
        if(s[i]<=s[i-k]){
            puts("No");
        }
        else puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
long long N, A[87], CurrentMoney = 1000;
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N - 1; i++) {
  long long Stocks = 0;
  if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
    CurrentMoney += (A[i + 1] - A[i]) * Stocks;
  }
  cout << CurrentMoney << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
typedef long long int ll;
 
using namespace std;
 
const ll INF = 1e17;
ll N;
ll a[300000];
ll l[300000];
ll r[300000];
map<ll, ll> dp[300000];
 
int main() {
  cin >> N;
  for (int i=0; i<N; i++)
    cin >> a[i];
  for (int i=0; i<N/2; i++) {
    l[i] = 2*i;
    r[N/2-1-i] = (N-1) - 2*i;
  }
  // for (int i=0; i<N/2; i++) {
  //   cout << l[i] << "-" << r[i] << endl;
  // }
  for (int j=l[0]; j<=r[0]; j++)
    dp[0][j] = a[j];
  for (int i=1; i<N/2; i++) for(int j=l[i]; j<=r[i]; j++) {
    dp[i][j] = -INF;
    for (int bj=l[i-1]; bj<=min(r[i-1], (ll)j-2); bj++) {
      dp[i][j] = max(dp[i][j], a[j] + dp[i-1][bj]);
    }
    // printf("dp[%d][%d]=%ld\n", i, j, dp[i][j]);
  }
  ll ans = -INF;
  for (int j=l[N/2-1]; j<=r[N/2-1]; j++) {
    ans = max(ans, dp[N/2-1][j]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39572
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N = (1<<27);
vector<bool> dp(N, false);
vector<bool> flag(N, false);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string s;
  cin >> s;

  bool flag1 = s[0]==s[s.size()-1];
  bool flag2 = s.size()%2==0;

  if(!(flag1^flag2)) cout << "First\n";
  else cout << "Second\n";

  return 0;
}


Measured memory_bytes: 33280
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;ll
#define Nmax 400005
#define OFF 100001
using namespace std;

ll n,k,s[Nmax],s2[Nmax],x;
int main()
{
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> x;
        s[i] = s[i-1] + max(0LL,x);
        s2[i] = s2[i-1] + x;
    }
    ll ans = 0;
    for (int i=k;i<=n;i++){
        ans = max(ans, s[i-k] + s[n] - s[i] + max(0LL,s2[i] - s2[i-k]));
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int n; cin >> n;
    ll ans = 1;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if(n%2){
        if(a[0]) ans = 0;
        for(int i = 1; i < n; i += 2){
            if(a[i] == i+1) ans = ans*2 % MOD;
            else ans = 0;
            if(a[i+1] != i+1) ans = 0;
        }
    }
    else{
        for(int i = 0; i < n; i += 2){
            if(a[i] == i+1) ans = ans*2 % MOD;
            else ans = 0;
            if(a[i+1] != i+1) ans = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
long double dp[300+1][300+1][300+1];
int main()
{
  ll i,j,n,k,m,count[4]={0};
  cin>>n;
  for(i=0;i<n;i++)
  {
          cin>>j;
          count[j]=count[j]+1;
  }
  
 for(k=0;k<=count[3];k++)
       for(j=0;j<=count[2];j++)
           for(i=0;i<=count[1];i++)
             dp[i][j][k]=0;
               
  for(k=0;k<=300;k++)
       for(j=0;j<=300;j++)
           for(i=0;i<=300;i++)
           {
               if(i+j+k==0)
                 continue;
               double ff=n,f1=i,f2=j,f3=k;
               dp[i][j][k]+=ff/(f1+f2+f3);
               if(i-1>=0)  
                dp[i][j][k]+=f1*(dp[i-1][j][k])/(f1+f2+f3);
               if(i+1<=300&&j-1>=0) 
                dp[i][j][k]+=f2*(dp[i+1][j-1][k])/(f1+f2+f3);
               if(j+1<=300&&k-1>=0) 
                dp[i][j][k]+=f3*(dp[i][j+1][k-1])/(f1+f2+f3);
           }
  printf("%.15Lf",dp[count[1]][count[2]][count[3]]);
  return 0;
}


Measured memory_bytes: 426368
X, K, D = map(int,input().split())

if X < 0: X = -X

if X >= D*K:
    print(X - D*K)
else:
    moves = X // D
    K -= moves
    X = X - D * moves    

    if K % 2 == 0:
        print(X)
    else:
        print(abs(X-D))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  // ここにプログラムを追記
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n;
    map<int, int> mp;

    cin >> n;

    irep(i, n-1) {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    
    irep(i, n) {
        cout << mp[i+1] << endl;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 12976
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h,n = mi()
a = []
for i in range(n):
    aa,bb = mi()
    a.append([aa,bb])
inf =  10 **9   
dp = [inf] * (h+1)
dp[0] = 0
for i in range(n):
    for j in range(h):
        if j + a[i][0] <= h:
            dp[j + a[i][0]] = min(dp[j+a[i][0]],dp[j] + a[i][1])
        else:
            dp[h] = min(dp[h],dp[j] + a[i][1])
print(dp[h])


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;

void solve()
{
    // ll n; cin>>n;
    // vector<ll>v(n);
    // rep(i,n) cin>>v[i];
    int n; cin>>n;
    if(n>=30) CY;
    else CN;

}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
   //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int ,int> dot[3000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		int size=0;
		for(int i=0;i<a;i++){
			scanf("%d%d",&dot[i].first,&dot[i].second);
		}
		std::sort(dot,dot+a);
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				int dx=dot[i].first-dot[j].first;
				int dy=dot[i].second-dot[j].second;
				if(binary_search(dot,dot+a,make_pair(dot[i].first-dy,dot[i].second+dx))&&binary_search(dot,dot+a,make_pair(dot[j].first-dy,dot[j].second+dx)))size=max(size,dx*dx+dy*dy);
				if(binary_search(dot,dot+a,make_pair(dot[i].first+dy,dot[i].second-dx))&&binary_search(dot,dot+a,make_pair(dot[j].first+dy,dot[j].second-dx)))size=max(size,dx*dx+dy*dy);
			}
		}
		printf("%d\n",size);
	}
}

Measured memory_bytes: 780
s=input()
stack=[]
tmpans=[]
ans=[]
for k,v in enumerate(s):
    if v=="\\":
        stack.append(k)
    elif v=="/" and len(stack)>0:
        p=stack.pop()
        a=k-p
        while len(tmpans)>0 and tmpans[-1][-1]>p:
            a+=tmpans[-1][0]
            tmpans.pop()
        tmpans.append([a,p])
x=[i[0] for i in tmpans]
print(sum(x))
print(len(x),*x)


Measured memory_bytes: 6508
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  REP(i,1,3501)REP(j,1,3501){
    ll tmp = n*i*j;
    ll tmp2 = 4*i*j - n*(i+j);
    if(tmp2!=0 && tmp%tmp2==0 && tmp/tmp2>0){
      cout << i << " " << j << " " << tmp/tmp2 << endl; return 0;
    }
  }
  return 0;
}

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

ls = []
temp = 0
n = 1
for i in S:
    if n == i:
        temp += 1
    else:
        ls.append(temp)
        n = i
        temp = 1
if temp != 0: 
    ls.append(temp)
if n == 0:
    ls.append(0)

if K * 2 + 1 > len(ls):
    m = 0
    for i in ls:
        m += i
    print(m)
else:
    m = 0
    temp = 0
    for i in range(2*K + 1):
        temp += ls[i]
    m = temp
    for i in range(len(ls) // 2 - K):
        temp = temp - ls[2*i] - ls[2*i+1] + ls[2*K + 2*i + 1] + ls[2*K + 2*i + 2]
        if m < temp:
            m = temp

    print(m)

Measured memory_bytes: 4800
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

H,W,K=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]

ans=float("inf")
for bit in range(2**H):
    cnt=0
    group_num=0
    GROUP={}
    for i,s in enumerate(S):
        if i==0:
            GROUP[i]=group_num
        else:
            if bit>>i-1&1==1:
                cnt+=1      #境目のカウントに+1
                group_num+=1
            GROUP[i]=group_num

    ok=None
    VALUE=defaultdict(lambda: 0)
    w=0
    break_flag=False
    for w in range(W):
        if break_flag:  #breakフラグがTrueならループを止める
            break
        for h in range(H):
            VALUE[GROUP[h]]+=int(S[h][w])
        #現在の値がKを超えていないか
        for v in VALUE.values():
            if v<=K:
                pass
            else:
                if ok is None:      #okに値がない場合は、このパターンは成り立たない
                    cnt=float("inf")    #不可能なパターンなのでカウントに無限大を代入
                    break_flag=True     #breakフラグにTrueを代入
                    break
                else:      #以前の列でok番号に値が入っていた、つまり成り立つ列があった場合
                    cnt+=1      #境目のカウントに+1
                    VALUE=defaultdict(lambda: 0)    #NGの場合は値を初期化して入れなおし
                    for h in range(H):
                        VALUE[GROUP[h]]+=int(S[h][w])
                    break
        else:
            ok=w    #値が全てK以下だった場合はok変数に列番号を記録
    ans=min(ans,cnt)
       
print ans

Measured memory_bytes: 33900
n,m=map(int,input().split())
s,c=[],[]
for i in range(m):
    S,C=map(int,input().split())
    s.append(S-1)
    c.append(str(C))

if n==3:
    st,ed=100,1000
elif n==2:
    st,ed=10,100
else:
    st,ed=0,10
ans=-1

for t in range(st,ed):
    t_=list(str(t)) 
    
    for j in range (m):
        if t_[s[j]]!=c[j]:
            break
            
    else:
        ans=t
        break
    
    
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define m 100005
int a[m],b[m],d[m],q[m]; 
int main()
  {
    int T,s=0,p=1;
    memset(a,1,sizeof(a));
    for(int i=2;i<m;i++)
      for(int j=2*i;j<=m;j+=i)
        a[j]=0;
    cin>>T;
    for(int i=1;i<=m;i++){
    if(a[i]&&a[(i+1)/2]&&(i+1)%2==0&&i!=1)
    s++;
    q[i]=s;
                        }
    for(int i=1;i<=T;i++)
    cin>>b[i]>>d[i];
    for(int i=1;i<=T;i++)
    cout<<q[d[i]]-q[b[i]-1]<<endl;
    return 0;
  }

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<28));
const ll linf = (1LL<<58);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n], b[n+1];
    for(int i=0; i<n; i++) cin >> a[i];
    map<int, int> mp;
    for(int i=0; i<n; i++) mp[a[i]]++;
    int ans = 0;
    for(int i=1; i<100001; i++)
    {
      int tmp = mp[i] + mp[i-1] + mp[i+1];
      ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
#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>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(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()
#define shandom_ruffle random_shuffle

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);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll h,w;
    cin >> h>>w;
    string s[h];
    rp(i,h) cin >> s[i];
    rp(i,h){
        cout << s[i]<<endl;
        cout << s[i]<<endl;
    }



    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

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

int main(){
  ll n, k, w, r = 0;
  cin >> n >> k;
  vector<ll> ws;
  REP(i, n){
    cin >> w;
    ws.push_back(w);
  }
  sort(ws.begin(), ws.end());
  for (int i = n - 1; i >= 0; --i) {
    if (k > 0) {
      ws[i] = 0;
      --k;
    } else {
      break;
    }
  }
  REP(i, n){
    r += ws[i];
  }
  cout << r;
}


Measured memory_bytes: 2544
N=int(input())
As=list(map(int,input().split()))

Ans=1
if As.count(0):
    print(0)
    exit()
else:
    for A in range(N):
        if Ans>10**18:
            Ans=-1
            print(Ans)
            exit()
        else:
            NewAns=Ans*As[A]
            Ans=NewAns
    if Ans>10**18:
        Ans=-1
    
    print(Ans)

Measured memory_bytes: 21824
S = input()

y, m, d = map(int, S.split("/"))

if y < 2019:
    print("Heisei")
elif y > 2019:
    print("TBD")
else:
    if m < 4:
        print("Heisei")
    elif m > 4:
        print("TBD")
    else:
        if d <= 30:
            print("Heisei")
        else:
            print("TBD")

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

int main()
{
    int n, C, *table = new int[100002], max{};
    std::vector<std::pair<int, int>> tv[30];

    std::fill(table, table + 100002, 0);
    scanf("%d%d", &n, &C);
    for (int i = 0; i < n; i++)
    {
        int s, t, c;
        scanf("%d%d%d", &s, &t, &c);
        tv[c - 1].push_back({s, t});
    }
    for (int i = 0; i < C; i++)
    {
        if (tv[i].empty()) continue;
        std::sort(tv[i].begin(), tv[i].end());
        int start = tv[i].begin()->first;
        for (int j = 1; j < tv[i].size(); j++)
        {
            if (tv[i][j - 1].second == tv[i][j].first) continue;
            table[start]++;
            table[tv[i][j - 1].second + 1]--;
            start = tv[i][j].first;
        }
        table[start]++;
        table[tv[i].back().second + 1]--;
    }

    for (int i = 1; i < 100000; i++)
    {
        table[i] += table[i - 1];
        max = std::max(max, table[i]);
    }
    printf("%d\n", max);

    delete[] table;
    return 0;
}

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

using namespace std;

const long long NMax = 1000003;

struct Point{
    long long nr,pos;
};
long long n;
Point a[NMax];
multiset<long long> seet;
bool cmp(Point x, Point y){
    return (x.nr > y.nr);
}
int main(){
    cin >> n;
    for(long long i = 1; i <= n; ++i){
        cin >> a[i].nr;
        a[i].pos = i;
    }
    sort(a + 1, a + 1 + n, cmp);

    seet.insert(a[1].pos);
    seet.insert(0);
    seet.insert(0);
    seet.insert(n + 1);
    seet.insert(n + 1);
    long long ans = 0;
    for(long long i = 2; i <= n; ++i){
        long long l = 0,r = 0;
        seet.insert(a[i].pos);
        auto ii = seet.find(a[i].pos);
        ii--;
        long long posm1 = *ii;
        ii--;
        long long posm2 = *ii;
        ii++;ii++;ii++;
        long long pos1 = *ii;
        ii++;
        long long pos2 = *ii;

        long long q = (pos2 - pos1) * (a[i].pos - posm1);
        q += (posm1 - posm2) * (pos1 - a[i].pos);
        //cout << (pos2 - pos1) << '\n';
        ans += q * a[i].nr;
        //ans += ((a[i].pos - l + 1 + 1) + (r - 1 - a[i].pos + 1)) * a[i].nr
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

const int maxn = 300010;

int n, a[maxn], sum[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if (n & 1) {
		int L = -1e9, R = 1e9, ans = 0, s = 0;
		for (int i = 1; i <= n; i++) if (i & 1) sum[i] = sum[i-1] + a[i]; else sum[i] = sum[i-1] - a[i];
		while (L <= R) {
			int mid = (L + R) >> 1;
			int mns = 0;
			for (int i = 1; i < n; i += 2) {
				if (sum[i] - mns >= mid) {
					mns = min(mns, sum[i+1]);
				}
			}
			if (sum[n] - mns >= mid) {
				L = mid + 1;
				ans = mid;
			} else R = mid-1;
		}
		for (int i = 2; i <= n; i += 2) ans += a[i];
		for (int i = 1; i <= n; i++) s += a[i];
		printf("%d %d\n", ans, s - ans);
	} else {
		int s0 = 0, s1 = 0;
		for (int i = 1; i <= n; i++) if (i & 1) s1 += a[i]; else s0 += a[i];
		if (s0 < s1) swap(s0, s1);
		printf("%d %d\n", s0, s1);
	}
	return 0;
}

Measured memory_bytes: 2560