akhauriyash/Code-Regression huggingface dataset:
import math





H,W = list(map(int,input().split(" ")))
x1 = 0
y1 = 0
x2 = 0
y2 = 0
cond = 0
mass = []
for _ in range(H):
    mass.append(list(map(int, input().split(" "))))

s = [0]
def move(sx,sy,gx,gy):
    temp = []
    go = -1
    if sy % 2 == 1:
        go = 1 #
    x = sx
    y = sy
    while True:

        # 現在地の確認

        if (x == W and go == 1) or (x == 1 and go == -1): #端っこにいるなら下がる→反転
            ny = y + 1
            temp.append([y, x, ny, x])
            s[0] += 1
            y = ny #下がる
            go *= -1
            if x == gx and y == gy:
                return temp



        nx = x + go
        temp.append([y, x, y, nx])
        s[0] += 1
        x = nx

        # check
        if  x == gx and  y ==gy:
            return temp






ans = []
for y,As in enumerate(mass):
    if y %2 == 0:
        start = 0
        end = W
        hoge = 1
    else:
        start = W-1
        end = -1
        hoge = -1
    for i in range(start,end,hoge):
        a = As[i]
        if a % 2 == 1:
            if cond %2 == 0:
                x1 = i + 1
                y1 = y + 1
                cond += 1
            else:
                x2 = i + 1
                y2 = y + 1
                ans.append(move(x1,y1,x2,y2))
                # if x2 > x1:
                #     step = -1
                # else:
                #     step = 1
                # cot  = abs(x2 -x1)
                # for _ in range(cot): #横に動く
                #     ans.append([y2,x2,y2,x2+step])
                #     x2 = x2+step
                # cot = abs(y2 -y1)
                # for _ in range(cot):
                #     ans.append([y2,x2,  y2 -1, x2])
                #     y2 = y2 -1
                cond += 1

print(s[0])
for temp in ans:
    for temp2 in temp:
        print(*temp2 )

Measured memory_bytes: 83036
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

a, b, c, d, e, f = MI()

def main():
    ans_sw=100*a
    ans_s=0
    for an in range(f+1):
        if a*an*100>f:break
        for bn in range(f+1):
            w=an*a+bn*b
            if w*100>f:break
            lim=min(w*e,f-w*100)
            for cn in range(f+1):
                dn=(lim-c*cn)//d
                if dn<0:break
                s=c*cn+d*dn
                if s*ans_sw>ans_s*(s+100*w):
                    ans_sw=s+100*w
                    ans_s=s
    print(ans_sw,ans_s)

main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

typedef long long ll;

const int maxn = 1e5+5;
int N,M;
int fa[maxn];
int size[maxn];
ll ans[maxn];
int l[maxn];
int r[maxn];

int find(int x)
{
    return fa[x] == x ? x:fa[x]= find(fa[x]); //这里一开始写错了，写成了x = find。。
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        size[a] += size[b];
        size[b] = 0;
       fa[b] = a;
    }
}
int main(){
	cin>>N>>M;

	for(int i=0;i<maxn;i++)
		fa[i] = i,size[i]=1;
	 memset(ans, 0, sizeof(ans));
		
	for(int i=1;i<=M;i++)
		scanf("%d%d", &l[i], &r[i]);
	ll cnt = N;
	ans[M+1] = cnt*(cnt-1)/2;
	for(int i = M;i>=2;i--){
		int x = find(l[i]);
		int y = find(r[i]);
		if(x!=y){
			ans[i] = ans[i+1]-size[x]*size[y];
			join(l[i],r[i]);
		}
		else 
			ans[i] = ans[i+1];
	}
	
	for(int i=2;i<=M+1;i++)
		  printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

struct Sieve{
  ll n;
  vector<ll> f, primes;
  Sieve(ll n = 1): n(n), f(n+1, 0){
    f[0] = f[1] = -1;
    for(ll i = 2; i <= n; i++){
      if(f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for(ll j = i*i; j <= n; j += i) if(!f[j]) f[j] = i;
    }
  }
  bool isPrime(const ll x){ return f[x] == x; }
  vector<ll> factorList(ll x){
    vector<ll> res;
    while(x != 1){
      res.emplace_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<ll, ll>> factor(const ll x){
    vector<ll> fl = factorList(x);
    if(fl.size() == 0) return {};
    vector<pair<ll, ll>> res(1, pair<ll, ll>(fl[0], 0));
    for(ll p : fl){
      if(res.back().first == p) res.back().second++;
      else res.emplace_back(pair<ll, ll>(p, 1));
    }
    return res;
  }
};

int main(void){
  ll n;
  cin >> n;
  Sieve s(n);
  ll ans = 0;
  
  REP(i, n){
    auto p = s.factor(i+1);
    ll m = 1;
    for(auto q : p){
      m *= (q.second+1);
    }
    ans += (i+1) * m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 89780
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <set>

using namespace std;




int main(void) {
	long long n;
	long long i, j, k;
	long long res;
	long long a, b;

	cin >> k;
	cin >> a >> b;

	for (i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}


	cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3636
a,b,c,d=map(int,input().split())
if a<=c<=d<=b:
  print(d-c)
elif a<=c<=b<=d:
  print(b-c)
elif c<=a<=b<=d:
  print(b-a)
elif c<=a<=d<=b:
  print(d-a)
else:
  print(0)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 08:44:21 2020

@author: teppe
"""

from collections import deque

def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

MOD = 10**9+7
fact, fact_inv = prepare(10+10**5, MOD)

def perm(n,k):
  if k > n or k < 0:
    return 0
  return fact[n] * fact_inv[n-k] % MOD


n, k = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
 
colored = [False]*n
colored[0] = True
num = len(e[0])
ans = perm(k, 1+num)
d = deque()
for i in e[0]:
    colored[i] = True
    d.append(i)
while d:
    f = d.pop()
    num = len(e[f]) - 1
    if num == 0:
        continue
    ans *= perm(k-2, num)
    ans %= MOD
    for i in e[f]:
        if not colored[i]:
            colored[i] = True
            d.appendleft(i)
print(ans % MOD)


Measured memory_bytes: 95820
s = input()

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] !=s[1]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] !=s[2]:
    print('Yes')
else:
    print('No')
        
       
       

Measured memory_bytes: 3060
using System;
namespace ATCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            if (n.Equals("AAA") || n.Equals("BBB"))
            {
                Console.WriteLine("No");
            }
            else Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a == b && b == c) || (a != b && b != c && a != c) ? "No" : "Yes");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

int main()
{
  int q,h,s,d,n;cin>>q>>h>>s>>d>>n;
  int beth=min(h,q*2);
  int bets=min(s,beth*2);
  int betd=min(d,bets*2);
  long long ans=0;
  ans+=(long long)n/2*betd+(long long)n%2*bets;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
const int N_MAX=100000;
int N;
vector<tuple<int,int,int>> happy;
int dp[N_MAX+1][3];

signed main(){
    cin>>N;
    REP(i,N){
        int a,b,c;
        cin>>a>>b>>c;
        happy.emplace_back(a,b,c);
    }
    for(int i=N-1;i>=0;--i){
        int a[3];
        tie(a[0],a[1],a[2])=happy[i];
        REP(j,3){
            int ret=0; 
            REP(k,3){
                if(j==k) continue;
                ret=max(ret,dp[i+1][k]+a[k]);
            }
            dp[i][j]=ret;
        }
    }
    cout<<max({dp[0][0],dp[0][1],dp[0][2]})<<endl;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__ << '\n';
#define MAX (ll)1e10
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main()
{
	ll i,n,k,j;
	cin >> n >> k;
	vl a(n);
	forn(0,n,i)
		cin >> a[i];
	//solve(0ll);
	vl dp(n,MAX);
	dp[0] = 0;
	for(i=1;i<n;i++)
	{
		if(i >= k)
		{
			for(j=i;j>=i-k;j--)
			{
				dp[i] = min(dp[i],dp[j] + abs(a[i] - a[j]));
			}
		}
		else
		{
			for(j=i-1;j>=0;j--)
			{
				dp[i] = min(dp[i],dp[j] + abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n-1] << '\n';
}












Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b.append(0)

ans = sum(a)

if a[0]<b[0]:
    b[0]-=a[0]
    a[0]=0
else:
    a[0]-=b[0]
    b[0]=0
    
for i in range(1,n+1):
    if a[i]<b[i-1]+b[i]:
        if a[i]>b[i-1]:
            b[i] -= a[i] - b[i-1]
            b[i-1] =0
        else:
            b[i-1] -= a[i]
        a[i]=0
    else:
        a[i] -= b[i-1]+b[i]
        b[i]=0
print(ans-sum(a))


Measured memory_bytes: 24100
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
#define tor(a,b) for(register int a=head[b];a;a=nxt[a])

const int MAXN=2005,INF=0x3f3f3f3f;

int n; char s[MAXN];
int ecnt,edge[MAXN<<1],head[MAXN],nxt[MAXN<<1];
int ans=INF,f[MAXN],siz[MAXN],cnt[MAXN];

inline void insert(int from,int to,int id){
	nxt[id]=head[from]; head[from]=id; edge[id]=to;
}

void dfs(int u,int fa){
	int sum=0,maxx=0;
	tor(i,u){
		int v=edge[i]; if(v==fa) continue;
		dfs(v,u);
		cnt[u]+=cnt[v]+siz[v]; siz[u]+=siz[v]; maxx=max(maxx,cnt[v]+siz[v]); sum+=cnt[v]+siz[v];
	}
	if(sum-maxx>=maxx) f[u]=sum>>1;
	else{
		tor(i,u){
			int v=edge[i]; if(v==fa) continue;
			if(cnt[v]+siz[v]==maxx){
				f[u]=max(f[u],(sum-maxx)+min((2*maxx-sum)>>1,f[v]));
			}
		}
	}
}

inline int calc(int root){
	lor(i,1,n) siz[i]=s[i]=='1',cnt[i]=f[i]=0;
	dfs(root,root);
	if((f[root]<<1)==cnt[root]) return f[root]; else return INF;
}

int main(){
	scanf("%d",&n); scanf("%s",s+1);
	lor(i,1,n-1){
		int a,b; scanf("%d%d",&a,&b); insert(a,b,++ecnt); insert(b,a,++ecnt);
	}
	lor(i,1,n) ans=min(ans,calc(i));
	printf("%d\n",ans==INF?-1:ans);

	return 0;
}

Measured memory_bytes: 512
import sys
s=sys.stdin.readline
while 1:
 n=int(s())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=s().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(s()):
  a+=d.get(*[s().strip()]*2)
 print(a)


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string t;
    cin >> t;
    rep(i,t.size()){
        if(t[i]=='?'){
            cout << 'D' ;
        }else{
            cout << t[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
ll n, m, k, a[200005], b[200005],ans=-1,ma=-1;

int main() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	int tim=0, su=0,nn=0,mm=0;
	for (int i = 0; i < n; i++) {
		if (tim + a[i] <= k)tim += a[i], su++,nn++;
		else break;
	}
	ans = nn;
	mm = 0;
	ma = 0;
		for (int i = nn-1; i >= -1; i--) {
			while (b[mm] <= k - tim && mm < m) { tim += b[mm], ans++, mm++; }
			if (ans > ma)ma = ans;
			if (i >= 0)tim -= a[i];
			if (i >= 0)ans--;
		}
	cout << ma << endl;

	return 0;
}

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

int main(){
  int n;
  cin>> n;
  
  //{1,2,...,n-1,n}を{2,3,...,n,1}で割ったあまりは{1,2,...,n-1,0}
  cout<< (int64_t)n*(n-1)/2 << endl;//桁が足りない？
}

Measured memory_bytes: 256
void main()
{
    long a, b, c;
    rdVals(a, b, c);

    writeln((a * b) >> 1);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
//in the name of GOD//

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
#define sz(s) s.size()

int main(){
  char c;
  cin >> c;
  if(c == 'S')
    cout << "Cloudy";
  else if(c == 'C')
    cout << "Rainy";
  else
    cout << "Sunny";
}


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

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if (a != b) {
        ans++;
    }
    if (b != c) {
        ans++;
    }
    if (c != a) {
        ans++;
    }
    if (a == b && b == c && c == a) {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

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

days,tasks = arr[0],arr[1]

def main(days, ais):
  sum = 0
  for i in ais:
    sum += i
    if sum > days: return -1

  return days - sum

print(main(days, ais))


Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
int max(int a,int b)
{
    return((a>b)?a:b);
}
void dfs(int p,bool visited[],vector <int> v[],int dp[])
{
    visited[p]=true;
    for(int i=0;i<v[p].size();i++)
    {
        if(!visited[v[p][i]])
        {
            dfs(v[p][i],visited,v,dp);
        }
        dp[p]=max(dp[p],1+dp[v[p][i]]);
    }
}
int main()
{
    int n,m,i,x,y,maxm=0;
    cin>>n>>m;
    vector <int> v[n+1];
    int dp[n+1]={0};       bool visited[n+1];
    for(i=0;i<=n;i++)
        visited[i]=false;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            dfs(i,visited,v,dp);
        }
    }
    for(i=1;i<=n;i++)
    {
        if(dp[i]>maxm)
        {
            maxm=dp[i];
        }
    }
    cout<<maxm;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

ll d[10][100];

int main() {
    cin >> n >> m;
    vp v(m);
    vi va(n);
    REP(i,n) {
        va[i] = i + 1;
    }
    REP(i,m) {
        cin >> v[i].first >> v[i].second;
        d[v[i].first][v[i].second] = 1;
        d[v[i].second][v[i].first] = 1;
    }
    do{
        if(va[0]!=1){
            cout << ans << Endl;
            return 0;
        }
        REP(i,n-1) {
            if(d[va[i]][va[i+1]]){
                if(i==n-2)
                    ans++;
                continue;
            }else{
                break;
            }
        }
    } while (next_permutation(ALL(va)));
}

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

int main(){
    int n,m;
    while(cin >> n >> m, n|m){
        int recomend[m] = {};
        for(int i= 0; i < n; i++){
            int d,v; cin >> d >> v;

            recomend[d-1] = max(recomend[d-1], v);
        }

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

        cout << sum << "\n";
    }
}


Measured memory_bytes: 3004
# https://atcoder.jp/contests/apc001/tasks/apc001_c
# nが奇数かつ同性がとなりに座ることはないので、男女は交互である。
# 制限回数が20回のところから、おそらくLogで求められる。
n = int(input())

# 0番についてクエリを投げ、結果を受け取る
q = 0
print(q)
zero = input()

if zero == "Vacant":
    exit()

left = 1
right = n - 1


for _ in range(19):
    q = (left + right) // 2
    print(q)
    s = input()
    if s == "Vacant":
        exit()
    elif q % 2 == 0:
        if s == zero:
            left = q + 1
        else:
            right = q
    else:
        if s == zero:
            right = q
        else:
            left = q + 1



Measured memory_bytes: 62056
N = int(input())
As = list(map(int, input().split()))
def xor(L):
  r = L[0]
  for i in range(1, len(L)):
    r ^= L[i]
  return r
re = 0
r = 0
s = 0
x = 0
for l in range(0, N):
  #s += As[l]
  #x ^= As[l]
  while r < N:
    #print(l, r, s, x)
    if s+As[r] == x^As[r]:
      s += As[r]
      x ^= As[r]
    #if sum(As[l:r+1]) == xor(As[l:r+1]):
      r += 1
    else:
      break
  s -= As[l]
  x ^= As[l]
  #print(l, r)
  re += r-l
print(re)


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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < v.size();++i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    string s;
    cin>>s;
    Yes(s.substr(0,4)=="YAKI");
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var ans = A - 2 * B;

        if (ans < 0)
            ans = 0;

        WriteLine(ans);
    }
}


Measured memory_bytes: 27924
import sys

for line in range(int(input())):
    str = input().split(" ")
    nums = sorted([int(str[2]), int(str[1]), int(str[0])])
    if nums[2]*nums[2] == nums[1]*nums[1] + nums[0]*nums[0]:
        print("YES")
    else:
        print("NO")

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

int main() {
   int d,n;
   cin >> d >> n;
   
   long long a=1;
   if(n==100)
   n++;
   rep(i,d)
   a*=100;
   cout << a*n << endl;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll dp[310][310][310];

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

  ll n,k;
  std::cin>>n>>k;

  std::vector<ll> h(n);
  rep(i,0,n)std::cin>>h[i];

  std::vector<ll> zaatsu=h,sum(n+1,0);
  std::sort(all(zaatsu));

  rep(i,1,n+1)sum[i]=zaatsu[i-1];
  rep(i,0,n)h[i]=(ll)(std::lower_bound(all(zaatsu),h[i])-zaatsu.begin())+1;

  rep(i,0,301)rep(j,0,310)rep(k,0,310)dp[i][j][k]=1e14;
  dp[0][0][0]=0;

  rep(i,0,n){
    rep(j,0,k){
      rep(l,0,n+1){
        if(l<h[i]){
          chmin(dp[i+1][j][h[i]],dp[i][j][l]+sum[h[i]]-sum[l]);
          chmin(dp[i+1][j+1][l],dp[i][j][l]);
        }
        if(l==h[i]){
          chmin(dp[i+1][j][l],dp[i][j][l]);
        }
        if(l>h[i]){
          chmin(dp[i+1][j+1][l],dp[i][j][l]);
          chmin(dp[i+1][j][h[i]],dp[i][j][l]);
        }
      }
    }
    rep(l,0,n+1){
        if(l<h[i]){
          chmin(dp[i+1][k][h[i]],dp[i][k][l]+sum[h[i]]-sum[l]);
        }
        if(l==h[i]){
          chmin(dp[i+1][k][l],dp[i][k][l]);
        }
        if(l>h[i]){
          chmin(dp[i+1][k][h[i]],dp[i][k][l]);
        }
    }
  }

  ll ans=1e14;

  rep(i,0,n+1)rep(j,0,k+1)chmin(ans,dp[n][j][i]);

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 227584
//Osenbei
#include <stdio.h>
#include <string.h>
int A[10001];

int main(){
  int C, R, tmp, mask, ans, a, b, c, i, j;
  while(true){
    scanf("%d %d", &C, &R);
    if((C | R) == 0){
      break;
    }
    memset(A, 0, sizeof(A));
    for(i = 0; i < C; ++i){
      for(j = 0; j < R; ++j){
        scanf("%d", &tmp);
        A[j] += tmp << i;
      }
    }
    for(i = 0; i < R; ++i){
      //printf("%d", A[i]);
    }
    //printf("\n");
    ans = 0;
    for(mask = 0; mask < (1 << C); ++mask){
      //printf("mask = %d \n", mask);
      a = 0;
      for(i = 0; i < R; ++i){
        tmp = A[i] ^ mask;
        //printf("%d", tmp);
        b = 0;
        while(tmp != 0){
          if((tmp & 1) == 1){
            b++;
          }
          tmp = tmp >> 1;
        }
        a += b > C - b ? b : C - b;
      }
      //printf(" a = %d \n", a);
      if(ans < a){
        ans = a;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(auto &h : H) cin >> h;
  vector<int> C(N,0);
  for(int i = N-2; i >= 0; --i){
    if(H[i] >= H[i+1]) C[i] = C[i+1] + 1;
  }
  cout << *max_element(C.begin(), C.end()) << endl;
}


Measured memory_bytes: 1024
a, b, c = gets.chomp.split(" ").map(&:to_i);

cnt = 0

if a.even? && b.even? && c.even? && a == b && a == c && a == b
    print -1
    exit
end

while a.even? && b.even? && c.even? do
    tmpa = b / 2 + c / 2
    tmpb = a / 2 + c / 2
    tmpc = a / 2 + b / 2
    a = tmpa
    b = tmpb
    c = tmpc
    cnt += 1
end

print cnt

Measured memory_bytes: 14332
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
int main(void)
{
	int i,j,k,cnt,x,sa;
	int a,b;
	int n,kk[4545],c[4545];
	while(cin>>n,n|n) {
		for(i=0;i<n+1;i++) {c[i]=0,kk[i]=0;}
		for(i=0;i<n+1;i++) cin>>kk[i];
		for(i=0;i<n+1;i++) {
			x=0;
			for(j=0;j<n+1;j++) if(i!=j) {c[x]=kk[j],x++;}
			cnt=0;
			sa=c[1]-c[0];
			for(j=1;j<n;j++) {
				if(c[j]-c[j-1]!=sa) break;
				else cnt++;
			}
			if(cnt==n-1) {cout<<kk[i]<<endl;break;}
		}
	}
	return 0;
}

Measured memory_bytes: 3120
#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 n; cin>>n;

    string ans = "hon";
    if(n % 10 == 3) ans = "bon";
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) ans = "pon";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int ans = 0;
void dfs (vector<int>& a, vector<vector<int>>& v) {
  if ((int) a.size() == n) {
    int score = 0;
    for (int i = 0; i < q; i++) {
      if (a[v[i][1]] - a[v[i][0]] == v[i][2]) score += v[i][3];
    }
    ans = max(ans, score);
    return;
  }
  if (a.empty()) {
    for (int i = 1; i <= m; i++) {
      a.push_back(i);
      dfs(a, v);
      a.pop_back();
    }
  } else {
    for (int i = a.back(); i <= m; i++) {
      a.push_back(i);
      dfs(a, v);
      a.pop_back();
    }
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> m >> q;
  vector<vector<int>> v;
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    v.push_back({a, b, c, d});
  }
  vector<int> a;
  dfs(a, v);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
A,B = (int(i) for i in input().split()) 
C=0
if A >= B+1 :
	C=2*A-1
	print( '%d' % C  )
elif B >= A+1 :
	C=2*B-1
	print( '%d' % C )
else:
	C=2*A
	print( '%d'% C)

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

#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()
#define TASK ""

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int N = 2005, INF = 1e9 + 7;

int n, k, q, a[N];

signed main() {
#ifdef LOCAL
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
if (strlen(TASK) > 0)
	freopen(TASK".in", "r", stdin),
	freopen(TASK".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> k >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int ans = INF;
	for (int p = 1; p <= n; ++p) {
		int x = a[p];
		vector<pii> groups;
		int i = 1;
		while (i <= n) {
			if (a[i] < x) {
				++i;
				continue;
			}
			int j = i;
			while (j <= n && a[j] >= x) {
				++j;
			}
			--j;
			groups.pb(mp(i, j));
			i = j + 1;
		}
		vector<int> sex;
		for (int i = 0; i < sz(groups); ++i) {
			vector<int> curr;
			for (int j = groups[i].x; j <= groups[i].y; ++j) {
				curr.pb(a[j]);
			}
			sort(all(curr));
			for (int j = 0; j < sz(curr) - k + 1; ++j) {
				sex.pb(curr[j]);
			}
		}
		sort(all(sex));
		if (sz(sex) >= q) {
			ans = min(ans, sex[q - 1] - x);
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner ob=new Scanner(System.in);
int a=ob.nextInt();	
int b=ob.nextInt();	
int c=ob.nextInt();
if(c>=a&&c<=b)
{
System.out.println("Yes");
}
else
System.out.println("No");
}
}

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

int f(string x, string y, string z, vector<bool> xy, vector<bool> xz, vector<bool> yz)
{
    const int MAX = 4005;
    int ret = INT_MAX;
    for (int i = 0; i < MAX; i++)
    {
        for (int j = 0; j < MAX; j++)
        {
            if (xy[i] && xz[i + j] && yz[j])
            {
                ret = min(
                    ret,
                    max({(int)x.size(), i + (int)y.size(), i + j + (int)z.size()}));
            }
        }
    }
    return ret;
}

int main()
{
    vector<string> S(3);
    cin >> S[0] >> S[1] >> S[2];

    const int MAX = 4005;
    vector<vector<vector<bool>>> valid(3, vector<vector<bool>>(3, vector<bool>(MAX, true)));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < MAX; k++)
            {
                string x = S[i];
                string y = string(k, '?') + S[j];
                if (y.size() < x.size())
                {
                    swap(x, y);
                }
                for (int l = 0; l < x.size(); l++)
                {
                    valid[i][j][k] = valid[i][j][k] && (x[l] == '?' || y[l] == '?' || x[l] == y[l]);
                }
            }
        }
    }
    int ans = min({
        f(S[0], S[1], S[2], valid[0][1], valid[0][2], valid[1][2]),
        f(S[0], S[2], S[1], valid[0][2], valid[0][1], valid[2][1]),
        f(S[1], S[2], S[0], valid[1][2], valid[1][0], valid[2][0]),
        f(S[1], S[0], S[2], valid[1][0], valid[1][2], valid[0][2]),
        f(S[2], S[0], S[1], valid[2][0], valid[2][1], valid[0][1]),
        f(S[2], S[1], S[0], valid[2][1], valid[2][0], valid[1][0]),
    });
    cout << ans << endl;
}


Measured memory_bytes: 256
function main(input) {
  var input = input.split('\n')[1].split(' ');
  var max = 0;
  var min = 10000000000;
  for (var i=0;i<input.length;i++){
  	var tmp = parseInt(input[i]);
  	if (tmp > max) {
  		max = tmp;
  	}
  	if (tmp < min) {
  		min = tmp;
  	}
   	
  }
  console.log(max - min);
}
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll gcd(ll n,ll m){
  if(n>m) return gcd(m,n);
  else if(n==0) return m;
  else return gcd(m-n*(m/n),n);
}

ll lcm(ll n,ll m){
  return n*(m/gcd(n,m));
}

int main(){
  ll n,t,a=1;
  cin>>n;
  fr(i,n){cin>>t;a=lcm(a,t);}
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
 
using namespace std;
 
int main(void) {
	double n, m;
	double x = 0;
	double p = 0;
	double q = 0;
	int sis = 100;
 
	cin >> n >> m;
 
	//x = (n - m) * 100;
 
	/*
	FOR(i, 1, sis) {
		p += 1800 * i*m + 100 * i*n;
	}
	q = pow((pow(2, m) - 1), sis) / pow(pow(2, m), sis + 2);
	q -= 1 / pow(4, m);
 
	cout << p << endl;
	cout << q << endl;
	cout << p * q << endl;
	*/
	p = (1, pow(2, m));
	FOR(i, 1, 10000) {
		x += ((i * 1900)*m+(i*100)*(n-m))*p;
		//cout << pow((pow(2, m) - 1), i - 1) / pow(pow(2, m), i) << " " << i << endl;
		//cout << pow((pow(2, m) - 1), i - 1) << endl;
		//cout << pow(pow(2, m), i) << endl;
		break;
		//cout << x << endl;
	}
	
	printf("%.0lf\n", x);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for(int i=0;i<2;i++) {
            if (a > b){

                ans += a;
                a--;
            }else {

                ans +=b;
                b--;
            }
        }
        System.out.println(ans);



    }
}


Measured memory_bytes: 22996
N = int(input())
for i in range(N):
    a, b, c = map(int, input().split())
    a2 = a ** 2
    b2 = b ** 2
    c2 = c ** 2
    if a2 + b2 == c2 or a2 + c2 == b2 or b2 + c2 == a2:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7520
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
 
//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
 
typedef pair<int, int> pii;
const int MAXN = 100100;
const int ROOT = 333;


int n, k;
int was[MAXN], qq[MAXN], en, st;
int ans;
int in[MAXN], dst[MAXN];
int dir[MAXN], ori[MAXN];
void bfs(int u)
{
	int to = dir[u];
	in[to]--;
	if (!in[to])
	{
		qq[en++] = to;
		was[to] = 1;
	}

	if (dst[u] == k - 1)
	{
		dir[u] = 0;
	}
	else
	{
		dst[to] = max(dst[to], dst[u] + 1);
	}

}

void dfs(int u, int l)
{
	was[u] = 1;
	if (l == k - 1)
	{
		dir[u] = 0;
		return;
	}
	if (was[dir[u]])
	{
		dir[u] = 0;
		return;
	}
	dfs(dir[u], l + 1);
}

void solve()
{
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &dir[i]);
		dir[i]--;
		ori[i] = dir[i];
		in[dir[i]]++;
	}
	
	if (dir[0])
	{
		in[dir[0]]--;
		dir[0] = 0;
		in[0]++;
	}

	was[0] = 1;
	for(int i = 1; i < n; ++i)
		if (!in[i])
		{
			qq[en++] = i;
			was[i] = 1;
		}
	while(st != en)
	{
		bfs(qq[st++]);
	}

	for(int i = 1; i < n; ++i)
	{
		if (!was[i])
			dfs(i, dst[i]);
	}
	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		//cerr << dir[i] << ' ';
		if (dir[i] != ori[i])
		{
			
			ans++;
		}
	}
	printf("%d\n", ans);
}

 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//cin >> t;

	for(int i = 0; i < t; ++i)
	{
		solve();
		
	}
	
    return 0;
}   

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

int main() {
  int n;
  cin >> n;
  bool flag = false;

  for(int i = 0; i < 9; i++){
    if(n % (i + 1) == 0 && n <= 9 * (i + 1)){
      flag = true;
      break;
    }    
  }

  if(flag) cout << "Yes";
  else cout << "No";

}

Measured memory_bytes: 256
n=input()
k=int(input())
dp0=[[0]*(k+1) for _ in range(len(n))]
dp1=[[0]*(k+1) for _ in range(len(n))]
for i in range(len(n)):
  dp0[i][0]=1
if len(n)==1:
  dp0[0][1]=int(n)
else:
  dp0[0][1]=int(n[0])-1
  dp1[0][1]=1
  for i in range(1,len(n)):
    num=int(n[i])
    for j in range(k):
      dp0[i][j+1]=dp0[i-1][j+1]+dp0[i-1][j]*9+dp1[i-1][j]*max(num-1,0)
    if num==0:
      for j in range(1,k+1):
        dp1[i][j]=dp1[i-1][j]
    else:
      for j in range(k):
        dp1[i][j+1]=dp1[i-1][j]
        dp0[i][j+1]+=dp1[i-1][j+1]
      dp1[i][1]=0
print(dp0[len(n)-1][k]+dp1[len(n)-1][k])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
 int main()
 {
  ll n,r;
  cin>>n>>r;
  if(n>=10)
    cout<<r<<endl;
  else
    cout<<r+(100*(10-n))<<endl;


 return 0;
  }





Measured memory_bytes: 256
n = int(input())

b = list(map(int, input().split( )))
ans = []

len = n
for j in range(n-1,-1,-1):
    len -= 1
    for i in range(min(j,len),-1,-1):

        if b[i]== i+1:
            ans.append(i)
            b.pop(i)
            break
                
ans.reverse()
if not b:
    for i in range(n):
        print(ans[i] + 1)
else:
    print(-1)

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

using namespace std;

int main(){
        int size; cin >> size;
        int array[size][3];
        for(int i=0; i<size; i++){
                for(int j=0; j<3; j++){
                int next; cin >> next;
                array[i][j]=next;
                }

        }
        int dp [size][3];
        for(int i=0; i< size; i++){
                for(int j=0; j<3; j++){
                dp[i][j]=-INT_MIN;
                }

        }
        dp[0][0]=array[0][0];
        dp[0][1]=array[0][1];
        dp[0][2]=array[0][2];
        for(int i=0; i<size; i++){

                for(int j=0; j<3; j++){

                    for(int k=0; k<3;k ++){
                        if(k!=j){
                        dp[i+1][k]= max( dp[i+1][k], array[i+1][k]+dp[i][j]);
                        }
                        }
                }

        }

        if(size==1){
        int big=dp[0][0];
        for(int i=0; i<3; i++){
                big=max(big,dp[0][i]);
        }
        cout << big;
        }
        else{
        int big=dp[size-1][0];
        for(int i=0; i<3; i++){
        big=max(big,dp[size-1][i]);
        }
        cout << big;
        }

}

Measured memory_bytes: 5972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;
typedef long long ll;
typedef vector<ll> vll;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    string s;
    cin >> s;
    int k; cin >> k;
    int n = s.size();
    int cnt = 0;
    set<string> dic;
    REP(len,1,min(n+1, k+1)){
        rep(j,n-len+1){
            string t = s.substr(j, len);
            dic.insert(t);
        }
    }

    for(set<string>::iterator it = dic.begin(); it != dic.end(); it++, cnt++){
        if(cnt == (k-1)){
            cout << *it << endl;
            break;
        }
    }
    return 0;
} 

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

using namespace std;

void outputArray(vector<int> array)
{
	for (int i = 0; i != array.size(); ++i)
	{
		cout << array[i];
		if (i + 1 != array.size())
		{
			cout << " ";
		}
	}
	cout << endl;
}

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

	vector<int> array(number);
	for (int i = 0; i != number; ++i)
	{
		cin >> array[i];
	}

	bool flag = true;
	int counter = 0;
	for (int i = 0; flag; ++i)
	{
		flag = false;
		for (int j = number - 1; j >= i+1; --j)
		{
			if (array[j] < array[j - 1])
			{
				swap(array[j], array[j - 1]);
				flag = true;
				++counter;
			}
		}
	}

	outputArray(array);

	cout << counter << endl;

	return 0;
}


Measured memory_bytes: 3148
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_string().chars().collect::<Vec<char>>();

    if n[0] == '7' || n[1] == '7' || n[2] == '7'{
        println!("Yes");
    }else{
        println!("No");
    }
}


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

#define ll long long int
#define Mod 1000000007

int power(int x, unsigned int y, ll p) 
{ 
    ll res = 1;
  
    x = x % p; 
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	int n; cin>>n;
	vector<pair<int,int>>v(n);
	vector<int>arr(n);
	for(int i=0;i<n;i++) {
		cin>>arr[i];
	}
	ll a[202020];
	memset(a,0,sizeof(a));
	auto ip = std::unique(arr.begin(), arr.end()); 
    arr.resize(distance(arr.begin(), ip)); 
	a[arr[0]]=0;
	ll ans=0,prev=1;
	for(int i=0;i<arr.size();i++)
	{
		ans=(prev+a[arr[i]])%Mod;
		prev=ans;
		a[arr[i]]=ans;
		//cout<<ans<<" ";
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> a(n), s(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) s[i] = a[i];
		else s[i] = s[i - 1] + a[i];
	}
	ans = 1LL << 61;
	for (i = 0; i < n - 1; i++) {
		ans = min(ans, abs(s[i] - (s[n - 1] - s[i])));
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



bool check(string s) {
    string temp =s ;
    reverse(all(temp));

    return temp == s;
}


void test_case() {

    string s;
    cin>>s;

    int n = s.size();

    string a = s.substr(0,n/2);

    string b = s.substr(n/2+1);

    if(check(a) && check(b) && check(s) && n%2 == 1) {
        yes;
    } else {
        no;
    }


  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

#define endl '\n'
#define ll long long
#define For(i,l,r) for(int i = l; i <= r; i++)
#define ForR(i,l,r) for(int i = l; i >= r; i--)

int main(){
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll n,d,c=0;
	cin>>n>>d;
	For(i,1,n){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)c++;
		}
	cout<<c;
	return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Linq;
using System.Text;


public class Test
{
	public static void Main( )
	{
		StringBuilder output = new StringBuilder();
		int n = int.Parse( Console.ReadLine() );
		int[] nums = Console.ReadLine().Split( ' ' ).Select( x => int.Parse( x ) ).ToArray();
		int i, j;
		for( i=0; i<n; i++ ) {
			var key = nums[i];
			j = i - 1;
			while( 0 <= j && key < nums[j] ) {
				nums[j+1] = nums[j];
				j--;
			}
			nums[j+1] = key;
			output.AppendLine( string.Join( " ", nums.Select( x => x.ToString() ).ToArray() ) );
		}
		Console.Write( output );
	}
}

Measured memory_bytes: 10060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        int a;
        int b;
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        long fee1 = Math.min(a * n, b);
        System.out.println(fee1);
    }
}

Measured memory_bytes: 23124