akhauriyash/Code-Regression huggingface dataset:
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()
if N%2 == 0:
    v1 = sum(A[::2])
    v2 = sum(A[1::2])
    M = max(v1, v2)
    l = 0
    for i in range(0, N, 2):
        v2 -= A[i+1]
        l += A[i]
        M = max(l + v2, M)
    print(M)
else:
    INF = 10**18
    DP = [[[-INF]*N for _ in range(3)] for _ in range(2)]
    DP[1][0][0] = A[0]
    DP[0][1][0] = 0
    for i in range(1, N):
        DP[1][0][i] = A[i] + DP[0][0][i-1]
        DP[1][1][i] = A[i] + DP[0][1][i-1]
        DP[1][2][i] = A[i] + DP[0][2][i-1]
        DP[0][0][i] = DP[1][0][i-1]
        DP[0][1][i] = max(DP[0][0][i-1], DP[1][1][i-1])
        DP[0][2][i] = max(DP[0][1][i-1], DP[1][2][i-1])

    print(max(DP[0][1][N-1], DP[1][1][N-1], DP[1][2][N-1]))




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

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int y, m, d;
        cin >> y >> m >> d;
        int ans = 0;
        while (y != 1000 || m != 1 || d != 1){
            ans++;
            if (y % 3 == 0){
                if (d == 20){
                    m++;
                    d = 1;
                }
                else d++;
            }
            else {
                if (m % 2 == 0){
                    if (d == 19){
                        m++;
                        d = 1;
                    }
                    else d++;
                }
                else {
                    if (d == 20){
                        m++;
                        d = 1;
                    }
                    else d++;

                }
            }
            if (m == 11){
                y++;
                m = 1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n; cin >> n;
	vector<int> a(n), b(n);
	int ans = 0;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	rep(i, 0, n) {
		a[i] -= b[i];
		if (a[i] > 0) ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1000003;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

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

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

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

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

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

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

template <typename T = int64>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

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

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
  t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template <typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template <typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  cin >> s;

  map<string, int> m;
  for (int i = 0; i < n; i++) {
    auto itr = m.find(s[i]);
    if (itr == m.end()) {
      m.insert(make_pair(s[i], 1));
    } else {
      itr->second += 1;
    }
  }

  vector<string> ans;
  int max = -1;
  for (auto &e : m) {
    if (max < e.second) {
      max = e.second;
      ans.clear();
      ans.push_back(e.first);
    } else if (max == e.second) {
      ans.push_back(e.first);
    }
  }

  for (auto &e : ans) {
    cout << e << endl;
  }
}


Measured memory_bytes: 27120
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int x = 0;
    int y = 0;

    for (int i = 0; i < n; ++i) {
      if (s.charAt(i) == 'I') {
        ++x;
      } else {
        --x;
      }
      if (x > y) {
        y = x;
      }
    }
    System.out.println(y);
  }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)

int main(){

  int n,k,h;

  cin>>n>>k;
  vector<int> hs;
  REP(i,0,n){
    cin>>h;
    hs.push_back(h);
  }
  sort(hs.begin(),hs.end());

  long long acum=0;
  REP(i,0,n-k)
    acum+=(long long)hs[i];
  cout<<acum<<endl;

  return 0;
}

Measured memory_bytes: 1400
N, L = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
(N-1).times do |i|
    if as[i] + as[i+1] >= L
        puts 'Possible'
        puts (1..i).to_a if 1 <= i
        puts ((i+2)..(N-1)).to_a.reverse if i+2 <= N-1
        puts i+1
        exit
    end
end
puts 'Impossible'

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

const int INF = 1E+9;

int main() {
    int N, M, X;
    cin >> N >> M >> X;

    int C[N], A[N][M];
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }
    
    int ans = INF;
    for (int bit=0; bit < (1<<N); bit++) {
        int cost = 0;
        int L[M];
        rep(i, M) L[i] = 0;

        rep(i, N) {
            if (bit & (1<<i)) {
                cost += C[i];
                rep(j, M) L[j] += A[i][j];
            }
        }

        bool ok = true;
        rep(i, M) if (L[i] < X) ok = false;
        
        if (ok) ans = min(ans, cost);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import sys 
sys.setrecursionlimit(10000)

#input

n ,m = map(int,input().split())
v = [0]*(n)
w = [0]*(n)

memo = [[None]*(m+1) for d in range(n+1)]


for a in range(n) :
    v[a],w[a] = map(int,input().split())

#func
def knapsack(i , c):
    if memo[i][c] != None :
      return memo[i][c]
    elif i==n or c == 0:
        return 0
    else :
        t1 = knapsack(i + 1 , c)
        t2 = -1
        if c >= w[i] :
            t2 = v[i] + knapsack(i + 1 , c - w[i])
        result = max(t1,t2)
        memo[i][c] = result
        return result
print(knapsack(0 , m))


Measured memory_bytes: 23636
#include<cstdio>
#include<cstdlib>
#define Maxn 5010

char s[Maxn];
int nxt[Maxn],n,mx[Maxn];

void KMP(int st)
{
	nxt[st]=st-1;int p=st-1;
	for(int i=st+1;i<=n;i++)
	{
		while(s[i]!=s[p+1]&&p>=st) p=nxt[p];
		if(s[i]==s[p+1]) p++;
		nxt[i]=p;
	}
	for(int i=st;i<=n;i++) mx[i]=st-1;
	for(int i=st+1;i<=n;i++) mx[nxt[i]]=i;
	for(int i=n;i>=st;i--)
	{
		if(mx[i]>=st) mx[nxt[i]]=mx[i];
	}
}

int main()
{
	int ans=0;
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
	{
		KMP(i);
		for(int j=n;j>=i;j--)
		{
			if(2*(j-i+1)<=mx[j]-i+1)
			{
				ans=j-i+1>ans?j-i+1:ans;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

  sort(vec.begin(), vec.end());
  int a = vec.end() - unique(vec.begin(), vec.end());
  cout << n - (a + 1) / 2 * 2 << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    cin >> A;
    int base = A[0] / 2;
    int add = A[0];
    for (int i = 1; i < N; i++) {
        base = (base * (A[i] / 2)) / __gcd(base, A[i] / 2);
        add = (add * A[i]) / __gcd(add, A[i]);
    }
    bool flag = false;
    for (int i = 0; i < N; i++) {
        if ((base - (A[i] / 2)) % A[i] != 0) flag = true;
    }
    if (flag || base > M) {
        cout << 0 << endl;
    } else {
        int ans = 1;
        M -= base;
        ans += M / add;
        cout << ans << endl;
    }
}


Measured memory_bytes: 1152
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F => int.Parse(ReadLine());
	long FL => int.Parse(ReadLine());
	int[] G => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var n = F;
		WriteLine(n < 1200 ? "ABC" : n < 2800 ? "ARC" : "AGC");
	}
}


Measured memory_bytes: 11092
#include <stdio.h>
int min(int a,int b){
    if (a<b) return a;
    else return b;
}
int main(){
    int P=10000,p,J=10000,j,i;
    for (i=0; i<3; i++) {
        scanf("%d",&p);
        P=min(P, p);
    }
    for (i=0; i<2; i++) {
        scanf("%d",&j);
        J=min(J, j);
    }
    printf("%d\n",P+J-50);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << "\n";
    
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXROBOT = 100000;
const int MAXEXIT = 100000;
const int MOD = 1000000007;
struct P { int x, y; P() {} P(int x, int y) :x(x), y(y) {} };
bool operator<(const P &a, const P &b) { if (a.x != b.x) return a.x < b.x; return a.y > b.y; }
bool operator==(const P &a, const P &b) { return a.x == b.x && a.y == b.y; }

int nrobot, nexit;
int probot[MAXROBOT], pexit[MAXEXIT];

int np;
P p[MAXROBOT];
int xx[MAXROBOT], nxx;
int yy[MAXROBOT], nyy;

int bit[MAXROBOT + 1];
void inc(int &a, int b) { if ((a += b) >= MOD) a -= MOD; }
void bmod(int idx, int by) { ++idx; while (idx <= nyy) { inc(bit[idx], by); idx += idx&-idx; } }
int bget(int idx) { ++idx; int ret = 0; while (idx > 0) { inc(ret, bit[idx]); idx -= idx&-idx; } return ret; }

int solve() {
	{ np = 0; int at = 0; REP(i, nrobot) { while (at < nexit && pexit[at] <= probot[i]) ++at; if (at < nexit && at - 1 >= 0) p[np++] = P(probot[i] - pexit[at - 1], pexit[at] - probot[i]); } }
	nxx = 0; REP(i, np) xx[nxx++] = p[i].x; sort(xx, xx + nxx); nxx = unique(xx, xx + nxx) - xx; REP(i, np) p[i].x = lower_bound(xx, xx + nxx, p[i].x) - xx;
	nyy = 0; REP(i, np) yy[nyy++] = p[i].y; sort(yy, yy + nyy); nyy = unique(yy, yy + nyy) - yy; REP(i, np) p[i].y = lower_bound(yy, yy + nyy, p[i].y) - yy;
	sort(p, p + np); np = unique(p, p + np) - p;
	//printf("p:"); REP(i, np) printf(" (%d,%d)", p[i].x, p[i].y); puts("");

	REPE(i, nyy) bit[i] = 0;
	REP(i, np) {
		int ways = (bget(p[i].y - 1) + 1) % MOD;
		bmod(p[i].y, ways);
	}
	int ret = (bget(nyy - 1) + 1) % MOD;
	return ret;
}

void run() {
	scanf("%d%d", &nrobot, &nexit);
	REP(i, nrobot) scanf("%d", &probot[i]);
	REP(i, nexit) scanf("%d", &pexit[i]);
	printf("%d\n", solve());
}

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


Measured memory_bytes: 2688
#include <stdio.h>
#include <string.h>
int main(void){
int n,k;
int money=0;
scanf("%d %d",&n,&k);
if(n==1){money=money+300000;}
else if(n==2){money=money+200000;}
else if(n==3){money=money+100000;}

if(k==1){money=money+300000;}
else if(k==2){money=money+200000;}
else if(k==3){money=money+100000;}

if(n==1&&k==1){money=money+400000;}
printf("%d\n",money);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int K, S; cin >> K >> S;
  int score = 0;
  for(int a = 0; a <= K; ++a){
    for(int b = 0; b <= K; ++b){
      int c = S - a - b;
      if(0 <= c and c <= K) ++score;
    }
  }
  cout << score << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using std::cout;
using std::cin;
using std::endl;
using std::vector;

int cnt = 0;
void merge(vector< int > &A,int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector< int > L(n1+1);
	vector< int > R(n2+1);

	for (int i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = 0x7FFFFFFF;
	R[n2] = 0x7FFFFFFF;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++){
		if (L[i] <= R[j]){
			A[k] = L[i];
			i++;
			cnt++;
		}else{
			A[k] = R[j];
			j++;
			cnt++;
		}
	}
}

void mergesort(vector< int > &A,int left,int right){
	if (left + 1 < right){
		int mid = (left + right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);	
	}
}

int main(){
	int n; cin >> n;
	vector< int>  A(n);
	for (int i = 0; i < n; i++){
		cin >> A[i];
	}
	mergesort(A,0,n);
	for (int i = 0; i < n; i++){
		cout << A[i] ;
		if (i != n-1){
			cout << " ";
		}
	}
	cout << endl;
	cout << cnt << endl;
return 0;
}

Measured memory_bytes: 6808
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;


int main(void) {
	int N, K;
	string S;
	cin >> N >> K >> S;

	

	int score = 0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] == S[i]) score++;
	}

	
	int ans = min(score + 2 * K, N - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

int main() {
    int t, x;
    cin >> t >> x;

    cout << (double)t / x << endl;

    return 0;
}


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

int main() {
    int n;
    cin>>n;
    string a,b;
    string ans="";
    cin>>a>>b;
    for(int i=0;i<n;i++){
        ans.push_back(a[i]);
        ans.push_back(b[i]);
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 3616
(let ((n (read))
    (a (make-array 15))
    (other 0)
    (ans 0))

    (loop for _ below n do
        (incf (aref a (floor (/ (read) 400))))
    )

    (loop for i below 15 do
        (if (<= i 7)
            (if (>= (aref a i) 1)
                (incf ans)
            )
            (incf other (aref a i))
        )
    )

    (if (<= ans 1)
        (format t "1")
        (format t "~D" ans)
    )

    (incf ans other)
    (format t " ~D~%" ans)
)

Measured memory_bytes: 24460
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string x;
    cin >> x;
    for (ll i=0;i<x.size();++i){
        if (x[i]=='C'){
            for (ll j=i+1;j<x.size();++j){
                if (x[j]=='F'){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string>v;

    for(int i = 0; i < s.size(); i++) {
        for (int j = 1; j<=min(k, int(s.size())); j++) {
            v.insert(s.substr(i, j));
        }
    }
    int c = 1;
    for (auto i = v.begin(); i != v.end(); i++) {
        if(c == k) {
            cout << *i << endl;
            return 0;
        }
        c++;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<queue>
#include<cstdio>
#include<cctype>
#include<vector>
const int N=200007;
int read(){int x=0,c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))x=x*10+c-48,c=getchar();return x;}
std::vector<int>e[N];std::queue<int>q;
int n,m,ans,vis[N],deg[N][2];char col[N];
int main()
{
    n=read(),m=read(),scanf("%s",col+1);
    for(int i=1,u,v;i<=m;++i) u=read(),v=read(),e[u].push_back(v),e[v].push_back(u),++deg[u][col[v]=='B'],++deg[v][col[u]=='B'];
    for(int i=1;i<=n;++i) if(!deg[i][0]||!deg[i][1]) ++ans,q.push(i),vis[i]=1;
    for(int u;!q.empty();)
    {
	u=q.front(),q.pop();
	for(int v:e[u]) if(!vis[v]&&!--deg[v][col[u]=='B']) ++ans,q.push(v),vis[v]=1;
    }
    puts(ans==n? "No":"Yes");
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

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

    int n;
    cin >> n;
    V<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i]; v[i] -= (i+1);
    }
    sort(begin(v), end(v));
    ll mid = v[n/2];
    ll sm = 0;    
    for (int i = 0; i < n; i++) {
        sm += abs(mid - v[i]);
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <vector>
#include <set>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

struct Point
{
	int		nPointX;
	int		nPointY;
	int		nIndex;
};

int main(int argc, char* argv[])
{
	Point		sStudentPoint[55];
	Point		sCheckPoint[55];
	int			nStudentNumber;
	int			nCheckNumber;
	int			nDistance;
	int			nMidDistance;
	int			nIndex;

	cin >> nStudentNumber >> nCheckNumber;

	for (int i = 1; i <= nStudentNumber; i++)
	{
		cin >> sStudentPoint[i].nPointX >> sStudentPoint[i].nPointY;
	}
	for (int i = 1; i <= nCheckNumber; i++)
	{
		cin >> sCheckPoint[i].nPointX >> sCheckPoint[i].nPointY;
		sCheckPoint[i].nIndex = i;
	}

	for (int i = 1; i <= nStudentNumber; i++)
	{
		nDistance	= INT_MAX;
		nIndex		= i;
		for (int j = 1; j <= nCheckNumber; j++)
		{
			nMidDistance = abs(sStudentPoint[i].nPointX - sCheckPoint[j].nPointX) + abs(sStudentPoint[i].nPointY - sCheckPoint[j].nPointY);
			
			if (nMidDistance < nDistance)
			{
				nDistance	= nMidDistance;
				nIndex		= j;
			}
		}
		cout << nIndex << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

P getE(P p){return p/abs(p);}

double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=0;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                    double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                    P c1=0.5*(ps[i]+ps[j])+getE(ps[j]-ps[i])*polar(d,PI/2);
                    P c2=0.5*(ps[i]+ps[j])+getE(ps[j]-ps[i])*polar(d,-PI/2);
                    cnt=0;
                    for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                    if(cnt>ans)ans=cnt;
                    cnt=0;
                    for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                    if(cnt>ans)ans=cnt;
                }
        if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 872
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, h, cur, ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (h >= cur) {
            ans++;
            cur = h;
        }
    }
    cout << ans << "\n";
    //system("pause");
    return 0;
}

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

int main()
{
	int n, left, right, res;
	string buf;
	while (cin >> n, n) {
		left = right = res = 0;
		for (int i = 0; i < n; i++) {
			cin >> buf;
			if (buf == "lu") {
				left = 1;
			} else if(buf == "ld"){
				left = 0;
			} else if(buf == "ru"){
				right = 1;
			} else {
				right = 0;
			}
			if ((res % 2 == 0 && left == 1 && right == 1) || (res % 2 == 1 && left == 0 && right == 0))
				res++;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

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 sum=a+b+c;

		if(a%2==1 || b%2==1 || c%2==1) {
			System.out.println(0);
		}
		else if(a==b&&b==c) {
			System.out.println(-1);
			System.exit(0);
		}
		else {
			int max=11451419;
			int tmpc=0;
			while(true) {
				long ksn=(((long)sum)*(powz(2,tmpc+1)-powz(-1,tmpc+1))+((long)a)*(3*powz(-1,tmpc+1)))/(3*powz(2,tmpc+1));
				if(ksn%2==0) {
					tmpc++;
				}
				else {
					max=Math.min(max, tmpc);
					tmpc=0;
					break;
				}
			}

			while(true) {
				long ksn=(((long)sum)*(powz(2,tmpc+1)-powz(-1,tmpc+1))+((long)b)*(3*powz(-1,tmpc+1)))/(3*powz(2,tmpc+1));
				if(ksn%2==0) {
					tmpc++;
				}
				else {
					max=Math.min(max, tmpc);
					tmpc=0;
					break;
				}
			}

			while(true) {
				long ksn=(((long)sum)*(powz(2,tmpc+1)-powz(-1,tmpc+1))+((long)c)*(3*powz(-1,tmpc+1)))/(3*powz(2,tmpc+1));
				if(ksn%2==0) {
					tmpc++;
				}
				else {
					max=Math.min(max, tmpc);
					tmpc=0;
					break;
				}
			}
			System.out.println(max+1);
		}
	}
	static long powz(long a,long b) {
		long tmpa=1;
		for(int i=0; i<b; i++) {
			tmpa*=a;
		}
		return tmpa;
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;cin>>a>>b>>n;
    if (b==1) {
        cout << 0 << endl;
    }
    else if (n<b) {
        cout << a*n/b << endl;
    }
    else {
        cout << a*(b-1)/b << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0){
        cout << abs(a - b) / 2 << endl;
    }else{
        ll k=n-max(a,b);
        ll f=min(a,b)-1;
        if(k>=f){
            ll s=min(a,b)-1;
            ll t=max(a,b)-1;
            s=s+t+1;
            cout<<s/2<<endl;
        }else{
            ll s=n-max(a,b);
            ll t=n-min(a,b);
            s=s+t+1;
            cout<<s/2<<endl;
        }
    }
}


Measured memory_bytes: 888
def main(argv)
  (n, m) = gets.chomp.split(' ').map(&:to_i)

  solved = [false] * n
  was = [0] * n

  m.times do |i|
    (x, s) = gets.chomp.split(' ')
    x = x.to_i - 1

    if s == 'AC' then
      solved[x] = true
    else
      unless solved[x] then
        was[x] += 1
      end
    end
  end
  
  a = solved.count{|x| x}
  b = 0
  n.times do |i|
    if solved[i] then
      b += was[i]
    end
  end

  puts [a, b].map(&:to_s).join(' ')
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) cout << "GREATER" << endl;
  else if (a.size() < b.size()) cout << "LESS" << endl;
  else {
    if (a > b) cout << "GREATER" << endl;
    else if (a < b) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[1000+100];
    cin>>n;
    int sum;
    int mi = 9999999,ma= -9999999,ct= 9999999;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        sum+=a[i];
        mi = min(mi,a[i]);
        ma = max(ma,a[i]);
    }
    for(int j=mi;j<=ma;++j)
    {
        int cc = 0;
        for(int i=1;i<=n;++i)
        {
            cc+= (a[i]-j)*(a[i]-j);
        }
        ct = min(ct,cc);
    }
    cout<<ct<<endl;
}


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

int main(){

  string s;
  cin >> s;
  for(int i=1;i<4;i++){
    if(s[i] == s[i-1]){
      cout << "Bad" << endl;
      return 0;
    }
  }

  cout << "Good" << endl;


}


Measured memory_bytes: 256
D,G = map(int, input().split())
li=[]
for i in range(D):
    li.append(list(map(lambda x: int(x), input().split())))

def bit():
    ans=10000040000
    for i in range(2 **D):
        #問題数n　得点p
        n=0
        p=0
        for j in range(D):
            if ((i >> j) & 1):
                n += li[j][0]
                p += li[j][1] 
                p += li[j][0] *100*(j+1)
        
        if p >= G:
            if n <= ans:
                ans=n
        
        for j in reversed(list(range(D))):
            if ((i >> j) & 1):
                continue
            else:
                for k in range(li[j][0]):
                    if p < G:
                        n += 1
                        p += 100*(j+1)
                    else:
                        if n <= ans:
                            ans=n
                            break
    print(ans)

bit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=5500000,ans=mzint;
  while(M--){
    vector<pair<int,int>> AAA={make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26)};
    vector<int> BBB={t[AAA[0].first],t[AAA[1].first],t[AAA[2].first]};
    int ans2=ans;
    for(int aaa=0;aaa<3;aaa++){
    int d=AAA[aaa].first,q=AAA[aaa].second;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    t[d]=q+1;
    }
    if(ans2>ans){
      ans=ans2;
      t[AAA[0].first]=BBB[0];
      t[AAA[1].first]=BBB[1];
      t[AAA[2].first]=BBB[2];
    }
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i > M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;

typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}
template<class T>
T POW(T n, T m) {
	T res = 1;
	rep(i, 0, m) {
		res *= n;
	}
	return res;
}

ll power(ll x, ll y, ll mod) {
	if (y == 0)return 1;
	if (y == 1)return x % mod;
	if (y == 1)return x % mod;
	if (y % 2 == 0)return POW(power(x, y / 2, mod), 2LL) % mod;
	return ((POW(power(x, y / 2, mod), 2LL) % mod)*(x%mod)) % mod;
}
ll div(ll a, ll  b, ll mod) {
	return (a* power(b, mod - 2, mod)) % mod;
}

template<
	typename Inputs,
	typename Functor,
	typename T = typename Inputs::value_type>
	void sort_by(Inputs& inputs, Functor f) {
	std::sort(std::begin(inputs), std::end(inputs),
		[&f](const T& lhs, const T& rhs) { return f(lhs) < f(rhs); });
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;

ll MOD_NUM = POW(10LL, 9LL) + 7;




int main() {
	ll N, T;
	cin >> N >> T;
	vpll ct(N);
	rep(i, 0, N)cin >> ct[i].first>>ct[i].second;

	sort_by(ct, []( pll i) {return i.second; });

	auto it = ct.begin();
	rep(i, 0, N) {
		if (ct[i].second <= T) it++;
	}
	if (ct[0].second>T) {
		cout << "TLE";
		return 0;
	}

	vll ctf;
	for(auto i = ct.begin(); i != it; i++) {
		ctf.push_back(i->first);
	}
	cout << *min_element(all(ctf));
	


	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char student[30] = {0};
	int i, n;
	
	for (i = 0; i < 28; i++){
		scanf("%d", &n);
		student[n - 1] = 1;
	}
	
	for (i = 0; i < 30; i++){
		if (student[i] == 0){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a + b + c >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 22228
package main

import (
   "fmt"
)

func solution(n int, a []int) int {
   out := 0
   for i := range a {
        out += a[i] - 1
   }
   return out
}

func main() {
   var n int
   fmt.Scan(&n)
   a := make([]int, n)
   for i := range a {
        fmt.Scan(&a[i])
   }
   fmt.Println(solution(n, a))
}

Measured memory_bytes: 2016
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
int main(){
   int n;
   cin>>n;
   vector<int> t(n+1),x(n+1),y(n+1);
   t[0]=0,x[0]=0,y[0]=0;
   rep(i,1,n+1){
       cin>>t[i]>>x[i]>>y[i];
   }
   rep(i,0,n){
       if(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])>t[i+1]-t[i] || (x[i]+y[i])%2 != t[i]%2){
           cout<<"No";
           return 0;
       }
   }
   if((x[n]+y[n])%2!=t[n]%2) {
       cout<<"No";
       return 0;
   }
   cout<<"Yes";
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int t[11],n[11];
  for(int i=0;i<4;i++){
    cin >> t[i] >> n[i];
    if(t[i]==1){
      n[i]=6000*n[i];
    }else if(t[i]==2){
      n[i]=4000*n[i];
    }else if(t[i]==3){
      n[i]=3000*n[i];
    }else if(t[i]==4){
      n[i]=2000*n[i];
    }
  }
  for(int i=0;i<4;i++){
    cout << n[i] <<endl;
  }
  return(0);
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const long long INF = 1e18;

struct Edge
{
	int to;
	long long cost;
};

struct Dijkstra
{
	using P = pair<long long, int>;
	int V;
	int s;
	const vector<vector<Edge>> &g;
	vector<long long> dist;
	vector<int> previous;

	Dijkstra(const vector<vector<Edge>> &g) : V(g.size()), g(g) {}

	void calc(int start) {
		s = start;
		dist.assign(V, INF);
		previous.assign(V, -1);
		dist[s] = 0;
		priority_queue<P, vector<P>, greater<P>> pque;
		pque.push(P(0, s));
		while (!pque.empty()) {
			P p = pque.top(); pque.pop();
			int v = p.second;
			if (p.first > dist[v]) continue;
			for (Edge e : g[v]) {
				if (dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					previous[e.to] = v;
					pque.push(P(dist[e.to], e.to));
				}
			}
		}
	}
};

int main() {
	int n, m, s;
	cin >> n >> m >> s;
	const int MAX = 2505;
	vector<vector<Edge>> g(n * (MAX+1));
	auto idx = [&](int v, int ginka) {
		return ginka*n + v;
	};
	for (int i = 0; i < m; i++) {
		long long u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		for (int j = 0; j <= MAX; j++) {
			if (j-a >= 0) g[idx(u, j)].push_back({idx(v, j-a), b});
			if (j+a <= MAX) g[idx(v, j+a)].push_back({idx(u, j), b});
		}
	}
	for (int i = 0; i < n; i++) {
		long long c, d;
		cin >> c >> d;
		for (int j = 0; j < MAX; j++) {
			g[idx(i, j)].push_back({idx(i, min(MAX, int(j+c))), d});
		}
	}
	Dijkstra D(g);
	D.calc(idx(0, min(s, MAX)));
	for (int i = 1; i < n; i++) {
		long long ans = INF;
		for (int j = 0; j <= MAX; j++) {
			ans = min(ans, D.dist[idx(i, j)]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k;
    for(int i = 0; i < k; i++) {
        s += "ACL";
    }

    cout << s << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

int edit_distance(string s,string t){
  int n=s.size(),m=t.size();
  vector< vector<int> > dp(n+1,vector<int>(m+1,n+m+1));
  dp[0][0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      chmin(dp[i+1][j],dp[i][j]+1);
      chmin(dp[i][j+1],dp[i][j]+1);
      if(i<n and j<m)
        chmin(dp[i+1][j+1],dp[i][j]+(s[i]!=t[j]));
    }
  }
  return dp[n][m];
}

const int LOCAL = 0;
string ANS = "Atcod3rIsGreat";
int ask(string T){
  cout<<"? "<<T<<endl;
  if(LOCAL) return edit_distance(ANS,T);
  int ans;
  cin>>ans;
  return ans;
}

void answer(string S){
  cout<<"! "<<S<<endl;
  if(LOCAL) assert(S==ANS);
  exit(0);
}

//INSERT ABOVE HERE
signed main(){
  string B;
  for(int i=0;i<26;i++) B+=char('a'+i);
  for(int i=0;i<26;i++) B+=char('A'+i);
  for(int i=0;i<10;i++) B+=char('0'+i);

  const int L = 128;
  int len=0;
  vector<string> ss(B.size());
  for(int i=0;i<(int)B.size();i++){
    ss[i]=string(L-ask(string(L,B[i])),B[i]);
    len+=ss[i].size();
  }

  using P = pair<int, string>;
  priority_queue<P, vector<P>, greater<P> > pq;
  for(int i=0;i<(int)B.size();i++)
    if(!ss[i].empty()) pq.emplace(ss[i].size(),ss[i]);

  while(pq.size()>1){
    string X=pq.top().second;pq.pop();
    string Y=pq.top().second;pq.pop();
    string Z;
    while(!X.empty() and !Y.empty()){
      string P=Z+Y[0]+X;
      if(ask(P)==len-(int)P.size()){
        Z+=Y[0];
        Y.erase(Y.begin());
      }else{
        Z+=X[0];
        X.erase(X.begin());
      }
    }
    Z+=X+Y;
    pq.emplace(Z.size(),Z);
  }

  answer(pq.top().second);
  return 0;
}


Measured memory_bytes: 3760
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=1e5+5;
int arr[N][3],ans[N][3];
using namespace std;
int main()
{
    ahmocs
    int n; cin>>n;
    for (int i=0; i<n; ++i)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    ans[0][0]=arr[0][0]; ans[0][1]=arr[0][1]; ans[0][2]=arr[0][2];
    for (int i=1; i<n; ++i)
    {
        ans[i][0] = max(ans[i-1][1],ans[i-1][2]) + arr[i][0];
        ans[i][1] = max(ans[i-1][0],ans[i-1][2]) + arr[i][1];
        ans[i][2] = max(ans[i-1][0],ans[i-1][1]) + arr[i][2];
    }
    cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){

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

























}


Measured memory_bytes: 256
n=int(input())
tM=list(map(int,input().split()))
aM=list(map(int,input().split()))
tm=[1]*n
am=[1]*n

tm[0]=tM[0]
for i in range(1,n):
    if tM[i]>tM[i-1]:
        tm[i]=tM[i]

aM.reverse()
am[0]=aM[0]
for i in range(1,n):
    if aM[i]>aM[i-1]:
        am[i]=aM[i]
aM.reverse()
am.reverse()

m=[]
M=[]
for i in range(n):
    m.append(max(tm[i],am[i]))
    M.append(min(tM[i],aM[i]))

ans=1
mod=10**9+7
for i in range(n):
    ans*=max(0,M[i]-m[i]+1)
    ans%=mod

print(ans)


Measured memory_bytes: 18752
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    string s;cin >> s;
    ll res = 1;
    rep(i,n){
        if(!i)continue;
        if(s[i] != s[i-1])res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
line = input().split(" ")
n = int(line[0])
k = int(line[1])

if (n%2 == 0):
    if (n//2 >= k):
        print("YES")
    else:
        print("NO")
else:
    if (n//2+1 >= k):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

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

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,n;
    cin >> a >> b >> n;
    ll x=n;
    if(n >= b-1) x = b-1;
    ll ans = a*(x%b)/b;
    cout << ans << endl;
   

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>

using namespace std;
int N;
int A[7] = {1, 2, 4, 8, 16, 32, 64};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	int ans;
	for (int a : A){
		if(N < a) break;
		ans = a;
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
	int num[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
  int k;
  
  cin >> k ;
  
  cout << num[k-1] <<  endl;
    return 0;
}


Measured memory_bytes: 256
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m,k,x,ans=0;
        cin>>n>>m>>k;
        vector<ll>a(n+1,0);
        for(ll i=1; i<=n; i++)
        {
            cin>>a[i];
            a[i]+=a[i-1];
        }
        vector<ll>b(m+1,0);
        for(ll i=1; i<=m; i++)
        {
            cin>>b[i];
            b[i]+=b[i-1];
        }
        for(ll i=0; i<=n; i++)
        {
            if(a[i]>k) break;
            ll baki=k-a[i];
            ll lb=upper_bound(b.begin(),b.end(),baki)-b.begin();
            lb--;
            //cout<<" baki: "<<baki<<"lb: "<<lb<<endl;
            ans=max(ans,i+lb);
            //cout<<ans<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6372
#include <iostream>
using namespace std;
int main(){
    while (true){
        int n,x;
        cin >> n >> x;
        if (n == 0 && x == 0){
            break;
        }
        n++;
        int ans = 0;
        for (int i = 1; i < n; i++){
            for (int j = i+1; j < n; j++){
                for (int k = j+1; k < n; k++){
                    if (i+j+k == x){
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3096