akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 1e5+5;

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

Measured memory_bytes: 3728
d, g = gets.split.map(&:to_i)
pc = d.times.map {gets.split.map(&:to_i)}

ans = 10000
(1 << d).times do |i|
    score = count = 0
    d.times do |j|
        i[j] == 0 and next
        score += 100 * (j+1) * pc[j][0] + pc[j][1]
        count += pc[j][0]
    end
    
    if score < g
        k = (d-1).downto(0) {|j| i[j] == 0 and break j}
        x = (g - score).fdiv(100 * (k + 1)).ceil
        next if x >= pc[k][0]
        count += x
    end

    ans > count and ans = count
end

p ans

Measured memory_bytes: 1788
def main():
    N = int(input())
    V = [int(v) for v in input().split()]
    C = [int(c) for c in input().split()]

    vcSum = 0

    for i in range(N):
        vc = V[i] - C[i]
        if vc > 0:
            vcSum += vc

    print(vcSum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
using ll = long long int;

struct Matrix {
    static const int MAXN = 55;
    int x[MAXN][MAXN];
    
    Matrix() {
        memset(x, 0, sizeof(x));
    }
    int* operator [] (int r) {
        return x[r];
    }
    static Matrix unit() {
        Matrix res;
        for (int i = 0; i < MAXN; i++) res[i][i] = 1;
        return res;
    }
    friend Matrix operator + (Matrix A, Matrix B) {
        Matrix res;
        for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) {
            res[i][j] = A[i][j] + B[i][j];
            if (res[i][j] >= MOD) res[i][j] -= MOD;
        }
        return res;
    }
    friend Matrix operator * (Matrix A, Matrix B) {
        Matrix res;
        for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) {
            long long SQMOD = (long long) MOD * MOD;
            long long sum = 0;
            for (int k = 0; k < MAXN; k++) {
                sum += (long long) A[i][k] * B[k][j];
                if (sum >= SQMOD) sum -= SQMOD;
            }
            res[i][j] = sum % MOD;
        }
        return res;
    }
    friend Matrix operator ^ (Matrix A, long long k) {
        if (k == 0) return unit();
        Matrix res, tmp;
        for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) {
            res[i][j] = tmp[i][j] = A[i][j];
        }
        k--;
        while (k) {
            if (k & 1) res = res * tmp;
            tmp = tmp * tmp;
            k >>= 1;
        }
        return res;
    }
};

int main() {
    long long int k;
    int n,i,j,s=0;
    Matrix m;
    cin>>n>>k;
    for(i=0;i<n;++i) {
        for(j=0;j<n;++j) {
            cin>>m[i][j];
        }
    }
    m = m^k;
    for(i=0;i<n;++i) for(j=0;j<n;++j) s = (s+m[i][j])%MOD;
    cout<<s<<endl;
    return 0;
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}

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

    int n,k;cin>>n>>k;
    vector<int> v(n,0),dp(n+4,INT_MAX);
    for(int i=0;i<n;i++)cin>>v[i];dp[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=1;j<=k && i+j<n;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
        }
    }cout<<(dp[n-1]);
    //for(auto x:dp)ce(x);
    
    

  }


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N,K;
  cin>>N>>K;

  ll res=0;
  while(N>0){
  	N/=K;
  	res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
rline = sys.stdin.readline

N = int(input())


def dfs(ans, max_c):
    if len(ans) == N:
        print(ans)
    else:
        for i in range(max_c + 1):
            dfs(ans + chr(ord('a') + i), max_c + 1 if i == max_c else max_c)


def solve():
    dfs('', 0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4340
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

constexpr int64_t MOD = 1000000007;

using namespace std;

class AAtCoderContestScheduling {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        int64_t D = 0;
        cin >> D;
        vector<int64_t> c_vec(26);
        for (int i = 0; i < 26; ++i) cin >> c_vec[i];
        vector<vector<int64_t>> s_vec(D, vector<int64_t>(26));
        for (int i = 0; i < D; ++i)
            for (int j = 0; j < 26; ++j) cin >> s_vec[i][j];

        for (int i = 0; i < D; ++i) {
            cout << i % 26 + 1 << endl;
        }
    }
};


int main() {
    AAtCoderContestScheduling solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2],R[MAX / 2 + 2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k = left;k < right;k++){
    if(L[i].value <= R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j].value <= x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t = A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p < r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit)stable = 0;
  }

  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}

Measured memory_bytes: 2956
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int size = 0;
        while (n != 0){
            n /= k;
            size ++;
        }
        System.out.println(size);
    }
}


Measured memory_bytes: 21972
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int l = sc.nextInt();
    int max = 0;
    int max1 = 0;

    int y[] = {n,m,l};

    int[] data ={n + m , m + l , n + l };

    for (int i = 0;i < y.length ;i++ ) {
      max1 = Math.max(max1,y[i]);
    }



    System.out.println(n+m+l - max1);


  }
}


Measured memory_bytes: 23764
# 0〜9
l=list(range(10))

# 入力
N,K=map(int,input().split())
l2=list(map(int,input().split()))

ans=''
f=False

# 使用可能な数字を求める
for x in l2:
  l.remove(x)

# 集合型に変換
l=set(l)

for x in range(1,1000000):
  y=set(map(int,list(str(x))))
  if N<=x and l.issuperset(y):
    print(x)
    break

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

int main () {
    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        int s[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            sum += s[i];
        }
        double m = sum * 1.0 / n;
        double v = 0.0;
        for (int i = 0; i < n; i++) {
            v += pow(m - s[i], 2.0);
        }
        printf("%lf\n", sqrt(v / n));
    }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

int N;
int y[50],x[50],yy[50],xx[50];
vint ys,xs;

int col[200][200];
bool used[200][200];

void solve(){
    ys.clear();xs.clear();
    rep(i,N){
        cin>>x[i]>>yy[i]>>xx[i]>>y[i];
        ys.pb(y[i]);ys.pb(yy[i]);
        xs.pb(x[i]);xs.pb(xx[i]);
    }
    xs.pb(-1001001001);ys.pb(-1001001001);

    sort(all(xs));xs.erase(unique(all(xs)),xs.end());
    sort(all(ys));ys.erase(unique(all(ys)),ys.end());
    rep(i,N){
        x[i]=lower_bound(all(xs),x[i])-xs.begin();
        y[i]=lower_bound(all(ys),y[i])-ys.begin();

        xx[i]=lower_bound(all(xs),xx[i])-xs.begin();
        yy[i]=lower_bound(all(ys),yy[i])-ys.begin();
    }

    for(int i=0;i<ys.size();i++){
        for(int j=0;j<xs.size();j++){
            int b=0;
            rep(k,N){
                b<<=1;
                if(x[k]<=j&&j<xx[k]&&y[k]<=i&&i<yy[k])b++;
            }
            col[i][j]=b;
        }
    }

    memset(used,0,sizeof(used));
    int ans=0;
    rep(i,ys.size())rep(j,xs.size()){
        if(used[i][j])continue;
        queue<pint>que;
        used[i][j]=true;
        ans++;
        que.push({i,j});
        while(que.size()){
            int y,x;
            tie(y,x)=que.front();
            que.pop();
            rep(d,4){
                int ny=y+dy[d],nx=x+dx[d];
                if(ny<0||ny>=ys.size()||nx<0||nx>=xs.size()||col[y][x]!=col[ny][nx]||used[ny][nx])continue;
                used[ny][nx]=true;
                que.push({ny,nx});
            }
        }
    }
    cout<<ans<<endl;
}

signed main(){
    while(cin>>N,N)solve();
}

Measured memory_bytes: 3256
#include <iostream>
using namespace std;
int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if(A >= K){
    A -= K;
  }else if(A < K && B >= K-A){
    B -= K-A;
    A = 0;
  }else if(A < K && B < K-A){
    A = 0;
    B = 0;
  }
  cout << A << ' ' << B;
}


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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string s;cin >> s;
  rep(i,3){
    if(s[i] == '1')cout<<"9";
    if(s[i] == '9')cout<<"1";
  }
}

Measured memory_bytes: 3632
from collections import deque
import sys
n,m=map(int,input().split())
g=[[] for _ in range(3*n)]
for _ in range(m):
  u,v=map(int, sys.stdin.readline().split())
  u-=1
  v-=1
  g[u].append(n+v)
  g[u+n].append(v+2*n)
  g[u+2*n].append(v)
s,t=map(int,input().split())
s-=1
t-=1
vit=set([s])
ans=[-3]*3*n
q=deque([s])
ans[s]=0
while q:
  a=q.popleft()
  for b in g[a]:
    if b in vit:
      continue
    vit.add(b)
    ans[b]=ans[a]+1 
    q.append(b)
print(ans[t]//3)

Measured memory_bytes: 93476
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

double dp[110][110];

bool lose[110], back[110];

int main() {
    cout << fixed;
    cout << setprecision(6);
    while (1) {
        int n, t, l, b;
        cin >> n >> t >> l >> b;
        if (n == 0) {
            break;
        }
        fill(lose, lose + 110, false);
        fill(back, back + 110, false);
        for (int i = 0; i < l; i++) {
            int los;
            cin >> los;
            lose[los] = true;
        }
        for (int i = 0; i < b; i++) {
            int bac;
            cin >> bac;
            back[bac] = true;
        }
        for (int i = 0; i < 110; i++) {
            fill(dp[i], dp[i] + 110, 0);
        }
        dp[0][0] = 1;
        for (int i = 1; i <= t; i++) {
            for (int j = 0; j < n; j++) {
                double pro = dp[i - 1][j] / 6.0;
                for (int k = 1; k <= 6; k++) {
                    int pos = j + k;
                    if (j + k > n) {
                        pos = n - (j + k - n);
                    }
                    if (lose[pos]) {
                        dp[i + 1][pos] += pro;
                    } else if (back[pos]) {
                        dp[i][0] += pro;
                    } else {
                        dp[i][pos] += pro;
                    }
                }
            }
        }
        double ans = 0;
        for (int i = 1; i <= t; i++) {
            ans += dp[i][n];
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    long long int  a[n];
    for(int i = 0 ; i < n ; i++ )a[i] = 0;
    for(int i = 0 ; i < n ; i++ ){
      cin >> a[i];
    }
    sort(a,a+n);
    long long sum = 0,res = 0;
    for(int i = 1 ; i < n ; i++ ){
      sum += a[i-1];
      res += sum;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	ll a{},b{},c{},d{};
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d))<<'\n';
	//system("pause");
	return 0;
}

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

int main(void){

    int r,g,b,n;
    cin >> r >> g >> b >> n;
    
    long long result = 0;
    for(int i=0; i<=n; i++) {
        for(int j=0; j<=n; j++) {
            long long temp_b = n-(i*r+j*g);
            if(temp_b%b==0 && temp_b >= 0 && temp_b/b<=n-i-j) {
//                cout << i << " " << j << " " << temp_b/b << endl;
                result++;
            }
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, q = map(int,input().split())
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())

def score(l):
    res = 0
    for i in range(q):
        temp = l[b[i] - 1] - l[a[i] - 1]
        if temp == c[i]:res += d[i]

    return res

def dfs(l):
    global ans
    if len(l) == n:
        ans = max(ans, score(l))
        return #中で使われている関数の終了

    if l:
        temp = l[-1]
    else:
        temp = 1
    for v in range(temp, m + 1):
        l.append(v)
        dfs(l)
        l.pop()

ans = 0
dfs([])
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;

ll n,m,q;
vector<ll> a;
Graph x(50, vector<int> (4));
ll ma = 0;
void tans(vector<int> &a){
  if (a.size()==n){
    ll ans = 0;
    for(int i=0; i<q; i++){
      if(a[x[i][1]-1]-a[x[i][0]-1]==x[i][2]){
        ans+=x[i][3];
      }
    }
    if(ma<=ans){
      ma = ans;
    }

  }else{
    for(int i=a.at(a.size()-1);i<=m;i++){
      vector<int>b=a;
      b.push_back(i);
      tans(b);
    }
  }
}


int main() {
  
  cin >> n >> m >> q;
  
  REP(i,q){
    REP(j,4){
      cin >> x.at(i).at(j);
    }
  }

  for(int i=1; i<=6; i++){
    vector<int> ab;
    ab.push_back(i);
    tans(ab);
  }

  cout << ma << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b, c, d;
    cin >>a >> b>> c >> d;
    if((a+b)==(c+d)){
        cout << "Balanced" << endl;
    }
    if((a+b)>(c+d)){
        cout << "Left" << endl;
    }else if((a+b)<(c+d)){
        cout << "Right" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;     // 辺の行先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++)
  {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  vector<int> v(N);
  for (int i = 0; i < M; i++)
  {
    v[a[i]]++, v[b[i]]++;
  }
  bool ok = true;
  for (auto &it : v)
    if (it % 2 != 0)
      ok = false;
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9+7;
const int maxn = (int)-1;

#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);

const db eps = 1e-6;
bool eq(const db &a, db const &b) { return fabs(a - b) < eps; }
bool ls(const db &a, db const &b) { return a + eps < b; }
bool le(const db &a, db const &b) { return eq(a, b) || ls(a, b); }

char s[55][55];

int main ()
{
    int h, w;
    scanf("%d%d", &h, &w);
    getchar();
    rep(i, 0, h) {
        scanf("%s", s[i]);
        getchar();
    }
    //cout<<s[1][1]<<endl;
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (s[i][j] == '#') continue;
            int cnt = 0;
            rep(k, 0, 3) rep(l, 0, 3) {
                int x = i + k - 1, y = j + l - 1;
                //cout<<x<<' '<<y<<endl;
                if ((x != i || y != j) && x >= 0 && x < h && y >= 0 && y < w) {
                    //dd(x), de(y), de(s[x][y]);
                    if (s[x][y] == '#') cnt++;

                }
            }
            s[i][j] = '0' + cnt;
            //cout<<cnt<<endl<<endl;
        }
    }
    rep(i, 0, h) rep(j, 0, w) {
        printf("%c", s[i][j]);
        if (j == w - 1) printf("\n");
    }


    return 0;
}


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

int main() {
  unsigned int N, K, Q;
  std::cin >> N >> K >> Q;
  std::vector<unsigned int> correct_array(N, 0);
  for (unsigned int i = 0; i < Q; ++i) {
    unsigned int a;
    std::cin >> a;
    correct_array.at(a - 1) += 1;
  }

  for (unsigned int i = 0; i < N; ++i) {
    const unsigned int others_correct_num = Q - correct_array.at(i);
    if (K > others_correct_num) {
      std::cout << "Yes" << std::endl;
    } else {
      std::cout << "No" << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;

double app() {
  int a;
  cin>>a;

  return a*2*3.14159265;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3780
#include <cstdio>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int H {in}, W {in};
	times(i, H) {
		int a {-1};
		for (int j: range(W))
			out(j ? " " : "", a = gcu() == 'c' ? 0 : a >= 0 ? a + 1 : -1);
		gcu();
		outl();
	}
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
int kan(int i){
  if(i%2==0)
    return i/2;
  else
    return 3*i+1;

}
int main(){
  int s;
  cin>>s;
  map<int, int> m;
  int count=1;
  while(m[s]!=1){
    m[s]++;
    s=kan(s);
    count++;
  }
  cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  P a[m];
  rep(i,m) cin >> a[i].S >> a[i].F;
  sort(a,a+m);
  rep(i,m) swap(a[i].F,a[i].S);
  int ans=0,x=0;
  rep(i,m) {
    if(a[i].F<x) continue;
    else {
      x=a[i].S;
      ans++;
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 1024
#!/usr/bin/env python3
N, M = map(int, input().split())
A = list(map(int, input().split()))

A_sum = sum(A)
Flag = A_sum / (4 * M)
A_fav = [i for i in A if i >= Flag]
#print(A_fav, Flag)
if len(A_fav) >= M:
    print("Yes")
else:
    print("No")

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

maxi = 0
mini = float("inf")


lmin = []
rmax = []

R = []

for i in range(n):

    r = int(input())
    R.append(r)

    if len(lmin) == 0:
        lmin.append(r)

    else:
        lmin.append(min(lmin[-1],r))

for i in range(n):

    i = n-1-i

    if len(rmax) == 0:
        rmax.append(R[i])

    else:
        rmax.append(max(R[i],rmax[-1]))

rmax.reverse()
lmin.insert(0,float("inf"))

ans = -1 * float("inf")

for i in range(n):

    ans = max(ans,rmax[i]-lmin[i])

#print (lmin)
#print (rmax)

print (ans)



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

int linearSearch(vector<int> S, int key){
  for(int i = 0; i < S.size(); i++){
    if(S[i] == key) return i;
  }
  return -1;
}

int main(void){
  vector<int> S;
  int n, q, cnt = 0;

  cin >> n;
  for(int i = 0; i < n; i++){
    int num;
    cin >> num;
    S.push_back(num);
  }

  cin >> q;
  for(int i = 0; i < q; i++){
    int key;
    cin >> key;
    if(linearSearch(S, key) >= 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1320
#include<stdio.h>
int main(void)
{
	int n,max,cnt,i,b,a;
	max=-1;
	b=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		a=i;
		cnt=0;
		//printf("a=%d\n",a);
		while(a%2==0){
			cnt++;
			a/=2;
			//printf("a=%d cnt=%d\n",a,cnt);
		}
		if(max<cnt){
			max=cnt;
			b=i;
		}
	}
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>d;
int w[100],v[100],N,W;
int dp(int i,int j){
	pair<int,int> p=make_pair(i,j);
	if(d.count(p)) return d[p];
	long res;
	if(i==N)res=0;
	else if(j<w[i])res=dp(i+1,j);
	else res=max(dp(i+1,j),dp(i+1,j-w[i])+v[i]);
	return d[p]=res;
}
int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++)cin>>w[i]>>v[i];
	cout<<dp(0,W)<<endl;
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int n;
struct Matrix {
    ll a[2][2] = {{0, 0}, {0, 0}};
    Matrix operator*(const Matrix& o) {
        Matrix res;
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < 2; j++)
                for (int k = 0; k < 2; k++)
                    res.a[i][k] = (res.a[i][k] + a[i][j] * o.a[j][k]) % n;
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    Matrix p, s;
    s.a[0][0] = s.a[0][1] = 1;
    s.a[1][1] = 10;
    p.a[0][0] = 7;
    for (int i = 1; i < 2e6; i++) {
        p = p * s;
        if (p.a[0][1] == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}
/*
*/

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#define int long long
using namespace std;
const int P=998244353;
const int M=1000000;

int powmod(int x, int p) {
	if (p == 0) return 1;
	int y = powmod(x, p/2);
	y = y * y % P;
	if (p&1) {
		y = y * x % P;
	}
	return y;
}

int inv(int x) {
	return powmod(x, P - 2);
}

int n;
vector<int> cnt(M + 1);
vector<int> D(M + 1);
vector<int> S(M + 1);

signed main() {
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	
	for (int i = 1; i <= M; ++i) {
		int sum = 0;
		int sum2 = 0;
		for (int j = i; j <= M; j += i) {
			sum = (sum + cnt[j] * j) % P;
			sum2 = (sum2 + cnt[j] * j % P * j) % P;
		}
		D[i] = ((sum * sum % P - sum2 + P) % P) * inv(2) % P;
	}
	
	for (int i = M; i >= 1; --i) {
		S[i] = D[i];
		for (int j = 2 * i; j <= M; j += i) {
			S[i] = (S[i] - S[j] + P) % P;
		}
	}
	
	int res = 0;
	
	for (int i = 1; i <= M; ++i) {
		res = (res + inv(i) * S[i]) % P;
	}
	
	cout << res << "\n";
	return 0;
}

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

int main(){
  int n, m, c = 0; cin >> n >> m;
  rep(i, m){
    int a = i+1, b = n-i-c;
    if(b-a <= n/2 && n % 2 == 0 && c == 0){
      c = 1; --b;
    }
    cout << a << " " << b << "\n";
  }
  return 0;
}


Measured memory_bytes: 3636
void main() {
	auto N = ri;
	int m = int.min;
	int res;
	foreach(i; 0..N) {
		auto p = ri;
		m = max(m, p);
		res += p;
	}
	res -= m / 2;
	res.writeln;
	
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main() {
    
    int X, N;
    cin >> X >> N;
    
    set<int> p;
    
    rep(i, N){
        int a;
        cin >> a;
        p.insert(a);
    }
    
    if(p.count(X) == 0){
        cout << X << endl;
        return 0;
    }
    
    int bigger = X + 1;
    int smaller = X -1;
    
    while(true){
        
        if(p.count(smaller) == 0){
            cout << smaller << endl;
            return 0;
        }
        
        if(p.count(bigger) == 0){
            cout << bigger << endl;
            return 0;
        }
        
        
        bigger++;
        smaller--;
    }
    
    
    return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2) {
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}

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

int main()
{
    int N;
    scanf("%d", &N);
    vector<long long> A(N + 1), B(N + 1);
    for (int i = 1; i <= N; i++) {
        scanf("%d%d", &A[i], &B[i]);
    }
    long long ans = 0;
    for (int i = N; i >= 1; i--) {
        A[i] += ans;
        if (A[i] % B[i] != 0) {
            ans += B[i] - (A[i] % B[i]);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll N;
    string S;
    cin >> N >> S;
    ll imos1[N] = {0};
    ll imos2[N] = {0};
    FOR(i,0,N){
        if(S[i] == '#')imos1[i]++;
        else imos2[i]++;
    }
    FOR(i,0,N-1){
        imos1[i+1] += imos1[i];
    }
    REP(i,0,N-1){
        imos2[i] += imos2[i+1];
    }
    ll ans = LINF;
    FOR(i,0,N-1){
        chmin(ans,imos1[i]+imos2[i+1]);
    }
    ll tmp1 = 0;
    ll tmp2 = 0;
    FOR(i,0,N){
        if(S[i] == '#')tmp1++;
        else tmp2++;
    }
    chmin(ans,N-tmp1);
    chmin(ans,N-tmp2);
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
struct point {
    double x, y;
    point (){}
    point (double x, double y) : x(x), y(y){}
    point friend operator - (point l, point r) {
        return point (l.x - r.x, l.y - r.y);
    }
    point friend operator + (point l, point r) {
        return point (l.x + r.x, l.y + r.y);
    }
    double friend operator * (point l, point r) {
        return l.x * r.x + l.y * r.y;
    }
    double friend operator ^ (point l, point r) {
        return l.x * r.y - l.y * r.x;
    }
    double len () {
        return sqrt (x * x + y * y);
    }
} A, B, C, D, E;
int main () {
//    freopen ("in.txt", "r", stdin);
    int Q;
    double x1, y1, x2, y2;
    cin >> A.x >> A.y >> B.x >> B.y;
    C = B - A;
    cin >> Q;
    while (Q --) {
        cin >> D.x >> D.y;
        E = D;
        D = D - A;
        double u = C * D;
        u /= C.len () * C.len ();
        D = C;
        D.x *= u, D.y *= u;
        D = D + A;
//        cout << D.x << ' ' << D.y << endl;
        D = D - E;
        D.x *= 2, D.y *= 2;
        printf ("%.10f %.10f\n", D.x + E.x, D.y + E.y);
    }
    return 0;
}



Measured memory_bytes: 3292
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,k;
	cin>>n>>k;
	if(n%k==0)cout<<0<<endl;
	else cout<<1<<endl;
	
	return 0;
}

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

int main(){
    int K;cin>>K;
    long long int ans = 1;
    long long int r,q;
    r = 7%K;
    q = 0;
    while(1){
        if(r==0){
            cout << ans;
            break;
        }
        else if(K%2==0||K%5==0||r==q){
            cout << -1;
            break;
        }
        q = r;
        r = (10*r + 7)%K;
        ans +=1;
    }

}


Measured memory_bytes: 3620
s = input()
s = str(s)
s1 = ""
s2 = ""
for i in range(1,len(s)+1):
	if(i%2==0):
		s1=s1+"1"
	else:
		s1=s1+"0"
for i in range(1,len(s)+1):
	if(i%2==0):
		s2=s2+"0"
	else:
		s2=s2+"1"

c1=0
c2=0
for i in range(0,len(s)):
	if(s1[i:i+1]!=s[i:i+1]):
		c1=c1+1
	if(s2[i:i+1]!=s[i:i+1]):
		c2=c2+1
print(min(c1,c2))

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class407
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string x1 = string.Join("", S.Where(_ => _ != 'x'));
            string x2 = string.Join("", x1.Reverse());
            if (x1 != x2) { Console.WriteLine(-1);return; }
            List<char> s = S.ToList();

            int l = 0;
            int count = 0;
            for (int i = 0; i < s.Count; i++)
            {
                if (s[i] == 'x' && s[s.Count - 1 - i] != 'x')
                {
                    s.Insert(s.Count - i, 'x');
                    count++;
                }
                else if(s[s.Count-1-i] == 'x' && s[i] != 'x')
                {
                    s.Insert(i, 'x');
                    count++;
                    l++;
                }
            }
            Console.WriteLine(count);

        }
    }

}


Measured memory_bytes: 34212
#include <bits/stdc++.h>
#define mod 1000000007
using ll = long long;
using namespace std; 
const double pi = acos(-1);

int main() {
    int n,m,x; cin >> n >> m >> x;
    vector<ll> money(n);
    int a[n][m];
    ll ans=10000000000;
    ll anss=0;
    bool ok=true;
    vector<int> aa(m);
    for (int i=0;i<n;i++){
        cin >> money[i];
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for (int i=0;i<(1<<n);i++){
        for (ll j=0;j<n;j++){
            if (i&(1<<j)){
                anss+=money[j];
                for (int k=0;k<m;k++){
                    aa[k]+=a[j][k];
                }
            }
        }
        for(int q=0;q<m;q++){
            if(aa[q]<x){
                ok=false;
            }
            aa[q]=0;
        }
        if(ok) ans=min(ans,anss);
        anss=0;
        ok=true;
    }
    if(ans==10000000000){
        cout << -1 << "\n";
    }
    else cout << ans << "\n";
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5000, M = 600;
ll dp[N][26], n, ans[M + 1];
string s, p = "FESTIVA";


ll calc(int i, int j) {
	if (j == 'A')
		return 1;
	if (i == n)
		return 0;
	ll &ret = dp[i][j];
	if (ret != -1)
		return ret;
	ret = calc(i + 1, j);
	if (p[p.find(j) + 1] == s[i])
		ret += calc(i + 1, s[i]);
	return ret;
}
int main(int argc, char **argv) {
	for (int i = 1; i <= M; ++i) {
		s += p;
		memset(dp, -1, sizeof dp);
		n = s.size();
		ans[i] = calc(0, 'Q');
	}
	reverse(p.begin(), p.end());
	s.clear();
	ll x, t;
	cin >> x;
	for (int i = 600; i >= 1; --i) {
		t = x / ans[i];
		s += string(t, 'L') + p;
		x -= t * ans[i];
	}
	reverse(s.begin(), s.end());
	puts(s.c_str());
	return 0;
}


Measured memory_bytes: 1536
n = int(input())
A = [int(input()) for i in range(n)]
def InsertionSort(A, n, g):
    global c
    for i in range(g, n):
        v = A[i]
        j = i - g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    
G = [1]
while G[-1]*3 + 1 <= n:
    G.append(G[-1]*3 + 1)

G.reverse()
m = len(G)
print(m)
print(*G)
c = 0
for g in G:
    InsertionSort(A, n, g)
    
print(c)
print(*A, sep="\n")            
    


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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}


void solve()
{
    int x;cin>>x;
    print(1-x)
}

int main()
{
    //fastio;
   // test
    solve();
}


Measured memory_bytes: 3596
#include<iostream> 
using namespace std;
int main(){
	int n,a,b,c,d;
	cin>>n;
	a=n%10;
	n=n/10;
	b=n%10;
	n=n/10;
	c=n%10;
	n=n/10;
	d=n%10;
	n=n/10;
//	cout<<a<<b<<c<<d<<endl;
	if(a==b&&a==c){cout<<"Yes";return 0;}
	if(c==b&&c==d){cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

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

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    
    int count = 0;
    for(int i=0;i<S.length()-1;i++){
        if(S[i] != S[i+1]) count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <queue>


using namespace std;

using ll = long long;


int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for (ll i =0;i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  vector<pair<ll, ll>> BC(M);
  for(ll i=0;i<M;i++) cin >> BC[i].second >> BC[i].first;
  sort(BC.begin(), BC.end());
  reverse(BC.begin(), BC.end());

  ll tt = 0;
  ll cidx = 0;
  for (ll i=0; i<N;i++) {
    if (A[i] < BC[cidx].first) {
      tt += BC[cidx].first;
      BC[cidx].second--;

      if (BC[cidx].second == 0) {
        cidx++;
      }
    } else {
      tt += A[i];
    }
  }

  cout << tt << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;

int n, m, p[N], inv[N], par[N];

int Find (int X) {
	if(par[X] == X) return X;
	return par[X] = Find(par[X]);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d",&p[i]);
		inv[p[i]] = i;
	}
	iota(par+1, par+1+n, 1);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		A = Find(A); B = Find(B);
		if(A != B) par[B] = A;
	}
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(Find(i) == Find(inv[i])) ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1408
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		
		int[] a = new int[N];
		long total = 0;

		for(int i=0; i<N; i++)
			a[i] = sc.nextInt();

		for(int i=0; i<N-1; i++){
			int s = a[i]+a[i+1] - x;
			
			if( s>0 && a[i]+a[i+1] > x ){
				if( a[i+1]>=s )
					a[i+1] = a[i+1]-s;
				else{
					a[i] = a[i] - (s-a[i+1]);
					a[i+1] = 0;	
				}
				total += s; 
			}
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 33204
#define I int
#include <iostream>
I main(){I n,c=0,l[100];std::cin>>n;bool f=0;for(I i=0;i<n;i++){std::cin>>l[i];i>0?l[i-1]==l[i]&&f==0?c++,f=1:f=0:0;}std::cout<<c<<"\n";}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = list(map(int,input().split()))
m = list(map(int,input().split()))
m.sort()
l = []
for i in m:
    l.insert(0,i)
ans = 0
s = 0
for i in m:
    s += i
for i in range(n[1]):
    if l[i]<s/4/n[1]:
        ans = 1
#print(l)
if ans == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N=1e5+5;
const int INF=0x3f3f3f;

int par[N];
int v[N];

int Find(int x){
    int temp=par[x];
    if(par[x]!=x)   par[x]=Find(par[x]),v[x]+=v[temp];
    return par[x];
}

int main(void){
    int n,m;
    cin >>n >>m;
    for(int i=1;i<=n;i++)   par[i]=i;
    bool flag=true;
    for(int i=1;i<=m;i++){
        int l,r,d;
        scanf("%d%d%d",&l,&r,&d);
        int rootl=Find(l);
        int rootr=Find(r);
        if(rootr==rootl){
            if(v[r]-v[l]!=-d)   flag=false;
        }
        else{
            par[rootl]=rootr;
            v[rootl]=d+v[r]-v[l];
        }
    }
    if(flag)    cout <<"Yes"<<endl;
    else    cout<<"No"<<endl;
}



Measured memory_bytes: 1152
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x*(-1),a))
heapq.heapify(a)
for i in range(m):
  mini=heapq.heappop(a)
  mini=(-1)*((-mini)//2)
  heapq.heappush(a,mini)
print(sum(a)*(-1))

Measured memory_bytes: 14180