akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#define MAX 1000
#define INFTY 1<<30 // 2^30
using namespace std;
typedef long long llong;
 
static const int VMAX = 10000;
int n, A[MAX+10], s;
int B[MAX+10], T[VMAX+10];
 
int solve()
{
  int ans = 0;
  bool V[MAX+10];
  for(int i = 0; i < n; i++)
  {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B,B+n);
  for(int i = 0; i < n; i++) T[B[i]] = i; // ????????????????????????????????????????????????
  for(int i = 0; i < n; i++)
  {
    if(V[i]) continue;
    int cur = i; // current point
    int S = 0; // sum of mass
    int m = VMAX; // min of the cycle
    int an = 0; // the number of material the cycle have
    while(1)
    {
      V[cur] = true; //already visited
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    ans += min(S+(an-2)*m, S+(an+1)*s+m);
  }
  return ans;
}
 
int main()
{
  cin >> n;
  s = VMAX;
  for(int i = 0; i < n; i++)
  {
    cin >> A[i];
    s = min(s,A[i]);
  }
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 3176
function main() {
  process.stdin.resume();
  process.stdin.setEncoding("utf8");
  var chunks = "";

  process.stdin.on("data", function (chunk) {
    chunks += chunk;
  });

  process.stdin.on("end", function () {
    var inputs = chunks.trim().split("\n");
    var ans = [inputs[1].trim()];

    for (var i = 2; i < inputs.length; i++) {
      var cur = inputs[i].trim();
      var found = false;
      for (var j = 0; j < ans.length; j++) {
        var tmp = ans[j];
        if (cmp(cur, tmp) < 0) {
          ans.splice(j, 0, cur);
          found = true;
          break;
        }
      }
      if (!found) {
        ans.push(cur);
      }
    }

    console.log(ans.join(""));
  });

  function cmp(a, b) {
    for (var i = 0; i < a.length; i++) {
      if (a[i] < b[i]) {
        return -1;
      } else if (a[i] > b[i]) {
        return 1;
      }
    }

    return 0;
  }
}

main();


Measured memory_bytes: 21192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0; sum[2] = 1;
  for(int i = 3 ; i < 1000000 ; i += 2 ){
    sum[i] = sum[i + 1] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i + i ; j < 1000000 ; j += i + i ){
        prime[j] = true;
      }
      sum[i]++;
      sum[i+1]++;
    }
  }

  int n;
  while(cin >> n){
    cout << sum[n] << endl;
  }
}



Measured memory_bytes: 7876
#coding:utf-8

import sys
import copy

def main():
    line = sys.stdin.readline()
    #case
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return

def analy(line):
    #??´???
    field = [int(n) for n in line.split()]
    # ?¨???????
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        #?¨???????
        data.append(b)
    print (compute(field, data))

def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
            #?¨???????????§????????????????
                if i == 0 :
                    #?????????
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #????????????
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left >> the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]

if __name__ == "__main__":
    main()

Measured memory_bytes: 4300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowerSocket solver = new BPowerSocket();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowerSocket {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (b == 1) {
                out.println(0);
                return;
            }
            int ans = a, count = 1;
            while (ans < b) {
                ans += a - 1;
                count++;
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using ll = long long;
using Cake = tuple<ll, ll, ll>;

vector<Cake> raw(1005);
int dx[] = { 1, -1,  1, -1,  1, -1,  1, -1};
int dy[] = { 1,  1, -1, -1,  1,  1, -1, -1};
int dz[] = { 1,  1,  1,  1, -1, -1, -1, -1};

int main()
{
    ll n, m;
    ll ans = 0;
    ll x, y, z;

    cin >> n >> m;

    for (ll i = 0; i < n; i++) {
        cin >> get<0>(raw[i]) >> get<1>(raw[i]) >> get<2>(raw[i]);
    }

    for (ll i = 0; i < 8; i++) {
        vector<ll> sorted;

        for (ll j = 0; j < n; j++){
            ll tmp = 0;
            tmp += get<0>(raw[j]) * dx[i];
            tmp += get<1>(raw[j]) * dy[i];
            tmp += get<2>(raw[j]) * dz[i];

            sorted.push_back(tmp);
        }

        sort(sorted.begin(), sorted.end(), greater<ll>());

        ll sum = 0;
        for (ll j = 0; j < m; j++) {
            sum += sorted[j];
        }

        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


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

int main(void){
    vector<int> mountain;
    int tmp;
    for(int i=0;i<10;i++){
        cin>>tmp;
        mountain.push_back(tmp);
    }
    sort(mountain.begin(),mountain.end(),greater<int>());
    for(int i=0;i<3;i++){
        cout<<mountain[i]<<endl;
    }
    return 0;
}



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

cnt_1 = 0
cnt_2 = 0
cnt_4 = 0

for a in A:
    if a % 4 == 0: 
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
    else:
        cnt_1 += 1

if cnt_4 >= cnt_1:
    print('Yes')
else:
    if cnt_2 == 0 and cnt_1 - cnt_4 == 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 20144
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
using gragh = vector<vector<int>>;

int main() {
    int X;
    cin>>X;
    int x;
    x = X;
    int hundred;
    int count;
    hundred = X/100;
    count = hundred;
    for (int i = 5; i > 0 ; --i) {
        while (x - (hundred * 100) >= i){
            if(count < 1){
                cout<<0<<endl;
                return 0;
            }else{
                count -= 1;
                x -= i;
            }
        }
    }
    cout<<1<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
 
int main(){
 int n;
 string s1,s2;
 int cntt=0;
 int cnth=0;
  
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>s1>>s2;
  if(s1>s2) cntt+=3;
  else if(s1<s2) cnth+=3;
  else{
   cntt++;
   cnth++;
  }
 }
 cout<<cntt<<" "<<cnth<<endl;
 
return 0;
}

Measured memory_bytes: 3088
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int a[3];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i,3) cin >> a[i];
	sort(a, a+3);
	if(a[0]+a[1] == a[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// C - Skill Up
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VL = vector<ll>;
using VVL = vector<VL>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N,M,X; cin>>N>>M>>X;
	VL C(N);
	VVL A(N);
	rep(i, N){
		cin>>C[i];
		A[i].resize(M);
		rep(j, M) cin>>A[i][j];
	}
	ll inf, ans = inf = 1e18;
	rep(bit, 1<<N){ // [0,(2^N)-1] full search
		ll cost = 0;
		VL a(M,0);
		rep(book, N) // [0,N-1]
			if(bit>>(N-1-book) & 1){ // buy
				cost += C[book];
				rep(j, M) a[j] += A[book][j]; // skill get
			}
		bool ok = true; // skill check
		rep(i, M) if(a[i] < X){ ok = false; break; }
		if(ok) ans = min(ans, cost); // min cost
	}
	if(ans == inf) ans=-1; // exist?
	cout<< ans <<endl;
}


Measured memory_bytes: 3632
n,m = map(int, input().split())
if n % 2 != 0:
    for i in range(1,m+1):
        print(i,n+1-i)
else:
    x = n//2
    for i in range((m+1)//2):
        print(i+1,x-i)
    for i in range(m//2):
        print(x+1+i, n-1-i)

Measured memory_bytes: 9224
_ = input()
S = 'E'+input().strip()+'W'

E = [0]*len(S)
now = 0
for i in range(len(S)):
  E[i] = now + int(S[i]=='E')
  now = E[i]

W = [0]*len(S)
now = 0
for i in range(len(S)):
  W[i] = now + int(S[i]=='W')
  now = W[i]

ans = float('inf')
# i人目をリーダーにする
for i in range(1,len(S)):
  ans = min(ans, W[i-1]+E[-1]-E[i])
  
print(ans)

Measured memory_bytes: 46132
import math
a, b = map(int, input().split())

mini_8 = a / 0.08
maxi_8 = mini_8 + 12.5
mini_8 = math.ceil(mini_8)
if maxi_8 - int(maxi_8) == 0:
    maxi_8 = int(maxi_8 - 1)
else:
    maxi_8 = int(maxi_8)

mini_10 = b / 0.1
maxi_10 = mini_10 + 9

for i in range(mini_8, maxi_8+1):
    if mini_10 <= i and i <= maxi_10:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3188
LI = lambda: list(map(int, input().split()))

X, A, B = LI()


def main():
    x = B - A
    if x <= 0:
        ans = "delicious"
    elif x <= X:
        ans = "safe"
    else:
        ans = "dangerous"
    print(ans)


if __name__ == "__main__":
    main()


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


const int MOD = 1e+9 + 7;


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

    // 以下、 A,G,C,T を 0,1,2,3 とする
    // dp[len][c3][c2][c1]: 長さが len で後ろから3,2,1番目がそれぞれ c3,c2,c1 であるもののうち
    //                      問題文の条件を満たす文字列の個数
    int dp[101][4][4][4] = {};
    dp[0][3][3][3] = 1;  // 0,1,2 についての制約しかないので、S は 333S だと考える
    for( int len = 0; len < N; ++len ){
        for( int c3 = 0; c3 < 4; ++c3 ){
            for( int c2 = 0; c2 < 4; ++c2 ){
                for( int c1 = 0; c1 < 4; ++c1 ){
                    // 0~3 のどの文字を足すか
                    for( int a = 0; a < 4; ++a ){
                        if( c2 == 0 and c1 == 1 and a == 2 ) continue;
                        if( c2 == 1 and c1 == 0 and a == 2 ) continue;
                        if( c2 == 0 and c1 == 2 and a == 1 ) continue;
                        if( c3 == 0 and c2 == 1 and a == 2 ) continue;
                        if( c3 == 0 and c1 == 1 and a == 2 ) continue;
                        dp[len+1][c2][c1][a] += dp[len][c3][c2][c1];
                        dp[len+1][c2][c1][a] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0;
    for( int c3 = 0; c3 < 4; ++c3 ){
        for( int c2 = 0; c2 < 4; ++c2 ){
            for( int c1 = 0; c1 < 4; ++c1 ){
                ans += dp[N][c3][c2][c1];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;

    return 0;
} 

Measured memory_bytes: 256
/**
 * Author: Behradm
 * Created: 19-04-2020 16:28:34
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	int r;
	cin >> r;
	double res = 2 * 3.14 * r;
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 3804
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)

	maxI := int(math.Ceil(math.Log2(float64(K))))
	next := make([][]int, maxI+1)
	for k := 0; k < maxI+1; k++ {
		next[k] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		next[0][i] = A[i] - 1
	}
	for k := 0; k < maxI; k++ {
		for i := 0; i < N; i++ {
			next[k+1][i] = next[k][next[k][i]]
		}
	}

	ans := 0
	k := 0
	for K > 0 {
		if K&1 == 1 {
			ans = next[k][ans]
		}
		K >>= 1
		k++
	}
	fmt.Println(ans + 1)
}

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 }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 103652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);
    
    ll sum = 0;
    rep(i, n) {
        ll a; scanf("%lld", &a);
        sum += a;
    }

    printf("%lld", sum - n);
    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else cout << "Yay!" << endl;
	return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e2) + 17;

int n;
int a[MAXN][MAXN];
ll dp[1 << 22];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        forn (j, n)
            cin >> a[i][j];

    return true;
}

ll add(ll a, ll b) { return (a += b) >= INF ? a - INF : a; }

void solve() {
    dp[0] = 1;
    vector<int> masks(1 << n);
    iota(masks.begin(), masks.end(), 0);
    sort(masks.begin(), masks.end(), [](int a, int b) { return __builtin_popcount(a) < __builtin_popcount(b); });

    for (const auto& mask : masks)
        if (mask != (1 << n) - 1) {
            int i = __builtin_popcount(mask);

            for (int j = 0; j < n; ++j)
                if (a[i][j] == 1 && ((mask >> j) & 1) == 0)
                    dp[mask | (1 << j)] = add(dp[mask | (1 << j)], dp[mask]);
        }

    cout << dp[(1 << n) - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

long long N;
long long H[100005];

int main(){
	cin >> N;
	for(long long i = 1; i <= N; i++){
		cin >> H[i];
	}

	for(long long i = 1; i <= N; i++){
		if(H[i-1] > H[i]){
			cout << "No" << endl;
			return 0;
		} else if(H[i-1] < H[i]){
			H[i]--;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

string solve(const string &s,const string &t){
	int n=s.length();
	static int dp[2001][2001],from[2001][2001];

	rep(i,n+1) dp[i][0]=0, from[i][0]=-1;
	rep(j,n+1) dp[0][j]=0, from[0][j]=-1;

	rep(i,n) rep(j,n) {
		if(s[i]==t[j]){
			dp[i+1][j+1]=dp[i][j]+1;
			from[i+1][j+1]=2;
		}
		else{
			if(dp[i][j+1]<dp[i+1][j]){
				dp[i+1][j+1]=dp[i+1][j];
				from[i+1][j+1]=1;
			}
			else{
				dp[i+1][j+1]=dp[i][j+1];
				from[i+1][j+1]=0;
			}
		}
	}

	int len=0,i_len[2];
	for(int i=1;i<n;i++){
		int tmp=2*dp[i][n-i];
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i;
		}

		tmp=2*dp[i][n-i-1]+1;
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i-1;
		}
	}

	int idx=dp[i_len[0]][i_len[1]];
	string ans(idx,'@');
	for(int i=i_len[0],j=i_len[1];~from[i][j];){
		switch(from[i][j]){
			case 0: i--; break;
			case 1: j--; break;
			case 2: i--; j--; idx--; ans[idx]=s[i]; break;
		}
	}
	if(len%2==1) ans+=s[i_len[0]];
	rep(i,len/2) ans+=ans[len/2-i-1];

	return ans;
}

int main(){
	for(char s[2001],t[2001];~scanf("%s",s);){
		strcpy(t,s);
		reverse(t,t+strlen(t));
		puts(solve(s,t).c_str());
	}
	return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	vector<int> a(5);

	for (int i = 0; i < 3; i++) {
		int x, y; cin >> x >> y;
		
		a[x]++;
		a[y]++;

	}

	for (int i = 0; i < 5; i++) {
		if (a[i] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	VI a(n);
	rep(i,n)cin>>a.at(i);
	sort(all(a));
	cout<<a.at(n-1)-a.at(0)<<endl;
	return 0;
}


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

using namespace std;

int main(){
    string s = "";
    cin >> s;
    bool he = false;
    for(int i =0;i<s.length();i++){
        if(i%2 ==0){
        if (s[i]!='R' && s[i]!='U' && s[i]!= 'D'){
            he = true;
        }
        }
        else{
            if (s[i]!='L' && s[i]!='U' && s[i]!= 'D'){
            he = true;
        }
        }
    }
    if(he==true){
        cout << "No";
    }
    else{
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> d(n);
    REP(i,n) cin>>d[i];

    sort(ALL(d));
    cout<<d[n/2]-d[n/2-1]<<endl;

	return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
int INF = 10000000;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<char>> A(H + 2, vector<char>(W + 2, '#'));
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			cin >> A[i][j];
		}
	}
	int sy, sx;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (A[i][j] == 'S'){
				sy = i;
				sx = j;
			}
		}
	}
	A[sy][sx] = '.';
	vector<vector<int>> d(H + 2, vector<int>(W + 2, INF));
	d[sy][sx] = 0;
	queue<pair<int, int>> Q;
	Q.push(make_pair(sy, sx));
	while (!Q.empty()){
		int y = Q.front().first;
		int x = Q.front().second;
		Q.pop();
		for (int i = 0; i < 4; i++){
			int y2 = y + dy[i];
			int x2 = x + dx[i];
			if (A[y2][x2] == '.' && d[y2][x2] == INF){
				d[y2][x2] = d[y][x] + 1;
				Q.push(make_pair(y2, x2));
			}
		}
	}
	int ans = INF;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (d[i][j] <= K){
				ans = min(ans, (i - 1 + K - 1) / K + 1);
				ans = min(ans, (H - i + K - 1) / K + 1);
				ans = min(ans, (j - 1 + K - 1) / K + 1);
				ans = min(ans, (W - j + K - 1) / K + 1);
			}
		}
	}
	cout << ans << endl;
}

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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

const int maxn = 2e3+5;
const int intinf = 1<<29;
const ll inf = 1ll<<60;


void GG(){cout<<"No\n"; exit(0);}


vector<int> tree[maxn];
int nx = 0;
int k;
bool seen[maxn];

int dfs(int at, int left){
	if (left<0) return 0;
	seen[at]=1;
	int re = 1;
	for (int &v: tree[at]){
		if (!seen[v]) re+=dfs(v,left-1);
	}
	seen[at]=0;
	return re;
}

int solve(int x){
	int ex = 0, aa = 1;
	seen[x]=1;
	for (int &v: tree[x]){
		int a = dfs(v, k/2-1), b = dfs(v,k/2);
		aa += a; MXTO(ex, b-a);
		//debug(v); debug(a); debug(b);
	}
	seen[x]=0;
	return aa + ex;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   	int n; cin>>n;
   	vector<int> a(n*2);
   	REP(i,2*n){
   		cin>>a[i];
   	}
   	sort(ALL(a));
   	int re=  0;
   	REP(i,2*n){
   		if (i%2==0){
   			re+=a[i];
   		}
   	}
   	cout<<re<<endl;
}

Measured memory_bytes: 256
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w, k = list(map(int,ipti().split()))
    s = [list(input()) for i in range(h)]

    empty_row =  []
    exist_row = []
    berry_id = 1


    for row in range(h):
        is_empty = True
        for col in range(w):
            if s[row][col] == "#":
                s[row][col] = berry_id
                berry_id += 1
                is_empty = False
        if is_empty:
            empty_row.append(row)
        else:
            exist_row.append(row)


    # まず空ではない行を埋める
    for row in range(h):
        if row in exist_row:
            berry_col = deque()
            for col in range(w):
                if s[row][col] != ".":
                    berry_col.append(col)

            first = 0
            fill_id = 0

            while berry_col:
                last = berry_col.popleft()
                fill_id = s[row][last]
                for j in range(first, last+1):
                    s[row][j] =fill_id
                first = last + 1
            for j in range(first, w):
                s[row][j] = fill_id

    for row in empty_row:
        is_filled = False
        for row2 in range(row+1, h):
            if row2 in exist_row:
                for col in range(w):
                    s[row][col] = s[row2][col]
                    is_filled = True
                break
                
        if not is_filled:
            for row2 in range(row-1, -1 , -1):
                if row2 in exist_row:
                    for col in range(w):
                        s[row][col] = s[row2][col]
                        is_filled = True
                    break

    for row in range(h):
        print(*s[row])

if __name__ == '__main__':
    main()

Measured memory_bytes: 54108
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	ll a,b,c,d,T;
	cin>>a>>b>>c>>d>>T;
	if((b-d)*T>=abs(a-c))
	{
		cout<<"YES"<<endl;
	}
	else 
		cout<<"NO"<<endl;
}

Measured memory_bytes: 3636
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;
const int MAX_C = 30;

int N, C;

int rec[MAX_N * 2 + 2];

vector<P> CH[MAX_C + 1];

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

    cin >> N >> C;

    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        CH[c].push_back(P(s, t));
    }

    for (int i = 1; i <= C; i++) {
        sort(CH[i].begin(), CH[i].end());
    }

    for (int i = 1; i <= C; i++) {
        int pt = -1;
        for (int j = 0; j < CH[i].size(); j++) {
            P p = CH[i][j];
            rec[p.first * 2]++;
            rec[p.second * 2 + 1]--;
            if (pt == p.first) {
                rec[p.first * 2]--;
                rec[pt * 2 + 1]++;
            }
            pt = p.second;
        }
    }

    int ans = 0;
    int need = rec[0];
    for (int i = 1; i <= 2 * MAX_N + 1; i++) {
        need += rec[i];
        ans = max(ans, need);
        //cout << "i = " << i << ", need = " << need << ", rec = " << rec[i] << "\n";
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> pos(n, INT_MAX);
  vector<map<int, int> > g(n);
  bool check  = true;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if (g[l].find(r)!= g[l].end() and g[l][r] != d) check = false;
    g[l][r] = d;
    if (g[r].find(l)!= g[r].end() and g[r][l] != -d) check = false;
    g[r][l] = -d;
  }
  if (!check) {cout << "No\n"; return 0;}
  vector<bool> vst(n, false);
  for (int i = 0; i < n; i++) {
    if (!vst[i]) {
      vst[i] = true;
      pos[i] = 0;
      stack<int> dfs;
      dfs.push(i);
      while (!dfs.empty()) {
        int y = dfs.top();
        dfs.pop();
        for (auto x: g[y]) {
          if (!vst[x.first]) {
            vst[x.first] = true;
            pos[x.first] = pos[y]+x.second;
            dfs.push(x.first);
          }
        }
      }
    }
  }
  for (int i = 0; i <n; i++) {
    for (auto x: g[i])
      if (pos[x.first] != pos[i]+x.second) check = false;
  }
  if (!check) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}



Measured memory_bytes: 24576
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 

void solve() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    int l_array[q][2];
    int a, b;
    rep(i,0,q){
        cin >> a >> b;
        l_array[i][0] = a-1; l_array[i][1] = b-1;
    }

    int cum_array[n];
    cum_array[0] = 0;
    int temp = 0;
    rep(i,1,n){
        if(s[i-1] == 'A' && s[i] == 'C'){
            temp += 1;
        }
        cum_array[i] = temp;
    }
    rep(i,0,q){
        cout << cum_array[l_array[i][1]] - cum_array[l_array[i][0]] << endl;
    }
}

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

Measured memory_bytes: 2240
import math
nVezes = int(input())
linha = input()
linha = linha.split()
listaDiferencas = []
somaFrente = 0
somaTras = 0
for aux in range(nVezes):
    if aux > 0:
        for x in range(aux+1,nVezes):
            somaFrente += int(linha[x])

        for y in range(0,aux+1):
            somaTras += int(linha[y])
        listaDiferencas.append(abs(somaTras - somaFrente))
        somaFrente = 0
        somaTras = 0
print(min(listaDiferencas))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int N;
int b[128];

int mareitaso[128];
int yukati[128];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	memcpy(mareitaso, b, sizeof(*b) * N);
	for (i = N; i > 0; i--) {
		int j;
		int ok = 0;
		for (j = i - 1; j >= 0; j--) {
			if (mareitaso[j] == j + 1) {
				yukati[i] = j + 1;
				memmove(mareitaso + j, mareitaso + j + 1, sizeof(*mareitaso) * (N - j /* - 1 */));
				ok = 1;
				break;
			}
		}
		if (!ok) {
			puts("-1");
			return 0;
		}
	}
	for (i = 1; i <= N; i++) {
		printf("%d\n", yukati[i]);
	}
	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using namespace std;

int main() {
    string n;
    cin >> n;
    if (n[0] == n[2])Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
c=input()
c=int(c)
a=input()
b=0
if c%2==1:
  print("No")
else:
  for i in range(int(c/2)):
    if a[i]!=a[i+int(c/2)]:
      b=b+1
  if b==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9092
N,K=gets.split.map(&:to_i)
ps=gets.split.map(&:to_i)
ps.map!{|e|(e+1)/2.0}
ss=Array.new(N+1,0)
N.times do |i|
    ss[i+1]+=ss[i]+ps[i]
end
res=0
(N-K+1).times do |i|
    res= res<(ss[i+K]-ss[i]) ? ss[i+K]-ss[i] : res
end
puts res


Measured memory_bytes: 16516
#include<stdio.h>
#include<math.h>
typedef long long ll;


int return_result(ll x){
  int count=0;
  while(x>0){
    x/=10;
    count++;
  }

  return count;
}

int main(void)
{
  ll n;
  scanf("%lld",&n);
  ll max=0;
  for(ll i=1;i<=(ll)sqrt(n);i++){
    if(n%i==0){
      if(i>max){
        max=i;
      }
    }
  }



  printf("%d\n",return_result(n/max));
  return 0;
}


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

input_patterns = []

patterns = {}

def init_key():
    ini_key = []
    for i in range(26):
        ini_key.append(0)
    return ini_key

for i in range(n):
    val = input()
    input_patterns.append(val)

count = 0
for inp in input_patterns:
    key = sorted(inp)
    skey = ''

    for k in range(len(key)):
        skey = skey + key[k]

    if skey in patterns:
        patterns[skey] = patterns[skey] + 1
    else:
        patterns[skey] = 1

    if patterns[skey] > 1:
        count = count + patterns[skey] - 1
    
print('{}'.format(count))


Measured memory_bytes: 24976
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
    ll n,a; cin >> n >> a; vl x(n);
    rep(i,n){
        cin>>x[i];
        x[i]-=a;
    }
    vvl dp(n+1,vl(5000));
    dp[0][n*a] = 1;
    rep(i,n){
        rep(j,2*n*a){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j+x[i]] += dp[i][j];
        }
    }
    cout << dp[n][n*a] - 1 << endl;
}

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

//________
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vp;
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define All(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << x << endl
#define outl(x) cout << x << '\n';

#define INF (1 << 29)

#define FAST cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//________

int h,w;
int cost[11][11];


Vi mcos(11,INF);

void dijkstra(){
	priority_queue< Pii, Vp, greater<Pii> > pq;
	pq.push( mkp(0,1));
	mcos[1] = 0;

	while(!pq.empty()){
		Pii now = pq.top(); pq.pop();
		int c = now.fi;
		int pos = now.se;
		rep(i,10){
			int ncos = cost[i][pos] + c;
			if( chmin(mcos[i], ncos)){
				pq.push( mkp(ncos, i));
			}
		}
	}
	return;
}

main(){
	FAST;
	int a;
	int ans = 0;
	cin >> h >> w;
	rep(i,10){
		rep(j,10){
			cin >> cost[i][j];
		}
	}

	dijkstra();

	rep(i,h){
		rep(j,w){
			cin >> a;
			if(a == -1 || a == 1)continue;
			ans += mcos[a];
		}
	}

	outl(ans);
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f=0;
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      if(i%2==0&&a[i]%2==1){
        f++;
      }
    }
    System.out.println(f);
  }
}


Measured memory_bytes: 35756
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
		return 0;
	}
	if (s == "Cloudy") {
		cout << "Rainy" << endl;
		return 0;
	}
	if (s == "Rainy") {
		cout << "Sunny" << endl;
		return 0;
	}
	return 0;
}


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

int main() {
    string a, b;
    cin >> a >> b;
    a += *(b.end()-1);
    if(a == b) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std; 
int main(void){
  int n;
  string s;
  cin >> n >> s;
  int m = n;

  for(int i = 0;i <n-1; i++){
    if(s[i] == s[i+1]){
      m--;
    }
  }
  
  cout << m << endl;
  
  return 0;
}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> costs(n), foods(n);
    rep(i, n) cin >> costs[i];
    rep(i, n) cin >> foods[i];

    sort(costs.begin(), costs.end());
    sort(foods.rbegin(), foods.rend());

    auto check = [&](ll x) -> bool {
        ll ans = 0;
        rep(i, n) {
            ll c = costs[i];
            ll f = foods[i];
            if (c * f <= x) continue;
            ll border = x / f;
            assert(border < c);
            ll t = c - border;
            ans += t;
        }
        return ans <= k;
    };


    ll floor = 0, ceil = INF;

    if (check(floor)) {
        cout << 0 << endl;
        ret();
    }

    assert(check(ceil));

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        bool ok = check(mid);
        if (ok) ceil = mid;
        else floor = mid;
    }

    cout << ceil << endl;

}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
main(){
	int n;
	cin>>n;
	int l=0,r=n;
	cout<<0<<endl;
	string pre,now;
	cin>>pre;
	int P=l;
	r(i,30){
		int mid=(l+r)/2;
		cout<<mid<<endl;
		cin>>now;
		if(now=="Vacant")break;
		if(P<mid&&(abs(P-mid)%2==0&&now==pre||abs(P-mid)%2==1&&now!=pre)||
		   P>mid&&(abs(P-mid)%2==1&&now==pre||abs(P-mid)%2==0&&now!=pre)
			){
			l=mid+1;
		}
		else{
			r=mid;
		}
		pre=now;
		P=mid;
	}
exit(0);
}


Measured memory_bytes: 852
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, d, n;
    int count;

    for(;;){
      a = sc.nextInt();
      d = sc.nextInt();
      n = sc.nextInt();
      if(a == 0 && d == 0 && n == 0)break;
      count = 0;

      for(;;a+=d)if(isprime(a) && ++count == n){
          out.println(a); break;
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean isprime(int p){
    int i;
    if(p == 1)return false;
    else for(i = 2;i * i <= p;i++)if(p % i == 0)return false;
    return true;
  }
}

Measured memory_bytes: 21176
#include<stdlib.h>
#include<stdio.h>
int main(){
	int n,*h,*ct;
	scanf("%d",&n);
	h=(int*)malloc(n*sizeof(int));
	for (int i = 0; i < n; ++i) scanf("%d",&h[i]);
	ct=(int*)malloc(n*sizeof(int));
	ct[0]=0;ct[1]=abs(h[1]-h[0]);
	for (int i = 2; i < n; ++i){
		if((ct[i-2]+abs(h[i]-h[i-2]))>(ct[i-1]+abs(h[i]-h[i-1]))) ct[i]=ct[i-1]+abs(h[i]-h[i-1]);
		else ct[i]=ct[i-2]+abs(h[i]-h[i-2]);
	}
	printf("%d",ct[n-1]);
	return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, B, C, K = mi()

if A+B < K:
    print(A-(K-A-B))
else:
    print(min(A, K))

Measured memory_bytes: 9212
//
var wday: [String: Int]
wday = [:]

wday["SUN"] = 7
wday["MON"] = 6
wday["TUE"] = 5
wday["WED"] = 4
wday["THU"] = 3
wday["FRI"] = 2
wday["SAT"] = 1

//
let s:String = readLine()!
print(wday[s]!)


Measured memory_bytes: 6000
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, m; cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");
            int c1 = Integer.parseInt(input[0]);
            int c2 = Integer.parseInt(input[1]);
            int c3 = Integer.parseInt(input[2]);

            boolean[] cards = new boolean[11];
            cards[c1] = true;
            cards[c2] = true;
            cards[c3] = true;

            int available = 0;
            for (int i = 1; i <= 10; i++) {
                if (!cards[i] && c1 + c2 + i <= 20) {
                    available++;
                }
            }

            if (available > 3) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }
}


Measured memory_bytes: 24072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		long[] A=new long[N];
		for(int i=0; i<N; i++) {
			A[i]=sc.nextLong();
		}
		long gcd=A[0];
		for(int i=1; i<N; i++) {
			gcd=gcd(gcd,A[i]);
		}
		long ans=11451419810364364L;
		for(int i=0; i<N; i++) {
			if(gcd<A[i]) {
				if(A[i]%gcd==0) {
					ans=Math.min(ans,gcd);
				}
				else {
					ans=Math.min(ans, A[i]);
				}
			}
			else {
				ans=Math.min(ans, A[i]);
			}
		}
		pl(ans);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static long lcm(long m, long n) {
		return m / gcd(m, n)*n;
	}
	public static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
		return gcd(n, m % n);
	}
}


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

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

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;

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

  cin >> N;

  cout << pow(N, 3) << "\n";
  return 0;
}

Measured memory_bytes: 512
/* ex3_2
   urah  */

#include <stdio.h>

int main(void){
    int N;

    // 入力受け取り
    scanf("%d", &N);

    // 条件分岐
    if (N%10 == 3) {
        printf("bon");
    } else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
        printf("pon");
    } else {
        printf("hon");
    }

    return 0;
}

Measured memory_bytes: 1688
#include <stdio.h>


int main(){
  unsigned int N ,X;
  
  scanf("%d %d", &N, &X);
  
  unsigned int mi[N];
  
  for(int i = 0;i < N; i++){
    scanf("%d", &mi[i]);
  }
  
  unsigned int min;
  unsigned int total, kosu;
  

  min = mi[0];
  
  for (int i=0; i<N; i++){
    total += mi[i];
    
    if (min > mi[i])
      min = mi[i];
    
  }
  
  X = X-total;
  
  kosu = X / min;
  
  printf("%d" , kosu + N);
  
  return 0; 
}


Measured memory_bytes: 128