akhauriyash/Code-Regression huggingface dataset:
#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;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<long long> as(n);
  for(int i=0;i<n;i++) cin>>as[i];
  using M = Mint<int>;
  M ans{0};
  for(int k=0;k<60;k++){
    int cnt=0;
    for(auto a:as) cnt+=(a>>k)&1;
    ans+=M(1LL<<k)*M(cnt)*M(n-cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s, ans = {""};
	for (int i = 0; i < 3; i++) {
		cin >> s;
		s[0] -= 32;
		ans += s[0];
	}
	cout << ans << endl;;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x<r || y<r){
        cout<<"No"<<endl;
    }
    else if((x+r)>W || (y+r)>H){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

bool ok(int x, int y, string a, string b) {
  int n = a.size();
  for (int i = 0; i < n; i++) {
    if (a[(x + i) % n] != b[i]) {
      return 0;
    }
  }
  return 1;
}

int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    if (ok(i, 0, a, b)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll a,b;
	
	cin>>a>>b;
	ll mina = ceil(a*12.5);
	ll minb = ceil(b*10);
	ll maxa = ceil((a+1)*12.5);
	ll maxb = ceil((b+1)*10);
	if(mina>=minb  && mina<maxb)cout<<mina;
	else if(minb>=mina  && minb<maxa)cout<<minb;
	else cout<<"-1"<<endl;
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())

lst = [[0]*3 for _ in range(3)]
for i in range(N):
  num = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == num:
        lst[j][k] = 1
ans = 'No'
if (lst[0][0] == 1 and lst[0][1] == 1 and lst[0][2] == 1):
  ans = 'Yes'
elif (lst[1][0] == 1 and lst[1][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[2][0] == 1 and lst[2][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[0][0] == 1 and lst[1][0] == 1 and lst[2][0] == 1):
  ans = 'Yes'
elif (lst[0][1] == 1 and lst[1][1] == 1 and lst[2][1] == 1):
  ans = 'Yes'
elif (lst[0][2] == 1 and lst[1][2] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[0][0] == 1 and lst[1][1] == 1 and lst[2][2] == 1):
  ans = 'Yes'
elif (lst[2][0] == 1 and lst[1][1] == 1 and lst[0][2] == 1):
  ans = 'Yes'

print(ans)

Measured memory_bytes: 38256
n=int(input())
d=list(map(int,input().split()))
d.sort()
for i in range(n):
    if i%2:
        d[i]=24-d[i]
d.insert(0,0)
d.sort()
ans=12
for i in range(1,n+1):
    if ans>d[i]-d[i-1]:
        ans=d[i]-d[i-1]
print(ans)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
using namespace std;
int sma, n, t, a, pro;
typedef pair<int, int> P;
vector<P> vec;
int main(void){
    // Your code here!
    cin >> n >> t >> sma;
    for (int i = 1; i < n; i++) {
        cin >> a;
        if (pro < a - sma) {
            vec.clear();
            vec.push_back(P(sma, a));
            pro = a - sma;
        } if (pro == a - sma) {
            vec.push_back(P(sma, a));
        }
        sma = min(sma, a);
    }
    cout << vec.size() - 1 << endl;
}


Measured memory_bytes: 892
fun main(args: Array<String>) {
    val n = readLine()!!.split("").filter { it.isNotEmpty() }.map { it.single() }
    println(if (op141b(n)) "Yes" else "No")
}

fun op141b(n: List<Char>): Boolean {
    val odd = listOf('R', 'U', 'D')
    val even = listOf('L', 'U', 'D')

    return n.filterIndexed { index, c ->
        if ((index + 1) % 2 == 0) {
            even.contains(c)
        } else {
            odd.contains(c)
        }
    }.size == n.size
}



Measured memory_bytes: 37944
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for (int i=0;i<=25;i++) {
        for (int j=0;j<=20;j++) {
            if ((i*4+j*7)==n) {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
}


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

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

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


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


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

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

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 


int main() {
    while (true) {
        ll n;
        cin >> n;

        if(n == 0 ) break;

        vector<ll> v;

        for(ll i = 0; i < n; i++) {
            ll w;
            cin >> w;
            v.push_back(w);
        }

        vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
        for(ll i = 0; i < n; i++) {
            dp[i][i+1] = 0;
        }
        for(ll i = 0; i < n - 1; i++) {
            dp[i][i+2] = abs(v[i] - v[i+1]) <= 1 ? 2 : 0;
        }

        for(ll diff = 3; diff <= n; diff++) {
            for(ll i = 0; i + diff <= n; i++) {
                //cout << "*** [" << i <<", " << i+diff << ")" << endl;
                if(dp[i+1][i+diff-1] == diff - 2 && abs(v[i] - v[i+diff-1]) <= 1) dp[i][i+diff] = diff;
                else 
                for(ll after = i+1; after <= i+diff-1; after++) {
                    // cout << "-> [" << i << ", " << after << ") + [" << after << ", " << i+diff << ")" << endl;
                    // cout <<  dp[i][after] + dp[after][i+diff] << endl;
                    dp[i][i+diff] = max(dp[i][i+diff], dp[i][after] + dp[after][i+diff]);
                  //  cout << "dp[" << i << "][" << i+diff << "] = " << dp[i][i+diff] << endl;
                }
            }
        }

        cout << dp[0][n] << endl;
    }

    return 0;    
}





Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    int n;
    cin >> n;
    map<string, int> ver;

    fo(i, n) {
        string s;
        cin >> s;
        ver[s]++;
    }

    cout << "AC x " << ver["AC"] << endl;
    cout << "WA x " << ver["WA"] << endl;
    cout << "TLE x " << ver["TLE"] << endl;
    cout << "RE x " << ver["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3660
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
d = [1 << i for i in range(n)]

same_groups = [0] * (1 << n)
for i in range(1, 1 << n):
    k = i
    rb = k & -k
    ri = rb.bit_length() - 1
    ar = a[ri]
    k ^= rb
    val = same_groups[k]
    while k:
        pb = k & -k
        val += ar[pb.bit_length() - 1]
        k ^= pb
    same_groups[i] = val

dp = [0] * (1 << n)
for grp in range(1 << n):
    g = grp
    while g:
        dp[grp] = max(dp[grp], same_groups[g] + dp[grp ^ g])
        g = (g - 1) & grp

print(dp[-1])


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  vi h(n); rep(i, n) std::cin >> h[i];
  vi dp(n, inf);
  dp[0] = 0;
  rep(i, n) {
    rrep(j, k) if (i+j<n) {
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  std::cout << dp[n-1] << "\n";
}


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

#define ll long long

using namespace std;
const int OO = 0x3f3f3f3f, MOD = 1000000007;

int arr[100005];
int mem[100005] = {};
int n, k;

int solve(int idx = 0)
{
    int& ret = mem[idx];

    if(~ret) return ret;
    if(idx == n-1) return ret = 0;
    if(idx >= n) return ret = OO;

    ret = OO;
    for(int i = 1;i <= k; i++)
        ret = min(ret, solve(idx + i) + abs(arr[idx + i] - arr[idx]));

    return ret;
}

int main()
{
    //freopen ("out.txt","w",stdout);

    cin >> n >> k;
    memset(mem, -1, sizeof mem);
    for(int i = 0;i < n; i++)
        cin >> arr[i];

    cout << solve();

	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>

std::vector<int> A, B;
std::unordered_map<int, int> map;
std::vector<bool> V;
int n;
int mmin;
int minCostSort(){
    int ans = 0;
    int min, cnt, tmp;
    for(int i = 0; i < n; i++){
	min = A[i];
	cnt = 0;
	if(V[i] == 1) continue;
	if(map[A[i]] == i){
	    V[i] = 1;
	    continue;
	}
	tmp = i;
	while(1){
	    if(V[tmp] == 1){
		break;
	    }
	    ans += A[tmp];
	    V[tmp] = 1;
	    cnt++;
	    min = std::min(min, A[tmp]);
	    tmp = map[A[tmp]];
	}
	ans += std::min((cnt - 2) * min, (cnt + 1) * mmin + min);
    }
    return ans;
}

int main(void){
    int ans;
    std::cin >> n;
    A.resize(n);
    V.resize(n);
    for(int i = 0; i < n; i++){
	std::cin >> A[i];
    }
    for(int i = 0; i < n; i++){
	V[i] = 0;
    }

    B = A;


    std::sort(B.begin(), B.end());

    mmin = B[0];
    for(int i = 0; i < n; i++){
	map[B[i]] = i;
    }

    ans = minCostSort();

    std::cout << ans << std::endl;

    return 0;

}



Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int b[] = new int[N-1];

		for (int i = 0; i < N-1; i++) {
			b[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (i==0) {
				ans += b[i];
				continue;
			}else if (i==N-1) {
				ans += b[i-1];
				continue;
			}
			ans += Math.min(b[i], b[i-1]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
n,sum = gets.split.map(&:to_i)

(n+1).times{|x|
  for y in 0..n-x do
    z=n-x-y
    if x*10000 + y*5000+ z*1000 == sum
      puts "#{x} #{y} #{z}"
      exit
    end
  end
}

puts "-1 -1 -1"


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
long long num[41],ppow[41];
int a[41];
void cal(long long x)
{
    int pos=0;
    while(x)
    {
        a[pos++]=x%2;
        x/=2;
    }
    long long t=0;
    for(int i=0;i<pos;i++)
    {
        if(a[i]==1)
        {
            for(int j=0;j<i;j++)
                num[j]+=ppow[i-1];
            num[i]+=t+1;
        }
        t+=a[i]*ppow[i];
    }
}
int main()
{
    ppow[0]=1;
    for(int i=1;i<=40;i++)
        ppow[i]=ppow[i-1]*2;
    long long a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    cal(b);
    for(int i=0;i<=40;i++)
        num[i]*=-1;
    if(a) cal(a-1);
    for(int i=0;i<=40;i++)
        num[i]*=-1,ans+=num[i]%2*(1ll<<i);
    printf("%lld\n",ans);
}


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

int N;
string S1, S2;
const int MOD = 1000000007;

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

    ll ans;
    int i = 0;
    bool ver = false;
    if (S1[0] == S2[0]) {
        ans = 3;
        i++;
        ver = true;
    }
    else {
        ans = 6;
        i += 2;
    }

    while (i < N) {
        if (S1[i] == S2[i]) {
            if (ver) {
                ans = (ans * 2) % MOD;
                i++;
                ver = true;
            }
            else {
                i++;
                ver = true;
            }
        }
        else {
            if (ver) {
                ans = (ans * 2) % MOD;
                i += 2;
                ver = false;
            }
            else {
                ans = (ans * 3) % MOD;
                i += 2;
                ver = false;
            }
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i, j;
    
    scanf("%d", &n);
    
    //printf("%d", n / 4);
    
    for(i = 0; i < (n / 4 + 1); i++) {
        for(j = 0; j < n - j; j++) {
            if(4 * i + 7 * j == n) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
/*??????2-1*/

#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0)
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
map<ll, ll> memo;

int main() {
    cin >> N;
    REP(i, N) {
        LCIN(a);
        memo[a]++;
        memo[a + 1]++;
        memo[a - 1]++;
    }
    ll ans = 0;
    FOREACH(m, memo) ans = max(m.second, ans);
    cout << ans << "\n";
}

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

int main(){
  int N;
  cin>>N;
  int A,B,C,D;
  A=N/1000;
  B=(N/100)%10;
  C=(N/10)%10;
  D=N%10;
  bool flg=true;
  bool flg1=true;
  if((A>1)||(A==0 && B==0)||(A==1 && B>2)){
    flg=false;
  }
  if((C>1)||(C==0 && D==0)||(C==1 && D>2)){
    flg1=false;
  }

  if(flg==true && flg1==true){
    cout<<"AMBIGUOUS"<<endl;
  }
  if(flg==true && flg1==false){
    cout<<"MMYY"<<endl;
  }
  if(flg==false && flg1==true){
    cout<<"YYMM"<<endl;
  }
  if(flg==false && flg1==false){
    cout<<"NA"<<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(b>(a-1)*(a-2)/2)puts("-1");
	else{
		int z=a-1+((a-1)*(a-2)/2-b),x=0,y=1;
		cout<<z<<endl;
		f(i,a-1){
			cout<<i+1<<" "<<a<<endl;
		}
		z-=a-1;
		while(z){
			if(y==a-1){
				x++;
				y=x+1;
			}
			cout<<x+1<<" "<<y+1<<endl;
			y++;
			z--;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main()
{
        ll n;
        double d;
        lscf(n);dscf(d);
        ll count=0;
        while(n--)
        {
            double x,y;
            dscf(x);dscf(y);
            if(sqrt(x*x+y*y)<=d)
            count++;
        }
        lpri(count);
return 0;
}

Measured memory_bytes: 3804
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int M;
int K;
long long A[200000];
long long B[200000];
long long sa[200000+1];
long long sb[200000+1];
int main(){
  int res = 0;
  int i;
  int j;
  rd(N);
  rd(M);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY=(0);e98WHCEY<(M);e98WHCEY++){
      rd(B[e98WHCEY]);
    }
  }
  for(i=(0);i<(N);i++){
    sa[i+1] = sa[i] + A[i];
  }
  for(i=(0);i<(M);i++){
    sb[i+1] = sb[i] + B[i];
  }
  j = M;
  for(i=(0);i<(N+1);i++){
    if(sa[i] <= K){
      while(sa[i] + sb[j] > K){
        j--;
      }
      chmax(res, i+j);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N, M, K;
// ll A[2d5], B[2d5];
// ll sa[2d5+1], sb[2d5+1];
// {
//   int res = 0, i, j;
//   rd(N,M,K,A(N),B(M));
//   rep(i,N) sa[i+1] = sa[i] + A[i];
//   rep(i,M) sb[i+1] = sb[i] + B[i];
// 
//   j = M;
//   rep(i,N+1) if(sa[i] <= K){
//     while(sa[i] + sb[j] > K) j--;
//     res >?= i+j;
//   }
//   wt(res);
// }


Measured memory_bytes: 10756
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let p: Vec<i32> = s.by_ref().take(3).map(|a| a.parse().unwrap()).collect();
	let t: Vec<_> = s.next().unwrap().chars().collect();
	let mut dp = vec![vec![0; 3]; n];
	let mut ans = 0;
	for m in 0..k {
		for hand in 0..3 {
			dp[m][hand] = match hand {
				0 if t[m] == 's' => p[0],
				1 if t[m] == 'p' => p[1],
				2 if t[m] == 'r' => p[2],
				_ => 0,
			};
		}
		let mut i = m + k;
		while i < n {
			for last in 0..3 {
				for hand in 0..3 {
					if last == hand {
						continue;
					}
					let t = match hand {
						0 if t[i] == 's' => p[0],
						1 if t[i] == 'p' => p[1],
						2 if t[i] == 'r' => p[2],
						_ => 0,
					};
					if dp[i][hand] < t + dp[i - k][last] {
						dp[i][hand] = t + dp[i - k][last];
					}
				}
			}
			i += k;
		}
		ans += std::cmp::max(std::cmp::max(dp[i - k][0], dp[i - k][1]), dp[i - k][2]);
	}
	println!("{}", ans);
}


Measured memory_bytes: 10492
#include<stdio.h>

void insertionSort(int *,int ,int);
void shellSort(int *,int);
int cnt;
int main()
{
  int n,i,A[1000000];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  shellSort(A,n);
  for(i=0;i<n;i++)
    {
      printf("%d\n",A[i]);
    }

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

  void shellSort(int *A,int n)
  {
    int m=0,G[n],i;
    G[0]=1;
    
    for(i=0;;i++)
      {	
	if(G[i]>n)break;
	G[i+1]=3*G[i]+1;
	m++;
      }
    printf("%d\n",m);
        for(i=m-1;i>=0;i--)
      {
	printf("%d ",G[i]);
	insertionSort(A,n,G[i]);
      }
    printf("\n%d\n",cnt);

  }

Measured memory_bytes: 4512
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, K, x;
  cin >> N >> K;
  set<ll> s;
  for (auto i = 0; i < 10; i++) s.insert(i);
  for (auto i = 0; i < K; i++) {
    cin >> x;
    s.erase(x);
  }

  while (true) {
    x = N;
    ll digit = 1;
    while (x > 0) {
//      cout << "N=" << N << " x=" << x << " digit=" << digit << endl;
      if (s.find(x % 10) == s.end()) {
        N = (x+1) * digit;
        break;
      }
      digit *= 10;
      x /= 10;
    }
    if (x == 0) break;
  }

  cout << N << endl;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	int ans = a[0];
	inc(i, n) { ans = gcd(ans, a[i]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <inttypes.h>

int32_t N;
uint32_t A[271828];

int sumipe(const int maaya[]) {
	int i;
	for (i = 0; i < 32; i++) {
		if (maaya[i] > 1) return 0;
	}
	return 1;
}

int main(void) {
	int32_t i;
	int32_t start;
	int bitCount[32] = {0}, j;
	int64_t answer = 0;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNu32, &A[i]) != 1) return 1;
	}
	start = 0;
	i = 0;
	while (start < N) {
		while (i < N && sumipe(bitCount)) {
			for (j = 0; j < 32; j++) bitCount[j] += ((A[i] >> j) & 1);
			i++;
		}
		if (sumipe(bitCount)) {
			answer += i - start;
		} else {
			answer += i - 1 - start;
		}
		for (j = 0; j < 32; j++) bitCount[j] -= ((A[start] >> j) & 1);
		start++;
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}


Measured memory_bytes: 896
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()

    val a: MutableList<Int> = mutableListOf()
    
    for (i in 0..n-1) {
        a.add(cin.nextInt())
    }
    val a_s = a.sortedDescending()
    
    for (i in 0..n-1) {
        if (a_s[0] == a[i]) {
            println(a_s[1])
        } else {
            println(a_s[0])
        }
    }
}

Measured memory_bytes: 91752
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split(' ')))

#
max_a = max(a)
min_a = min(a)
sign = lambda x: 1 if x >= 0 else -1

ans = []

if sign(max_a) == sign(min_a):
    # 全ての正負が同じ
    if max_a > 0:
        for j in range(N-1):
            ans.append((j, j+1))

    else:
        for j in range(N-1, 0, -1):
            ans.append((j, j-1))


else:
    # 全ての正が異なる
    if abs(max_a) >= abs(min_a):
        # 正の方が大きい
        i = a.index(max_a)
        for j in range(N):
            if i != j:
                ans.append((i, j))

        for j in range(N-1):
            ans.append((j, j+1))


    else:
        # 負の方が大きい
        i = a.index(min_a)
        for j in range(N):
            if i != j:
                ans.append((i, j))

        for j in range(N-1, 0, -1):
            ans.append((j, j-1))

print(len(ans))
for i, j in ans:
    print(i+1, j+1)




Measured memory_bytes: 38384
#include<stdio.h>
int main(void)
{
	int h,w,n,m,s=0,count=0,max;
	scanf("%d %d %d",&h,&w,&n);
	while(s<n)
	{
		if(h>w)
		{
			s=s+h;
			w--;
		}
		else
		{
			s=s+w;
			h--;
		}
		count++;
		
	}
	printf("%d",count);
	return 0;
 } 

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

using namespace std;

int n;
double p, ans;
double dp[3010];


int main() {
	cin >> n; 
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> p;
		for (int coins = i; coins >= 0; coins--) {
			dp[coins] = (coins == 0 ? 0 : dp[coins - 1] * p) + dp[coins] * (1 - p);
		}
	}
	cout.precision(20);
	for (int i = n / 2 + 1; i <= n; i++) 
		ans += dp[i];           
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  const M = +input[0][1];
  const psets = input.slice(1);
 
  const accepted = new Set();
  const penas = {};
  var totalPenas = 0;
 
  var q;
  for (var i = 0; i < M; i++) {
    q = psets[i][0];
 
    if (accepted.has(q)) continue;
 
    if (psets[i][1][0] === 'A') {
      accepted.add(q);
      if (penas[q]) {
        totalPenas += penas[q];
      }
    } else {
      penas[q] = (penas[q] || 0) + 1;
    }
  }
 
  const answer = '' + accepted.size + ' ' + totalPenas;
 
  console.log(answer);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim()
  .split('\n')
  .map((v) => v.split(' '))
);

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

int main() {
  int N, now = 0;
  
  
  cin >> N;
  
  vector<int> button(N);
  vector<int> count(N);
  
  count.at(0) = 1;
  
  for (int i = 0; i < N; i++) {
    cin >> button.at(i);
  }
  int counter = 0;
  for (int i = 0; i < N; i++) {
    now = button.at(now) - 1;
    // cout << now << endl;
    count.at(now)++;
    counter++;
    if (count.at(now) >= 2) {
      cout << -1 << endl;
      break;
    }
    else if (now == 1) {
      cout << counter << endl;
      break;
    }
  }
}

Measured memory_bytes: 1152
n,a,b = map(int,input().split())
mod = 10**9+7
def c(n,r,m):
    a=b=1
    for i in range(1,r+1):
        a=a*n%m
        b=b*i%m
        n-=1
    return a*pow(b,m-2,m)
print((pow(2,n,mod)-c(n,a,mod)-c(n,b,mod)-1)%mod)

Measured memory_bytes: 3060
N,K = map(int,input().split())
tmp = K/N
q = 1
p = 2 ** 100
while p/q >2:
    qp = q*2
    if qp > tmp:
        p = qp
    else:
        q = qp
res = 0
for i in range(N,0,-1):
    ans = i*q
    if ans < K:
        q*=2
    res+= float(1)/q
print(res/N)

Measured memory_bytes: 3064
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
VL AA;
void dfs(LL x){
    AA.PB(x);
    if(x>=1e9)return;
    int v=x%10;
    FOR(i,max(v-1,0),min(9,v+1)){
        dfs(x*10+i);
    }
}
int main(){
    int K;
    R(K);
    FOR(i,1,9){
        dfs(i);
    }
    sort(ALL(AA));
    W(AA[K-1]);
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;

        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            cnt[a - 1]++;
        }
    }

    int sum = 0;
    for (int i = 0; i < m; i++) {
        if (cnt[i] == n) {
            sum++;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,w;cin >> h >>w;
    vector<vector<char>> g(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> g[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(g[i][j]=='#')continue;
            ll cnt=0;
            rep(k,8){
                ll ny=i+dy[k],nx=j+dx[k];
                if(ny<0||nx<0||ny>=h||nx>=w)continue;
                if(g[ny][nx]=='#')cnt++;
            }
            g[i][j]='0'+cnt;
        }
    }
    rep(i,h){
        rep(j,w){
            cout << g[i][j];
        }
        cout << endl;
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n;
  string s,ans;
  cin>>n>>ans;
  for(int i=1;i<n;i++){
    string tmp;
    cin>>s;
    bool flag=true;
    while(flag){
      flag=false;
      for(int j=0;j<ans.size();j++){
	for(int k=0;k<s.size();k++){
	  if(ans[j]==s[k]){
	    tmp=tmp+ans[j];
	    ans.erase(ans.begin()+j);
	    s.erase(s.begin()+k);
	    flag=true;
	    //cout<<"debug: "<<ans<<" "<<s<<endl;
	  }
	}
      }
    }
    ans=tmp;
  }
  sort(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}


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

inline void swap(int& a, int& b) {
	int t = 0;
	t = a, a = b, b = t;
}

class Dice {
private:
	int label[6];
public:
	Dice(int* a) {
		for (int i = 0; i < 6; i++) {
			label[i] = a[i];
		}
	}

	void N() {
		int cpy[] = { label[0],label[1],label[4],label[5] };
		label[0] = cpy[1];
		label[1] = cpy[3];
		label[4] = cpy[0];
		label[5] = cpy[2];

	}
	void S() {
		int cpy[] = { label[0],label[1],label[4],label[5] };
		label[0] = cpy[2];
		label[1] = cpy[0];
		label[4] = cpy[3];
		label[5] = cpy[1];

	}
	void W() {
		int cpy[] = { label[0],label[2],label[3],label[5] };
		label[0] = cpy[1];
		label[2] = cpy[3];
		label[3] = cpy[0];
		label[5] = cpy[2];

	}
	void E() {
		int cpy[] = { label[0],label[2],label[3],label[5] };
		label[0] = cpy[2];
		label[2] = cpy[0];
		label[3] = cpy[3];
		label[5] = cpy[1];

	}
	void clock() {
		int cpy[] = { label[1],label[2],label[3],label[4] };
		label[1] = cpy[2];
		label[2] = cpy[0];
		label[3] = cpy[3];
		label[4] = cpy[1];
	}

	int getup() {
		return label[0];
	}
	int getfront() {
		return label[1];
	}
	int getright() {
		return label[2];
	}
};

int main() {
	int a[6];
	for (int i = 0; i < 6; i++) {
		cin >> a[i];
	}
	class Dice dice(a);
	int Q = 0;
	int q[2] = {0};
	cin >> Q;
	for (int j = 0; j < Q;j++) {
		cin >> q[0] >> q[1];
		for (int i = 0; i < 4; i++) {
			if (dice.getup() == q[0]) {
				break;
			}
			dice.N();
		}
		if (dice.getup() != q[0]) {
			dice.W();
		}
		if (dice.getup() != q[0]) {
			dice.E(), dice.E();
		}
		while (dice.getfront() != q[1]) {
			dice.clock();
		}
		cout << dice.getright() << endl;

	}
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=105;
int n,m;
char s[N][N];
int f[N][N];
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) scanf("%s",s[i]+1);
	memset(f,10,sizeof(f));
	f[1][1]=(s[1][1]=='#');
	For(i,1,n) For(j,1,m){
		f[i][j+1]=min(f[i][j+1],f[i][j]+(s[i][j]!=s[i][j+1]));
		f[i+1][j]=min(f[i+1][j],f[i][j]+(s[i][j]!=s[i+1][j]));
	}
	int ans=f[n][m]+(s[n][m]=='#');
	printf("%d\n",ans/2);
} 

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

int main(){
    string S;
    cin >> S;

    char atgc[4] = {'A' ,'T', 'G', 'C'};

    int sum=0;
    int ans = 0;
    for (int i=0; i<S.size(); i++){
        if (S.at(i)==atgc[0] || S.at(i)==atgc[1]
        || S.at(i)==atgc[2] || S.at(i)==atgc[3]){
            sum++;
        } else {
            ans = max(ans, sum);
            sum = 0;
        }
    }

    ans = max(ans, sum);

    cout << ans << endl;

}

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

/*注文時刻から一分でも遅れてしまうと次の注文まで待たなければならない。よってそのような余分な時間を取り除きたい。余分な時間が取り除けるのは最後の注文である。なぜなら注文が届いた時点で時間の測定が終了するからである。たとえば12, 14, 18の3つがあったとするとどれも一度注文すると、20の倍数の時間を待たなければならない。が最後の注文のみは異なるので、最も効率の良い注文は(14, 18, 12) 乃至は (18, 14, 12)となる。つまり一の位が最小である注文時間を持つ料理を最後に頼めばよい。ただし一の位が0であるときを除く(12と11と10のとき、(12, 11, 10)と(12, 10, 11)では後者の方が9分早い*/

/*まあ120通り全部計算しても時間には余裕があるだろうが...*/

int main(){
  int sum = 0;                                          //所要時間
  int a = 10;                                               //1の位の最小の値を格納
  for(int i = 0; i < 5; i++){
    int I;
    cin >> I;
    if(I % 10 == 0)                                   //10 -> 10　修正は無い
      sum += I;
    else{
      sum += (I/10 + 1) * 10;              //17->20  32->40といった処理
      if(a > I % 10)                                    //一の位の最小値を更新
        a = I % 10;
    }

  }

  if(a != 10)
    cout << sum - 10 + a << endl;
  else                                                                 //一の位がすべて0であったということ
    cout << sum << endl;
  return 0;
  
}




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


int main(){
  int K;

  cin >>K;

  if( K % 2 == 0){
    cout <<(K/2) * (K/2)<<endl;
  }
  else{
    cout <<(K/2 + 1) * (K/2)<<endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll t1, t2, a1, a2, b1, b2;
string s;
ll N;

int main() {
    cin >> N;
    vector<int> A(N), B(N), x, y;
    REP(i, N)cin >> A[i];
    REP(i, N)cin >> B[i];
    x = A,y = B;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    ll a, b, cnt = 1;
    do {
        bool isTrue = true;
        REP(i, N)if (A[i] != x[i])isTrue = false;
        if (isTrue)a = cnt;
        cnt++;
    } while (next_permutation(A.begin(), A.end()));
    cnt = 1;
    do {
        bool isTrue = true;
        REP(i, N)if (B[i] != y[i])isTrue = false;
        if (isTrue)b = cnt;
        cnt++;
    } while (next_permutation(B.begin(), B.end()));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int a, b;
     
    cin>> a >> b;
     
    if ( a < b ) 
		cout << "a < b" << endl;
    else if ( a > b ) 
		cout << "a > b" << endl;
    else 
		cout << "a == b" << endl;

    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a < 3200)
  {
    cout << "red";
  }
  else
  {
    cout << s;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char ch;
    cin >> ch;
    if(ch >= 'A' and ch <= 'Z'){
    	cout << 'A';
    }
    else
    	cout << 'a';
    return 0;
}
 


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> B(N-1),A(N);
  for(int i=0;i<N-1;i++){
    cin >> B.at(i);
  }
  A.at(0)=B.at(0);
  for(int i=1;i<N-1;i++){
    A.at(i)=min(B.at(i),B.at(i-1));
  }
  A.at(N-1)=B.at(N-2);
  int64_t ans=0;
  for(int i=0;i<N;i++){
    ans+=A.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int ans = 0;
    for (auto t : cnt) {
        if (t.first > t.second) {
            ans += t.second;
        }
        else if (t.first < t.second) {
            ans += t.second - t.first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define int long long

void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

void solve()
{

  int a;cin>>a;
  cout<<a*(1+a+a*a)<<endl;
}

int32_t main()
{
    // fastio();
  //   ios_base::sync_with_stdio(0);
  //   cin.tie(0);cout.tie(0);
    // int t;cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3620