akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    double x;
    cin >> x;
    double side = x / 3.000000;
    double ans = (side * side * side);
    cout << ans << '\n';
}

int main() {_
    cout.precision(12);
    cout << fixed;
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9,n;
int t,j,cs=0,a,b,i;
string s;

int main()
{
    cin>>n;
    cout<<n*(n-1)/2<<endl;

}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,K,a,ans=0;
  cin>>N>>K;
  priority_queue<ll> deq;
  for(ll i=0;i<N;i++){
    cin>>a;
    deq.push(a);
  }
  for(ll i=0;i<K;i++){
    deq.pop();
  }
  for(ll i=0;i<N-K;i++){
    ans+=deq.top();
    deq.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2420
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n = gets_i
alist = gets_i_list
blist = gets_i_list
total = alist.sum
n.times do |i|
  a, b = alist[i], blist[i]
  if a >= b
    alist[i] = a - b
  else
    alist[i] = 0
    c = a + alist[i+1] - b
    alist[i+1] = c < 0 ? 0 : c
  end
end
puts total - alist.sum


Measured memory_bytes: 30108
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


class Solution {
public:
    const int static MAX = 2e5 + 5;
    ll A[MAX], a[MAX];
    void solve(std::istream& in, std::ostream& out) {
        int n;
        ll ans = 0;
        memset(A, 0, sizeof(A));
        in >> n;
        rep(i, 0, n, 1) {
            in >> a[i];
            A[a[i]]++;
        }
        rep(i, 1, n+1, 1) {
            ans += (A[i] * (A[i] - 1)) / 2;
        }
        rep(i, 0, n, 1) {
            ans -= (A[a[i]] * (A[a[i]] - 1)) / 2;
            A[a[i]]--;
            ans += (A[a[i]] * (A[a[i]] - 1)) / 2;
            out << ans << endl;
            ans -= (A[a[i]] * (A[a[i]] - 1)) / 2;
            A[a[i]]++;
            ans += (A[a[i]] * (A[a[i]] - 1)) / 2;
        }
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 5760
N, K  = map(int,input().split())
h_list = list(map(int,input().split()))

INF = 100001010000100
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    start = max(0,i-K)
    dp[i] = min([dp[j]+abs(h_list[i]-h_list[j]) for j in range(start,i)])

print(dp[N-1])

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n,sum = 0;
    cin >> n;
    vll p(n);
    rep(i,n){
        cin >> p[i];
        sum += p[i];
    }

    sort(all(p));
    sum -= p[n-1]/2;

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <set>
using namespace std;
char s[500001];
int fst[26][500002];
int nxt[19][500002];
char st[500000];
int main() {
    int q;
    scanf("%s %d", s, &q);
    int n = strlen(s);
    for(int i = 0; i < 26; i++)
        fst[i][n] = fst[i][n + 1] = n + 1;
    for(int i = 0; i < 19; i++)
        nxt[i][n] = nxt[i][n + 1] = n + 1;
    for(int i = n - 1; i >= 0; i--) {
        fst[s[i] - 'a'][i] = i + 1;
        for(int j = s[i] - 'a' + 1; j < 26; j++)
            fst[j][i] = fst[j - 1][fst[j - 1][i]];
        nxt[0][i] = fst[25][fst[25][i]];
        for(int j = 0; j + 1 < 19; j++)
            nxt[j + 1][i] = nxt[j][nxt[j][i]];
        for(int j = 0; j < s[i] - 'a'; j++)
            fst[j][i] = fst[j][nxt[0][i]];
    }
    for(int i = 0; i < q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        l--;
        for(int j = 18; j >= 0; j--)
            while(nxt[j][l] <= r)
                l = nxt[j][l];
        puts(l == r ? "Yes" : "No");
#if 0
        stack<char> st;
        for(int j = l; j < r; j++) {
            char c = s[j];
            while(!st.empty() and st.top() == c) {
                st.pop();
                c++;
            }
            if(c <= 'z')
                st.push(c);
        }
        puts(st.empty() ? "Yes" : "No");
#endif
    }
}


Measured memory_bytes: 88960
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int A =sc.nextInt();
      int B =sc.nextInt();
     
      if(A>=B*2){
      System.out.println(A-B*2);
      }else if(A<B*2){
      System.out.println(0);
    }
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    priority_queue<int> p;

    int a,b,c;
    cin >> a>>b >>c;
  
  int count =3;
  if (a==b || a==c || b==c)count =2;
  if (a==b && a==c)count=1;
  

  
      cout <<count;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int n;
 scanf("%d", &n);
 char arr[n+1];
 scanf("%s", arr);
 
 if (n%2==1){
 
 puts("No");
}
else{
 int flag = 1;
 
 for ( int i =0; i<n/2; i++){
 if(arr[i]!= arr[i+n/2]){
 
 flag=0;
}
}
if (flag){
 puts("Yes");
}
else{
 puts("No");
}
}
 return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1000000009)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void vout(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
//----------------------------------------START-------------------------------------------
const ll maxN = (ll)(1 * 1e5 + 5 );


void solve()
{
	ll n, k;
	cin >> n >> k;
	ll a[n];
	in(a, n);
	fr(i, k, n)
	{

		if (a[i - k] < a[i])cout << "Yes\n";
		else cout << "No\n";
	}
}
int main()
{
	fast();
#ifndef ONLINE_JUDGE
	freopen ("inp1.txt", "r", stdin);
	freopen ("out1.txt", "w", stdout);
#endif
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 5184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] bucket = new int[10001];
        foreach (var item in a) bucket[item]++;
        int ptr = 0;
        for (int i = 0; i < bucket.Length; i++)
            for (int j = 0; j < bucket[i]; j++)
                a[ptr++] = i;
        Console.WriteLine(string.Join(" ", a));
    }
}


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

string s ;

void input ( ) {
    cin >> s ;
}

void solve ( ) {
    if ( s[ 1 ] == 'S' ) {
        if ( s[ 0 ] == 'R' || s[ 2 ] == 'R' ) { cout << "1\n" ; }
        else { cout << "0\n" ; }
    }
    else {
        int cnt = 1 ;
        cnt += ( s[ 0 ] == 'R' ) ;
        cnt += ( s[ 2 ] == 'R' ) ;
        cout << cnt << "\n" ;
    }
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3648
#include<stdio.h>
#define MAX 101

void print(int n,int *A){
  int i;
  for(i=0;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[i]);
}

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

int main(){
  int n,i;
  int a[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  insertion_sort(n,a);
  return 0;
}



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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep3(i, n, m) for (int i = n; i <= m; i++)

using ll = long long;

/* vector<ll> v(N);
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
  xの二乗:  pow(x, 2.0);
  int: -2,147,483,648 ～ 2,147,483,647(2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807(9×10^18)
  long long型の2次元配列(3×4要素の)の宣言
  vector<vector<ll>> ;
  string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)
*/
 
 //126~
 //126-d

int main() {
  int r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x= r*x-d;
    cout << x << endl;
  }

}

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

int main(void){
	int k, n;
	cin >> k >> n;
	int A[n];
	for(int i=0; i<n; i++)cin >> A[i];
	int sum = k;
	for(int i=0; i<n; i++){
		int x = i==0? A[n-1] - A[i] : A[i-1] + k - A[i];
		sum = min(sum, x);
	}
	cout << sum << endl;	
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
 ll n,x,y;
  cin>>n>>x>>y;
  x--;y--;
  vector<vll> g(n);
  rep(i,n-1){
   g[i].push_back(i+1);
   g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);
  ll cnt[2200][2200]; //始まり,距離
  rep(i,n){
   vector<ll> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<ll> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[i] = 0;
    que.push(i); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (ll nv : g[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
           cnt[i][dist[nv]]++;
            que.push(nv);
        }
    }
    
    
  }//for
    for(int i=1;i<n;i++){
      ll ans=0;
      for(int j=0;j<n;j++){
         ans+=cnt[j][i];
        //cout<<cnt[j][i]<<" "<<j<<i<<endl;
      }
      cout<<ans/2<<endl;
    }
}

Measured memory_bytes: 36096
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]
 
DP = np.zeros(W+1, dtype=int)

for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])

Measured memory_bytes: 15480
from decimal import *
import sys
getcontext().prec=120
ndp=lambda i,j,k:sum(map(int,str("{:.100f}".format(Decimal(str(i))/Decimal(str(j)))).split(".")[-1][:k]))
l=[list(map(int,l.split())) for l in sys.stdin]
[print(ndp(i[0],i[1],i[2])) for i in l]



Measured memory_bytes: 6400
n, q = map(int,input().split())
s = input()
inputlist = []
for i in range(q):
  inputlist.append(list(map(int,input().split())))

aclist = []
acnum = 0
for j in range(n - 1):
  if s[j] == "A" and s[j + 1] == "C":
    aclist.append(j)
    acnum += 1
if acnum == 0:
  for i in range(q):
    print(0)
else:
  rightac = []
  acindex = 0
  for j2 in range(n):
    if j2 == aclist[acindex] + 1:
      acindex = min(acindex + 1, len(aclist) - 1)
      acnum -= 1
    rightac.append(acnum)

  anslist = []
  for k in range(q):
    ans = rightac[inputlist[k][0] - 1] - rightac[inputlist[k][1] - 1]
    anslist.append(ans)

  print(*anslist, sep = "\n")

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/




int main()
{

    ll q,i,j,a[N],b,k;
    cin>>q;
    for(i=0;i<q;i++)
        cin>>a[i];
    sort(a,a+q);
    cout<<a[q-1]-a[0]<<endl;
    return 0;

}
































Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}

	ans := 0
	for ll := 0; ll <= k; ll++ {
		lim := ll
		if n < lim {
			lim = n
			if n%2 != ll%2 {
				lim--
			}
		}

		for p := 0; p <= lim; p++ {
			q := lim - p
			if q < p {
				continue
			}
			// fmt.Println()
			// fmt.Println("*", ll, ":", q, p)

			for l := 0; l <= q; l++ {
				r := q - l

				gs := make([]int, 0)
				for i := 0; i < l; i++ {
					gs = append(gs, vs[i])
				}
				for i := 0; i < r; i++ {
					gs = append(gs, vs[n-i-1])
				}
				sort.Ints(gs)

				v := 0
				for i := p; i < q; i++ {
					v += gs[i]
				}

				if lim < ll {
					x := ll - l
					for i := p; i < min(p+x, q); i++ {
						if gs[i] < 0 {
							v += -gs[i]
						}
					}
				}

				// fmt.Println(l, r, gs, v)
				ans = max(ans, v)
			}
		}
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5632
o[1<<20],n,r;
main(i){
 for(;++i<999;)
  if(!o[i])
   for(r=i+i;r<1<<20;r+=i)
    o[r]=1;
 for(;scanf("%d",&n),n;printf("%d\n",r))
  for(i=1,r=0;++i<=n/2;)
   o[i]+o[n-i]||r++;
 exit(0);
}

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

int main(void)
{
	long long N, M;
	cin >> N >> M;
	N = __gcd(N, M);
	int cnt = 1;
	for (int i = 2; i < 1200000; i++)
	{
		if (N % i == 0)
		{
			cnt++;
			while (N % i == 0) N /= i;
		}
	}
	if (N > 1) cnt++;
	cout << cnt << endl;
	return 0;
}


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

int main(void){
  int N, L, ia;
  cin >> N >> L;
  vector<int> t(N);
  int a,s0,s1;
  
  ia=0; // index eating apple
  a=0;  // taste of eating apple
  s0=0;
  for(int i = 0; i < N; i++){
    t.at(i) = L+(i+1)-1;
    if(i == 0 || abs(t.at(i)) < a){
      ia = i;
      a = abs(t.at(i));
    }
    s0 = s0 + t.at(i);
  }

  //cout << s0 << ' ' << ia << ' ' << a << endl;
  
  s1=0;
  for(int i = 0; i < N; i++){
    if(i != ia) s1 = s1 + t.at(i);
  }
  
  cout << s1 << endl;
  
/*  for(int i = 0; i < N; i++){
    cout << t.at(i) << ' ';
  }
  cout << endl;*/
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    bool latte[1000001];
    fill(latte,latte+1000001,false);
    latte[1]=true;
    for(int i=1;i<=1000000;i++){
         if(!latte[i])continue;
         if(i*2<=1000000)latte[i*2]=true;
         if(i*3<=1000000)latte[i*3]=true;
         if(i*5<=1000000)latte[i*5]=true;
    }
    int m;
    while(cin>>m,m){
        int n;
        cin>>n;
        int cnt=0;
        for(int i=m;i<=n;i++)if(latte[i])cnt++;
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 2136
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    r = int(token[0])

    return (r,)


def solve(r,):

    return 3 * r * r




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

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


int main() {
	int n; cin >> n; 
  	int cnt = 0;
 	while (n) 
      cnt += n%10, n/=10;
  	if (cnt == 1) cnt = 10;
  	cout << cnt << endl;
	return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  cout << N*N*N << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum=0,j;
    cin>>n;
    int a[n+1];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
            sum=sum+a[i]*a[j];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
#define endl "\n"

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    vector<ll> dp(N);
    for (int i = 0; i < N; ++i) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        if (i + 1 < N) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        }
        if (i + 2 < N) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
        }
    }

    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













using ld = long double;
ld a, b, c;
const ld EPS = 1e-14;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> a >> b >> c;

	if (sqrtl(a) + sqrtl(b) < sqrtl(c) - EPS) cout << "Yes" << endl;
	else cout << "No" << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	string a, b;
	
	cin >> a >> b;
	
	for(int i = 0; i < n; i++){
		cout << a[i] << b[i];
	}
	
	cout << endl;

	return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int N,K,n1,n2,flg1,flg2;
   double ptA,ptB;
   char s[60];
   flg1=1;
   flg2 =0;
    //char s[101];
    // 整数の入力
    scanf("%d %d", &N,&K);
    ptB =0;
    for(int i=1;i<=N;i++)
    {
        flg1 =i;
        flg2 =0;
        ptA = 1 ;
        while(K>flg1)
        {
            flg2=flg2+1;
            flg1=flg1*2;
            ptA =i/(double)flg1;
        }
        //printf("%d %d\n",flg1,flg2);
        ptB = ptB + ptA/N;
        flg1 =1;
        flg2 =0;
    }
    printf("%.16f\n",ptB);
    // 出力
    //printf("%d %s\n",a+b+c,s);
   return 0;
}


Measured memory_bytes: 128
n, k, q = map(int, input().split())
 
C = [0] * n
 
for a in range(q) :
    C[int(input())-1] += 1
 
sum_c = sum(C)
 
for i in range(n) :
    minus = sum_c - C[i]
    if minus < k :
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 4680
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, a[100100];

int main(){

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a + i);

    int mn = *min_element(a, a + n);

    vector<int> v;

    for (int i = 0; i < n; i++) {
        if (a[i] == mn) {
            v.pb(i);
        }
    }

    if (v.size() > 2) {
        printf("Impossible\n");
        return 0;
    }

    if (n == 2) {
        if (mn != 1 || v.size() != 2) printf("Impossible\n");
        else printf("Possible\n");
        return 0;
    }

    vector<int> cnt(n, 0);

    for (int i = 0; i < n; i++) cnt[a[i]]++;

    if (v.size() == 1) {
    
        int root = v[0];
        int d = a[root];
        cnt[d]--;
        for (int i = 1; i <= d; i++) {
            if (i + d >= cnt.size()) {
                printf("Impossible\n");
                return 0;
            }
            if (cnt[i + d] < 2) {
                printf("Impossible\n");
                return 0;
            }
            cnt[i + d] -= 2;
        }

        for (int i = d + d + 1; i < cnt.size(); i++) {
            if (cnt[i]) {
                printf("Impossible\n");
                return 0;
            }
        }

        printf("Possible\n");
        return 0;
    }

    int x = v[0], y = v[1];

    int d = a[x] - 1;

    cnt[d]--;
    for (int i = 1; i <= d; i++) {
        if (i + d + 1 >= cnt.size()) {
            printf("Impossible\n");
            return 0;
        }
        if (cnt[i + d + 1] < 2) {
            printf("Impossible\n");
            return 0;
        }
        cnt[i + d + 1] -= 2;
    }

    for (int i = d + d + 2; i < cnt.size(); i++) {
        if (cnt[i]) {
            printf("Impossible\n");
            return 0;
        }
    }

    printf("Possible\n");

    return 0;
}


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

ll f(int x) {
    if (x%2==1) return 0;
    return f(x/2) + 1;
}

int main() {
    int n, ret = 1000000001;
    cin >>n;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        a = f(a);
        ret = min(a, ret);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3600
e=list(str(input()))
o=list(str(input()))

ln=len(e)+len(o)
ans=['' for i in range(ln)]
for i in range(ln):
    if i %2==0:
        ans[i]=e[i//2]
    else:
        ans[i]=o[(i-1)//2]

print("".join(ans))

Measured memory_bytes: 9060
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	as := ReadInts(N)

	sum := as[0]
	for _, a := range as[1:] {
		sum ^= a
	}

	for i := 0; i < len(as); i++ {
		fmt.Printf("%d ", sum^as[i])
	}
}

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100000 + 5;
struct node{
	int parent,leftchild,rightsibling,dep;
}tree[maxn];
int findDep(struct node t)
{
	if(t.dep!=-1)return t.dep;
	if(t.parent == -1)return t.dep = 0;
	return 	t.dep = 1 + findDep(tree[t.parent]);
}
int main()
{		
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)tree[i].parent = tree[i].leftchild = tree[i].rightsibling = tree[i].dep = -1;
	
	int id,k,c;
	for(int i=0;i<n;++i){	
		scanf("%d %d",&id,&k);
		if(k){
			int lemo;
			scanf("%d",&lemo);
			tree[lemo].parent = id;
			tree[id].leftchild = lemo;
			
			for(int i=1;i<k;++i){
				scanf("%d",&c);
				tree[c].parent = id;
				tree[lemo].rightsibling = c;
				lemo = c;
			}
		}
	}	
	for(int i=0;i<n;++i)tree[i].dep = findDep(tree[i]);
	
	for(int i=0;i<n;++i){
		printf("node %d: parent = %d, depth = %d, %s, [",i,tree[i].parent,tree[i].dep,tree[i].parent==-1?("root"):(tree[i].leftchild==-1?("leaf"):("internal node")));
		int child = tree[i].leftchild;
		if(child!=-1){printf("%d",child);child = tree[child].rightsibling;}
		while(child!=-1){
			printf(", %d",child);
			child = tree[child].rightsibling;
		}
		printf("]\n");
	}
	return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0)break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
n,w=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(n)]
DP=[[0]*(w+1) for _ in range(n+1)]
for i in list(range(n))[::-1]:
  wi,vi=goods[i][0],goods[i][1]
  for j in range(w+1):
    if j<wi:
      DP[i][j]=DP[i+1][j]
    else:
      DP[i][j]=max(DP[i+1][j],DP[i+1][j-wi]+vi)
print(DP[0][w])


Measured memory_bytes: 121052
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		int ans1 = a * b;
		int ans2 = c * d;
		if(ans1 < ans2) {
			System.out.println(ans2);
		}else {
			System.out.println(ans1);
		}
	}
}

Measured memory_bytes: 35672
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  rep(i, N) {
    if(p[i] == i) {
      if(i == N-1)
        swap(p[i], p[i-1]);
      else
        swap(p[i], p[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
s = input()

ans_a = 0
ans_b = 0
for i in range(len(s)):
	if i%2 == 0 and s[i] =="0":
		pass
	elif i%2 == 1 and s[i]=="1":
		pass
	else:
		ans_a += 1

for i in range(len(s)):
	if i%2 == 0 and s[i] =="1":
		pass
	elif i%2 == 1 and s[i]=="0":
		pass
	else:
		ans_b += 1
print(min(ans_a, ans_b))

Measured memory_bytes: 3188
'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''
'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''
'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''
'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''
'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
'''
リスト同士の演算
list(map(lambda x, y: x+y, el2, el3))
'''
'''
配列の初期化
配列名=[a]*n+[b]*m
'''
'''
重複
list(set())
２次元配列
list(map(list, set(map(tuple, addition))))
'''
'''
順列
for el in itertools.permutations(配列のパターン):
'''
'''
Decimal()
'''
# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()




from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul
def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


H = int(stdin.readline().rstrip())
W = int(stdin.readline().rstrip())
N = int(stdin.readline().rstrip())
use = 0
if H >= W:
    use = H
else:
    use = W
res = N / use
if N % use != 0:
    res += 1
print(int(res))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	int sum = 0;
	for(int i=0; i<N; ++i){
		cin >> m[i];
		sum += m[i];
	}
	sort(m.begin(), m.end());
	cout << N + (X-sum)/m[0] << endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  ll sum = 0;
  vector<ll> a(n), count(1e5 + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
    count.at(a.at(i))++;
  }
  
  int q;
  cin >> q;
  
  while (q--) {
    ll b, c;
    cin >> b >> c;
    ll keep = count.at(b);
    count.at(b) = 0;
    sum -= b * keep;
    count.at(c) += keep;
    sum += c * keep;
    cout << sum << '\n';
  }
}

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

void dfs(vector<vector<int>>& Tree, vector<int>& Dists, int now, int before) {
	for (int u : Tree[now]) {
		if (u == before) continue;
		Dists[u] = Dists[now] + 1;
		dfs(Tree, Dists, u, now);
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> Tree(N);
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		Tree[A - 1].push_back(B - 1);
		Tree[B - 1].push_back(A - 1);
	}
	vector<int> DistF(N), DistS(N);
	dfs(Tree, DistF, 0, -1);
	dfs(Tree, DistS, N - 1, -1);
	int sum = 0;
	for (int i = 0; i < N; i++) sum += DistF[i] <= DistS[i];
	cout << (sum > N / 2 ? "Fennec" : "Snuke") << endl;
}


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


int main(void){
    // Your code here!
    long long x;
   
    cin>>x;
    
    //bool end=false;
    //int a,b;
    for(int i=0;i<=150;i++){
      for(int j=-150;j<=150;j++){
        if(pow(i,5) - pow(j,5)==x){
          cout<<i<<" "<<j<<endl;
          return 0;
        }
      }
    }
    
}


Measured memory_bytes: 4012
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False



s = STR()
k = INT()
tmp = 0
for i in range(len(s)):
    if s[i] != '1':
        tmp = i
        break
debug(tmp)
if tmp > k - 1:
    print(1)
else:
    print(s[tmp])

Measured memory_bytes: 5156
s = io.read()
t = io.read()
a = {}
for i = 1, #s do
  a[i] = s:sub(i, i)
end
b = {}
for i = 1, #t do
  b[i] = t:sub(i, i)
end
table.sort(a)
table.sort(b, function(x, y) return x > y end)
s = table.concat(a)
t = table.concat(b)
print(s < t and "Yes" or "No")


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

using namespace std;
using ll = long long;
using pll = pair <ll, ll>;

ll p1 = 37237, q1 = 3726473, mod1 = 998244353;
ll p2 = 20202039, q2 = 1716162, mod2 = 1000000007;

string S[202020];
vector <pll> V[1010101];
ll C[26];
ll n, ans;

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

	ll i, j, k, s, c;
	ll hs, hs1, hs2;

	cin >> n;

	for(i = 0; i < n; i ++){
		cin >> S[i];
	}

	sort(S, S + n, [&](string &a, string &b){
		return a.size() < b.size();
	});

	for(i = 0; i < n; i ++){
		if(i && S[i].size() != S[i - 1].size()){
			s = S[i - 1].size();
			sort(V[s].begin(), V[s].end());
		}

		for(j = 0; j < S[i].size(); j ++){
			C[S[i][j] - 'a'] ++;
		}
		hs = hs1 = hs2 = 0;	
		for(j --, s = 1; j >= 0; j --, s ++){
			c = S[i][j] - 'a';

			k = lower_bound(V[s].begin(), V[s].end(), pll(hs, 0)) - V[s].begin();
			for(; k < V[s].size() && V[s][k].first == hs; k ++){
				if(C[V[s][k].second]) ans ++;
			}
			C[c] --;

			if(j == 0) break;
			hs1 = (hs1 * p1 + c * q1) % mod1;
			hs2 = (hs2 * p2 + c * q2) % mod2;
			hs = hs1 * mod2 + hs2;
		}
		V[S[i].size()].emplace_back(hs, c);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 37016
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>

#define MOD 1000000007
#define ll long long
#define ld long double

using namespace std;


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

  ll size = inpstr.size();

  vector<vector<ll> > R(27); 
  for(ll i =0;i<size;i++){
    R[inpstr[i]-'a'].push_back(i);
  }

  ll ans = size*(size-1);
  ans /=2;

  //-----------------------
  for(ll i = 0;i< 26;i++){
    if(R[i].size()<=1) continue;

    vector<ll> lar;
    ll num =0;
    for(ll j =1;j<R[i].size();j++){
      if(R[i][j]==(R[i][j-1])){
	num++;
      }
      else{
	num++;
	lar.push_back(num);
	num=0;
      } 
    }
    lar.push_back(num);
    ll rem =1;
    for(ll i =0;i<lar.size();i++){
      rem*=lar[i];
    }
    ans = ans-rem-(lar.size()*(lar.size()-1)/2);
  }
  
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 5256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
int main(){
    long long x,y;
    cin>>x>>y;
    long long res=(y+1)*x;
    if(res%y==0)res=-1;
    cout<<res;
    return 0;
}

Measured memory_bytes: 384
while True:
    m, f, r = [int(line) for line in input().split()]
    if m == f == r == -1:
        break
    if -1 in (m, f):
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5600
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
ans = []
s = []
for i,a_ in enumerate(a,1):
    for _ in range(a_):
        s.append(str(i))
        if len(s)==w:
            ans.append(s)
            s = []
for i,w in enumerate(ans):
    if i%2==0:
        print(' '.join(list(w)))
    else:
        print(' '.join(list(w[::-1])))

Measured memory_bytes: 40944
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
}

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

template <typename monoid>
class segmentTree {
public:
    using M = monoid;
    using T = typename M::value_type;

    int sz;
    vector<T> x;

    segmentTree(int n = 0) {
        sz = 1;
        while(sz < n) sz *= 2;
        x.assign(sz*2, M::id());
        init();
    }

    void fill(const T& val) {
        fill(x.begin() + sz, x.end(), val);
        init();
    }

    void init() {
        for(int i=sz-1; i>=1; --i) {
            x[i] = M::op(x[i*2], x[i*2+1]);
        }
    }

    T query(int l, int r) const {
        T al = M::id(), ar = M::id();
        for(l += sz, r += sz; l<r; l/=2, r/=2) {
            if(l&1) al = M::op(al, x[l++]);
            if(r&1) ar = M::op(x[--r], ar);
        }
        return M::op(al, ar);
    }

    void update(int i, const T &val) {
        x[i += sz] += val;
        while(i > 1) {
            x[i/2] = M::op(x[i], x[i^1]);
            i /= 2;
        }
    }

    T operator[](int i) const { return x[sz+i]; }
};

template <typename T>
struct min_monoid {
    using value_type = T;
    static constexpr T id() { return std::numeric_limits<T>::max(); }
    static T op(const T &a, const T &b) { return min(a, b); }
};

template <typename T>
struct max_monoid {
    using value_type = T;
    static constexpr T id() { return std::numeric_limits<T>::min; }
    static T op(const T &a, const T &b) { return max(a, b); }
};

template <typename T>
struct sum_monoid {
    using value_type = T;
    static constexpr T id() {return 0;}
    static T op(const T &a, const T &b) { return a+b; }
};

template <typename T>
using rmq = segmentTree<min_monoid<T>>;

template <typename T>
using rsq = segmentTree<sum_monoid<T>>;

signed main() {
    int n, q;
    cin >> n >> q;
    rsq<int> seg(n);
    for(int i=0; i<q; ++i) {
        int c, x, y;
        cin >> c >> x >> y;
    	x--;
        if(c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.query(x, y) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3884
n=int(input())
s=input()
e,w=[0]*n,[0]*n
es,ws=0,0
ans=[0]*n
for i in range(n):
    if s[i]=="W": ws+=1
    if s[n-i-1]=="E": es+=1
    w[i]=ws
    e[n-i-1]=es
for i in range(n):
    ans[i]=w[i]+e[i]
print(min(ans)-1)

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

using namespace std;
 
typedef long long ll;

const int INF = 0x3f3f3f3f;

int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(ll i=0 ; i<n ; i++)cin>>h[i];
    ll dp[n+1]={0};
    dp[0]=0;
    
    for(ll i=1 ; i<n ; i++)
    {
       ll mn=INF;
        for(ll j=max(0ll,i-k) ; j<i ; j++)
        {
            mn=min(mn,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=mn;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 10000000000LL
using namespace std;
typedef long long ll;

int N, M, R, X, Y, T, Z[1000];
char SL;
ll d[2][200][200];
ll dp[1000][200];

int main(void) {
  while(cin >> N >> M, N || M) {
    REP(w, 0, 2) REP(i, 0, N) REP(j, 0, N) d[w][i][j] = (i == j ? 0 : INF);
    REP(i, 0, M) {
      cin >> X >> Y >> T >> SL;
      d[SL == 'L'][X - 1][Y - 1] = T;
      d[SL == 'L'][Y - 1][X - 1] = T;
    }

    REP(w, 0, 2) REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) {
      d[w][i][j] = min(d[w][i][j], d[w][i][k] + d[w][k][j]);
    }

    cin >> R;
    REP(i, 0, R) cin >> Z[i], Z[i]--;

    REP(i, 0, R) REP(j, 0, N) dp[i][j] = INF;
    dp[0][Z[0]] = 0;

    REP(i, 1, R) {
      REP(j, 0, N) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + d[1][Z[i - 1]][Z[i]]);
      }
      REP(j, 0, N) REP(k, 0, N) {
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + d[1][Z[i - 1]][j] + d[0][j][k] + d[1][k][Z[i]]);
      }
    }

    ll ans = INF;
    REP(i, 0, N) ans = min(ans, dp[R - 1][i]);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5172