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

int main() {
    int N; cin >> N;
    vector<int> B(N);
    rep(i,N) {
        int b; cin >> b; b--;
        B[i] = b;
    }
    vector<int> C;
    while (!B.empty()) {
        int cnt = 0, ma = 0;
        for (int i = 0; i < B.size(); i++) {
            if (i == B[i]) {
                cnt++;
                ma = i;
            }
        }
        if (cnt == 0 && !B.empty()) {
            cout << -1 << endl;
            return 0;
        } else {
            B.erase(B.begin() + ma);
            C.push_back(ma);
        }
    }
    reverse(C.begin(), C.end());
    rep(i,N) cout << C[i]+1 << endl;
}

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

class Program
{
    static void Main(string[] arg){
        //string[] input = Console.ReadLine().Split(' ');
        int K = int.Parse(Console.ReadLine()); 
        string n = Console.ReadLine();

        if(n.Length<=K){
            Console.WriteLine(n);
            return;
        }else{
            Console.WriteLine(n.Substring(0,K) + "...");
            return;
        }

    }
}


Measured memory_bytes: 27436
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

            decimal bunsi = inpt[0] + inpt[1];
            decimal bunbo = inpt[0] * inpt[1];

            Console.WriteLine(bunbo/bunsi);

       }


        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"



2 3


";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            bool f = false;
            for (int i = 1; i <= 3; i++){
                if(S[i] == S[i - 1])
                {
                    f = true;
                }
            }
            if(f == true)
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}

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

int main() {
    int M, N, A[103], total, cnt;

    cin >> N >> M;

    total = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        total += A[i];
    }

    cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i] * 4 * M >= total)
            cnt += 1;
    }

    if (cnt >= M)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=7e5+5;

void multi(ll &a, ll b){
	a%=MOD; b%=MOD; a*=b; a%=MOD;
}

void add(ll &a, ll b){
	a%=MOD; b%=MOD; a+=b; a%=MOD;
}

ll modpow(ll a, ll b){
	ll r = 1LL;
	while(b){
		if(b&1)multi(r,a);
		multi(a,a);
		b>>=1;
	}
	return r;
}

ll fact[mxn];
void init(){
	fact[0]=1LL;
	for(int i=1; i<mxn; i++){
		fact[i]=fact[i-1]*1LL*i%MOD;
	}
}

ll nCr(int x, int y){
	ll res = fact[x];
	multi(res,modpow(fact[y],MOD-2));
	multi(res,modpow(fact[x-y],MOD-2));
	return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    init();
	int x; int y;
	cin >> x >> y;
	ll t = x+y;
	if(t%3==0){
		t/=3;
		if(x<t||y<t){
			cout << 0 << endl;
		}else{
			cout << nCr(t,x-t) << endl;
		}
	}else{
		cout << 0 << endl;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

using namespace std;

#define rep(i, n) for(int i=0 ;i<(n); ++i)

template<typename T> inline void chmax(T& t, T f){if(t < f)t = f;}

int N, W, H, S, T;

int solve(vector<vector<int> >& csum){
    for(int x=1; x<=W; ++x)for(int y=1; y<=H; ++y){
        csum[x][y] += csum[x-1][y] + csum[x][y-1] - csum[x-1][y-1];
    }
    int res = 0;
    for(int x=0; x+S<=W; ++x)for(int y=0; y+T<=H; ++y){
        chmax(res, csum[x][y] - csum[x+S][y] - csum[x][y+T] + csum[x+S][y+T]);
    }
    return res;
}

int main(){
    while(cin >> N, N){
        cin >> W >> H;
        vector<vector<int> > field(W+1, vector<int>(H+1));
        while(N--){
            int x, y;
            cin >> x >> y;
            field[x][y] = true;
        }
        cin >> S >> T;
        cout << solve(field) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1260
s = input()

c1 = 0
c2= 0

for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      c1 += 1
    else:
      c2 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      c2 += 1
    else:
      c1 += 1

print(min(c1, c2))

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    ll A, V; cin >> A >> V;
    ll B, W; cin >> B >> W;
    ll T; cin >> T;
    string ans = "NO";
    for (ll i = 0; i < T; i++) {
        if (A == B) {
            ans = "YES";
        }
        else if (A < B) {
            A += V;
            B += W;
            if (A >= B) {
                ans = "YES";
                break;
            }
        }
        else {
            A -= V;
            B -= W;
            if (A <= B) {
                ans = "YES";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void WarshallFloyd(Graph& G, Matrix& d) {//O(V^3)
	d.resize(G.size());
	REP(i, d.size())d[i].resize(G.size());
	REP(i, d.size()) {
		REP(j, d[i].size()) {
			d[i][j] = INF;
		}
	}
	REP(i, G.size()) {
		REP(j, G[i].size()) {
			d[i][G[i][j].to] = G[i][j].cap;
		}
	}
	REP(i, G.size()) {
		REP(j, G.size()) {
			REP(k, G.size()) {
				chmin(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
}

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

	ll n;
	cin >> n;
	Array p(n, 0);
	REP(i, n) cin >> p[i];
	ll ans = 0;
	bool flag = true;
	REP(i, n) {
		if (flag) {
			if (i+1 == p[i]) {
				ans++;
				flag = false;
			}
		}
		else {
			flag = true;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
N = gets.to_i
MARCH = 'MARCH'.split('')
hash = Hash.new(0)
N.times do
    c = gets[0]
    hash[c] += 1 if MARCH.include?(c)
end

ans = 0
MARCH.combination(3) do |c1, c2, c3|
    ans += hash[c1] * hash[c2] * hash[c3]
end

puts ans


Measured memory_bytes: 2044
#include <stdio.h>
main()
{   long int x,ret;
 
    while(EOF != scanf("%ld",&x))
    {
        ret = x * x * x * (600/x-1)*(600/x)*(600/x*2-1)/6;
 
    printf("%ld\n",ret);
    }
return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,K,W,H,ans = 1,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 0; i < N; ++i)
	{
		if(ans < K){
			ans *= 2;
		}else{
			ans += K;
		}
	}

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> K;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

int main(){
  int n,ans = 0;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=0;i<n-2;i++){
    if(p[i] > p[i+1] && p[i+1] > p[i+2])ans += 1;
  	if(p[i] < p[i+1] && p[i+1] < p[i+2])ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,m,t;
  cin>>n>>m>>t;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  Int INF=100000000000;
  vector<Int> w(t,INF);
  w[a[0]%t]=a[0];
  for(Int i=0;i<n;i++)
    w[(a[0]-a[i])%t]=min(w[(a[0]-a[i])%t],a[0]-a[i]);

  //for(Int i=0;i<t;i++) cout<<i<<"+"<<w[i]<<endl;
  
  vector<Int> dist(t,INF),used(t,0);
  dist[0]=0;
  while(1){
    Int u=-1;
    for(Int i=0;i<t;i++){
      //cout<<i<<";"<<used[i]<<" "<<dist[i]<<endl;
      if(used[i]) continue;
      if(u<0||dist[i]<dist[u]) u=i;
    }
    //cout<<u<<"   "<<dist[u]<<endl;
    if(u<0) break;
    //cout<<u<<"   "<<dist[u]<<endl;
    used[u]=1;
    for(Int i=0;i<t;i++)
      dist[(u+i)%t]=min(dist[(u+i)%t],dist[u]+w[i]);
    //for(Int i=0;i<t;i++) cout<<(u+i)%t<<" "<<dist[(u+i)%t]<<" "<<dist[u]+w[i]<<endl;
  }
  //for(Int i=0;i<t;i++) cout<<i<<":"<<dist[i]<<endl;
  //cout<<a[0]*m<<endl;
  vector<Int> res(t,INF);
  for(Int i=0;i<t;i++)
    res[(a[0]*m+(t-i))%t]=a[0]*m-dist[i];
  //for(Int i=0;i<t;i++) cout<<i<<":"<<res[i]<<endl;
  for(int i=t-2;i>=0;i--) res[i]=max(res[i],res[i+1]);
  //for(Int i=0;i<t;i++) cout<<i<<":"<<res[i]<<endl;

  
  Int q;
  cin>>q;
  
  while(q--){
    Int A,B;
    cin>>A>>B;
    if(res[A]>=B*t) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

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

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

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

    ll ans = 0;
    ll flag = 0;

    for(ll i = 0; i < n - 1; i++){
        if(flag == 0){
            if(a[i] < a[i + 1]){
                flag = 1;
            }else if(a[i] > a[i + 1]){
                flag = 2;
            }
        }else if(flag == 1){
            if(a[i] > a[i + 1]){
                ans++;
                flag = 0;
            }
        }else if(flag == 2){
            if(a[i] < a[i + 1]){
                ans++;
                flag = 0;
            }
        }
    }
    ans++;

    cout << ans << endl;
}

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

#define i64 long long int

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;


int n, k;

i64 calc(int l, int r) {
	if(r<l) return 0LL;
	return 1LL*(l+r)*(r-l+1)/2;
}

int main() {
	scanf("%d%d", &n, &k);
	
	int ans = 0;
	for(int i=k;i<=n+1;i++) {
		i64 l = calc(0, i-1);
		i64 r = calc(n-i+1, n);
		ans = ma.add(ans, (r-l+1)%ma.mod);
	}
	printf("%d\n", ans);
	
	return 0;
}

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

int x,y;

struct grid{
  char g[11][11];
  int count;
};

void DFS(grid& gr,char firstcell,char changecolor,int posx,int posy){

  //if(posx < 0 || posx >= x  || posy < 0 || posy >= y || gr.g[posx][posy] != firstcell){
  if(gr.g[posx][posy] != firstcell){
    return;
  }

  gr.g[posx][posy] = changecolor;

  DFS(gr,firstcell,changecolor,posx+1,posy);
  DFS(gr,firstcell,changecolor,posx-1,posy);
  DFS(gr,firstcell,changecolor,posx,posy+1);
  DFS(gr,firstcell,changecolor,posx,posy-1);
}

int main(){

  while(1){

    cin >> x >> y;

    if(x==0 && y==0){
      break;
    }

    grid start;

    for(int i=0; i<y; i++){
      for(int j=0; j<x; j++){
        cin >> start.g[j][i];
      }
    }

    char firstcell = start.g[0][0];

    bool flag = true;

    for(int i=0; i<y; i++){
      for(int j=0; j<x; j++){
        if(start.g[j][i]!=firstcell){
          flag = false;
          break;
        }
      }
      if(!flag){
        break;
      }
    }
    if(flag){
      cout << 0 << endl;
      continue;
    }

    start.count = 0;

    queue<grid> q;

    q.push(start);

    while(1){

      grid BeforeGrid = q.front();
      q.pop();

      BeforeGrid.count++;

      grid tmp = BeforeGrid;

      firstcell  = tmp.g[0][0];

      if(firstcell != 'R'){
          DFS(tmp,firstcell,'R',0,0);

          flag = true;
          for(int i=0; i<y; i++){
            for(int j=0; j<x; j++){
              if(tmp.g[j][i]!='R'){
                flag = false;
                break;
              }
            }
            if(!flag){
              break;
            }
          }
          if(flag){
            cout << tmp.count << endl;
            break;
          }

          q.push(tmp);
          tmp = BeforeGrid;
      }

      if(firstcell != 'G'){
          DFS(tmp,firstcell,'G',0,0);

          flag = true;
          for(int i=0; i<y; i++){
            for(int j=0; j<x; j++){
              if(tmp.g[j][i]!='G'){
                flag = false;
                break;
              }
            }
            if(!flag){
              break;
            }
          }
          if(flag){
            cout << tmp.count << endl;
            break;
          }

          q.push(tmp);
          tmp = BeforeGrid;
      }

      if(firstcell != 'B'){
          DFS(tmp,firstcell,'B',0,0);

          flag = true;
          for(int i=0; i<y; i++){
            for(int j=0; j<x; j++){
              if(tmp.g[j][i]!='B'){
                flag = false;
                break;
              }
            }
            if(!flag){
              break;
            }
          }
          if(flag){
            cout << tmp.count << endl;
            break;
          }

          q.push(tmp);
      }

    }






  }


    return 0;
}

Measured memory_bytes: 18604
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

A_max = 10 ** 4
INF = float('inf')

dp = [INF] * (H + A_max + 1)
dp[0] = 0
for i in range(H):
    if dp[i] == INF:
        continue
    for a, b in AB:
        if dp[i] + b < dp[i + a]:
            dp[i + a] = dp[i] + b
print(min(dp[H:]))


Measured memory_bytes: 42972
n = int(input())
k = int(input())
x = int(input())
y = int(input())

cost = 0
if 1 <= n <= 10000 and 1 <= k <= 10000 and 1 <= y < x <= 10000:
  if n > k:
    cost += x * k
    cost += y * (n - k)
  elif n <= k:
    cost += n * x
  
print(cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }

// int gcd (int a , int b){
//     return __gcd(a,b);
// }

// void print_vi(vi a){
//     for (int i: a){
//         cout << i << " " ;
//     }
//     cout << endl;
// }

// Best algo to find maximum sum subarray (contiguous)
// ll kadane (vl a){
//     ll curr = 0 , maxi = 0;
//     f(i , 0 , a.size()){
//         curr = max(a[i] , curr + a[i]);
//         maxi = max(maxi , curr);
//     }
//     return maxi;
// }

// Method to get the factors of a big number here a[j] = factors of number j
// ll x;
// cin >> x;
// vl a(x+1 , 0);
// f( i , 1 , x+1){
//     for (int j = i ; j < x+1 ; j+= i){
//         a[j]++;
//     }
// }

void solve(){
    
    char c;
    cin >> c;
    if (isupper(c)){
        cout << "A" << endl;
        return;
    }
    cout << "a" << endl;
    return;
}

 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    
    int t = 1;
    // cin >> t;
    
    while(t--){
        
        solve();
    }
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  
  int n;
  cin >> n;
  
  vector<int> x(n);
  vector<int> xForSort(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
    xForSort[i] = x[i];
  }
  sort(xForSort.begin(),xForSort.end());
  int median1 = xForSort[n/2-1];
  int median2 = xForSort[n/2];

  
  for(int i=0;i<n;i++){
    if(x[i]<=median1){
      cout << median2 << endl;
    }
    else if(median2<=x[i]){
      cout << median1 << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4844
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

const int maxn = 2e6 + 5;
const int mod = 1e9 + 7;

int fact[maxn], inv[maxn];

int k, n;
string s;

int powmod(int x, int k)
{
    if(k == 0) return 1;
    int t = powmod(x, k / 2);
    if(k % 2 == 0) return t * 1LL * t % mod;
    else return t * 1LL * t % mod * x % mod;
}

void prep()
{
    fact[0] = 1;
    for(int i = 1; i < maxn; ++i)
        fact[i] = fact[i - 1] * 1LL * i % mod;
    inv[maxn - 1] = powmod(fact[maxn - 1], mod - 2);
    for(int i = maxn - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * 1LL * (i + 1) % mod;
}

void read_input()
{
    cin >> k;
    cin >> s;
    n = sz(s);
}

int C(int k, int n)
{
    return fact[n] * 1LL * inv[k] % mod * inv[n - k] % mod;
}

int add(int x, int y)
{
    int res = x + y;
    if(res >= mod) res -= mod;
    else if(res < 0) res += mod;
    return res;
}

void solve()
{
    int ans = 0;
    for(int i = 0; i < n; ++i)
        ans = add(ans, C(i, n + k) * 1LL * powmod(25, n + k - i) % mod);
    ans = add(powmod(26, n + k), -ans);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    prep();
    read_input();
    solve();
}



Measured memory_bytes: 19876
# seishin.py
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

INF = 10**18

from heapq import heappush, heappop

l0, r0 = P[0]

L = [-l0+1]
R = [l0-1]
s = t = 0

def debug(L, s, t, R):
    L0 = L[:]
    Q1 = []; Q2 = []
    while L0:
        Q1.append(-s-heappop(L0))
    R0 = R[:]
    while R0:
        Q2.append(t+heappop(R0))
    print("debug:", *Q1[::-1]+Q2)


#print(L, s, t, R)
res = 0
for i in range(N-1):
    l0, r0 = P[i]
    l1, r1 = P[i+1]
    #print(">", l1, r1)
    s += (r1 - l1); t += (r0 - l0)
    if -s-L[0] <= l1-1 <= t+R[0]:
        #print(0)
        heappush(L, -l1+1-s)
        heappush(R, l1-1-t)
        # res += 0
    elif l1-1 < -s-L[0]:
        #print(1)
        heappush(L, -l1+1-s)
        heappush(L, -l1+1-s)
        p = -heappop(L)-s
        #d = (-L[0]-s) - p
        heappush(R, p-t)
        #print(d)
        #res += d
        res += (p - (l1-1))
    elif t+R[0] < l1-1:
        #print(2)
        heappush(R, l1-1-t)
        heappush(R, l1-1-t)
        p = heappop(R) + t
        #d = R[0]+t - p
        heappush(L, -p-s)
        #print(d)
        res += (l1-1 - p)
    #print(L, s, t, R, -s-L[0], R[0]+t, res)
    #debug(L, s, t, R)
print(res)


Measured memory_bytes: 102488
e,a,b,c=1,0,0,0
p=1000000007
for i in input():
  if i == "A":
    a+=e
  elif i == "B":
    b+=a
  elif i == "C":
    c+=b
  else:
    e,a,b,c = (3*e)%p,(e+3*a)%p,(a+3*b)%p,(b+3*c)%p
print(c%1000000007) 

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

const int INF = 1e9;
int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> right(N, 0), left(N, 0);
    for (int i = 0; i < N-1; i++) {
        if (S[i] == 'E') right[i+1] = right[i] + 1;
        else right[i+1] = right[i];
    }
    for (int i = N-1; i > 0; i--) {
        if (S[i] == 'W') left[i-1] = left[i] + 1;
        else left[i-1] = left[i];
    }

    int MIN = INF;
    for (int i = 0; i < N; i++) {
        int num = N-1-right[i]-left[i];
        MIN = min(MIN, num);
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 3076
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < ll(n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define DUMPOUT cerr
#define dump(...) DUMPOUT<<"  ";DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;DUMPOUT<<"    ";dump_func(__VA_ARGS__)
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) { DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...); }
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x)) //最大値を求める
#define MIN(x) *min_element(all(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define pb emplace_back //vectorヘの挿入
#define mp make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int up_b(vector<ll> v,ll i){
    int itr=upper_bound(all(v),i)-v.begin();
    if(itr==v.size()){
        return -1;
    }else{
        return itr;
    }
}
int lo_b(vector<ll> v,ll i){
    int itr=lower_bound(all(v),i)-v.begin();
    if(itr==v.size()){
        return -1;
    }else{
        return itr;
    }
}


//------------------------------------------------------------


//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n;cin>>n;
  string s="";
  rep(i,n){
  s+="ACL";
  }
  
    O(s);
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
vector <double> vd;
 
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
set <int> st;
//#define sort(v) sort(v.begin(),v.end());
#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i];}
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
 
//int cnt =0;
 
//void SieveOfEratosthenes(int n=1000000)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
 
 
//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
 
//vector <int> arr(100,-1);
//
//int fib(int n)
//{
//    if(n<=1)return 1;
//
//    if(arr[n]==-1)
//    {
//        arr[n] = fib(n-1)+fib(n-2);
//    }
//    //else return arr[n];
//
//   return arr[n];
//}
 
 
//int arr[1050][1050];
//
//int mx=0;
//int LCS(string s, string p)
//{
//    for(int i=1; i<=s.size(); i++)
//    {
//        for(int j=1; j<=p.size(); j++)
//        {
//
//            if(s[i-1]==p[j-1])
//                arr[i][j]=1+arr[i-1][j-1];
//            else
//                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
//
//        }
//    }
//    return arr[s.size()][p.size()];
//}
//
//
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        x++;
//        n /= 2;
//    }
//    h+=x;
//    x=0;
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            x++;
//            n /= i;
//        }
//        h+=x;
//        x=0;
//
//    }
//
//    if(n>2){
//        h++;
//    }
//
//}

int main()
{
    map <int,int>mp;
    int a,b,c,n;
    char ch;
    string s,p;
    
    cin >> n;
    cin >> s;
    
    
    for(int i=0; i<s.size(); i++)
    {
        
        ch = s[i];
        
        a = ch;
        
        a+=n;
        
       if(a>90)
       {
           a = a-90;
           a = 64+a;
       }
        
        ch = a;
        
        cout << ch;
        
        
    }
    cout << endl;
    
    
  
    return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll in;
  cin>>in;

  int flag9=1;
  int res=0;
  while(in/10>0){
    if(in%10!=9)flag9=0;
    res += 9;
    in =in/10;
  }
  if(flag9==1){
    res += in;
  }
  else res += in - 1;

  cout<<res<<endl;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> x(n), y(n), h(n);
  REP(i, n) {
    cin >> x[i] >> y[i] >> h[i];
  }
  bool ok = false;
  vector<int> ans(3);
  ans[0] = -1;
  ans[1] = -1;
  ans[2] = -1;
  REP(cx, 101) {
    REP(cy, 101) {
      int hmax = 0;
      ok = true;
      REP(i, n) {
        if(hmax == 0 && (h[i] != 0)) {
          hmax = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
          i = -1;
          continue;
        }
        if(h[i] == 0 && abs(cx - x[i]) + abs(cy - y[i]) < hmax) {
          ok = false;
          break;
        } else if (h[i] > 0 && abs(cx - x[i]) + abs(cy - y[i]) + h[i] != hmax) {
          ok = false;
          break;
        }
      }
      if(ok) {
        ans[0] = cx;
        ans[1] = cy;
        ans[2] = hmax;
        break;
      }
    }
  }

  cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++)
    if(s[i]=='0')cnt++;
  cout<<min((int)s.size()-cnt,cnt)*2<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long

int cur;
signed main(){
  
  string s;
  cin >> s;
  int n = s.size();

  int ans = 0;

  for(int i = 0;i<n;i++){
    if(s[i]=='A' || s[i]=='T' || s[i] =='C' || s[i] =='G'){
      cur++;
    }
    else
    {
      ans = max(cur,ans);
      cur = 0;
    }
  }  
  
  ans = max(cur,ans);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<int> parent;

int find(int i){
	if(parent[i] < 0) return i;
	int idx = i;
	while(parent[i] >= 0) i = parent[i];
	parent[idx] = i;
	return i;  
}

void union_(int i, int j){
	int p1 = find(i), p2 = find(j);
	if(p1 == p2) return;
	if(abs(parent[p1]) > abs(parent[p2])){
		parent[p1] += parent[p2];
		parent[p2] = p1;
	}
	else{
		parent[p2] += parent[p1];
		parent[p1] = p2;
	}
	return;
}

void solution(){
	int n,m; cin >> n >> m;
	parent = vector<int>(n,-1);
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		u--; v--;
		union_(u,v);
	}
	int ans = 1;
	for(int x : parent){
		if(x < 0){
			ans = max(ans, abs(x));
		}
	}
	cout << ans << endl;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
int h,w,n,a[10010];
int ans[110][110];
int main() {
	scanf("%d %d %d",&h,&w,&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	bool flag=0;
	int I=1,J=1;
	for (int i=1;i<=n;i++) {
		int cnt=0,tmp;
		if (!flag) {
			if (a[i]<=w-J+1) {
				for (int j1=J;j1<=J+a[i]-1;j1++)
					ans[I][j1]=i;
				if (a[i]==w-J+1) {
					I++;
					J=1;
				}
				else J+=a[i];
			}
			else {
				for (int j1=J;j1<=w;j1++) {
					ans[I][j1]=i;
					cnt++;
				}
				flag=1;
				tmp=I+(a[i]-cnt)/w;
				for (int i1=I+1;i1<=tmp;i1++)
					for (int j1=1;j1<=w;j1++) {
						ans[i1][j1]=i;
						cnt++;
					}
				I=tmp+1;
				for (int j1=w;j1>=w-(a[i]-cnt)+1;j1--)
					ans[I][j1]=i;
				J=w-(a[i]-cnt);
			}
		}
		else {
			if (a[i]<=J) {
				for (int j1=J;j1>=J-a[i]+1;j1--)
					ans[I][j1]=i;
				if (a[i]==J) {
					I++;
					J=w;
				}
				else J-=a[i];
			}
			else {
				for (int j1=1;j1<=J;j1++) {
					ans[I][j1]=i;
					cnt++;
				}
				flag=0;
				tmp=I+(a[i]-cnt)/w;
				for (int i1=I+1;i1<=tmp;i1++)
					for (int j1=1;j1<=w;j1++) {
						ans[i1][j1]=i;
						cnt++;
					}
				I=tmp+1;
				for (int j1=1;j1<=a[i]-cnt;j1++)
					ans[I][j1]=i;
				J=a[i]-cnt+1;
			}
		}
	}
	for (int i=1;i<=h;i++) {
		for (int j=1;j<=w;j++)
			printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int now = 100;
	for(int i = 1;; i++){
		now = now / 100 + now;
		if(now >= x){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3616
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

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

int A,B;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>A>>B;
	if(B<=1){
		cout<<"0"<<endl;
		return 0;
	}
	int sum=0;
	for(int i=1;i<=1000;i++){
		if(sum+A>=B){
			cout<<i<<endl;
			return 0;
		}
		sum+=A-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}


int a[5][5];
bool ok[5][5];


int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    for(int i = 1; i <= 3; ++i)
        for(int j = 1; j <= 3; ++j)
            cin >> a[i][j];
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        for(int xx = 1; xx <= 3; ++xx)
            for(int yy = 1; yy <= 3; ++yy)
                if(a[xx][yy] == x)
                    ok[xx][yy] = 1;
    }
    bool oki = 0;
    for(int i = 1; i <= 3; ++i)
    {
        int s = 0;
        for(int j = 1; j <= 3; ++j)
            s += ok[i][j];
        if(s == 3)
            oki = 1;
        s = 0;
        for(int j = 1; j <= 3; ++j)
            s += ok[j][i];
        if(s == 3)
            oki = 1;
        if(i == 1)
        {
            s = 0;
            for(int j = 1; j <= 3; ++j)
                s += ok[j][j];
            if(s == 3)
                oki = 1;
            s = 0;
            for(int j = 3; j >= 1; --j)
                s += ok[j][4 - j];
            if(s == 3)
                oki = 1;
        }
    }
    cout << (oki == 1 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		long a=scn.nextLong();
		long b=scn.nextLong();
		long c=scn.nextLong();
		long d=scn.nextLong();
		if(c%d==0) {
			if(d>a) {
				System.out.println(b-a+1-(b/d));
			}else {
				System.out.println(b-a+1-(b/d-a/d+(a%d!=0?0:1)));
			}
		}else if(d%c==0) {
			if(c>a) {
				System.out.println(b-a+1-(b/c));
			}else {
				System.out.println(b-a+1-(b/c-a/c+(a%c!=0?0:1)));
			}
		}else {
			if(c>a&&d>a) {
				System.out.println(b-a+1-b/c-b/d+b/(c*d));

			}else if(c>a) {
				System.out.println(b-a+1-b/c-(b/d-a/d+(a%d!=0?0:1))+b/(c*d));

			}else if(d>a) {
				System.out.println(b-a+1-(b/c-a/c+(a%c!=0?0:1))-b/d+b/(c*d));

			}else {
				System.out.println((long)(b-a+1-(b/c-a/c+(a%c!=0?0:1))-(b/d-a/d+(a%d!=0?0:1))+b/(lcm(c,d))-a/(lcm(c,d))+((a%(lcm(c,d))!=0&&a>c*d)||a<lcm(c,d)?0:1)));

			}
		}
	}
	static long lcm(long a, long b){
		return a / gcd(a,b) * b;
	}
	static long gcd(long a, long b){
		if(a<b){
			a^=b;
			b^=a;
			a^=b;
		}
		if(a%b==0){
			return b;
		}else{
			return gcd(b,a%b);
		}
	}
}


Measured memory_bytes: 21972
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 5e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    bool can[25][25];
    int dpd[MAX];
    int a;
    void solve()
    {
        cin>>n;
        fo(i,0,n)
            fo(j,0,n)
            cin>>can[i][j];

        dpd[0]=1;
        fo(mask,0,(1<<n))
        {
            a=__builtin_popcount(mask);
            fo(b,0,n)
            {
                if(can[a][b] && !(mask & (1<<b)))
                {
                    dpd[mask|(1<<b)]=(dpd[mask|(1<<b)]+dpd[mask])%MOD;
                }
            }
        }

        cout<<dpd[(1<<n)-1]<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }   

Measured memory_bytes: 18816
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  bool CAN=true;
  vector<pair<ll,ll>> L;
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    L.PB(MP(b,a));
  }
  SORT(L);
  
  ll cnt=0;
  REP(i,N){
    cnt+=L[i].second;
    if(cnt>L[i].first) CAN=false;
  }
  
  if(CAN) COYe;
  else CONo;
  return 0;
}

Measured memory_bytes: 7448
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A, B, C; cin >> A >> B >> C;

	if(C >= A and C <= B) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}


Measured memory_bytes: 256