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

typedef long long LL;

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;

	int p = s.size();
	int ans = 0;
	for(int i = 0; i < p/2; i++){
        if(s[i] != s[p-1-i]){
            ans++;
        }
	}
	cout << ans << "\n";
	return 0;
}


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

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n >= k)
    {
        cout << x * k + y * (n - k) << endl;
    }
    else
    {
        cout << x * n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn=2e5+7;
int n,m,ans,a[maxn];

char cc;ll ff;
template<typename T>void read(T& aa) {
	aa=0;cc=getchar();ff=1;
	while((cc<'0'||cc>'9')&&cc!='-') cc=getchar();
	if(cc=='-') ff=-1,cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	aa*=ff;
}

int fir[maxn],nxt[maxn],to[maxn],e=0;
void add(int x,int y) {
	to[++e]=y;nxt[e]=fir[x];fir[x]=e;
}

int dep[maxn],rd[maxn];
void dfs(int pos,int d,int f) {
	dep[pos]=rd[pos]=d; int y,z;
	for(y=fir[pos];y;y=nxt[y]) {
		dfs(z=to[y],d+1,pos);
		rd[pos]=max(rd[pos],rd[z]);
	}
	if(f>1&&rd[pos]-dep[pos]+1==m) {
		rd[pos]=0;
		++ans;
	}
}

int main() {
	read(n); read(m);
	For(i,1,n) read(a[i]);
	if(a[1]!=1) ++ans,a[1]=1;
	For(i,2,n) add(a[i],i);
	dfs(1,0,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 9984
#include<stdio.h>
int main(){
	int a,b,c,k,count=0;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	while(a>=b){
		b=b*2;
		count++;
	}
	while(b>=c){
		c=c*2;
		count++;
	}
	if(count>k)
	printf("No");
	else
	printf("Yes");
}

Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> A(N);

	for (int i = 0;i < N;i++)
		cin >> A.at(i);

	sort(A.begin(), A.end());

	cout << A.at(N - 1) - A.at(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
#define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";
 
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(s);
}

void solve() {
  bool ok = true;
  if (s[2] != s[3])  ok = false;
  if (s[4] != s[5])  ok = false;
  PRINT(ok?"Yes":"No");
}

int main(void){
  input();
  solve();
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  int sum = 0, ma = 0;
  rep(i, n) {
    int l; std::cin >> l;
    sum += l;
    chmax(ma, l);
  }
  std::cout << (sum-ma > ma ? "Yes" : "No") << "\n";
}


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

int main()
{
    int x;
    int i = 1;

    while( cin >> x )
    {
        if( x != 0 )
        {
            cout << "Case " << i << ": " << x << endl;
            i++;
        }
        else
            break;
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = String.valueOf(n);
		char[] c = new char[4];
		c[0] = s.charAt(0);
		c[1] = s.charAt(1);
		c[2] = s.charAt(2);
		c[3] = s.charAt(3);
		if (c[0] == c[1] && c[1] == c[2] || c[1] == c[2] && c[2] == c[3]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,k;
  	scanf("%d %d %d %d %d",&a,&b,&c,&d,&k);
  	int aa=a*60+b,cc=c*60+d;
  	printf("%d\n",cc-aa-k);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }

    vector<bool> used(n);
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        int num = 0, index;
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (used.at(j)) continue;

            cnt++;
            if (b.at(j) == cnt) {
                num = b.at(j);
                index = j;
            }
        }

        if (num == 0) {
            cout << -1 << endl;
            return 0;
        }

        ans.at(n - i - 1) = num;
        used.at(index) = true;
    }

    for (int i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())
 
n,m=IA()
def f1(n):
    res=1
    for i in range(1,n+1):
        res*=i
    return res
def f(n):
    if n<2:return 0
    return f1(n)//(f1(n-2)*f1(2))

print(f(n)+f(m))


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, k;
  scanf("%d %d", &n, &k);

  map<int, int> mp;
  REP(i,n){
    int t;
    scanf("%d", &t);
    mp[t]++;
  }

  vector<int> v;
  REPI(itr,mp){
    v.pb(itr->second);
  }

  SORTV(v);

  int ans = 0;
  
  REP(i,mp.size() - k){
    if(mp.size() - i <= k){
      break;
    }
    ans += v[i];
  }

  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;
  	string s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ans;
 	cin>>n>>s;
  	for(int i=0;i<s.size();i++){
    	for(int j=0;j<26;j++){
      		if(s[i]==a[j]){
        		char x=a[(j+n)%26];
        		ans+=x;
      		}
    	}
  	}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a, b; cin>>a>>b;
	if(b%a==0) cout<<a+b<<endl;
	else cout<<b-a<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    int n = s.size();
    int ans = count(s.begin(), s.end(), 'o');
    cout << (ans + 15 - n >= 8 ? "YES" : "NO");

}



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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

/* define class and method names */
#define TCC ParenthesisRemoval
#define TCM countWays


using namespace std;


typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;




/* testing process */
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(C>=A && C<=B) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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

int N;

void dfs(int pos,int use,string s){
    if(pos == N){
        cout << s << endl;
        return;
    }
    for (int i = 0;i < use;i++){
        dfs(pos+1,use,s+char('a'+i));
    }
    dfs(pos+1,use+1,s+char('a'+use));
    return;
}

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

    cin >> N;

    dfs(0,0,"");

    return 0;

}

Measured memory_bytes: 1536
A, B, K = map(int, input().split())
arr = range(A, B + 1)
ans = []
for i in range(K):
    ans.append(A + i)
for j in range(K):
    ans.append(B + 1 - K + j)

anset = list(set(ans))
anset.sort()
if A+K<=B+1:
    for ele in range(len(anset)):
        print(anset[ele])
else:
    for ele in range(A,B+1):
        print(ele)


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

using namespace std;
typedef long long ll;

const int N = 4e6;
int x[2][N], lz[2][N];
ll n, q, t;

void build(int v, int l, int r) {
    lz[0][v] = lz[1][v] = n;
    x[0][v] = x[1][v] = n;
    if (l == r) {
        return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m);
    build(2 * v + 1, m + 1, r);
}
void push(int t, int v) {
  	for (int i = 0; i < 2; i++) {
        x[i][v] = min(x[i][v], lz[i][v]);
        lz[i][2 * v] = min(lz[i][2 * v], x[i][v]);
        lz[i][2 * v + 1] = min(lz[i][2 * v + 1], x[i][v]);      	
    }
}
int find_min(int v, int l, int r, int b) {
    push(t, v);
    if (l == r && r == b) {
        return x[t][v];
    }
    int m = (l + r) / 2;
    if (b <= m) {
        return find_min(2 * v, l, m, b);
    }
    return find_min(2 * v + 1, m + 1, r, b);
}
void upd(int v, int l, int r, int L, int R, int z) {
    if (L <= l && r <= R) {
        lz[t][v] = min(lz[t][v], z);
      	push(t, v);
        return;
    }
    if (r < L || R < l) {
        return;
    }
    push(t, v);
    int m = (l + r) / 2;
    upd(2 * v, l, m, L, R, z);
    upd(2 * v + 1, m + 1, r, L, R, z);
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    build(1, 1, n);
    ll r = (n - 2) * (n - 2);
    while (q--) {
        int a; cin >> t >> a; t--;
        int b = find_min(1, 1, n, a);
        r -= max(0, b - 2); t = 1 - t;
        upd(1, 1, n, 1, b - 1, a);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 15972
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque, Counter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

fac = [-1] * (10**2+1)

fac[0] = fac[1] = 1

def initNCM(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i

def NCM(n, r):
    return fac[n] / (fac[r] * fac[n-r])

initNCM(100)

def main():
    N, A, B = LI()
    v = sorted(LI())[::-1]
    cnt = Counter(v)
    selected = v[:A]
    print(sum(selected)/A)
    ans = 1
    used = 0
    for x in list(set(selected)):
        used += cnt[x]
    used -= cnt[selected[-1]]
    ans = 0
    if len(list(set(selected))) > 1:
        use_last = A - used
        ans += NCM(cnt[selected[-1]], use_last)
    else:
        for use_last in range(1, N+1):
            if not A <= used + use_last <= B:
                continue
            if use_last > cnt[selected[-1]]:
                continue
            ans += NCM(cnt[selected[-1]], use_last)
    print(int(ans))

main()



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

int mid(int x, int y, int z) {
    int a[] = { x, y, z };
    sort(a, a + 3);
    return a[1];
}

template<class T> ostream &operator <<(ostream &os, const vector<T> &v) {
    for (T x : v) os << x << " ";
    return os;
}

vector<int> gen(int n) {
    vector<int> a(n * 2 - 1);
    for (int i = 0; i < n * 2 - 1; i++) a[i] = i + 1;

    random_shuffle(a.begin(), a.end());
    return a;
}

void dodo(vector<int> a, int n) {
    cout << "*" << a << endl;
    cout << mid(a[n - 2], a[n - 1], a[n]) << endl;
    for (int i = 0; i < n - 1; i++) {
        vector<int> b(n * 2 - 1 - 2 * i - 2);
        for (int j = 0; j < b.size(); j++) {
            b[j] = mid(a[j], a[j + 1], a[j + 2]);
        }
        cout << b << endl;
        a = b;
    }
}

void solve() {
    for (int i = 0; i < 10; i++) {
        dodo(gen(10), 10);
    }
}

int main() {
    srand(time(NULL));
    int n, x;
    cin >> n >> x;

    if (x == 1 || x == n * 2 - 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        vector<int> b(n * 2 - 1);
        for (int i = 0; i < n * 2 - 1; i++) {
            b[i] = i + 1;
        }
        swap(b[n - 1], b[x - 1]);
        swap(b[n - 2], b[0]);
        swap(b[n], b[2 * n - 2]);
        for (int i = 0; i < n * 2 - 1; i++) {
            cout << b[i] << endl;
        }
        // dodo(b, n);
    }
}

Measured memory_bytes: 2304
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop();
 int top, S[1000];

int main(){
  int x,y;
  char s[100];
  
  top = 0;

  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      
      x = pop();
      
      y = pop();
      
      push(x+y);
      
    } else if ( s[0] == '-' ){
      y = pop();
      
      x = pop();
      
      push(x-y);
      
    } else if ( s[0] == '*' ){
      x = pop();

      y = pop();

      push(x*y);      

    } else {
      push(atoi(s));
    }
    
  }

  printf("%d\n",pop());
  
  return 0;
}

void push(int a){
  S[++top]=a;
}

int pop(){
  top--;

  return S[top+1];
}



Measured memory_bytes: 2108
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    max_ = heapq.heappop(A)
    max_ = -max_//2
    heapq.heappush(A, -max_)
print(-sum(A))

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

int main()
{
    int h,w,n;
    scanf("%d",&h);
    scanf("%d",&w);
    scanf("%d",&n);
    int ma,mi;
    if (h > w)
    {
        ma = h;
        mi = w;
    }
    else
    {
       ma = w;
       mi = h;
    }
    int cou=0;
    int va = 0;
    for (int i = 0; i < mi; i++)
    {
        cou += 1;
        va += ma;
        if (va >= n)
        {

            break;
        }
    }
    printf("%d",cou);
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

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

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 6e3 + 5;


ll n, m, query;

int a[N];
int ans = 0;
bool check(int n){
    while(n){
        if(a[n % 10]) return false;
        n /= 10;
    }
    return true;
}
void Solve(){
    int n;
    cin >> n >> m;
    for(int i = 1, x; i <= m; i++){
        cin >> x;
        a[x] = 1;
    }
    while(!check(n)) n++;
    cout << n;
}

int main(){
//    Speed;
    int query = 1;
//    cin >> query;
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout)
    while(query--){
        Solve();
    }
}






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

int main()
{
  long long n;

  cin >> n;

  vector<long long> a(n);

  long long sum = 0;

  long long MOD = 1000000007;
  long long ans = 0;

  rep(i, n)
  {
    cin >> a.at(i);
    ans += a.at(i);
    ans %= MOD;
  }
  // cout << ans << endl;

  for (int i = 0; i < n-1; i++)
  {
    ans -= a.at(i);
    if (ans < 0)
      ans += MOD;
    sum += (a.at(i) * ans);
    sum %= MOD;
  }

  cout << sum;
}


Measured memory_bytes: 4808
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
//        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int b = 0;
        for(int i=0;i<a;i++){
            int temp = (i*(i+1))/2;
            if(temp == a){
                b = i;
            }
        }
        if(a==1){
            WriteLine("Yes");
            WriteLine("2");
            WriteLine("1 1");
            WriteLine("1 1");
        }else if(b==0){
            WriteLine("No");
        }else{
            WriteLine("Yes");
            WriteLine(b+1);
            int[,] map = new int[b+1,b];
/*            for(int i=0;i<b+1;i++){
                for(int j=0;j<b;j++){
                    map[i,j] = 1;
                }
            }*/
            int kazu = 1;
            for(int i=0;i<b;i++){
                for(int j=i;j<b;j++){
                        map[i,j] = kazu;
                        map[j+1,i] = kazu;
                        kazu++;
//                        WriteLine("{0} {1} {2}",i,j,map[i,j]);
//                        WriteLine("{0} {1} {2}",j+1,i,map[j+1,i]);
                }
            }
            for(int i=0;i<b+1;i++){
                Write(b+" ");
                for(int j=0;j<b;j++){
                    if(j == b-1){
                        Write(map[i,j]);
                    }else{
                        Write(map[i,j]+" ");
                    }
                }
                WriteLine();
            }
        }
    }
}

Measured memory_bytes: 15836
$line = <STDIN>;chomp $line;
($N, $K)=split " ",$line;
$line = <STDIN>;chomp $line;
@A=split " ",$line;

for($i=0;$i<=$#A;$i++){
	$N{$A[$i]}+=1;
}
@SN = sort{ $N{$b}<=>$N{$a} } keys %N;

$s=0;
for($i=$K;$i<=$#SN;$i++){
	$s+=$N{$SN[$i]};
}
print $s,"\n";


Measured memory_bytes: 61000
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map { it.toInt() }
    a = a.sorted()
    val minn = a[1]
    var cnt: Int
    if (n == 2) {
        println(a.max()!!)
        return
    }
    for (i in minn downTo 1) {
        cnt = 0
        for (j in 0 until n) {
            if (a[j] % i != 0) {
                cnt++
                if (cnt >= 2) break
            }
        }
        if (cnt <= 1) {
            println(i)
            return
        }
    }
    println(1)
}


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

int main() {
    int n,k,i;
    i = 1;
    cin >> n >> k;
    for (int j = 0;j < n;j++) {
        if (i >= k) {
            i += k;
        }
        else {
            i *= 2;
        }
    }
    cout << i <<endl;
}


Measured memory_bytes: 256
// diverta 2019 Programming Contest 2
// https://atcoder.jp/contests/diverta2019-2
import * as fs from "fs";

const stdin = fs.readFileSync("/dev/stdin", "utf8");
const split = stdin.split("\n");
Main(split);

function Main(inputLines: string[]) {
  const tmp = inputLines[0].split(" ");
  const N = Number(tmp[0]);
  const K = Number(tmp[1]);

  if (K === 1) {
    return console.log(`0`);
  }
  // 1人1個ずづ
  const sub = N - K;
  console.log(`${sub}`);
}


Measured memory_bytes: 9420
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

ansp=1
ansq=1
f=1
for i in range(1,n):
    t=0
    f*=i
    for j in range(1,i+1):
        if p[-i-1]>p[-j]:
            t+=1
    ansp+=t*f
f=1
for i in range(1,n):
    t=0
    f*=i
    for j in range(1,i+1):
        if q[-i-1]>q[-j]:
            t+=1
    ansq+=t*f

print(abs(ansp-ansq))

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

using namespace std;
int main(){
	int arr[5];
	int i;

	for(i = 0; i < 5; i++){
		cin >> arr[i];
		if(arr[i] == 0){
			cout << i + 1;
		}
	}
}


Measured memory_bytes: 3520
from collections import Counter

N = int(input())
cs = []
for _ in range(N):
    s = input()
    c = Counter(s)
    cs.append(c)
#     print(c)

ans = ""    
for alpha in list("abcdefghijklmnopqrstuvwxyz"):
    min_cnt = 50
    for c in cs:
        min_cnt = min(min_cnt, c[alpha])
    ans += alpha*min_cnt
print(ans)


Measured memory_bytes: 3316
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

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

    lint ans = 0, prev = -T;
    for (int i = 0; i < N; ++i) {
        lint t;
        cin >> t;
        ans += min(t - prev, T);
        prev = t;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long i,a,b;
    string s;
    cin>>a>>b;
    cin>>s;
    if(s[a]!='-'){
    cout<<"No"<<endl;
    return 0;
    }
    s[a]='1';
    for(i=0;i<=a+b;i++){
    if(s[i]<'0' || s[i]>'9'){
    cout<<"No"<<endl;
    return 0;
    }}
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int a1;
    int a2;
    if( b > a) a1 = b-a;
    else if(a==b) a1 = d;
    else a1 = a-b;

    if(c > b) a2 = c - b;
    else if(b==c) a2 = d;
    else a2 = b-c;

    int c1;
    if(c > a) c1 = c-a;
    else if(a==c) c1 = c1 = d;
    else c1 = a-c;

    if(a1 <= d && a2 <= d) cout << "Yes" << endl;
    else if (c1 <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3552
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (int)
N = int(input().rstrip())

# 1 ✕ N
A = list(map(int, input().rstrip().split()))

print(sum(A) - N)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = 2197152, MOD = (int)1e9 + 7;

int n;

vector<int> a[30];

ll dp[30][N];
bool was[30][N];

ll calc(int x,int mask){
	if(x > n)return 1;
	if(was[x][mask])return dp[x][mask];
	was[x][mask] = 1;
	for(int i=0;i<sz(a[x]);i++){
		int to=a[x][i];
		if(!(mask&(1 << (to - 1)))){
			dp[x][mask] += (calc(x+1,mask^(1 << (to - 1))) % MOD);
			dp[x][mask] %= MOD;
		}
	}
	return dp[x][mask];
}

int main(){
		
	NFS
	
	cin >> n;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			int x;
			cin >> x;
			if(x == 1)a[i].pb(j);
		}
	}
	
	cout << calc(1,0) << endl;

	ioi
}

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

int main() {
    int n,x,y;
    cin >> n>>x>>y;
    vector<int> kyori(n+1,0);
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int a=min(j-i,abs(y-j)+abs(x-i)+1);
            kyori[a]++;
        }
    }
    rep(i,n-1){
        cout << kyori[i+1] << endl;
    }
}

Measured memory_bytes: 256
#!/usr/local/gnu/bin/bash

function bubble_sort(){
    local arr=($@)
    local i j
    local tmp
    for i in `seq 0 $((${#arr[@]}-1))`
    do
        for j in `seq 1 $((${#arr[@]}-i+1))`
        do
            if((arr[j]<arr[j-1]))
            then
                tmp=${arr[j]}
                arr[$j]=${arr[j-1]}
                arr[$j-1]=$tmp
            fi
        done
    done
    echo ${arr[@]}
}

function sum(){
    local result=0
    local i
    for i in $@
    do
        result=$((result+i))
    done
    echo $result
}


read n k
read -a arr
arr=(`bubble_sort ${arr[@]}`)
sum ${arr[@]:n-k}

Measured memory_bytes: 868
k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a = sorted(a)
miner = a[-1] - a[0]
for i in range(1, n):
    miner = min(miner, abs(a[- 1  + i] + k - a[i]))

print(miner)

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

#define MOD 10000

int n, m;
int dp[102][3][3];
int t[102];

void init(){
  memset(dp, 0, sizeof(dp));

  if(t[0] != -1){
    if(t[1] != -1){
      dp[2][t[1]][t[0]]++;
    }
    else{
      for(int i = 0; i < 3; i++){
        dp[2][i][t[0]]++;
      }
    }
  }
  else{
    if(t[1] != -1){
      for(int i = 0; i < 3; i++){
        dp[2][t[1]][i]++;
      }
    }
    else{
      for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
          dp[2][i][j]++;
        }
      }
    }
  }
}

int main(){
  while(cin >> n >> m){
    memset(t, -1, sizeof(t));

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      a--; b--;
      t[a] = b;
    }

    init();

    for(int i = 2; i < n; i++){
      for(int j = 0; j < 3; j++){
        for(int k = 0; k < 3; k++){
          if(t[i] != -1){
            if(j != k || t[i] != j){
              dp[i + 1][t[i]][j] += dp[i][j][k];
              dp[i + 1][t[i]][j] %= MOD;
            }
          }
          else{
            for(int l = 0; l < 3; l++){
              if(j != k || l != j){
                dp[i + 1][l][j] += dp[i][j][k];
                dp[i + 1][l][j] %= MOD;
              }
            }
          }
        }
      }
    }

    int ans = 0;

    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        ans += dp[n][j][k];
        ans %= MOD;
      }
    }

    cout << ans << endl;
  }
}

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

int main() {
    char s[200001] = { 0 };
    int len = 0;
    int aflag = 0;
    int acnt = 0, zcnt = 0;

    scanf("%s", s);
    len = strlen(s);
    for (int i = 0; i < len; i++) {
        if (s[i] == 'A' && aflag == 0) {
            acnt = i;
            aflag = 1;
        }
        if (s[i] == 'Z') {
            zcnt = i;
        }
    }
    printf("%d\n", zcnt - acnt + 1);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  set<char> s = {'a', 'e', 'i', 'o', 'u'};
  char c;
  cin >> c;
  cout << (s.find(c) == s.end() ? "consonant" : "vowel") << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, q = map(int, input().split())
INF = 10 ** 15
s = [-INF] + [int(input()) for _ in range(a)] + [INF] # sorted
t = [-INF] + [int(input()) for _ in range(b)] + [INF] # sorted

from bisect import bisect_left, bisect_right

for _ in range(q):
    x = int(input())
    i = bisect_left(s, x)
    j = bisect_left(t, x)
    d = INF
    for sx in [s[i - 1], s[i]]:
        for tx in [t[j - 1], t[j]]:
            d1 = abs(sx - x) + abs(sx - tx)
            d2 = abs(tx - x) + abs(sx - tx)
            d = min(d, d1, d2)
    print(d)

Measured memory_bytes: 77032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int k;
  cin >> k;
  queue<ll> q;
  rep(i, 9) {
    q.push(i + 1);
  }
  ll cur;
  
  rep(i, k) {
    cur = q.front(); q.pop();

    ll base = cur % 10;
    cur *= 10;
    for(int i = -1; i < 2; ++i) {
      int end = base + i;
      if(end < 0 || end > 9) continue;
      q.push(cur + end);
    }
  }
  cout << cur / 10 << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}


int main() {
  set<string> said;
  lli n; cin >> n;
  string prev; cin >> prev;
  said.insert(prev);
  const char* res = "Yes";
  for (int i=1; i<n; ++i) {
    string s; cin >> s;
    if (prev.back() != s.front() || said.count(s) != 0) {
      res = "No";
    }
    said.insert(s);
    prev = move(s);
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a=s.size();
  int n=stoi(s);
  int b;
  for(int i=0;i<a;i++){
    b += s[i]-'0';
  }
  if(n%b==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#ifdef LOCAL
    #define LLD_SPEC "%lld"
#else
    #define LLD_SPEC "%I64d"
#endif

int main() {
    int n;
    scanf("%d", &n);

    vector<bool> likes(10, true);
    {
        int k;
        scanf("%d", &k);
        for (int i = 0; i < k; ++i) {
            int x;
            scanf("%d", &x);
            likes[x] = false;
        }
    }

    for (int i = n; ; ++i) {
        bool ok = true;
        int x = i;
        while (x > 0) {
            int d = x % 10;
            x /= 10;

            if (!likes[d]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

if x <= 6:
  print(1)
elif x <= 11:
  print(2)
elif not x % 11 == 0:
  if x % 11 > 6:
    print(x // 11 * 2 + 2)
  else:
    print(x // 11 * 2 + 1)
else:
  print(x // 11 * 2)

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

int main() {
  int a, b;
  cin >> a >> b;

  
  if ( (int)(a/2)*2 != a && (int)(b/2)*2 != b ) {
    cout << "Odd";
  } else {
    cout << "Even";
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 1000000
#define INF 2000000000
using namespace std;
int n,V,x[MAXN+5];
int cnt[25];
int l[25][MAXN+5],r[25][MAXN+5];
int f1[MAXN*5+5],f2[MAXN*5+5];
bool ans[MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN*5+3;i++)
		f1[i]=0,f2[i]=INF;
}
int UpFind(int id,int pos)
{
//	if(cnt[id]==0)
//		return pos;
	pos++;
	int p=upper_bound(l[id]+1,l[id]+cnt[id]+1,pos)-l[id];
	p--;
	if(p<=0)
		return pos;
	return max(r[id][p],pos-1);
}
int LowFind(int id,int pos)
{
//	if(cnt[id]==0)
//		return pos;
	pos--;
	int p=lower_bound(r[id]+1,r[id]+cnt[id]+1,pos)-r[id];
	if(p>=cnt[id]+1)
		return pos;
	return min(l[id][p],pos+1);
}
int main()
{
	Init();
	scanf("%d %d",&n,&V);
	int logV=0;
	for(logV=0;(1<<logV)<=V;logV++);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	x[n+1]=INF;
	x[0]=-INF;
	for(int LG=0;LG<=logV;LG++)
	{
		int d=V/(1<<LG);
		cnt[LG]=1;
		l[LG][1]=1;
		for(int i=1;i<=n;i++)
		{
			r[LG][cnt[LG]]=i;
			if(x[i+1]-x[i]>d)
			{
				cnt[LG]++;
				l[LG][cnt[LG]]=i+1;
			}
		}
		cnt[LG]--;
	}
	if(cnt[0]>logV+1)
	{
		for(int i=1;i<=n;i++)
			printf("Impossible\n");
		return 0;
	}
	int all=(1<<(logV+1));
	f1[0]=0,f2[0]=n+1;
	for(int s=0;s<all;s+=2)
		for(int i=0;i<=logV;i++)
		{
			if(!(s&(1<<i)))
				continue;
			f1[s]=max(f1[s],UpFind(i,f1[s-(1<<i)]));
			f2[s]=min(f2[s],LowFind(i,f2[s-(1<<i)]));
		}
	for(int i=1;i<=cnt[0];i++)
	{
		int ln=l[0][i],rn=r[0][i];
		for(int s1=0;s1<all;s1+=2)
		{
			int s2=all-1-s1-1;
			int lpos=f1[s1];
			int rpos=f2[s2];
			if(lpos>=ln-1&&rpos<=rn+1)
			{
				ans[i]=true;
				break;
			}
		}
	}
	int pos=1;
	for(int i=1;i<=n;i++)
	{
		if(ans[pos]==true)
			printf("Possible\n");
		else
			printf("Impossible\n");
		if(x[i+1]-x[i]>V)
			pos++;
	}
	return 0;
}

Measured memory_bytes: 128256
#include <iostream>

using namespace std;

int main() {
	int a[3][3], cnt[8] = {};
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	int n; cin >> n;
	while (n--) {
		int b; cin >> b;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (a[i][j] == b) {
					++cnt[i];
					++cnt[j + 3];
					if (i == j) ++cnt[6];
					if (i + j == 2) ++cnt[7];
				}
			}
		}
	}
	bool flag = false;
	for (int i = 0; i < 8; ++i)
		if (cnt[i] > 2) flag = true;
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
b = [0] * 3
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

b[0] = list(input().split())
b[1] = list(input().split())
b[2] = list(input().split())

# print(b)
# print(c)

n = int(input())
for i in range(n):
    a = input()
    for i in range(3):
        for j in range(3):
            if b[i][j] == a:
                c[i][j] = 1


for i in range(3):
    if c[i][0] == c[i][1] == c[i][2] == 1:
        print("Yes")
        sys.exit()
    if c[0][i] == c[1][i] == c[2][i] == 1:
        print("Yes")
        sys.exit()
if c[0][0]==c[1][1]==c[2][2]==1:
    print("Yes")
    sys.exit()
if c[2][0]==c[1][1]==c[0][2]==1:
    print("Yes")
    sys.exit()
print("No")


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

int main(void){
    long long int h;
    cin >> h;
    long long ans = 1,memo = 1;
    for(long long int i = 0;h > 1;i++,h /= 2){
        ans += memo*2;
        memo *= 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&b!=a)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MAXN = 300;
ll A[MAXN][MAXN], D[MAXN][MAXN];
struct Edge {
    int u, v; ll d;  
    bool operator<(const Edge &rhs) const {
        if(d == rhs.d) {
            if(u == rhs.u) return v < rhs.v;
            return u < rhs.u;
        }
        return d < rhs.d;
    }
};

int main() {
    FAST_IO();
    int N; cin >> N;
    rep(i, N) rep(j, N) cin >> A[i][j];
    rep(i, N) rep(j, N) D[i][j] = A[i][j];
    rep(k, N) rep(i, N) rep(j, N) {
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
    }
    rep(i, N) rep(j, N) {
        if(A[i][j] != D[i][j]) {
            cout << "-1\n";
            return 0;
        }
    }
    rep(i, N) rep(j, N) D[i][j] = INT_MAX;
    rep(i, N) D[i][i] = 0;
    vector<Edge> edges;
    rep(i, N) for(int j = i + 1; j < N; ++j) {
        edges.push_back({i, j, A[i][j]});
    }
    sort(all(edges));
    ll sum = 0;
    for(auto &e : edges) {
        if(D[e.u][e.v] > e.d) {
            D[e.u][e.v] = e.d;
            rep(i, N) rep(j, N) {
                D[i][j] = min(D[i][j], min(D[i][e.u] + e.d + D[e.v][j], D[i][e.v] + e.d + D[e.u][j]));
            }
            sum += e.d;
        }
    }
    cout << sum << "\n";
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int N; cin >> N;
    vector<double> v(N);
    rep(i, N) cin >> v[i];
    rep(i, N-1){
        sort(v.begin()+i, v.end());
        double n = (v[i]+v[i+1])/2;
        v[i+1]=n;
    }
    cout << v[N-1] << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby
s=input()
n=len(s)
s=list(s)
gr=groupby(s)
cnt=[]
for k,g in gr:
    cnt.append(len(list(g)))

ans=0
nn=len(cnt)
if s[0]=='<':
    for i in range(nn):
        if i%2==0:
            if i==nn-1:
                if nn%2==1:
                    ans+=cnt[i]*(cnt[i]+1)//2
                else:
                    t_max=max(cnt[i],cnt[i+1])
                    t_min=min(cnt[i],cnt[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(cnt[i],cnt[i+1])
                t_min=min(cnt[i],cnt[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+1)//2                
else:
    for i in range(nn):
        if i==0:
            t_max=cnt[i]
            ans+=t_max*(t_max+1)//2
            continue
        if i%2==1:
            if i==nn-1:
                if nn%2==0:
                    ans+=cnt[i]*(cnt[i]+1)//2
                else:
                    t_max=max(cnt[i],cnt[i+1])
                    t_min=min(cnt[i],cnt[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(cnt[i],cnt[i+1])
                t_min=min(cnt[i],cnt[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+1)//2 

print(ans)


Measured memory_bytes: 11932
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
 
graph = defaultdict(list)
for _ in range(M):
	L, R, D = MAP()
	graph[L-1].append((R-1, D))
	graph[R-1].append((L-1, -D))
 
num = [None]*N

for i in range(N):
	if num[i] != None:
		continue
	q = deque([i])
	num[i] = 0
	while q:
		n = q.popleft()
		for node, weight in graph[n]:
			if num[node] == None:
				num[node] = num[n] + weight
				q.append(node)
			elif num[node] != num[n] + weight:
				print("No")
				exit()

else:
	print("Yes")

Measured memory_bytes: 78720
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])

mlist=[]
for i in range(N):
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

cur = -10**10
ans=0
for i in range(N):
    if mlist[i][1] >= cur:
        ans+=1
        cur = mlist[i][0]
print(ans)

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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n+1,0);
    for(int i=0;i<n-1;i++){
        int c;
        cin >> c;
        vec[c]++;
    }
    for(int i=1;i<=n;i++){
        cout << vec[i] << endl;
    }
}

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

int main(){
    string str; cin >> str;
    int n = str.size();
    int ans = 0;
    for(int i=0;i<n;i++){
        int cnt = 0;
        for(int j=i;j<n;j++){
            if( str[j] == 'A' || str[j] == 'C' ||
                str[j] == 'G' || str[j] == 'T'){
                cnt++;
            }
            else{
                break;
            }
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256