akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  long long int s, i, c=0;
  cin >> s;
  
  if(s<3){
    cout << 4;
    return 0;
  }
  
  for(i=0; c<2; i++){
    if(s==4)
      c++;
    if(s%2==0)
      s/=2;
    else
      s=3*s+1;
  }
  cout << i;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	string order;
	string str;
	typedef set<string> set_t;
	set_t A;
	while(n--) {
		cin >> order;
		if (order == "insert") {
			cin >> str;
			A.insert(str);
		} else if (order == "find") {
			cin >> str;
			if (A.count(str) == 0) cout << "no" << endl;
			else cout << "yes" << endl;
		}
	}
}



Measured memory_bytes: 32572
import math

def modpow(a, n, p):
    if n == 0:
        return 1
    elif n == 1:
        return a % p
    elif n%2 == 1:
        return (a * modpow(a, n-1, p)) % p
    else:
        temp = modpow(a, n//2, p)
        return (temp * temp) % p

def n_permutations(n, a):
    p = 7 + pow(10, 9)
    ans = 1
    for i in range(n-a+1, n+1):
        ans = ans * i
        ans = ans % p
    return ans

def permutations(a):
    p = 7 + pow(10, 9)
    ans = 1
    for i in range(1, a+1):
        ans = ans * i
        ans = ans % p
    return ans

n, a, b = map(int,input().split())
p = 7 + pow(10, 9)

ans = modpow(2, n, p) - 1
ans = ans - ((n_permutations(n, a) * modpow(permutations(a), (p-2), p))%p)
ans = ans - ((n_permutations(n, b) * modpow(permutations(b), (p-2), p))%p)

print(ans%p)


Measured memory_bytes: 3064
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
inf = float("inf")
N, M, L = map(int, input().split())
graph = np.zeros((N, N))
for _ in range(M):
    A, B, C = map(int, input().split())
    graph[A-1][B-1] = C
    graph[B-1][A-1] = C
shortest_paths = shortest_path(csr_matrix(graph), directed=False, method="D")
graph = np.full((N, N), inf)
for i in range(N):
    for j in range(N):
        if shortest_paths[i][j] <= L:
            graph[i][j] = 1

Q = int(input())
def int_(num_str):
    return int(num_str) - 1

costs = shortest_path(csr_matrix(graph), directed=False, method="D")
for _ in range(Q):
    s, t = map(int_, input().split())
    print(int(costs[s][t])-1 if costs[s][t] != inf else -1)

Measured memory_bytes: 20444
#include <stdio.h>
#include <stdlib.h>
int main (void) {
	char str[20];
	int l = sizeof(str) / sizeof(char);
	int r = 999;
	gets(str);
	for (int i = 0; i < l - 2; i++) {
		char s[5] = {};
		sprintf(s, "%c%c%c", str[i], str[i + 1], str[i + 2]);
		if (abs(753 - atoi(s)) < r) {
			r = abs(753 - atoi(s));
		}
	}
	printf("%d\n", r);
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n,x;
    cin >>n>>x;
    int sum=0,mm=numeric_limits<int>::max();
    rep(i,n) {
        int mi;
        cin >> mi;
        sum+=mi;
        mm=min(mm,mi);
    }
    auto ans=n+(x-sum)/mm;
    out(ans)

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
#define rep(i,n) for(int i=0;i<(n);i++)  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LINF = (LLONG_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000000007

int main(){
  int n; cin >> n;
  vi table(n);
  vi ans;
  rep(i,n)  cin >> table[i];
  for(int j = n-1; j > 0; j -= 2)
    ans.pb(table[j]);
  
  if(n%2 == 1)
    ans.pb(table[0]);
  for(int j = n%2; j < n; j += 2)
    ans.pb(table[j]);
  for(int i = 0; i < n; i++){
    cout << ans[i];
    if(i != n-1)
      cout << " ";
    else
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
int n;
cin >> n;
int a,b;
a=n%10;n/=10;b=n%10;
if(a==9||b==9) cout <<"Yes"<<endl;
else cout <<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(str.equals("A")){
            System.out.println("T");
        } else if(str.equals("T")){
            System.out.println("A");
        } else if(str.equals("G")){
            System.out.println("C");
        } else if(str.equals("C")){
            System.out.println("G");
        }
    }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,k,s;
    in(n,k,s);
    rep(i,n){
        if(k){
            printf("%d ",s);
            k--;
        }else{
            if(s=1000000000){
                printf("%d ",s-1);
            }else{
                printf("%d ",s+1);
            }
        }
    }
    printf("\n");
}

Measured memory_bytes: 3740
from heapq import*
L,R=[],[]
B=t=0
Q,*E=open(0)
for e in E:
  if' 'in e:_,a,b=map(int,e.split());t^=1;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
  else:print(-L[0],B-L[0]*t)

Measured memory_bytes: 28652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int A = sc.nextInt();

		if (H % A != 0) {
			System.out.println(H / A + 1);
		} else {
			System.out.println(H / A);
		}

		sc.close();
	}
}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll count;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a>>b>>c;

	if(a<=b*c) cout<<"Yes";
	else cout<<"No";


	return 0;

}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m, L;
    cin >> n >> m >> L;
    yukari<pair<int, int>> g(n);
    yukari<int> dp(n, akari<int>(n, n + 1)), fuel(n, akari<int>(n));
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (L < c)
        {
            continue;
        }
        a--, b--;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
    }
    for (int s = 0; s < n; s++)
    {
        akane<tuple<int, int, int>> pq;
        dp[s][s] = 0;
        fuel[s][s] = L;
        pq.push(make_tuple(0, -L, s));
        while (!pq.empty())
        {
            int v, d, res;
            tie(d, res, v) = pq.top();
            res *= -1;
            pq.pop();
            if (d != dp[s][v])
            {
                continue;
            }
            for (const auto &p : g[v])
            {
                int nv, c;
                tie(nv, c) = p;
                if (dp[s][nv] < d || (dp[s][nv] == d && fuel[s][nv] >= res - c))
                {
                    continue;
                }
                if (res < c)
                {
                    dp[s][nv] = d + 1;
                    fuel[s][nv] = L - c;
                    pq.push(make_tuple(d + 1, c - L, nv));
                }
                else
                {
                    dp[s][nv] = d;
                    fuel[s][nv] = res - c;
                    pq.push(make_tuple(d, c - res, nv));
                }
            }
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (dp[s][t] == n + 1 ? -1 : dp[s][t]) << '\n';
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 2432
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(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 REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    long long N, K; cin >> N >> K;
    vector<int>A(N);
    rep(i, N)cin >> A[i];
    long long count = 0;
    rep(i, N)for (int j = i + 1; j < N;j++)if (A[j] < A[i])count++;
    count %= INF;
    count *= K;
    count %= INF;
    sort(A.begin(), A.end());
    vector<int>B(N);
    long long ans = 0;
    REP(i, N) {
        if (A[i - 1] != A[i])B[i] = i;
        else B[i] = B[i - 1];
        ans += B[i];
        ans %= INF;
    }
    long long a=(K* (K - 1) / 2) % INF;
    ans *= a;
    ans += count;
    ans %= INF;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int L, R, d;
    cin >> L >> R >> d;

    int ans = 0;
    FOR(i, L, R + 1) {
        if (i % d == 0) ans++;
    }

    print(ans);
    
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
    int N;

    cin >> N;
    
    unsigned long H[N];

    for ( int i; i < N; i ++ ) {
        cin >> H[i];
    }

    H[0] --;
    for ( int i = 1; i < N; i ++ ) {
        if ( H[i] -1 >= H[i-1] ) {
            H[i] --;
        } else if ( H[i] < H[i-1] ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
/*
さいころ

mapを使っているところは普通のサイコロとかなら配列で大丈夫
まぁ、せいぜいO(log24)なのでOKか

参考:
http://www.prefield.com/algorithm/misc/dice.html
*/
#include <bits/stdc++.h>
using namespace std;

//up(上),down(下),front(前),back(後ろ),right(右),left(左)
enum FACE{UP,DOWN,FRONT,BACK,RIGHT,LEFT};
template<typename T>
struct Dice{
    T var[6];
    map<pair<T,T>,int> M;
    vector<Dice> V;
    Dice(){}
    T& operator[](FACE f){return var[f];}
    Dice operator[](int idx){return V[idx];};
    Dice find(T up,T front){return V[ M[{up,front}] ];}
    int id(){return M[{var[FRONT],var[UP]}];}

    void rollR(){roll(UP,LEFT,DOWN,RIGHT);}
    void rollL(){roll(UP,RIGHT,DOWN,LEFT);}
    void rollU(){roll(UP,FRONT,DOWN,BACK);}
    void rollD(){roll(UP,BACK,DOWN,FRONT);}
    void rollT(){roll(FRONT,RIGHT,BACK,LEFT);}
    void rollH(){roll(FRONT,LEFT,BACK,RIGHT);}
    void roll(FACE a,FACE b,FACE c,FACE d){
        int tmp=var[a];
        var[a]=var[b];
        var[b]=var[c];
        var[c]=var[d];
        var[d]=tmp;
    }

    void allDice(){
        int cnt=0;
        V.resize(24);
        Dice d=*this;
        for(int k=0;k<6;(k&1?d.rollR():d.rollD()),k++){
            for(int i=0;i<4;d.rollT(),i++,cnt++){
                V[cnt]=d;
                M[{d[UP],d[FRONT]}]=cnt;
            }
        }
    }
};

signed main(){
    Dice<int> d;
    cin>>d[UP]>>d[FRONT]>>d[RIGHT]>>d[LEFT]>>d[BACK]>>d[DOWN];
    int N;
    cin>>N;
    d.allDice();
    while(N--){
        int u,f;
        cin>>u>>f;
        auto a=d.find(u,f);
        cout<<a[RIGHT]<<endl;
    }
}


Measured memory_bytes: 3096
N = int(input())
A = list(map(int, input().split()))
m = A[0]
c = 1000
for i, a in enumerate(A):
  if i == N-1:
    if a != m:
      c += c // m * (a - m)
    continue
  
  if a <= A[i+1]:
    continue
  
  c += c // m * (a - m)
  m = A[i+1]
print(c)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int n,m,i;
    cin>>n>>m;
    string a[n];
    f(i=0; i<n; i++)
    {
       cin>>a[i];
    }
    sort(a,a+n);
    f(i=0; i<n; i++)
    {
       cout<<a[i];
    }
    return 0;

}

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

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++)
    {
        if (2 * i + 4 * (X - i) == Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
        
    }
    
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;
int N;
ll A[100010];

int inf = 1e18;
struct edge{int to; ll cap;int rev;};
vector<edge> G[10010];
int level[10010];
int iter[10010];
void add_edge(int from, int to, ll cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> Q;
	level[s] = 0;
	Q.push(s);
	while(!Q.empty()){
		int v = Q.front(); Q.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to]<0){
				level[e.to] = level[v]+1;
				Q.push(e.to);
			}
		}
	}
}

ll dfs(int v,int t,ll f){
	if(v==t) return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(level[v]<level[e.to] && e.cap>0){
			ll d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(int s,int t){
	ll flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		ll f;
		while((f=dfs(s,t,inf))>0) flow += f;
	}
}

int main(){
	cin >> N;
	ll sum = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		if(A[i]<=0) add_edge(0,i,-A[i]);
		else{
			add_edge(i,N+1,A[i]);
			sum += A[i];
		}
	}
	for(int i=1;i<=N;i++){
		for(int j=i;j<=N;j++){
			if(j%i==0){
				add_edge(j/i,j,inf);
			}
		}
	}
	cout << sum-max_flow(0,N+1) << endl;
}

Measured memory_bytes: 640
N = int(input())
ss = []
for i in range(N):
    s = list(input())
    s.sort()
    ss.append(s)

ss.sort()
ans = 0
tmp = 1
for i in range(N-1):
    if ss[i] == ss[i+1]:
        tmp += 1
        if i == N-2:
            ans += (tmp * (tmp-1)) // 2
    else:
        ans += (tmp * (tmp-1)) // 2
        tmp = 1

print(ans)


Measured memory_bytes: 26304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	string S;
	cin >> S;
	N = S.length();
	ans = N;
	for (k = 1; k <= N-1; k++) {
		if (S[k-1] != S[k]) {
			ans = min(ans, max(k, N - k));
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
#include<stdio.h>
#define M 5
#define N 5

void ma(int a[M][N] ,int ans[]){
    int i,j,k,l,x,y,sum,max;

    sum=max=0;

    for(i=0;i<M;i++)
        for(j=0;j<N;j++)
            for(k=i;k<M;k++)
                for(l=j;l<N;l++){
                    sum=0;
                    for(x=i;x<=k;x++)
                        for(y=j;y<=l;y++)
                            sum=sum+a[x][y];
                    if(max<sum){
                        max=sum;
                        ans[0]=i;ans[1]=j;ans[2]=k-i+1;ans[3]=l-j+1;
                    }
                }
    /*
       int i,j,l,k,c,e=0,tem,tmp,sum=0,max=-30000,w=0,h=0,u=0,v=0;
       int b[M]={0};
       int d[M][N*(N+1)/2]={{0}};

       for(c=0;c<N;c++){
       for(l=c;l<N;l++){
       for(i=0;i<M;i++){
       if(l==c)d[i][e]=a[i][l];
       else d[i][e]=d[i][e-1]+a[i][l];
       }
       e++;
       }
       }
       for(l=0;l<e;l++){
       for(k=1;k<=M;k++){
       for(i=0,tem=0;i<k;i++)tem+=d[i][l];
       for(i=0;i+k<M;i++)b[i]=d[i+k][l]-d[i][l];
       for(i=1;i<M-k;i++)b[i]+=b[i-1];
       for(i=0;i<M-k;i++)b[i]+=tem;
       if(max<tem){
       max=tem;
       u=0;
       w=k;
       v=l;

       h=c;
       }
       for(i=0;i<M-k;i++){
       if(max<b[i]){
       max=b[i];
       u=i;
       w=k;
       v=l;
       h=c;
       }
       }
       }

       }
       for(i=0;v>=N;i++){
       v=v-N+i;
       }
       ans[0]=u+1;
       ans[1]=i;
       ans[2]=w;
       ans[3]=v+1;
       ans[4]=max;
       */
    /*puts("");
      for(i=0;i<M;i++){
      for(j=0;j<N;j++){
      printf("%4d ",a[i][j]);
      }puts("");
      }*/

}

int main(){
    int n,a[M][N],ans[4];
    int i,j,sum;
    scanf("%d",&n);
    while(n--){
        sum=0;
        for(i=0;i<M;i++){
            for(j=0;j<N;j++){
                scanf("%d",&a[i][j]);
                if(a[i][j]==0)a[i][j]=-1000;
            }
        }
        ma(a,ans);
        for(i=ans[0];i<ans[0]+ans[2];i++){
            for(j=ans[1];j<ans[1]+ans[3];j++){
                sum+=a[i][j];
            }
        }
        printf("%d\n",sum);
        //printf("%2d%2d%2d%2d\n",ans[0],ans[1],ans[2],ans[3]);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> nums;
  int num = 0;
  char prev = s[0];
  rep(i, n) {
    if (s[i] != prev) {
      prev = s[i];
      nums.push_back(num);
      num = 0;
    }
    if (s[i] == '0') num--;
    if (s[i] == '1') num++;
  }
  nums.push_back(num);
/*
  for (auto& v : nums) {
    cerr << v << " ";
  }
  cerr << endl;
*/
  int l = 0;
  int r = 0;
  int tmp = abs(nums[0]);
  int ans = 0;
  int num_0 = nums[0] < 0 ? 1 : 0;
  for (int l = 0; l < nums.size(); l++) {
    if (l > 0 && nums[l-1] < 0) num_0--;
    if (l > 0) tmp -= abs(nums[l-1]);
    while (r+1 < nums.size() && num_0 + (nums[r+1] < 0 ? 1 : 0) <= k) {
      r++;
      if (nums[r] < 0) num_0++;
      tmp += abs(nums[r]);
    }
//    cerr << "l: " << l << " r: " << r << "  tmp: " << tmp << endl;
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int h,heap[2000001];
void maxHeapify(int i){
  int l,r,largest;
  l=i*2;
  r=i*2+1;
  if(l<=h && heap[l]>heap[i]) largest=l;
  else largest=i;
  if(r<=h && heap[r]>heap[largest]) largest=r;
  if(largest!=i){
    swap(heap[i],heap[largest]);
    maxHeapify(largest);
  }
}
int main(){
  scanf("%d",&h);
  for(int i=1;i<=h;i++) scanf("%d",&heap[i]);
  for(int i=h/2;i>=1;i--) maxHeapify(i);
  for(int i=1;i<=h;i++) printf(" %d",heap[i]);
  printf("\n");
  return 0;
}
   


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=5*1e5+10;
const int mod=1e9+7;
int n,m,ans,delta,sum0;
int a[maxn],sum1[maxn],sum2[maxn],sum3[maxn],fac[maxn];
bool vis[maxn];
struct Tree_arry
{
	#define lowbit(x) (x&-x)
	int a[maxn];
	inline void add(int x,int k){for(int i=x;i<=n;i+=lowbit(i))a[i]+=k;}
	inline int query(int x){int res=0;for(int i=x;i;i-=lowbit(i))res+=a[i];return res;}
}tr;
signed main()
{
	//freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%lld",&n);
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=(fac[i-1]*i)%mod;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),vis[a[i]]=1;
	for(int i=1;i<=n;i++)sum1[i]=sum1[i-1]+(!vis[i]);//ÕýÏò 
	for(int i=n;i;i--)sum2[i]=sum2[i+1]+(!vis[i]);//·´Ïò 
	for(int i=1;i<=n;i++)sum3[i]=sum3[i-1]+(!a[i]);//0µÄ¸öÊý
	m=sum3[n]; 
	for(int i=1;i<=n;i++)if(!vis[i])sum0=(sum0+i-1)%mod;
	for(int i=1;i<=n;i++)
	{
		int res=0;
		if(a[i])
		{
			tr.add(a[i],1);
			res=(res+(a[i]-tr.query(a[i])+mod)%mod*fac[m]%mod)%mod;
			if(m)res=(res-sum3[i]*sum1[a[i]]%mod*fac[m-1]%mod+mod)%mod;
			delta=(delta+sum2[a[i]])%mod;
		}
		else
		{
			res=(res+(sum0-delta+mod)%mod*fac[m-1]%mod)%mod;
			if(m>=2)res=(res-m*(m-1)/2%mod*sum3[i-1]%mod*fac[m-2]%mod)%mod;
		}
		ans=(ans+res*fac[n-i]%mod)%mod;
	}
	printf("%lld",((ans+fac[m])%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
int64_t f(vector<int64_t>a,int k){
int N=a.size();
  if(N<k)
  return 20000000000;
  else if(k==1){
  return 0;
  }else {
  if(a.at(0)<a.at(1)){
  a.erase(a.begin());
    return f(a,k-1);
  }else{
  int64_t t=a.at(0)+1-a.at(1);
    vector<int64_t>b=a;
    vector<int64_t>c=a;
    b.erase(b.begin());b.at(0)+=t; c.erase(c.begin()+1);
    return min(t+f(b,k-1),f(c,k));
  }
  
  }
 
}
int main(){
int N,K;
  cin>>N>>K;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int64_t ans=f(a,K);
  cout<<ans<<endl;
   return 0;
}

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

long long N, W;
long long ans[110][100100];
long long w[110], v[110];

int main()
{
    cin >> N >> W;
    for(int i=0 ; i<N ; i++)
        cin >> w[i] >> v[i];
    for(int i=0 ; i<N ; i++)
        for(long long j=0 ; j<=W ; j++)
        {
            if(j - w[i] >= 0)
                ans[i + 1][j] = max(ans[i][j - w[i]] + v[i] , ans[i + 1][j]);

            ans[i + 1][j] = max(ans[i + 1][j] , ans[i][j]);
        }
    cout << ans[N][W];
    return 0;
}

Measured memory_bytes: 79360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int i,j;
  //  dic_t dic[200000];
  int ii[100];
  int ilen[100];
  int min,max;
  int len,flg;
  int cnt,maxcnt;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d\n",&ii[i]);
  }
  qsort(ii, len, sizeof(int), compare_int);
  for(i=0;i<len;i++){
    //    printf("%d %d %d\n",i,ii[i],ii[i]);
  }
  min = ii[0];
  max = ii[len-1];
  //      printf("min %d  max %d\n",min,max);
  if(max == min){
    printf("0\n");
    return 0;
  }
  for(i=0;i<=max-min;i++){
    ilen[i]=0;
    for(j=0;j<len;j++){
      ilen[i] += pow((ii[j] - i),2);  
    }
  }
  qsort(ilen, max-min+1, sizeof(int), compare_int);
  for(i=0;i<=max-min;i++){
//    printf("%d %d %d\n",i,ilen[i],ilen[i]);
  }
  printf("%d\n",ilen[0]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
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; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int h,w; cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h)rep(j,w) cin >> a.at(i).at(j);
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    dp.at(0).at(0) = 1;
    for(int i = 1; i < w; i++) dp.at(0).at(i) = a.at(0).at(i) == '.'? dp.at(0).at(i-1) : 0;
    for(int i = 1; i < h; i++) dp.at(i).at(0) = a.at(i).at(0) == '.'? dp.at(i-1).at(0) : 0;

    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            dp.at(i).at(j) = a.at(i).at(j) == '.'? (dp.at(i-1).at(j) + dp.at(i).at(j-1))%mod : 0;
        }
    }
    cout << dp.at(h-1).at(w-1) << endl;
    return 0;   

}


Measured memory_bytes: 9088
def main():
    N, K = map(int, input().split())
    if K % 2 == 1:
        d = N // K
        return d * d * d
    else:
        d = N // K
        d = N // (K // 2)
        d1 = N // K
        d2 = d - d1
        return d1*d1*d1 + d2*d2*d2

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 2940
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
    string s;

    cin >> s;
    int cnt = 0;
    int max = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
            if (max < cnt) {
                max = cnt;
            }
        }
        else {
            cnt = 0;
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextString(scanner)
	b := getNextString(scanner)
	c := getNextString(scanner)
	ans := 0
	for i := 0; i < n; i++ {
		ans += cnt(a[i], b[i], c[i]) - 1
	}

	fmt.Fprintln(writer, ans)
}

func cnt(a, b, c byte) int {
	m := map[byte]bool{}
	m[a] = true
	m[b] = true
	m[c] = true

	return len(m)
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  bool flg = false;
  for (int i = 0; i * 4 <= n; ++i) {
    for (int j = 0; i * 4 + j * 7 <= n; ++j) {
      if (i * 4 + j * 7 == n) {
        flg = true;
        break;
      }
    }
  }

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void a_candy_distribution_again(void) {
	int n, x;
	int a[100];
	int cnt = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++)cin >> a[i];

	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (i == n - 1){
			cnt = (x==a[i])?cnt+1:cnt;
		}
		else {
			cnt = (x >= a[i]) ? cnt + 1 : cnt;
		}
		x -= a[i];
		if (x <= 0)break;
	}
	cout << cnt << endl;
}

int main()
{
	a_candy_distribution_again();
    return 0;
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<int>pn(n);
    for(int i = 0; i < n; i++){
        cin >> pn.at(i);
    }
    bool ck = false;
    bool ng = false;
    for(int i = 0; i < n; i++){
        if(pn.at(i) == i + 1){
            continue;
        }
        else if(!ck){
            swap(pn.at(i), pn.at(pn.at(i) - 1));
            ck = true;
        }
        else{
            ng = true;
        }
    }
    if(ng){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    solve();
    return 0;
}



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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            WriteLine(ReadLine().Count(c => c == '1'));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26224
s = list(input())
t = list(input())
pair = []
li =[]
ans = "Yes"

for i in range(len(s)):
    if [s[i],t[i]] in li:
        pass
    else:
        li.append([s[i],t[i]])

def check2(pair,i,li):
    for j in range(len(pair)):
        if (li[i][0]==pair[j][0] and li[i][1]!=pair[j][1])or(li[i][0]!=pair[j][0] and li[i][1]==pair[j][1]):
            return False
    return True

for i in range(len(li)):
    if check2(pair,i,li):
        pair.append([li[i][0],li[i][1]])
    else:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 6704
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr ll MOD = 1000000007;

ll modpow(ll n, ll r, ll mod) {
    if(r == 0) return 1;
    if(n == 0) return 0;
    if(r % 2 == 0) {
        ll tmp = modpow(n, r / 2, mod);
        return tmp * tmp % mod;
    }
    else {
        return n * modpow(n, r - 1, mod) % mod;
    }
}

int main(){
    Stream io;

    int N;
    io.read(N);

    vector<int> D(N);
    vector<int> E(N);

    for(int i = 0; i < N; i++){
        io.read(D[i], E[i]);
    }

    string ans = "No";
    for(int i = 0; i < N - 2; i++){
        if(D[i] == E[i] && D[i + 1] == E[i + 1] && D[i + 2] == E[i + 2]){
            ans = "Yes";
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3632
N = int(input())
H = list(map(int, input().split()))

current_max_H = -1
for i in range(N):
    if H[i] > current_max_H:
        current_max_H = H[i]
    if H[i] >= current_max_H - 1:
        continue
    else:
        print("No")
        break

else:
    print("Yes")


Measured memory_bytes: 14252
a,b = map(int,input().split())
c1,c2,mx1,mx2 = (".","#",a,b) if a < b else ("#",".",b,a)
grid = [[c1]*100 for _ in range(100)]
cnt1 = 1
cnt2 = 0   

for i in range(0,100,4):
    for j in range(0,100,4):
        if cnt1 < mx1:
            for k in range(i,i+3):
                for l in range(j,j+3):
                    if k == i+1 and l == j+1: continue
                    grid[k][l] = c2
            cnt1 += 1
            cnt2 += 1
        elif cnt2 < mx2:
            grid[i][j] = c2
            cnt2 += 1
        else:
            break

print(100,100)
for i in range(100): print("".join(grid[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, t, T, x, y, sum, cnt;
ll dp[1002][20005], ans;
struct data {
  int w, s, v;
  bool operator < (const data& rhs) const {
    return w + s < rhs.w + rhs.s;
  }
} a[1005];
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  FOR(i, 1, n) {
    cin >> a[i].w >> a[i].s >> a[i].v;
  }
  sort(a+1, a+n+1);
  FOR(i, 1, 20000) dp[0][i] = -1e15;
  FOR(i, 1, n) {
    FOR(j, 0, 20000) {
      dp[i][j] = dp[i-1][j];
    }
    FOR(j, 0, a[i].s) {
      if (j + a[i].w <= 20000) dp[i][j+a[i].w] = max(dp[i][j+a[i].w], dp[i-1][j] + a[i].v);
    }
  }
  FOR(i, 0, 20000) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 160084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<cstring>
#define INF 1000000000
using namespace std;
string s,t;
int yes=1;
int main(){
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
            yes=0;
    if(yes)
        cout<<"Yes";
    else
        cout<<"No";
    
        
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = k; i < n; i++) {
        if (a[i-k] < a[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4412
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = [int(input()) for _ in range(5)]
    b = min(a)
    if n%b==0:
        print(n//b+4)
    else:
        print(n//b+5)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	int n;
	cin >> n;
	vector<int> t(n);
	for(int i=0; i<n; i++) cin >> t[i];

	int m;
	cin >> m;
	vector<int> p(m);
	vector<int> x(m);
	for(int i=0; i<m; i++) cin >> p[i] >> x[i];


	int sum = accumulate(t.begin(), t.end(), 0);

	for(int i=0; i<m; i++){
		int ans = sum - t[ p[i]-1 ] + x[i];
		cout << ans << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K;
    string S;
    cin>>S>>K;

    long long int end=1000000;
    end = end * end *end;

    if(S.size()==1){
      cout<<S[0]<<endl;
      return 0;
    }

    if(S[0]!='1')
    {
  cout<<S[0]<<endl;
  return 0;
  }

    for(int i=0;i<S.size();i++){
      if(S[i]!='1'){
        end = i+1;
        break;
      }
    }

    //cout<<end<<endl;
    if(end<=K){
      cout<<S[end-1]<<endl;
    }
    else{
      cout<<1<<endl;
    }

    return 0;

}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))

cnt = 0
flag = 0

for i in range(n - 1):
    if flag == 0:
        if a[i + 1] - a[i] > 0:
            flag = 1
        elif a[i + 1] - a[i] < 0:
            flag = -1
    elif flag == 1 and a[i + 1] - a[i] < 0:
        cnt += 1
        flag = 0
    elif flag == -1 and a[i + 1] - a[i] > 0:
        cnt += 1
        flag = 0
print(cnt + 1)

Measured memory_bytes: 62704
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    var ans = 0

    for (i in 1..n step 2) {
        var cnt = 0
        for (j in 1..200) {
            if (i % j == 0) cnt++
            if (j == i) break
        }

        if (cnt == 8) ans++
    }

    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33492
"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const len = input.split("\n")[0];
const ary = input.split("\n")[1].split("").map(e => [e, 0]);
let count = 0;
for (let a of ary.reverse()) {
    if (a[0] === "E") { count ++ };
    a[1] = count;
}
count = 0;
for (let a of ary.reverse()) {
    if (a[0] === "W") { count ++ };
    a[1] += count - 1;
}

console.log(ary.reduce((p, c) => p[1] > c[1] ? c : p)[1]);

Measured memory_bytes: 69264
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
//typedef long double ld;
typedef pair<int,int>pii;
//const ll mod= 998244353;
//long double PI = acosl(-1);
//const ll infl = 1e15;
const int inf = 2e9;
const int nmax = 1e5+5;
//const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

void NA(){
    cout<<"No", exit(0);
}
void HO(){
    cout<<"Yes\n", exit(0);
}

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

    int n;
    cin>>n;
    vector<int>v(n);
    for(int &x : v) cin>>x;
    map<int, int>cnt;
    for(int x : v) cnt[x]++;

    vector<int>v2 = v;
    sort(v2.begin(), v2.end());
    v2.erase(unique(v2.begin(), v2.end()), v2.end());

    if(v2.size()==1 and v2[0]==0) HO();
    else if(v2.size()==1) NA();
    else if(v2.size()==2){
        if(v2[0]!=0) NA();
        if(n%3!=0) NA();
        if(cnt[0]==n/3) HO();
        NA();
    }
    else if(v2.size()==3){
        int jor = 0;
        int N = n/3;
        for(int x : v2) jor^=x;
        bool thikase = true;
        for(int x : v2) if(cnt[x]!=N) thikase = false;
        if(!jor and thikase) cout<<"Yes\n";
        else cout<<"No\n";
    }
    else NA();
}


Measured memory_bytes: 4480