akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  int a, b, c;
  while (cin >> a >> b >> c) {
    if ((a|b|c) == 0)
      break;

    int N;
    cin >> N;

    vector<int> aa(N), bb(N), cc(N), r(N);
    for (int i = 0; i < N; ++i) {
      cin >> aa[i] >> bb[i] >> cc[i] >> r[i];
      --aa[i];
      --bb[i];
      --cc[i];
    }


    vector<int> ans(a+b+c, 2);
    for (int i = 0; i < N; ++i) {
      if (r[i] == 1)
	ans[aa[i]] = ans[bb[i]] = ans[cc[i]] = 1;
    }

    for (int i = 0; i < N; ++i) {
      if (r[i] == 0) {
	if (ans[aa[i]] == 1 && ans[bb[i]] == 1)
	  ans[cc[i]] = 0;
	else if (ans[aa[i]] == 1 && ans[cc[i]] == 1)
	  ans[bb[i]] = 0;
	else if (ans[bb[i]] == 1 && ans[cc[i]] == 1)
	  ans[aa[i]] = 0;
      }
    }

    for (int i = 0; i < a+b+c; ++i)
      cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

ll N,H,d[100010],h[100010],sumd[100010];

struct segtree{
	ll x;
	int l,r;
	segtree *cl,*cr;
	
	segtree(int l,int r): l(l),r(r){
		if(l+1==r){
			x=h[l];
			return;
		}
		cl=new segtree(l,l+r>>1);
		cr=new segtree(l+r>>1,r);
		x=max(cl->x,cr->x);
	}
	
	void change(int pos,ll v){
		if(pos<l || r<=pos){
			return;
		}
		if(l+1==r){
			x=v;
			return;
		}
		cl->change(pos,v);
		cr->change(pos,v);
		x=max(cl->x,cr->x);
	}
	
	ll query(int L,int R,int& ind){
		if(R<=l || r<=L){
			return -INF*INF;
		}
		if(l+1==r){
			ind=l;
			return x;
		}
		int ind1,ind2;
		ll res1 = cl->query(L,R,ind1);
		ll res2 = cr->query(L,R,ind2);
		if(res1 >= res2){
			ind=ind1;
			return res1;
		}
		ind=ind2;
		return res2;
	}
} *root;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>H;
	rep(i,N-1){
		cin>>d[i]>>h[i];
		sumd[i+1]=sumd[i]+d[i];
	}
	root=new segtree(0,N-1);
	ll ans=0,hp=H,from=0;
	rep(i,N-1){
		hp-=d[i];
		//cout<<hp<<" "<<ans<<" "<<from<<endl;
		while(hp<=0){
			ll need=1-hp;
			int ind;
			ll maxi=root->query(from,i+1,ind);
			from=ind;
			ll HPpre=hp+sumd[i+1]-sumd[ind];
			//cout<<hp<<" "<<HPpre<<endl;
			//cout<<from<<" - "<<i<<" : "<<maxi<<"("<<ind<<")"<<endl;
			ll maxtime=(H-HPpre)/maxi;
			ll want=(need+maxi-1)/maxi;
			//cout<<maxtime<<" "<<want<<endl;
			if(want <= maxtime){
				ans+=want;
				hp+=want*maxi;
				break;
			}else{
				ll rest=(H-HPpre)%maxi;
				root->change(ind,rest);
				ans+=maxtime;
				hp+=maxtime*maxi;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 12916
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll,ll> pp;

ll mod = 1e9+7;
ll INF = 1e15;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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





void solve()
{
  int s,w;
  cin>>s>>w;
  if(w>=s)
  cout<<"unsafe\n";
  else cout<<"safe\n";


}



int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;

  int cnt = 0;
  for (int i = 0; i < S.size() - T.size() + 1; ++i)
  {
    int tmp = 0;
    for (int j = 0; j < T.size(); ++j)
    {
      if (S[i + j] == T[j])
        tmp++;
    }
    cnt = max(cnt, tmp);
  }
  cout << T.size() - cnt << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



int L[101];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, x, y; cin >> W >> H >> x >> y;
	double ans = (double)W*H / 2.0;
	int cnt = 0;
	if (W % 2 == 0 && H % 2 == 0 && x == W / 2 && y == H / 2)cnt++;
	cout << setprecision(10) << ans << " " << cnt << endl;
}


Measured memory_bytes: 256
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class Test
{
    public static void Main()
    {
        var N = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var sum = a.Sum();
        var x = 0L;
        var minDif = Int64.MaxValue;  // 最低1枚は取る

        for (int i = 0; i < N - 1; i++)
        {
            x += a[i];
            minDif = Math.Min(minDif, Math.Abs((sum - x) - x));
        }

        Console.WriteLine(minDif);
    }
}

Measured memory_bytes: 34396
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[][] a = new int[n][4];
			for(int i=0;i<n;i++){
				sc.nextLine();
				sc.nextLine();
				for(int j=0;j<4;j++) a[i][j] = sc.nextInt();
			}
			
			int max = 0;
			for(int k=1;k<4;k++){
				int[][] dp = new int[n+1][m+1];
				for(int i=0;i<n;i++){
					for(int j=0;j<=m;j++){
						if(j<a[i][0]) dp[i+1][j] = dp[i][j];
						else dp[i+1][j] = Math.max(dp[i][j], dp[i+1][j-a[i][0]]+a[i][k]);
					}
				}
				max = Math.max(max, dp[n][m]);
			}
			
			System.out.println(max);
		}	
	}	
}

Measured memory_bytes: 159444
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}




vector<vector<int>> path;
vector<char> color;

int visited[2][100005];

int dfs(int i, char c, int cnt){
    visited[c=='W'][i]=1;
    for(auto p:path[i]){
        if(color[p]!= c && color[p]!='.') continue;
        if(visited[c=='W'][p]==1) continue;
        color[p]=c;
        cnt=dfs(p,c,cnt+1);
    }
    return cnt;
}


int main() {
    int n;cin>>n;
    path.resize(n+1);
    rep(i,n-1){
        int a,b;cin>>a>>b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    queue<int> q;
    int banpei = INT_MIN;
    
    int used[n+1];
    rep(i,n+1){used[i]=0;}
    used[1] = 1;
    q.push(1);
    q.push(banpei);
    bool flag = true;
    map<int,int> parent;
    while(flag){
        
        while(q.front()!=banpei){
            
            auto pos = q.front();
            q.pop();
            
            if(pos == n){flag = false; break;}
     
            for(auto targ:path[pos]){
                if(used[targ]==1)continue;
                used[targ] = 1;
                q.push(targ);
                parent[targ] = pos;
            }
        }
        q.pop();
        q.push(banpei);
    }
    vector<int> shortest;
    int cur = n;
    shortest.push_back(cur);
    while(cur!=1){
        cur = parent[cur];
        shortest.push_back(cur);
    }
    
    int curp = 0;
    int curn = (int)shortest.size()-1;
    reverse(all(shortest));
    color.resize(n+1,'.');
    
    while(1){
        if(curp>curn)break;
        color[shortest[curp]] = 'B';
        curp++;
        if(curp>curn)break;
        color[shortest[curn]] = 'W';
        curn--;
    }
    
    if (dfs(1,'B',0) <= dfs(n,'W',0)) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
    
    return 0;
}












Measured memory_bytes: 14460
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


a, b =  map(int, sys.stdin.readline().split())

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

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

const int MAX = 2e5 + 5;
int n;
pair <int, int> a[MAX];
char d[MAX];

double f(double t) {
	double mnX = 1e10, mnY = 1e10;
	double mxX = -1e10, mxY = -1e10;

	for(int i = 1; i <= n; i++) {
		double X = a[i].first;
		double Y = a[i].second;

		if(d[i] == 'U')
			Y += t;

		else if(d[i] == 'R')
			X += t;

		else if(d[i] == 'D')
			Y -= t;

		else X -= t;

		mnX = min(mnX, X);
		mxX = max(mxX, X);

		mnY = min(mnY, Y);
		mxY = max(mxY, Y);
	}

	return (mxX - mnX) * (mxY - mnY);
}

int main() {
	scanf("%d", &n);

	for(int i = 1; i <= n; i++) {
		int x, y; char s[5];
		scanf("%d%d%s", &x, &y, s);
		a[i] = { x, y };
		d[i] = s[0];
	}

	double st = 0, nd = 6e8;

	for(int i = 1; i <= 200; i++) {
		double m1 = st + (nd - st) / 3.0;
		double m2 = nd - (nd - st) / 3.0;

		if(f(m1) < f(m2))
			nd = m2;

		else st = m1;
	}

	double opt = (st + nd) / 2.0;

	printf("%.10lf\n", f(opt));
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) x-'0'
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

int main()
{
    weewoo;
    ll n;
    cin >> n;
    ll cur=1;
    ll ans=0;
    while(n>0){
        ans+=cur;
        n/=2;
        cur*=2;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       string s;
       ll a[30],i,j;
       for( i=0;n>0;i++)
       {   
           if(n%26==0)
           {
               a[i]=26;
               n=n-1;
           }   
           else
           a[i]=n%26;
           if(n==26)
           break;
           n=n/26;
           
       }
       for(j=0;j<i;j++)
       {
           s=(char)(a[j]+96)+s;
       }
       cout<<s<<"\n";
    }
}



Measured memory_bytes: 3668
<?php
fscanf(STDIN, '%d %d', $n, $m);
for ($i  = 0; $i < $m; $i++) fscanf(STDIN, '%d %d', $s[], $c[]);

$arr = array_fill(0, $n, -1);
for ($i  = 0; $i < $m; $i++) {
    if ($arr[$s[$i] - 1] !== -1 && $arr[$s[$i] - 1] !== $c[$i]) {
        $ans = -1;
        break;
    }
    $arr[$s[$i] - 1] = $c[$i];
}

for ($i = 0; $i < $n; $i++) {
    if ($i == 0) {
        if ($arr[$i] === -1) {
            if ($n > 1) {
                $arr[$i] = 1;
            } else {
                $arr[$i] = 0;
            }
        }
        continue;
    }
    if ($arr[$i] === -1) {
        $arr[$i] = 0;
    }
}
if (strlen(strval(intval(implode('', $arr)))) !== $n) {
    $ans = -1;
}

if (!isset($ans)) {
    $ans = intval(implode('', $arr));
}
echo $ans . PHP_EOL;

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

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
typedef long long ll;
const unsigned int mod = 1000000007;
const int INF = 1000000001;
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// typedef pair<int,int> pii;
// vector<vector<ll>> adj(100000);
// vector<ll> ans(100000,0);
// ll minans = 1;


int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif

int n,k;
cin>>n>>k;
int a[n+1] = {0};
while(k--){
	int d;
	cin>>d;
	while(d--){
		int p;
		cin>>p;
		a[p]++;
	}
}
int ans = 0;
forne(i,1,n+1){
	if(!a[i]) ans++;
}
cout<<ans<<endl;

}

Measured memory_bytes: 3604
#include <stdio.h>

int main () {
	char string[105], x = 0, n;
	scanf("%d\n", &n);
	scanf("%s", string);
	
	int temp = x;
	for(int i = 0; i < n; i++) {
		if(string[i] == 'I') {
			x++;
			if (temp <= x) {
				temp = x;
			}
		}
		else if (string[i] == 'D') {
			x--;
			if (temp <= x) {
				temp = x;
			}
		}
	}
	printf("%d", temp);
	
	
	return 0;
}

Measured memory_bytes: 1712
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

/*全てのライブラリをインクルード*/
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll count = k;
    rep(i, n - 1)
    {
        count *= (k - 1);
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a >= 13 ? b : 12 >= a && a >= 6 ? b/2: 0);
	}
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  
  int value = 1;
  rep(i, N)
  {
    if ((value * 2) < (value + K))
    {
      value *= 2;
    }
    else
    {
      value += K;
    }
  }
  
  cout << value << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000001
struct Node {
	int key = MAX;
	int parent = MAX;
	int left = MAX;
	int right = MAX;
};

Node T[500001];
int found = 0;

void find_l(int search, int f) {
	if (T[search].key == f) {
		found = 1;
		return;
	}
	if (f < T[search].key && T[search].left != MAX) {
		find_l(T[search].left, f);
	} else if (f > T[search].key && T[search].right != MAX) {
		find_l(T[search].right, f);
	}
}

void find(int f) {
	found = 0;
	find_l(0, f);
	if (found == 1) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
}


void search_i(int search) {
	if (T[search].left != MAX) {
		search_i(T[search].left);
	}
	cout << " " << T[search].key;
	if (T[search].right != MAX) {
		search_i(T[search].right);
	}
}

void search_l(int search) {
	cout << " " << T[search].key;
	if (T[search].left != MAX) {
		search_l(T[search].left);
	}
	if (T[search].right != MAX) {
		search_l(T[search].right);
	}
}


void print() {
	search_i(0);
	cout << endl;
	search_l(0);
	cout << endl;
}

void insert(int k) {
	int p = 0;
	while (1) {
		if (T[k].key < T[p].key) {
			if (T[p].left == MAX) {
				T[p].left = k;
				T[k].parent = p;
				return;
			}
			else {
				p = T[p].left;
			}
		}
		else {
			if (T[p].right == MAX) {
				T[p].right = k;
				T[k].parent = p;
				return;
			}
			else {
				p = T[p].right;
			}
		}
	}
}

int main() {
	int n, tmp;
	string com;
	cin >> n;
	cin >> com;
	cin >> tmp;
	T[0].key = tmp;
	for (int i = 1; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			cin >> tmp;
			T[i].key = tmp;
			insert(i);
		}
		else if (com == "print"){
			print();
		}
		else {
			cin >> tmp;
			find(tmp);
		}
	}
}


Measured memory_bytes: 10984
import java.util.Scanner;

public class Main {

	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	
		int n, a, b;
		
		Scanner scan = new Scanner(System.in);
		
		n = scan.nextInt();
		a = scan.nextInt();
		b = scan.nextInt();
		
		int total = 0;
		for(int i = 1; i <= n; ++i) {
			int sum = checkSum(i);
			if(sum >= a && sum <= b) {
				total += i;
			}
		}
		
		System.out.println(total);


	}
	
	static int checkSum(int n) {
		int sum = 0;
		while(n > 0) {

			sum += n % 10;
			n /= 10;

		}
		
		return sum;
	}

}


Measured memory_bytes: 23120
#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 N;

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

  std::cin >> N;

  for(int i=0;i<=N;++i){
      if(i * 108 / 100 == N){
          std::cout << i << std::endl;
          return 0;
      }
  }

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


Measured memory_bytes: 256
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    walked = s * t
    if walked >= d:
        print "Yes"
    else:
        print "No"
    return





d, t, s = RA()
solve()


Measured memory_bytes: 64776
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
    scanf("%d %d", &x, &n);
	if (n == 0) {
		printf("%d", x);
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
        printf("%d", x);
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
 	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
        printf("%d", rV);
	} else if (d2 < d1) {
		printf("%d", lV);
	} else {
		printf("%d", min(rV, lV));
	}
	return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int p[N];
    int i,j,min,minnum,tmp;
    int ans = 0;
    
    for(i = 0;i < N;i++){
        cin >> p[i];
    }

    //小さい順に並び変えて
    for(i = 0;i < N;i++){
        min = p[i];
        minnum = i;
        for(j = i + 1;j < N;j++){
            if(min > p[j]){
                min = p[j];
                minnum = j;
            }
        }
        tmp = p[i];
        p[i] = p[minnum];
        p[minnum] = tmp;
    }
	
    //下から足す
    for(i = 0;i < K;i++){
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


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

int dp[100010][3]={0},a[100010][3]={0};


int main(){
   int n;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
        scanf("%d",&a[i][j]);
    }
   }
   dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
   for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
        if(j==0){
            dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
        }else if(j==1){
            dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j-1]);
        }else dp[i][j]=a[i][j]+max(dp[i-1][j-2],dp[i-1][j-1]);
    }
   }
   printf("%d",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
    return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int k; cin>>k;
    string s; cin>>s;

    if(s.size() <= k) cout << s << endl;
    else{
        string ans = s.substr(0, k);
        ans += "...";
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
from fractions import gcd
n,x=map(int,input().split())
lst=list(map(int,input().split()))
gaps=[]
ans=1
if x in lst:
    pass
else:
    lst.append(x)
    lst=sorted(lst)
for i in range(1,len(lst)):
    gaps.append(lst[i]-lst[i-1])
#print(gaps,lst)
tmp=gaps[0]
for i in range(1,len(gaps)):
    ans=gcd(tmp,gaps[i]) ; tmp=ans
if len(lst)==2:
    print(lst[1]-lst[0])
else:
    print(ans)
    

Measured memory_bytes: 16280
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
flg = 1
while flg:
    for i in range(N):
        if A[i] % 2:
            flg = 0
            break
        A[i] //= 2
    if flg == 1:
        ans += 1

print(ans)


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

int main() {
    int N, a;
    cin >> N;
    vector<vector<int>> S(N, vector<int>(3)), ans(N, vector<int>(3));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> S.at(i).at(j);
        }
    }
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            for (int j = 0; j < 3; j++) {
                ans.at(i).at(j) = S.at(i).at(j);
            }
        }
        else {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }
                    if (a < ans.at(i - 1).at(k) + S.at(i).at(j)) {
                        a = ans.at(i - 1).at(k) + S.at(i).at(j);
                    }
                }
                ans.at(i).at(j) = a;
                a = 0;
            }
        }
    }
    cout << max({ans.at(N - 1).at(0),ans.at(N - 1).at(1),ans.at(N - 1).at(2)}) << endl;
}

Measured memory_bytes: 11136
#include<stdio.h>

int main(void)
{
    char n[10];
    scanf("%s",n);
    while((100>atoi(n))||(atoi(n)>999))
    {
        scanf("%s",n);
    }
    if(n[0]==n[2])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値
//a^nをpで割ったあまり

//a^nをpで割ったあまり
int modPow(int a, int n, int p) {
    int ans = 1;
    while(n != 0){
        if(n&1) ans = ans*a % p;
        a = a*a % p;
        n = n >> 1;
    } 
    return ans;
}

//nCrをMODで割った余り
int nCr(int n, int r,int mod){
    int ans=0,x=1,y=1;
    for(int i=1;i<=r;i++){
        x=x*(n-i+1)%mod;
        y=y*i%mod;
    }
    ans=x*modPow(y,mod-2,mod);
    return ans;
}

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m,k;
    string s;
    cin >> n >> m;
    int ans=0;
    ans = n*(n-1)/2+m*(m-1)/2;
    
    cout << ans;
    return 0;    

}

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

using namespace std;

const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W];

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

void dfs(int i, int j) {
  char c = field[i][j];
  if (c == 0) return;
  field[i][j] = 0;  // mark as visited

  for (int k = 0; k < 4; k++) {
    int new_i = i + dy[k];
    int new_j = j + dx[k];
    if (field[new_i][new_j] == c) {
      dfs(new_i, new_j);
    }
  }
}

int main() {

  while (1) {
    int W, H;
    cin >> H >> W;
    if (W == 0 && H == 0) {
      break;
    }

    int ans = 0;

    memset(field, 0, MAX_W * MAX_H);
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> field[i][j];
      }
    }

    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if (field[i][j]) {
          dfs(i, j);
          ans++;
        }
      }
    }

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

Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,K;
  	cin>>n>>K;
  	string s;
  	cin>>s;
  	if(n==1)
    {
      cout<<1<<endl;
      return 0;
    }
  	vector<int>o;
  	for(int i=0;i<n;i++)
    {
      if(s[i]=='1' && i==0)o.push_back(i);
      else if(s[i-1]=='0' && s[i]=='1')o.push_back(i);
    }
  	vector<int>l;
  	for(int i=n-1;i>=0;i--)
    {
      if(s[i]=='1' && i==n-1)l.push_back(i);
      else if(s[i]=='1' && s[i+1]=='0')l.push_back(i);
    }
  	int os=o.size();
  	int ls=l.size();
  	if(os==1 && s[0]=='1' && s[n-1]=='1')
    {
      cout<<n<<endl;
      return 0;
    }
  	if(os==0 && ls==0)
    {
      cout<<n<<endl;
      return 0;
    }
  	sort(l.begin(),l.end());
  	int ans=0;
  	
  	for(int i=0;i<os;i++)
    {
		ans=max(ans,abs(l[min((i+K),ls-1)]-o[i]+1));
      	
    }
  	if(s[0]=='0')ans=max(ans,l[min(0+K-1,ls-1)]+1);
  	if(s[n-1]=='0')ans=max(ans,n-o[os-K]);
    cout<<ans<<endl;
    return 0;
}	

Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int main(){
    string s;
    string S[11];
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '0'){
            S[cnt] = '0';
            cnt++;
        }
        else if(s[i] == '1'){
            S[cnt] = '1';
            cnt++;
        }
        else{
            if(cnt != 0){
                S[cnt] = "\0";
                cnt--;
            }
        }
    }
    rep(i, cnt) cout << S[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import lru_cache
N,M = map(int,input().split())
S = tuple(map(int,input().split()))
T = tuple(map(int,input().split()))
MOD = 10**9 + 7

dp = [1]*(M+1)

for i,s in enumerate(S, start=1):
    ndp = [None]*(M+1)
    ndp[0] = 1
    for j,t in enumerate(T, start=1):
        if s == t:
            ndp[j] = dp[j]+ndp[j-1]
        else:
            ndp[j] = dp[j]+ndp[j-1]-dp[j-1]
    dp = ndp

print(ndp[-1]%MOD)


Measured memory_bytes: 124636
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

vector<bool> sieve(size_t max){
  std::vector<bool> IsPrime;
  if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
    IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
  } 
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない
  
  for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
    if(IsPrime[i]) // iが素数ならば
      for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
        IsPrime[i*j] = false;      // 素数ではない
  return IsPrime;
}

int vmax = 1e6;

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

  vector<bool> primes = sieve(vmax);
  vector<int> prime_num(vmax, 0);
  int res = 0;
  REP(i, vmax+1){
    if(primes[i] && primes[(i+1)/2]) res++;
    prime_num[i] = res;
  }
  /*
  for(auto &e: prime_num) cout << e << " ";
  cout << endl;
  */

  int Q; cin >> Q;
  REP(i, Q){
    int l, r;
    cin >> l >> r;
    cout << prime_num[r] - prime_num[l-1] << endl;
  }
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    ll i,n,k,p,sum=0;
    sll(n,k);
    rep0(i,k)
    {
        sl(p);
        sum+=p;
    }
    puts(sum>=n?"Yes":"No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
//#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
   Fast;
   ll mod=998244353;
   
   ll n;
   I n;
   int ans=0;
   if(n>=500){int l=n/500;
       ans+=l*1000;
       n=n-(l)*500;
       l=n/5;
       ans+=l*5;
   }else{
       int l=n/5;
       ans=l*5;
   }
   cout<<ans;
   
   XXX;
}




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

int main(){
	ll n;
    cin >> n;
    ll ans = n*(n-1)*(n-2)/6;
    vector<int> ns(n);
    rep(i, n) cin >> ns.at(i);
    vector<int> tw(0);
    for(int i=0; i<n-1; i++) for(int j=i+1; j<n; j++){
      tw.push_back(ns.at(i)+ns.at(j));
    }
    sort(tw.begin(), tw.end());
    rep(i, n){
      ans -= (upper_bound(tw.begin(), tw.end(), ns.at(i)) - tw.begin());
//      cout << upper_bound(tw.begin(), tw.end(), ns.at(i)) - tw.begin() << endl;
    }
    cout << ans << endl;
    return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), M = input();
    vector< int > as(M), bs(M);

    int even = (M + 1) / 2;
    range(i, 0, even) {
        as[i] = i + 1;
        bs[i] = as[i] + 2 * (even - i) - 1;
    }

    int odd = M - even;
    range(i, 0, odd) {
        int p = i + 2 * even;
        as[i + even] = p + 1;
        bs[i + even] = as[i] + p - i + 2 * (odd - i);
    }

    range(i, 0, M) {
        cout << as[i] << " " << bs[i] << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005


struct Node{
	bool operator<(const struct Node &arg) const{
		return weight < arg.weight;
	};
	int from,to,weight;
};

struct Info{
	Info(int arg_node,int arg_value){
		node = arg_node;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{

		return value < arg.value;
	}
	int node,value;
};

int parent[SIZE],height[SIZE];

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;	//元々同じグループ

	if(height[a_parent] > height[b_parent]){ //高い方に吸収する
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}


int main(){

	int V,E;

	scanf("%d",&V);
	E = 2*(V-1);

	vector<Info> X,Y;
	for(int i = 0; i < V; i++){

		int x,y;
		scanf("%d %d",&x,&y);
		X.push_back(Info(i,x));
		Y.push_back(Info(i,y));
	}

	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());

	Node nodes[E];

	int index = 0;

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

		nodes[index].from = X[i-1].node;
		nodes[index].to = X[i].node;
		nodes[index].weight = abs(X[i-1].value-X[i].value);
		index++;
	}

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

		nodes[index].from = Y[i-1].node;
		nodes[index].to = Y[i].node;
		nodes[index].weight = abs(Y[i-1].value-Y[i].value);
		index++;
	}

	sort(nodes,nodes+E);

	//統合するのは頂点
	for(int i = 0; i < V; i++){
		parent[i] = i;
		height[i] = 0;
	}

	ll sum = 0;

	for(int i = 0; i < E; i++){
		if(!isSame(nodes[i].from,nodes[i].to)){ //同じグループでなければくっつけて、そのコストを足す
			sum += nodes[i].weight;
			unite(nodes[i].from,nodes[i].to);
		}
	}

	printf("%lld\n",sum);

	return 0;
}


Measured memory_bytes: 8012
#include<stdio.h>
#define SIZE 100000
int main(){
  int n,a[SIZE],i;
  int counter=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    while(a[i]%2==0){
      counter++;
      a[i]=a[i]/2;
    }
  }
  printf("%d\n",counter);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int Max = 3e5;

int num[Max + 5];
bool f;

int main()
{
	int n, a, b, pos = 0;
	scanf("%d%d%d", &n, &a, &b);
	if(a + b > n + 1 || (b == 1 && a != n)) f = 1;
	for(int i = a; i >= 1; i--) num[++pos] = i;
	if(b != 1)
	{
		int ans = (n - a) / (b - 1);
		int t = (n - a) % (b - 1);
		for(int i = 1; i <= ans; i++) {
			int x = n - (b - 1) * i + 1;
			for(int j = 0; j < b - 1; j++)
			{
				num[++pos] = x + j;
			}
		}
		if(t != 0) {
			ans++;
			for(int i = a + 1; i <= a + t; i++) num[++pos] = i;
		}
		if(ans > a) f = 1;
	}
	if(f) printf("-1\n");
	else {
		for(int i = pos; i > 1; i--) printf("%d ", num[i]);
		printf("%d\n", num[1]);
	}
	return 0;
}

Measured memory_bytes: 3328
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    T = list(S())

    L = len(T)
    # print(T)
    for i in range(L):
        if T[i]=='?':
            T[i] = 'D'

    print(''.join(T))

    # if T[-1]=='?':
    #     T[-1] = 'D'
    # for i in range(L-1):
    #     print(L-1-i)
    #     c_first = T[L-2-i]
    #     c_second = T[L-1-i]
    #     print(c_first, c_second)
    #     if c_second=='P':
    #         T[L-1-i] = 'D'
    #     else c_second=='D':


if __name__ == '__main__':
    resolve()

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

using namespace std;
long long a,b,c;
int main()
{
	//freopen("2510.in","r",stdin);
	//freopen("2510.out","w",stdout);
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<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);
	   int n = sc.nextInt();
	   int k = sc.nextInt();
	   int[] arr = new int[n];
	   for(int i = 0;i<n;i++){
	       arr[i] = sc.nextInt();
	   }
	   Arrays.sort(arr);
	   int sum = 0;
	   for(int i = 0;i<k;i++){
	       sum += arr[i];
	   }
	    System.out.println(sum);
	}
	
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = int.Parse(Console.ReadLine());
            double ans = R * 2 * Math.PI;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18572
while True:
	k=map(int,raw_input().split(" "))
	if k[0]==k[1]==0:
		break
	ct=0
	a=0
	b=0
	c=0	
	max=k[0]
	sum=k[1]
	a=max+1
	while True:
		a-=1
		b=a-1
		c=sum-a-b
		if not a>c:
			print ct
			break
		while b>c:
			if c>0:
				ct+=1
			b-=1
			c+=1

Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
    vector<string> s(3);
    rep(i,3) cin >> s[i];
    int now = 0;
    rep(i,500) {
        if(s[now] == "") {
            char ans = 'A'+now;
            cout << ans << endl;
            return 0;
        }
        char c = s[now][0];
        if(s[now].size() == 1) {
            s[now] = "";
        } else {
            s[now] = s[now].substr(1);
        }
        now = c-'a';
    }
}

Measured memory_bytes: 256