akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1 << 25;

struct E {
  int from, to, cost;
};

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<E> edges;
    for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      --a;
      --b;
      edges.push_back(E{a, b, c});
    }
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++) dist[i][i] = 0;
    for (auto& e : edges) dist[e.from][e.to] = dist[e.to][e.from] = e.cost;
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
    int res = 0;
    for (auto& e : edges) {
      if (dist[e.from][e.to] < e.cost) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
c=0
def f(a,x,y):
    if 0<=x<12 and 0<=y<12 and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:f(a,x+dx,y+dy)

while 1:
    try:
        if c:input()
    except:break
    a = [list(input()) for _ in [0]*12]
    c=1;b=0
    for i in range(12):
        for j in range(12):
            if a[j][i]=='1':
                b+=1;f(a,i,j)
    print(b)

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

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

long long read(){
	long long i;
	cin >> i;
	return i;
}

char Judge(const vector<int> &tests) {
	char score = 'F';
	if (tests[0] == -1 || tests[1] == -1) {
		score = 'F';
	}else if (tests[0] + tests[1] >= 80) {
		score = 'A';
	}else if (tests[0] + tests[1] >= 65) {
		score = 'B';
	}else if (tests[0] + tests[1] >= 50) {
		score = 'C';
	}else if (tests[0] + tests[1] >= 30) {
		score = 'D';
		if (tests[2] >= 50) {
			score = 'C';
		}
	}

	return score;
}

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

	vector<vector<int> > students;
	while(1) {
		int m = read();
		int f = read();
		int r = read();
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		vector<int> tests(3);
		tests[0] = m;
		tests[1] = f;
		tests[2] = r;
		students.push_back(tests);
	}
	REP(i, students.size()) {
		cout << Judge(students[i]) << endl;
	}

	return 0;
}



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

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
	int n;
	cin >> n;
	int cntOdd = 0;
	int cntEven = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2)
			cntOdd++;
		else
			cntEven++;
	}
	if (n == 1 || cntOdd % 2 == 0)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll MINF = -1000000000000000;

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

    vector<tiii> edges(m);
    rep(i, 0, m)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[i] = make_tuple(a, b, c);
    }

    vector<ll> dis(n, MINF);

    dis[0] = 0;
    rep(i, 0, n)
    rep(e, 0, m)
    {
        ll a, b, c;
        tie(a, b, c) = edges[e];
        if (dis[a] == MINF) continue;

        if (dis[a] + c > dis[b])
            if (i == n - 1)
                dis[b] = -1 * MINF;
            else
                dis[b] = dis[a] + c;
    }

    if (dis[n - 1] == -1 * MINF)
        cout << "inf" << endl;
    else
        cout << dis[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; ++i){
        cin >> c[i];
        for(int j = 0; j < m; ++j)  cin >> a[i][j];
    }

    int ans = INF;
    for(int bit = 0; bit < (1 << n); ++bit){
        int costs = 0;
        vector<int> sum(m, 0);
        for(int i = 0; i < n; ++i){
            if((bit >> i) & 1){
                costs += c[i];
                for(int j = 0; j < m; ++j){
                    sum[j] += a[i][j];
                }
            }
        }

        bool ok = true;
        for(int i = 0; i < m; ++i){
            if(sum[i] < x){
                ok = false;
                break;
            }
        }
        if(ok)  chmin(ans, costs);
    }

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

Measured memory_bytes: 3664
x=input()
x=list(x)
a=len(x)
t=0
p=0
for i in range(a):
	if i%2==1:
		if x[i]=="R":
			p=1
	if i%2==0:
		if x[i]=="L":
			p=1
if p==1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3064
n,t=map(int,input().split())
a=list(map(int,input().split()))
a_r=list(reversed(a))

MAX=[0]
MIN=[10**10]

for i in range(n):
    MAX.append(max(a_r[i],MAX[-1]))
    MIN.append(min(a[i],MIN[-1]))
    
MAX.reverse()

MAX=MAX[:n]
MIN=MIN[1:]

t=[MAX[i]-MIN[i] for i in range(n)]

m=max(t)

cnta,cntb=0,0

for i in range(n):
    if t[i]==m:
        if MAX[i]==a[i]:
            cnta+=1
        if MIN[i]==a[i]:
            cntb+=1
print(min(cnta,cntb))

Measured memory_bytes: 14484
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int n; cin >> n;
	unordered_map<string,int> mp;
	FOR(i,1,n) {
		string x; cin >> x;
		mp[x]++;
	}
	int mx = 0;
	for (auto i : mp) {
		maxself(mx,i.s);
	}
	vector<string> v;
	for (auto i : mp) {
		if(i.s == mx) v.pb(i.f);
	}
	sort(all(v));
	for (auto i : v) cout << i << '\n';
}


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

using namespace std;
#define ll long long
#define ld long double
const int N=2e5+5;
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    int cnt[n+1];
    memset(cnt, 0, sizeof(cnt));
    for(int i=1,x;i<n;i++) {
        cin >> x;
        cnt[x]++;
    }
    for(int i=1;i<=n;i++) {
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, k, arr[nax];

int main(){
	IOS
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	n--, k--;
	cout << ceil((double)n/k) << '\n';
}


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

int main(){
  int n, x, a[202] = {0};
  int amin = 200, amax = -200, cost = 10000000;
  cin >> n;
  for ( int i = 0; i < n; i ++ ){
    cin >> x;
    a[x + 100]++;
    amin = min(amin, x);
    amax = max(amax, x);
  }
  
  int sum;
  for(int i = amin; i <= amax; i++){
    sum = 0;
    for( int j = amin; j <= amax; j++ ){
      sum += ( i - j ) * ( i - j ) * a[j + 100];
    }
    cost = min( cost, sum );
  }
  cout << cost << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	char o[100];
	char e[100];
	int i;
	cin>>o;
	cin>>e;
	int len1=strlen(o);
	int len2=strlen(e);
	if(len1==len2){
		for(i=0;i<len1;i++){
			cout<<o[i]<<e[i];
		}
		cout<<endl;
	}else{
		for(i=0;i<len2;i++){
			cout<<o[i]<<e[i];
		}
		cout<<o[len1-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){

  bool all_visited = true;
  for (int i=0; i<N; ++i){
    if (visited[i] == false) all_visited = false;
  }

  if (all_visited){
    return 1;
  }

  int ret = 0;

  for (int i=0; i<N; ++i){
    if (graph[v][i] == false) continue;
    if (visited[i]) continue;

    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }

  return ret;
}

int main(){

  int N, M;
  cin >> N >> M;
  for (int i=0; i<M; ++i){
    int x, y;
    cin >> x >> y;
    graph[x-1][y-1] = graph[y-1][x-1] = true;
  }

  bool visited[nmax];
  for (int i=0; i<N; ++i) visited[i] = false;

  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());

		switch(n % 10)
		{
			case 2:
			case 4:
			case 5:
			case 7:
			case 9:
				Console.WriteLine("hon");
				break;
			case 3:
				Console.WriteLine("bon");
				break;
			default:
				Console.WriteLine("pon");
				break;
		}

		return;
	}
}

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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a, b, c;
   int x;
   int count = 0;
   cin >> a >> b >> c >> x;
   for(int i = 0;i <= a;i++) {
      for(int j = 0;j <= b;j++) {
         for(int k = 0;k <= c;k++) {
            if(x==i*500+j*100+k*50) {
               count++;
            }
         }
      }
   }
   cout << count << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n, i, x = 0;
    scanf("%d", &n);
    for(i = 1; i <= n; i++)
    {
        x =i;
    if(x % 3 == 0)
    {
        printf(" %d", i);
        continue;
    }
    while (x)
    {
    if(x % 10 == 3)
    {
        printf(" %d", i);
        break;
    }
    x /= 10;
    }
   }
    
  printf("\n");
  return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int t;
  cin >> t;
  while(t){
    t--;
    int n,k;
    cin >> n >> k;
    int a[n],c[n-1];
    int i,j,b;
    cin >> a[0];
    b=a[0];
    int sum=0;
    for(i=1;i<n;i++){
      cin >> a[i];
      c[i-1]=a[i]-b;
      sum+=c[i-1];
      b=a[i];
    }
    sort(c,c+n-1);
    reverse(c,c+n-1);
    int ret=sum;
    for(i=0;i<min(k-1,n-1);i++){
      ret-=c[i];
    }
    cout << ret << endl;
  }
}



Measured memory_bytes: 3864
#include<stdio.h>
int main ()
{
    int A,B;
    scanf ("%d %d",&A,&B);
    if (A>=1&&A<=20&&B>=1&&B<=20)
    {
        if (A>=1&&A<=9&&B>=1&&B<=9)
        {
            printf ("%d\n",A*B);
        }
        else
        {
            printf ("-1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, M;
vector<ll> E[200000];

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) {
    ll A, B;
    cin >> A >> B;
    A--;
    B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  bool ans = false;
  REP(i, 0, E[0].size()) {
    REP(j, 0, E[E[0][i]].size()) if(E[E[0][i]][j] == N - 1) ans = true;
  }
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12776
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];//开字符数组就不用多说了吧 
int wi[8]={1,1,0,-1,-1,-1,0,1};
int wj[8]={0,-1,-1,-1,0,1,1,1},n=0,m=0;//wi和wj分别是不同的方向，同来方便统计雷数，否则很麻烦
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }//就是输入

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                cout<<'#';//如果是雷就直接输出，过
            }
            else//如果不是雷
            {
                int num=0;//统计雷数
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.')
                    {
                        continue;//还是一样
                    }
                    if(a[i+wi[m]][j+wj[m]]=='#')//如果是周围的雷
                    {
                        num++;//那么计数器就加1
                    }
                }
                cout<<num;//输出就好了
            }
        }
        cout<<endl;//每行输出后的换行
    }
    //因为在循环中多出一个换行，所以就不用多换行来满足AT了
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, 0)
print(*ans)

Measured memory_bytes: 230960
a=list(map(int,input().split()))
a=sorted(a)
maxim=a[-1]
for i in range(3):
    a[i]=a[-1]-a[i]

ans=a[1]+(a[0]-a[1])//2 if (a[0]-a[1])%2==0 else a[1]+(a[0]-a[1])//2+2
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int h, m, s;
    int in, out;
    while(cin >> h >> m >> s){
        in = h * 60 * 60 + m * 60 + s;
        cin >> h >> m >> s;
        out = h * 60 * 60 + m * 60 + s;
        in = out - in;
        cout << in / 60 / 60 << ' ' << in / 60 % 60 << ' ' << in % 60 << endl;
    }
}

Measured memory_bytes: 1160
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cost_list = [0] * (N+1)
for i in range(1, N+1):
    if A.count(i) == 1:
        cost_list[i] = cost_list[i-1] + 1
    else:
        cost_list[i] = cost_list[i-1]

print(min(cost_list[X], cost_list[-1] - cost_list[X]))

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i; i < N; i++) {
    cin >> vec[i];
  }
  int now = 0;
  for (int i; i < N; i++) {
    now = vec[now] - 1;
    if (now == 1) {
      cout << i + 1 << endl;
      exit(0);
    } 
  }
  cout << -1 << endl;
}

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

int main()
{
  int x,y,z;
  cin>>x>>y>>z;
  int tmp = x;
  x = y;
  y = tmp;
  
  tmp = x;
  x = z;
  z= tmp;
  
  cout<<x<<" "<<y<<" "<<z;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  string a;
  cin>>a;
  if(a[2]==a[3] && a[4]==a[5])cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
import java.text.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		//BufferedReader cin = new BufferedReader(new FileReader("in.txt"));
		BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<String> words = new ArrayList<String>();
		int maxlen =0;
		String max_count ="";
		String max_len ="";
		String line;
		while((line=cin.readLine())!=null&&line.length()!=0){
			String[] parts = line.split("[\\s]+");
			int l = parts.length;
			for(int i=0;i<l;i++){
				words.add(parts[i]);
				int wl = parts[i].length();
				if(wl>maxlen){
					max_len =parts[i];
					maxlen=wl;
				}
			}
		}
		
		Collections.sort(words);
		ArrayList<String> unique = new ArrayList<String>();
		ArrayList<Integer> count = new ArrayList<Integer>();
		int s = words.size();
		for(int i=0;i<s;i++){
			if(i==0||(words.get(i).equals(words.get(i-1)))==false){
				unique.add(words.get(i));
				count.add(1);
			}
			else{
				int size = count.size();
				int temp = count.get(size-1);
				count.set(size-1,temp+1);
			}
		}
		int ss=unique.size();
		int freq =0;
		for(int i=0;i<ss;i++){
			if(count.get(i)>freq){
				max_count = unique.get(i);
				freq = count.get(i);
			}
		}
		
		System.out.println(max_count+" "+max_len);
		cin.close();
	}
	
}

Measured memory_bytes: 16904
#include<bits/stdc++.h>
#define mod 1000000007
#define INF 10000000000000001
#define F first
//#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 100005
#define sz(x) (ll)x.size()
#define ins insert
#define mp make_pair
#define int  long long
typedef long long ll;
typedef long double ld;
using namespace std;



signed  main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll x;
	cin>>x;
	cout<<!x<<endl;
}

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

int main()
{
	int n;
	cin>>n;
	vector<pair<long long, long long> > a(n);
	for (int i=0; i<n; i++)
		cin>>a[i].first>>a[i].second;
	sort(a.begin(), a.end(),
		[](const pair<long long, long long> & x, const pair<long long, long long> & y) {
			return x.first+x.second>y.first+y.second;
	});
	long long score[2]={0};
	for (int i=0; i<a.size(); i++)
		if (i%2) score[1]+=a[i].second;
		else score[0]+=a[i].first;
	cout<<score[0]-score[1]<<endl;

	char I;
	cin >> I;
	return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector< vector< int > > ans(h, vector<int>(w));
  int cur = 0;
  for(int color=1; color<=n; ++color) {
    int x;
    cin >> x;
    while(x--) {
      int row = cur/w, col = row%2 ? w - cur%w - 1 : cur%w;
      ans[row][col] = color;
      ++cur;
    }
  }
  for(int i=0; i<h; ++i) {
    for(int j=0; j<w; ++j) {
      if(j>0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b){if(a>b) a=b;} //Compare two numbers and return smaller one in reference variety a
#define MAX_N 200000

int main()
{
    ll l,center;
    ll ans=0;
    int N;
    int i=0;
    cin>>N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A.begin(),A.end());
    center=A[N/2];
    for(int i=0;i<N;i++)
    {
        ans+=abs(A[i]-center);
    }

    cout<<ans<<endl;
}

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

using namespace std;

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

    vector<int> p(n), q(n), permutation(n);
    for(auto&& p_i : p) {
        cin >> p_i;
    }
    for(auto&& q_i : q) {
        cin >> q_i;
    }
    iota(permutation.begin(), permutation.end(), 1);

    int a = 0, b = 0, count = 1;
    while(a == 0 || b == 0) {
        if (p == permutation) {
            a = count;
        }
        if (q == permutation) {
            b = count;
        }
        next_permutation(permutation.begin(), permutation.end());

        count++;
    }

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
        int W, H, x, y, r;
        int Wchk, Hchk;

        scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
        Wchk = ((x < r)? 0 : 1) && (((W - r) < x)? 0 : 1);
        Hchk = ((y < r)? 0 : 1) && (((H - r) < y)? 0 : 1);
        if (Wchk && Hchk)
                printf("Yes\n");
        else
                printf("No\n");

        return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int c[6],cnt=0;
	for (int i = 0; i < 6; i++){
		cin >> c[i];
	}
	cnt = c[0] +( c[1] * 5) +( c[2] * 10) +( c[3] * 50) +( c[4] * 100) +( c[5] * 500);
	if (cnt >= 1000){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    // input
    int N;
    ll K; cin >> N >> K;
    vector<int> P(N);
    rep(i,N) {
        cin >> P[i];
        P[i]--;
    }
    vector<ll> C(N);
    rep(i,N) cin >> C[i];

    ll ans = -HINF;
    rep(i,N) {

        int now = i;
        ll tot = 0,sz = 0;
        vector<ll> route;
        while (1) {
            now = P[now];
            route.push_back(C[now]);
            tot += C[now];
            ++sz;
            if (now == i) break;
        }

        ll ret = 0;
        if (tot < 0) {
            rep(j,min(K,sz)) {
                ret += route[j];
                ans = max(ans,ret);
            }
        } else if (K <= sz){
            rep(j,K) {
                ret += route[j];
                ans = max(ans,ret);
            }
        } else {
            ret += (K/sz - 1) * tot;
            ans = max(ans,ret);
            rep(j,sz) {
                ret += route[j];
                ans = max(ans,ret);
            }
            rep(j,K%sz) {
                ret += route[j];
                ans = max(ans,ret);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  int res = 0, F[31] = {0};
  for(int i = 0; i < N; ++i) cin >> a[i];
  for(int i = 0; i < N; ++i) {
    res ^= a[i];
    int R = a[i] ^ (a[i] - 1);
    for(int j = 1; j < 31; ++j) {
      if(R == (1 << j) - 1) F[j-1]++;
    }
  }
  int cnt = 0;
  for(int i = 29; i >= 0; --i) {
    if(res >= (1 << i)) {
      if(F[i] == 0) {
        std::cout << -1 << std::endl;
        return 0;
      }
      res ^= (1 << (i+1)) - 1;
      cnt++;
    }
  }
  if(res == 0) {
    std::cout << cnt << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }
  return 0;
}


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

long long int T, A, B, C, D, E, F;

int main(){
    scanf("%lld", &T);
    for(int i = 0; i < T; ++i){
        scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        if(A < B){
            puts("No");
            continue;
        }
        if(B > D){
            puts("No");
            continue;
        }
        A %= B;
        if(A > C){
            puts("No");
            continue;
        }
        if(D % B == 0){
            puts("Yes");
            continue;
        }
        E = __gcd(D, B);
        F = (C - A + E) / E;
        if(A + F * E > C && A + F * E < B){
            puts("No");
            continue;
        }
        puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    string s;
    cin>>s;
    int ans=0;
    vector<int> l(s.size()+1,0),r(s.size()+1,0);
    rep(i,s.size()){
        if(s[i]=='<')
        l[i+1]=l[i]+1;
        else l[i+1]=0;
        if(s[s.size()-i-1]=='>')
        r[s.size()-i-1]=r[s.size()-i]+1;
        else r[s.size()-i-1]=0;
    }
    rep(i,s.size()+1)ans+=max(l[i],r[i]);
    cout<<ans<<endl;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b!=c) cout<<"Yes"<<endl;
  else if(b==c && c!=a) cout<<"Yes"<<endl;
  else if(c==a && a!=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

B = [A[i-1] + A[i] for i in range(1,N)]

if max(B) < L :
    print("Impossible")
else :
    print("Possible")

    ind = B.index(max(B))
    for i in range(ind) :
        print(i+1)
    for i in range(N-1,ind,-1) :
        print(i)


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

int main(){
  string s;
  int n;
  cin >> s;
  n = s.size();
  vector<int> a(n);
  rep(i, n) a.at(i) = s.at(i) - '0';
  
  int64_t ans = 0;
  for (int i = 0; i < (1<< n-1); i++){
    int64_t sum = a.at(0);
    for(int j = 0; j < n - 1; j++){
      if(i & (1<<j)){
        ans += sum;
        sum = a.at(j+1);
      } else {
        sum *= 10;
        sum += a.at(j+1);
      }
    }
    ans += sum;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int dice[6], q, top, front, right[24], tmp;
    for(int i=0; i<6; i++){
        scanf("%d", &dice[i]);
    }
    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%d %d", &top, &front);
        if(dice[2] == top || dice[3] == top){
            tmp = dice[1];
            dice[1] = dice[2];
            dice[2] = dice[4];
            dice[4] = dice[3];
            dice[3] = tmp;
        }
        while(top != dice[0]){
            tmp = dice[0];
            dice[0] = dice[1];
            dice[1] = dice[5];
            dice[5] = dice[4];
            dice[4] = tmp;
        }
        while(front != dice[1]){
            tmp = dice[1];
            dice[1] = dice[2];
            dice[2] = dice[4];
            dice[4] = dice[3];
            dice[3] = tmp;
        }
        printf("%d\n", dice[2]);
    }
    return 0;
}



Measured memory_bytes: 2040
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		boolean isTwo = false;
		int tmp=0;
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] array = new int[N];
		boolean[] flags = new boolean[N];
		for(int i=0; i<array.length; i++){
			tmp = in.nextInt();
			if(tmp == 2){
				isTwo = true;
			}
			array[i] = tmp;
		}
		if(isTwo == false){
			System.out.print("-1");
			System.exit(0);
		}
		int count = 0;
		count++;
		int now = 1;
		while(array[now-1] != 2){
			if(flags[now-1] == true){
				System.out.print("-1");
				System.exit(0);
			}
			flags[now-1] = true;
			now = array[now -1];
			count++;
		}
		System.out.print(count);
	}
}


Measured memory_bytes: 50376
//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

LL c(LL n) {
	return n * (n - 1) / 2;
}

int main() {
	int n; cin >> n;
	vector<int> a(n);

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

	map<LL, LL> m;
	for (int i = 0; i < n; i++) {
		m[a[i]]++;
	}

	LL ans = 0;
	for (auto x : m) {
		ans += c(x.second);
	}

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

Measured memory_bytes: 10240
#include <stdio.h>

int main(void)
{
	char a[101];
	char b[101];
	char c[101];
	char s = 'a';
	char ans = '\0';
	
	int i = 0;
	int j = 0;
	int k = 0;
		
	scanf("%s",a); scanf("%s",b); scanf("%s",c);
	
	do
	{
		if (s == 'a')
		{
			switch (a[i])
			{
				case 'a' : s = 'a'; i++; break;
				case 'b' : s = 'b'; i++; break;
				case 'c' : s = 'c'; i++;break;
				case '\0': s = '\0'; ans = 'A'; break;
			}
		}
		else if (s == 'b')
		{
			switch (b[j])
			{
				case 'a' : s = 'a'; j++; break;
				case 'b' : s = 'b'; j++; break;
				case 'c' : s = 'c'; j++; break;
				case '\0': s = '\0'; ans = 'B'; break;
			} 
		}
		 else if (s == 'c')
		{
			switch (c[k])
			{
				case 'a' : s = 'a'; k++; break;
				case 'b' : s = 'b'; k++; break;
				case 'c' : s = 'c'; k++; break;
				case '\0': s = '\0'; ans = 'C'; break;
			}
		}
			
	} while (s != '\0');
		
	printf("%c",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,k,a[200010],go[200010],ans;
set<int> ss;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1])
			go[i]=go[i-1]+1;
		else
			go[i]=0;
		if(go[i]>=k-1)
			ans=1;
	}
	for(int i=0;i<k;i++)
		ss.insert(a[i]);
	if(go[k-1]!=k-1)
		ans++;
	for(int i=k;i<n;i++){
		ss.insert(a[i]);
		if((*ss.begin()!=a[i-k]||*ss.rbegin()!=a[i])&&go[i]<k-1)
				ans++;
		ss.erase(a[i-k]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 11136
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    a[n+1]=-1;
    int sum=0;
    for(int i=1;i<=n;)
    {
        if(a[i]==a[i+1]) i=i+2;
        else
        {
            sum++;
            i=i+1;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 640
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  map<ll,ll> mp;
  rep(i,n){
    ll a;
    cin>>a;
    mp[a]++;
  }
  map<ll,ll> mp1;
  for(auto c:mp){
    if(c.second%2==0){
      mp1[c.first]++;
      mp1[c.first]++;
    }else{
      mp1[c.first]++;
    }
  }
  ll tmp=0;
  for(auto c:mp1){
    if(c.second==2){
      tmp++;
      c.second=0;
    }
  }
  ans+=(tmp/2)*2;
  for(auto c:mp1){
    if(c.second==1) ans++;
  }
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << max(0, (a - (b * 2))) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        if(s[s.Length-1] == 's')
        {
            s = s + 'e';
        }
        s += 's';
        Console.WriteLine(s);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25904
N = int(input())
X = [int(i) for i in input().split()]

INF = 10**9
m = INF
for x in range(1,max(X)+1):
    temp = 0
    for i in range(N):
        temp += (x - X[i])**2
    if m > temp:
        m = temp
print(m)

Measured memory_bytes: 38640
n, m = map(int, input().split())
a = [0]*n

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

b = [0]*m

for j in range(m):
    b[j] = int(input())

c = [0]*n

for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in range(n):
    print(c[i])


Measured memory_bytes: 6012
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x: x[1])
now = 0
for i in range(n):
    now += l[i][0]
    if(now > l[i][1]):
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 53728
import sys,math,copy,queue,itertools,bisect,collections,heapq
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**9+1

N = NI()
a = LI()

root = [[] for _ in range(N)]
for _ in range(N-1):
    u,v = LI()
    root[u-1].append(v-1)
    root[v-1].append(u-1)

lis = [INF for _ in range(N)]
q = []

q.append((0,0,0))
ans = [-1 for _ in range(N)]
while q:
    c,p,v = q.pop()
    if c == 0:
        x = bisect.bisect_left(lis,a[p])
        y = lis[x]
        if y == INF: v +=1
        if y > a[p]: lis[x] = a[p]
        ans[p] = v
        q.append((1,x,y))
        for d in root[p]:
            if ans[d] < 0: q.append((0,d,v))
    else:
        lis[p] = v
print(*ans,sep='\n')

Measured memory_bytes: 151268
#include<cstdio>
#include<algorithm>
using namespace std;
long long po[15];
int Query(long long a) {
	printf("? %lld\n", a);
	fflush(stdout);
	char p[3];
	scanf("%s", p);
	if (p[0] == 'Y')return 1;
	return 0;
}
int ck1[15], ck2[15];
void Answer(long long a) {
	printf("! %lld\n", a);
	fflush(stdout);
}
void Do() {
	int i;
	po[0] = 1;
	for (i = 1; i < 15; i++)po[i] = po[i - 1] * 10;
	int n1 = -1, n2 = -1;
	for (i = 0; i < 10; i++) {
		ck1[i] = Query(po[i]);
		if (!ck1[i] && n1 == -1)n1 = i;
	}
	if (n1 == -1) {
		for (i = 1; i <= 10; i++) {
			ck2[i] = Query(po[i] - 1);
			if (!ck2[i])n2 = i;
		}
		if (n2 == -1) {
			Answer(1);
			return;
		}
		Answer(po[n2]);
		return;
	}
	long long b = po[n1], e = po[n1+1] - 1, r = 0, mid;
	while (b <= e) {
		mid = (b + e) >> 1;
		if (Query(mid))r = mid, e = mid - 1;
		else b = mid + 1;
	}
	Answer(r/10);
}
int main() {
	Do();
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        

        static void Main(string[] args)
        {

            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = data[0];
            int X = data[1];

            int min = X;
            int sum = 0;
            for (int i = 0; i < N; i++)
            {
                int a = int.Parse(Console.ReadLine());
                if (min > a) min = a;
                sum += a;
            }

            Console.WriteLine(N + (X - sum) / min);


        }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main()
{
	int A, B, C;
	
	cin >> A >> B >> C;
	
	if ( (A < C && C < B) || (B < C && C < A) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
num = [i for i in range(1, N+1)]
count = [0] * N

for i in range(len(num)):
    while num[i] % 2 == 0:
        count[i] += 1
        num[i] //= 2
ans = 0
cnt = 0
for i, j in enumerate(count):
    if j > cnt:
        cnt = j
        ans = i+1

print(ans if N != 1 else 1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100002;
const int oo = INT_MAX;
string s,t;

int main(){
    cin>>s>>t;
    int ans=oo,cnt=0;
    for(int i=0;i<=s.size()-t.size();i++){
        cnt=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j])
                cnt++;
        }
        ans=min(ans,cnt);
        
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 3160
#include<iostream>
#include <cassert>

using namespace std;

typedef long long ll;

int ask(int i){
    printf("%d\n", i); fflush(stdout);
    char buf[100];
    scanf("%s", buf); fflush(stdout);
    if (buf[0] == 'V') return 0;
    else if (buf[0] == 'M') return 1;
    else if (buf[0] == 'F') return 2;
}

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

    int l = 0;
    int la = ask(l);
    int r = N;
    int ra = la;

    while(r > l){
        int c;
        if ((r - l + 1) % 2 == 0){
            assert (la == ra);
            c = (r + l - 1) / 2;
        } else {
            assert (la != ra);
            c = (r + l) / 2;
        }

        int ca = ask(c);
        if (ca == 0){
            return 0;
        }

        if ((ca == la && (c - l + 1) % 2 == 0) || (ca != la && (c - l + 1) % 2 == 1)){
            r = c;
            ra = ca;
        } else {
            l = c;
            la = ca;
        }
    }
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    cin>>x>>y;
    if(y%2)
        return cout<<"No",0;
    int b=(y-2*x)/2,a=x-b;
    if(a>=0&&b>=0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <unordered_map>
#include <string>
int main() {
    std::unordered_map<char, int> count_dic;
    for (char c = 'a'; c <= 'z'; c++) {
        count_dic[c];
    }
    std::string s;
    while (std::getline(std::cin, s)) {
        for (char c: s) {
            c = char(tolower(c));
            if ('a' <= c && c <= 'z') {
                count_dic[c] += 1;
            }
        }

    }
    for (char c = 'a' ; c <= 'z'; c++) {
        std::cout << c << " : " << count_dic[c] << std::endl;
    }
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 5e3 + 10;
typedef long long LL;
LL data[MAXN];
LL sum[MAXN];
int n , k;
bitset<MAXN> dp;
bool Check(int x)
{
	if(data[x] >= k)
		return 1;
	dp.reset();
	dp[0] = 1;
	for(int i = 0 ; i < n ; ++i)
	{
		if(x == i)
			continue;
		dp |= (dp << data[i]);
	}
	for(int i = k - 1 ; i >= k - data[x] ; --i)
	{
		if(dp[i])
			return 1;
	}
	return 0;

}
int Solve()
{
	sort(data , data + n);
	int l = 0 , r = n - 1 , mx = -1;
	while(l <= r)
	{
		int mid = l + r >> 1;
		if(Check(mid))
			r = mid - 1;
		else
		{
			l = mid + 1;
			mx = max(mx , mid);
		}
	}
	return mx + 1;
}
int main()
{
	scanf("%d%d" , &n , &k);
	for(int i = 0 ; i < n ; ++i)
	{
		scanf("%lld" , &data[i]);
	}
	printf("%d\n" , Solve());
}


Measured memory_bytes: 256
//#include<cstdio>
#include<iostream>
//#include<string>
using namespace std;
int main(){
  string s; int n;
  cin >> s >> n;
  //scanf("%d", &n);
  int x=0;
  for(int i = 0; i < s.length(); i+= n){
    cout << s[i];
    //x+=n;
  }
  cout << endl;
  //puts("");
}


Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int, input().split()))

count = Counter(A)
vals = count.values()
sum_ = 0
for v in vals:
  if v >= 2: sum_ += v*(v-1)
sum_ //= 2

for k in range(N):
  if count[A[k]] < 2: print(sum_)
  else:print(sum_ + 1 - count[A[k]])

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

int main() {
	int n;cin>>n;
  
  	vector<int> vecP(n);
  	vector<int> vecQ(n);
  
  for(int i=0;i<n;i++){
  	cin>>vecP.at(i);
  }
  for(int i=0;i<n;i++){
  	cin>>vecQ.at(i);
  }
  
    vector<int> vecN(n);
  for(int i=0;i<n;i++){
  	vecN.at(i) = i+1;
  }
  
  map<vector<int>,int> mp;
  do{
  	mp[vecN] = mp.size();
  } while(next_permutation(vecN.begin(),vecN.end()));
  
  int ans = abs(mp[vecP]-mp[vecQ]);
  cout<<ans<<endl;
  
  return 0;
  
}

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

bool solve() {
  int N; cin >> N;
  rep(i, 0, N) rep(j, 0, N) {
    if(4 * i + 7 * j == N) return true;
  }
  return false;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


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


Measured memory_bytes: 3092