akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long unsigned int ll;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    vector<int> having(n);
    rep(i, k)
    {
        cin >> d.at(i);
        rep(j, d.at(i))
        {
            int a;
            cin >> a;
            a = a - 1;
            having.at(a) += 1;
        }
    }
    int ans = 0;
    rep(i, n)
    {
        if (having.at(i) == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n,m=map(int,readline().split())
    
    if n==m:
        ans=2*(f(n,mod))**2
    elif n==m-1 or m==n-1:
        ans=f(n,mod)*f(m,mod)
    else:
        ans=0
    ans%=mod
    print(ans)
    
def f(n,mod):
    res=1
    for i in range(1,n+1):
        res*=i
        res%=mod
    return res
    
if __name__=="__main__":
    main()

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

template <long long Mod> class mod_int{
    public:
    long long x;
    mod_int(long long x=0LL):x((x%Mod+Mod)%Mod){};

    mod_int operator-()const{return mod_int(-x);}

    mod_int pow(long long t)const{
        if(!t)return 1;
        mod_int<Mod>a=pow(t>>1);
        a*=a;
        if(t&1)a*=*this;
        return a;
    }
    //for prime mod
    mod_int inv()const{return pow(Mod-2);}

    mod_int operator+(const mod_int<Mod>a)const{return mod_int<Mod>(*this)+=a;}
    mod_int operator-(const mod_int<Mod>a)const{return mod_int<Mod>(*this)-=a;}
    mod_int operator*(const mod_int<Mod>a)const{return mod_int<Mod>(*this)*=a;}
    mod_int operator/(const mod_int<Mod>a)const{return mod_int<Mod>(*this)/=a;}//for prime mod

    mod_int& operator+=(const mod_int<Mod>a){(x+=a.x)%=Mod;return *this;}
    mod_int& operator-=(const mod_int<Mod>a){if((x+=Mod-a.x)>=Mod)x-=Mod;return *this;}
    mod_int& operator*=(const mod_int<Mod>a){(x*=a.x)%=Mod;return *this;}
    mod_int& operator/=(const mod_int<Mod>a){return *this *= a.inv();}//for prime mod

    friend istream& operator>>(istream& is,mod_int<Mod>& a){return is>>a.x;}
    friend ostream& operator<<(ostream& os, const mod_int<Mod>& a){return os<<a.x;}
};

long long N,K;
int main(){
    cin>>N>>K;

    mod_int<998244353> dp[N+1];
    for(int i=0;i<=N;i++)dp[i]=0LL;
    dp[1]=1LL;
    dp[2]=-1LL;
    int LR[K][2];
    for(int i=0;i<K;i++){
        cin>>LR[i][0]>>LR[i][1];
        LR[i][1]++;
    }

    long long acc=1LL;
    for(int i=1;i<=N;i++){
        //cout<<"acc:"<<acc<<endl;

        for(int j=0;j<K;j++){
            if(i+LR[j][0]<=N)dp[i+LR[j][0]]+=acc;
            if(i+LR[j][1]<=N)dp[i+LR[j][1]]-=acc;
        }

        //for(int j=0;j<=N;j++)cout<<dp[j]<<" \n"[j==N];
        acc+=dp[i+1].x;
    }
    //for(int j=0;j<=N;j++)cout<<dp[j]<<" \n"[j==N];

    mod_int<998244353>ans=0LL;

    for(int i=0;i<=N;i++)ans+=dp[i];
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 5188
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

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

  vector<vv<char> > result(2, vv<char>(h, vector<char>(w, '.')));
  rep (i, h) {
    result[0][i][0] = '#';
    result[1][i][w-1] = '#';
  }
  rep (i, h) {
    int r_b = i % 2;
    FOR (j, 1, w-1) {
      result[r_b][i][j] = '#';
    }
  }
  rep (i, h) {
    rep (j, w) {
      char tmp;
      scanf(" %c", &tmp);
      if (tmp == '#') {
        result[0][i][j] = result[1][i][j] = '#';
      }
    }
  }

  rep (i, h) {
    rep (j, w) {
      printf("%c", result[0][i][j]);
    }
    printf("\n");
  }
  printf("\n");
  rep (i, h) {
    rep (j, w) {
      printf("%c", result[1][i][j]);
    }
    printf("\n");
  }

  return 0;
}


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

int main()
{
  int a, b;
  char op;
  while (cin >> a >> op >> b) {
    if (op == '?') continue;
    int ans;
    switch (op) {
      case '+':
        ans = a + b;
        break;
      case '-':
        ans = a - b;
        break;
      case '*':
        ans = a * b;
        break;
      case '/':
        ans = a / b;
        break;
    }
    cout << ans << endl;
  }
  return 0;
}



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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int n;
  cin >> n;
  int ans = 3;
  int p = 1;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if(a % 2 == 0) p *= 2;
    if(i != 0) ans *= 3;
  }
  cout << ans - p << endl;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> c(N);
  for (int i = 1;i<N;i++) {
    if (S.at(i) == 'E') c.at(0)++;
  }
  for (int i = 1;i<N;i++) {
    c.at(i) = c.at(i-1);
    if (S.at(i-1) == 'W') c.at(i)++;
    if (S.at(i) == 'E') c.at(i)--;
  }
  sort(c.begin(),c.end());
  cout << c.at(0) << endl;
}



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

#define INF 100000000000

int n;
long long max1 = -INF, max2 = -INF;
long long min1 = INF, min2 = INF;
long long ans;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x, y; scanf("%d%d", &x, &y);
		max1 = max(max1, (long long) x + y);
		min1 = min(min1, (long long) x + y);
		max2 = max(max2, (long long) x - y);
		min2 = min(min2, (long long) x - y);
	}
	ans = max(max1 - min1, max2 - min2);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3824
#include<cstdio>
#include<algorithm>

typedef long long int lli;

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

    int a[105];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);

    lli res=10000000000000LL;
    for(int t=-100; t<=100; t++) {
        lli test=0;
        for(int i=0; i<n; i++) test+= (t-a[i])*(t-a[i]);
        res = std::min(res, test);
    }
    printf("%lld\n",res);

}

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

using namespace std;

long long max(long long a, long long b) {

    if(a > b)return a;
    return b;

}
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long mn = max(a*c,a*d);
    mn = max(mn, b * c);
    mn = max(mn, b*d);
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
long long int dp[100040] = {};
int main() {
	int n;
	cin >> n;
	vector<long long int> s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end(), greater<long long int>());
	int a = 0;
	long long int ans = 1;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) {
			ans = ans * s[i];
			i = i + 1;
			a++;
			if (a == 2) {
				break;
			}
		}
		if (i == s.size() - 1) {
			cout << 0;
			return 0;
		}
	}
	cout << ans;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  if (A+B < C+D){
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

vector<vector<int>> memo(1110, vector<int>(1110, -1));

int rec(int x, int y){
    if(memo[x][y]!=-1) return memo[x][y];
    if(x<=1 && y<=1) return memo[x][y]=0;

    int ans=0;
    for(int i=1; 2*i<=x; ++i) if(!rec(x-2*i, y+i)) ans=1;
    for(int i=1; 2*i<=y; ++i) if(!rec(x+i, y-2*i)) ans=1;
    return memo[x][y]=ans;
}

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

    ll x, y; cin >> x >> y;
    if(x<=1 && y<=1) cout << "Brown\n";
    else if(abs(x-y)<=1) cout << "Brown\n";
    else cout << "Alice\n";

    
    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>
int min(int a,int b){
    if(a>b)return b;
    else return a;
}
int main(){
    int d[10][10];
    int i,j,k,n,s,ans1,ans2;
    int v;
    v=0;
    s=0;ans1=0;ans2=-1;
    int t1,t2,t3;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<=9;i++){
            for(j=0;j<=9;j++)if(i!=j)d[i][j]=100000;else d[i][j]=0;
	    }
        for(i=1;i<=n;i++){
            scanf("%d%d%d",&t1,&t2,&t3);
            d[t1][t2]=t3;d[t2][t1]=t3;
            if(t1>v)v=t1;if(t2>v)v=t2;
        }
        for(k=0;k<=v;k++)
            for(i=0;i<=v;i++)
                for(j=0;j<=v;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        for(i=0;i<=v;i++){
            for(j=0;j<=v;j++)s=s+d[i][j];
            if(ans2<0||s<ans2){ans1=i;ans2=s;}
            s=0;
        }
        printf("%d %d\n",ans1,ans2);
        v=0;ans1=0;ans2=-1;s=0;
    }
    return 0;
}



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

using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( i = 0; i < (int)n; ++i )
typedef long long ll;

int main()
{
    //IOS

    int i, aux, pos;

    forin(i, 5)
    {
        cin >> aux;
        if ( aux == 0 ) pos = i + 1; 
    }

    cout << pos;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool ans = false;
    for(int i=0;i<1000;i++){
        if((c+i*b)%a==0){
            ans = true;
            break;
        }
    }
    if(ans){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, A, B;
ll a[51];
ll C[51][51];

void init() {
    C[0][0] = 1;
    for (int i = 1; i <= 50; ++i) {
        C[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
}

int main() {
    init();
    cin >> n >> A >> B;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n, greater<ll>());
    if (A > B)
        swap(A, B);
    double sum = 0;
    for (int i = 0; i < A; ++i) {
        sum += a[i];
    }
    double mean = sum / A;
    cout << mean << endl;
    int li = n - 1;
    int ri = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == a[A - 1]) {
            li = min(li, i);
            ri = max(ri, i);
        }
    }
    int left = A - li;
    int tt = ri - li + 1;
    if (li == 0) {
        ll ans = 0;
        for (int i = A; i <= min(tt, B); ++i) {
            ans += C[tt][i];
        }
        cout << ans << endl;
    } else {
        cout << C[tt][left] << endl;
    }

    return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;int mx=0,ans=0;
	rep(i,N){
		int a;cin>>a;
		ans+=max(0ll,mx-a);
		chmax(mx,a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
def solve():
    ans = 0
    N = int(input())
    P = list(map(int, input().split()))
    lis = [0]*N
    for i in range(N):
        if i+1==P[i]:
            if lis[i-1]==0:
                lis[i]=1
    ans = sum(lis)
    return ans
print(solve())

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


P visit(int p, int v, vector<vector<int>> &G){
	P r(0, v);
	for (auto e : G[v]){
		if (e != p){
			P t = visit(v, e, G);
			t.first += 1;
			if (r.first < t.first) r = t;
		}
	}
	return r;
}

signed main(){

	int N;
	cin >> N;
	vector<vector<int>> G(N);
	rep(i, N - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	P r = visit(-1, 0, G);
	P t = visit(-1, r.second, G);

	int dia = t.first;

	if (dia % 3 == 1){
		cout << "Second" << endl;
	}
	else
		cout << "First" << endl;


	return 0;
}

Measured memory_bytes: 26752
#include<stdio.h>


int main()
{
    long int n,t[105],m,p,x,i,sum=0;

    scanf("%ld",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%ld",&t[i]);
        sum+=t[i];

    }


    scanf("%ld",&m);
    for(i=1; i<=m; i++)
    {


        scanf("%ld%ld",&p,&x);

        printf("%ld\n",sum+x-t[p]);
    }

    return 0;


}


Measured memory_bytes: 128
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,A[100],i;
inline void solve(){
  IN(N);
  INS(i,N,A);
  sort(A,A+N);
  OUT(A[N-1]-A[0]);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X,u=0,L[110],count;
  cin>>N>>X;
  for(int i=0;i<N;i++) cin>>L[i];
  for(int i=0;i<N;i++){
    u += L[i];
    if(u<=X) count++;
    else break;
  }
  cout<<count+1<<endl;
}


Measured memory_bytes: 3648
a, b, k = map(int, input().split())

if b-a+1 <= k*2:
    for h in range(a, b+1):
        print(h)

else:
    for i in range(a, a+k):
        print(i)
    for j in range(b-k+1, b+1):
        print(j)

Measured memory_bytes: 3060
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
min=sum(l)*(1/(4*m))
ans=0
for i in l:
    if i>=min:
        ans+=1
if ans>=m:
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 3060
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

int digCount(int a)
{
    int ret = 0;
    do
    {
        a /= 10;
        ret++;
    } while (a > 0);
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    arri arr(n);

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

    if (n == 1)
    {
        cout << "Yes";
        return 0;
    }

    for (int i = n - 1; i >= 1; i--)
    {
        if (arr[i] < arr[i - 1])
        {
            if (arr[i] < (arr[i - 1] - 1))
            {
                cout << "No";
                return 0;
            }

            arr[i - 1]--;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        cout << (N+1)*N/2<< endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <string>


using namespace std;


void a(){

    int A,B,T; cin >> A >> B >> T;

    int c = T/A;

    cout << c*B;

}

int main(){

    a();
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  writeln(max(a-2*b, 0));
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if(a % 2 != 0) cnt++;
        }
        if(cnt % 2 != 0) System.out.println("NO");
        else System.out.println("YES");
        sc.close();
    }

}


Measured memory_bytes: 49512
/*
__   __                                       _ 
\ \ / /                                      | |
 \ V /___  _   _ _ __   __ _ _ __   ___  __ _| |
  \ // _ \| | | | '_ \ / _` | '_ \ / _ \/ _` | |
  | | (_) | |_| | | | | (_| | | | |  __/ (_| | |
  \_/\___/ \__,_|_| |_|\__, |_| |_|\___|\__,_|_|
                        __/ |                   
                       |___/                     
*/

// #pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
// #pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef double db;
typedef long long ll;
const int N=1e5+5;
const int mod=1e9+7;

char s[N];
int n,las[N],f[N],cnt[26];

void Mul(int &x,int y){x=1ll*x*y%mod;}
int mul(int x,int y){return 1ll*x*y%mod;}
void Dec(int &x,int y){x=x-y<0?x+mod-y:x-y;}
int dec(int x,int y){return x-y<0?x+mod-y:x-y;}
void Inc(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
int inc(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int ksm(int a,int b=mod-2,int ans=1){for(;b;a=mul(a,a),b>>=1) if(b&1) ans=mul(ans,a);return ans;}


signed main(){
    scanf("%d%s",&n,s+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        int now=s[i]-'a',at=1;
        for(int i=0;i<26;i++){
            if(i!=now) Mul(at,cnt[i]+1);
        } Inc(ans,at);
        cnt[now]++;
    } printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int n, k;
int ans;
int main () {
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    
    if (n == 1) {
        cout << k << endl;
        return 0;
    }
    
    if (n == 2) {
        cout << k * (k-1) << endl;
        return 0;
    }
    else {
        ans = 1;
        ans *= k;
        for (int i =2; i <=n; i++)
            ans *= (k-1);
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll bpow(ll x,ll n,ll m=MD,ll r=1LL){for(;n>0;n>>=1,x=x*x%m) if(n&1) r=r*x%m; return r;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n ,k;
	cin >>n >>k;
	ll ans = 0;
	VL dp(k+5);
	rep2(i, 1, k+1) dp[i] = bpow(k/i, n);
	repr(i, k, 1){
		for(int j=2*i; j<=k; j+=i) (dp[i] += MD - dp[j]) %=MD;
		(ans += dp[i] * i) %=MD;
	}
	
	cout <<ans <<"\n";
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int d;
    cin >> d;
    vi c(26);
    rep(i, 26) cin >> c[i];
    vector<vi> s(d, vi(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
    vi t(d);
    rep(i, d) {
        cin >> t[i];
        t[i]--;
    }
    int m;
    cin >> m;
    vpii dq(m);
    rep(i, m) {
        cin >> dq[i].first >> dq[i].second;
        dq[i].first; dq[i].second--;
    }
    vi last(26);
    ll sum = 0;
    rep1(i, d) {
        sum += s[i-1][t[i-1]];
        last[t[i-1]] = i;
        rep(j, 26) sum -= c[j] * (i - last[j]);
    }
    rep(i, m) {
        int fq = t[dq[i].first-1], tq = dq[i].second;
        int td = dq[i].first;
        int fl = dq[i].first-1, fr = dq[i].first+1, tl = dq[i].first, tr = dq[i].first;
        while (fl > 0) {
            if (t[fl-1] == fq) break;
            --fl;
        }
        while (fr <= d) {
            if (t[fr-1] == fq) break;
            ++fr;
        }
        while (tl > 0) {
            if (t[tl-1] == tq) break;
            --tl;
        }
        while (tr <= d) {
            if (t[tr-1] == tq) break;
            ++tr;
        }
        sum -= s[td-1][fq];
        sum += (td-fl)*(td-fl-1)*c[fq]/2 + (fr-td)*(fr-td-1)*c[fq]/2;
        sum -= (fr-fl)*(fr-fl-1)*c[fq]/2;
        sum += s[td-1][tq];
        sum -= (td-tl)*(td-tl-1)*c[tq]/2 + (tr-td)*(tr-td-1)*c[tq]/2;
        sum += (tr-tl)*(tr-tl-1)*c[tq]/2;
        cout << sum << endl;
        t[td-1] = tq;
    }
    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

// int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;



int main() {

  string S;
  cin >> S;
  if(S == "ABC")cout << "ARC";
  else cout << "ABC";

}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int n, a, b, ans = 0, m1, d1, m2;
  //string s;
  cin >> m1 >> d1 >> m2;
  //vector<int> v(n), c(n);
  //if(m1 != m2) {}
  //for(int i = 0; i < n; i++){}
  cout << (m1 != m2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
const int MOD=1e9+7;
const int INF=1e15;
 
signed main(){
    int N;cin>>N;
    map<int,int>amemo;
    map<int,int>bmemo;
    REP(i,N){
        int v;cin>>v;
        if(i%2==0)amemo[v]++;
        else bmemo[v]++;
    }
    int max1=0;
    int max1v=0;
    int max2=0;
    int max2v=0;
    for(auto it=amemo.begin();it!=amemo.end();it++){
        int d=it->second;
        if(max1<d){
            max1=d;
            max1v=it->first;
        }
    }
  	for(auto it=amemo.begin();it!=amemo.end();it++){
        int d=it->second;
        if(it->first!=max1v&&max2<d){
            max2=d;
          	max2v=it->first;
        }
    }
    int bmax1=0;
    int bmax1v=0;
    int bmax2=0;
    int bmax2v=0;
    for(auto it=bmemo.begin();it!=bmemo.end();it++){
        int d=it->second;
        if(bmax1<d){
            bmax1=d;
            bmax1v=it->first;
        }
    }
  	for(auto it=bmemo.begin();it!=bmemo.end();it++){
        int d=it->second;
        if(it->first!=bmax1v&&bmax2<d){
            bmax2=d;
          	bmax2v=it->first;
        }
    }
  	if(max1v!=bmax1v)cout<<N-max1-bmax1<<endl;
    else cout<<N-max1-max(max2,bmax2)<<endl;
}

Measured memory_bytes: 6528
r=range
M=10**9+7
n=input()
d=int(input())
dp=[[[0,0]for j in r(d)]for i in r(len(n)+1)]
dp[0][0][0]=1
for i,x in enumerate(map(int,n),1):
  for j in r(10):
    for k in r(d):
      dp[i][(j+k)%d][1]+=dp[i-1][k][1]
      dp[i][(j+k)%d][1]%=M
      if j<x:
        dp[i][(j+k)%d][1]+=dp[i-1][k][0]
        dp[i][(j+k)%d][1]%=M
      if j==x:
        dp[i][(j+k)%d][0]+=dp[i-1][k][0]
        dp[i][(j+k)%d][0]%=M
print(~-sum(dp[-1][0])%M)

Measured memory_bytes: 129372
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int a,p;
    cin >> a >> p;
    p += a*3;
    cout << floor(p/2) << endl;
}


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

# define endl "\n"
# define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;
typedef vector<int> vector_i;
typedef vector<long long int> vector_lli;
typedef vector<unsigned int> vector_ui;
typedef vector<unsigned long long int> vector_ulli;
typedef set<int> set_i;
typedef set<long long int> set_lli;
typedef set<unsigned int> set_ui;
typedef set<unsigned long long int> set_ulli;
typedef unordered_set<int> u_set_i;
typedef unordered_set<long long int> u_set_lli;
typedef unordered_set<unsigned int> u_set_ui;
typedef unordered_set<unsigned long long int> u_set_ulli;

string s, t;
int k, l, n;

int main() {
    cin >> s >> k;
    vector<string> S;
    n = s.size();
    for(int i = 0; i < n; i ++){
        t = "";
        l = min(k, n - i);
        for(int j = 0; j < l; j++){
            t += s[j + i];
            S.push_back(t);
        }
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout  << S[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void primer(vector<int>& U, int N) {//素因数分解
	for (size_t j = 2; j*j <= N; j++)
	{
		while (N%j==0)
		{
			N /= j;
			U.at(j)++;
		}
	}
	U.at(N)++;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N+1,1);
	for (size_t i = 1; i <= N; i++)
	{
		primer(A, i);
	}
	long long ans=1;
	for (size_t i = 2; i <= N; i++)
	{
		ans *= A.at(i) % mod;
		ans %= mod;
	}
	//cout << A.at(2) << endl;
	cout << ans;
}

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

for i in range(n):
    ans = 0
    mi = float('inf')
    for j in range(m):
        u = abs(s[i][0] - t[j][0]) + abs(s[i][1] - t[j][1])
        if u < mi:
            mi = u
            ans = j + 1
    print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        int a,b;
        while(~getII(a,b)){
                F(i,0,max(a,b)) printf("%d",min(a,b));
                puts("");
        }
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
   ll n;
   cin >> n;
   llv b(n-1);
   rep(i, n-1) cin >> b[i];
   ll ans = b[0];
   rep(i, n-2){
       ans += min(b[i], b[i+1]);
   }
   ans += b[n-2];
   cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = 0;
            var s = ReadInt();
            while(true)
            {
                count++;
                if (s == 1 || s==2||s==4)
                {
                    WriteLine(count + 3);
                    break;
                }
                s = f(s);
            }
            

        }
        static int f(int n)
        {
            if (n % 2 == 0)
            {
                return n / 2;
            }
            else
            {
                return 3 * n + 1;
            }
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13140
'use strict';
 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});
 
process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
 
// main function .... code start ... ///
function main() {
 
    //var input = readline()
    var T = Number(readline());
    
    var s = readline();
    var m = s.replace(/(.)\1+/g, "$1")
    console.log(m.length);
    
}

Measured memory_bytes: 9548
import Data.Char

main :: IO ()
main = do
  n <- readLn
  c <- getLine
  putStrLn $ solve n c

solve :: Int -> String -> String
solve n = map $ _chr . (`mod` 26) . (+ n) . _ord
  where
    _ord c = ord c - ord 'A'
    _chr i = chr $ i + ord 'A'

Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const int INF = 1<<30;
int MAXN = 1e5+2;
const double eps = 1e-13;


int main(){
	DRIII(n,m,k);
	REP(i,n+1){
		REP(j,m+1){
			int c=i*(m-j)+j*(n-i);
			if(k==c){
				puts("Yes");return 0;
			}
		}
	}
	puts("No");
}


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

int main() {
  int h,w;
  
  cin >> h >> w;
  
  char pic[h][w];
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> pic[i][j];
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << pic[i][j];
      if(j==w-1){
        cout << endl;
        for(int j=0;j<w;j++){
          cout << pic[i][j];
        }
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define endl "\n"
#define int long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
const int nmax = 1e5 + 7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(2);
    int n; cin >> n;
    vector <int> a(n);
    for (auto& x : a) cin >> x;
    sort(a.rbegin(), a.rend());
    int cou = 2, ans = a[0];
    int i = 1;
    for (; i < n && cou < n; ++i) {
        cou += 2; ans += a[i] * 2;
    }
    if (cou > n) ans -= a[i - 1];
    cout << ans << endl;


}

Measured memory_bytes: 4776
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		StringBuffer S = new StringBuffer(sc.next());
		char a=S.charAt(0);
		
		int i;
		for(i=0;i<S.length()&&a==S.charAt(i);i++) {
			
		}
		if(i==S.length()) {
			p(0);
		}else {
		char b=S.charAt(i);
		
		int v=0;
		int ans=0;
		while(i<S.length()) {
			for(;i<S.length()&&b==S.charAt(i);i++) {
				
			}
			if(i==S.length()) {
				ans=v*2+1;
				break;
			}
			v++;
			for(;i<S.length()&&a==S.charAt(i)&&i<S.length();i++) {
				
			}
			if(i==S.length()) {
				ans=v*2;
				break;
			}
		}
		p(ans);}
	}
	
		
	
	
		
	
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 27020
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<double> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));

  // r =  ok
  ll l = 0, r = a.back();
  while(r-l > 1){
    ll x = (l+r)/2;
    ll m = 0;
    REP(i, n) m += (a[i]+x-1)/x - 1;
    if(m <= k){
      r = x;
    }else{
      l = x;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4836
H,W=map(int,input().split())
A=[input() for i in range(H)]

#'#'が入っている行および列を列挙する
Tate=[0]*H
Yoko=[0]*W
for i in range(H):
    for j in range(W):
        if A[i][j]=='#':
            Tate[i]+=1
            Yoko[j]+=1

ans=['']*H
for i in range(H):
    for j in range(W):
        if Tate[i]*Yoko[j]>0:
            ans[i]+=A[i][j]

for i in ans:
    if i!='':
        print(i)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  char string[24];
  char revString[24];
  int i,s;

  fgets(string,22,stdin);
  for(i = 21;string[i] != '\n';i--){
    if(i == 0){
      break;
    }
  }
  i--;
  for(s = 0;i >= 0;i--){
    revString[s] = string[i];
    s++;
  }
  revString[s] = '\0';

  printf("%s\n",revString);  
  return 0;
}

Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
int main(){
  long long n,K,v[200],ans=0,A[200],b;
  cin>>n>>K;
  rep(i,n) cin>>v[i];
  rep(i,min(n,K)+1)rep(j,min(i,K-i)+1)rep(k,i){
    b=0;
    rep(l,i) A[l]=v[(l-k+n)%n],b+=A[l];
    sort(A,A+i);
    rep(l,j) if(A[l]<0) b-=A[l];
    ans=max(ans,b);
  }
  cout<<ans;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
h={}
m.times do
  s, l = gets.split.map(&:to_i)
  h[s] = [h[s], l].compact.min
end
i = 0
while !h.empty? do
  j = h.keys.max
  h.select!{|_,v|v <= j}
  i += 1
end
puts i


Measured memory_bytes: 52924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
inline int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		ch=getchar();
		if (ch=='-') w=-1;	
	}
	while (ch<='9' && ch>='0'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*w;
}
int n;
int main(){
	n=read();
	for (int i=1;i<=n;++i){
		int x=read();
		if (x&1){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}

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

int main()
{
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	double ans=0;
	if(d!=0)
		ans=(1.0*(n-d)*2.0/n/n)*(m-1);
	else
		ans=(1.0*(n-d)/n/n)*(m-1);
	printf("%.7lf\n",ans);
	
	return 0;
}


Measured memory_bytes: 256