akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5&&b==5&&c==7) printf("YES\n");
	else if(a==5&&b==7&&c==5) printf("YES\n");
	else if(a==7&&b==5&&c==5) printf("YES\n");
	else printf("NO\n");                                                                         \
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int x, y ,z;
	cin >> x >> y >> z;
	cout << (x <= z && z <= y ? "Yes" : "No") << endl;
}



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

int main(){
	ll n, a, b; cin >> n >> a >> b;
	if((b-a)%2 == 0){
		cout << (b-a)/2 << endl;
	}else{
		cout << min(((a+b)/2), ((2*n-a-b)/2 + 1)) << endl;
	}
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int now = 0;
  while(1) {
    if (now == 0) {
      if (a.size() == 0) break;
      now = a[0] - 'a';
      a = a.substr(1);
    } else if (now == 1) {
      if (b.size() == 0) break;
      now = b[0] - 'a';
      b = b.substr(1);
    } else {
      if (c.size() == 0) break;
      now = c[0] - 'a';
      c = c.substr(1);
    }
  }
  cout << (char)(now + 'A') << endl;
  return 0;
}

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

using namespace std;

typedef long long LL;

#define MAX_N 100005
#define MAX_Q 100005

int N;
string S[MAX_N];
int Q;
int K[MAX_Q];
string P[MAX_Q];

void input()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> S[i];
  }
  cin >> Q;
  for (size_t i = 0; i < Q; i++) {
    cin >> K[i] >> P[i];
  }
}

string SS = "";

class Node{
public:
  Node()
  {
    term = 0;
    for (size_t i = 0; i < 26; i++) {
      nextNode[i] = NULL;
    }
    memset(edgeCnt, 0, sizeof(edgeCnt));
  }

  void addString(const string &S, int pos, int _term)
  {
    if(pos < 0 || S.length() < pos){
      return;
    }

    if(S.length() == pos){
      term = _term;
      return;
    }

    if(nextNode[S[pos] - 'a'] == NULL){
      nextNode[S[pos] - 'a'] = new Node();
    }

    edgeCnt[S[pos] - 'a']++;
    nextNode[S[pos] - 'a']->addString(S, pos+1, _term);

  }

  Node* eraseEdge()
  {
    Node* ret = NULL;
    int cnt = 0;
    bool update = true;

    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        cnt++; ret = nextNode[i];
        auto it = nextNode[i]->eraseEdge();
        if(it != NULL){
          update = false;
          delete(nextNode[i]);
          nextNode[i] = it;
        }
      }
    }

    if(cnt == 1 && term == 0 && update){
      return ret;
    }
    else{
      return NULL;
    }

  }

  int solve(const string &P, const string &S, int ret = 0, int pos = 0)
  {
    if(pos == S.length()){
      return ret + 1;
    }

    if(term > 0){
      ret++;
    }

    for (size_t i = 0; i < P.length(); i++) {
      if(P[i] == S[pos]){
        return nextNode[S[pos] - 'a']->solve(P, S, ret, pos+1);
      }
      else{
        ret += edgeCnt[P[i] - 'a'];
      }
    }
  }

  void debugPrint(string p = "")
  {
    if(term > 0){
      cout << p << endl;
    }
    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        char c = 'a' + i;
        nextNode[i]->debugPrint(p + c);
      }
    }
  }

  bool updateS()
  {
    bool ret = false;
    if(term > 0){
      if(S[term-1] != SS){
        ret = true;
      }
      S[term-1] = SS;
    }
    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        char c = 'a' + i;
        SS += c;
        ret |= nextNode[i]->updateS();
        SS.pop_back();
      }
    }
    return ret;
  }

  int term;
  Node* nextNode[26];
  int edgeCnt[26];

}Root;

int main()
{
  input();

  for (size_t i = 0; i < N; i++) {
    Root.addString(S[i], 0, i+1);
  }

  do{
    Root.eraseEdge();
  }while(Root.updateS());

  for (size_t q = 0; q < Q; q++) {
    //cerr << "*** " << S[K[q]-1] << endl;
    cout << Root.solve(P[q], S[K[q]-1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 156156
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    print(min(a+b,b+c,c+a))
    return

#B
def B():
    def check(s):
        x = len(s)
        if x % 2:
            return False
        if s[:x // 2] == s[x // 2:]:
            return True
    s = S()
    for i in range(1,len(s)):
        if check(s[: - i]):
            print(len(s) - i)
            return

#C
def C():
    II()
    a = LI()
    ans1 = a[-1::-2]
    ans2 = a[-2::-2][::-1]
    ans = ans1 + ans2
    print(*ans)
    return

#D
def D():
    def power_func(a, b):
        """ a^b mod p を求める """
        """ bを2進数分解して高速累乗 """

        if b == 0: return 1
        if b % 2 == 0:
            d = power_func(a, b // 2)
            return d * d % mod
        if b % 2 == 1:
            return (a * power_func(a, b - 1)) % mod

    def combination_mod(n, k):
        """ power_funcを用いて(nCk) mod p を求める """ 
        """ nCk = n!/((n-k)!k!)を使用 """

        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        a = factorial[n]
        b = invfactorial[k]
        c = invfactorial[n - k]
        return (a * b * c) % mod

    n = II() + 1
    a = LI()
    d = [0] * n
    for i in range(n):
        if d[a[i]]:
            a = d[a[i]] - 1
            c = n - i - 1
            break
        d[a[i]] = i + 1
    factorial = [1] * (n + 1)
    invfactorial = [1] * (n + 1)
    for i in range(1, n + 1):
        factorial[i] = (factorial[i - 1] * i) % mod
        invfactorial[i] = power_func(i, mod - 2) * invfactorial[i-1] % mod
    for i in range(1, n + 1):
        ans = combination_mod(n, i) - combination_mod(a + c, i - 1)
        print(ans%mod)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 68128
import numpy as np
from scipy.sparse.csgraph import shortest_path
import collections

def main():
    n, x, y = map(int, input().split(" "))
    graph = np.zeros([n, n])
    for i in range(n-1):
        graph[i, i+1] = 1
        graph[x-1, y-1] = 1
    
    s_path = shortest_path(graph, method='D', directed=False)
    
    c = collections.Counter(s_path.flatten())
    for k in range(n-1):
        k += 1
        ans = int(c[k] / 2)
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 146472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<vector<int>> g(n);
    rep(i,n){
        int a;cin >> a;
        a--;
        g[i].push_back(a);
    }
    vector<int> d(n,inf);
    d[0]=0;
    stack<int> st;
    st.push(0);
    while(!st.empty()){
        int p=st.top();
        st.pop();
        for(int x:g[p]){
            if(d[x]==inf){
                d[x]=d[p]+1;
                st.push(x);
            }
        }
    }
    cout << (d[1]!=inf?d[1]:-1) << endl;
}

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

#define ll long long int
using namespace std;
int main()
{
   ll n,l,r,sum=0;
   cin>>n;
   for(int i=0;i<n;i++ )
   {
       cin>>l>>r;
       sum +=(r-l+1);
   }
   cout<<sum<<endl;
    return 0;
}


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

class UnionFind{
    int N;
    vector<int> par;
    vector<int> rank;
    public:
    UnionFind(int N):N(N),par(N),rank(N,0){iota(par.begin(),par.end(),0);}
    int find(int x);
    void unite(int x,int y);
    bool same(int x,int y){return find(x)==find(y);}
};

int UnionFind::find(int x){
    if(par[x]==x) return x;
    return par[x]=find(par[x]);
}
void UnionFind::unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y) return;
    if(rank[x]>=rank[y]){
        if(rank[x]==rank[y]) rank[x]++;
        par[y]=x;
    }else{
        par[x]=y;
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    UnionFind u(n);
    for(int i=0;i<q;i++){
        int com,x,y;
        cin>>com>>x>>y;
        if(com){
            cout<<u.same(x,y)<<endl;;
        }
        else{
            u.unite(x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 3200
while line = gets
  hit = 0
  blow = 0
  a = line.chomp.split(" ").map(&:to_i)
  b = gets.chomp.split(" ").map(&:to_i)
  4.times do |i|
    if a.index(b[i])
      if a[i] == b[i]
        hit += 1
      else
        blow += 1
      end
    end
  end
  puts "#{hit} #{blow}"
end

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

const int maxn=100+10;
int h,w;
int n,a[10000+10];
int clr[maxn][maxn];

void dfs(int i,int r,int c,bool flag){
    if(a[i]==0) i++;
    if(r>h) return;
    if(c<1) {r++;c=1;flag=true;}
    if(c>w) {r++;c=w;flag=false;}
    clr[r][c]=i;a[i]--;
    c+=(flag)?1:-1;
    dfs(i,r,c,flag);
}

int main(void){
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    memset(clr,0,sizeof(clr));
    dfs(1,1,1,true);
    for(int r=1;r<=h;r++){
        for(int c=1;c<=w;c++){
            cout<<clr[r][c]<<(c!=w?" ":"");
        }
        cout<<endl;
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    int maxi = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a < maxi) {
            cout << "No" << endl;
            return 0;
        }
        maxi = max(maxi, a - 1);
    }
    cout << "Yes" << endl;

    return 0;
}

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


int main(){
    int N, M, m[100001];
    cin >> N >> M;
    for(int i=0; i<M; i++) cin >> m[i];
    m[M] = N+1;

    vector<int> intervals;
    for(int i=0; i<M; i++) intervals.push_back(m[i+1] - m[i] - 1);
    sort(intervals.begin(), intervals.end());

    int loss[100001];
    int now = m[0] - 1;
    int num = 0;
    for(int l=N; l>0; l--){
        while(intervals.size() > 0 && intervals.back() >= l){
            intervals.pop_back();
            num++;
        }
        now += num;
        loss[l] = -now;
    }
    int Q;
    cin >> Q;
    while(Q--){
        int l;
        cin >> l;
        int ans = lower_bound(loss, loss+N+1, -l) - loss;
        if(ans == 0) ans = 1;
        if(ans == N+1) ans = -1;
        cout << ans << endl;
    }
}



Measured memory_bytes: 4268
/*	ex5_4
	suzuto	*/

#include <stdio.h>
#define  LIMIT 10

int main(void) {
  char word[LIMIT]; /*変数の宣言*/
  char *w_ptr, ins;
  int max_count = 0, count = 0, i;

  scanf("%s", &word); /*調べる文字列を入力*/
  w_ptr = &word; /*文字列の最初の要素のアドレスを記憶*/
  for(i = 0; i < LIMIT + 1; i++){
    ins = *(w_ptr++); /*注目する要素を一時記憶*/
    if(ins == '\0'){ /*文字の終端を判定*/
      break;
    }
    if(ins == 'A'||ins == 'C'||ins == 'G'||ins == 'T'){ /*insが'A','C','G','T'のいずれかに含まれるか判定*/
      count++; /*含まれていたのでカウントを継続*/
    }else{
      if(max_count < count){ /*最長の部分文字列か判定*/
        max_count = count; /*答えを更新*/
      }
      count = 0; /*countを初期化*/
    }
  }
  if(max_count < count){ /*最後に更新されなかった時*/
    max_count = count; /*答えを更新*/
  }
  printf("%d\n", max_count);/*結果を出力*/
  return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<int>);
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        a.pb(tmp);
    }
    ll ans = 0;
    REP(i, n - 1){
        if(a[i] + a[i + 1] <= x){
            continue;
        }else{
            ans += a[i + 1] + a[i] - x;
            if(a[i] <= x){
                a[i + 1] -= a[i + 1] + a[i] - x;
            }else{
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	vvmint dp(N + 1, vmint(N + 1, 0)), rdp(N + 1, vmint(N + 1, 0));
	dp[0][0] = 1;
	rep(j, N + 1)rdp[0][j] = 1;

	repn(i, N)for (ll j = i; j <= N; j++) {
		dp[i][j] = rdp[i - 1][j];
		rdp[i][j] = rdp[i][j - 1] + dp[i][j];
	}

	mint ans = rdp[K - 1][N - 1];
	if (N > K)ans *= pw(2, N - K - 1);
	cout << ans << endl;
}

Measured memory_bytes: 66072
#include <stdio.h>

int main(int argc, char const *argv[]) {
  char arr[100001];
  char com = '0';
  int i,count1=0,count2=0;

  scanf("%s", arr);

  for (i = 0; arr[i] != '\0'; i++) {
    if (com != arr[i]) {
      count1++;
    }
    if (com == '0') {
      com = '1';
    } else {
      com = '0';
    }
  }

  com = '1';

  for (i = 0; arr[i] != '\0'; i++) {
    if (com != arr[i]) {
      count2++;
    }
    if (com == '0') {
      com = '1';
    } else {
      com = '0';
    }
  }

  if (count1 < count2) {
    printf("%d\n",count1);
  } else {
    printf("%d\n",count2);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

ll MOD=1000000007;
ll fac[2000010], inv[2000010], finv[2000010];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2000010; ++i){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll N, M, K;
	cin >> N >> M >> K;
	COMinit();
	ll r=((N-1)*N*(N+1)/6)%MOD, c=((M-1)*M*(M+1)/6)%MOD;
	for(int i=0; i<2; ++i){
	    r=(r*M)%MOD;
	    c=(c*N)%MOD;
	}
	cout << (((r+c)%MOD)*COM(N*M-2, K-2))%MOD << endl;
	return 0;
}


Measured memory_bytes: 47232
from collections import Counter
from itertools import combinations

N = int(input())
ctr = Counter()
for i in range(N):
    s = input()
    ctr[s[0]] += 1

ans = 0
for ptn in combinations('MARCH', 3):
    tmp = 1
    for c in ptn:
        tmp *= ctr[c]
    ans += tmp
print(ans)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;

namespace _1173
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == ".") break;
                Stack<char> kakko = new Stack<char>();
                bool flag = true;
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '(' || s[i] == '[') kakko.Push(s[i]);
                    else if (s[i] == ')' || s[i] == ']')
                    {
                        if (kakko.Count == 0) flag = false;
                        else
                        {
                            char c = kakko.Pop();
                            if ((c != '(' && s[i] == ')') || (c != '[' && s[i] == ']')) flag = false;
                        }
                    }
                }
                Console.WriteLine(flag && kakko.Count == 0 ? "yes" : "no");
            }
        }
    }
}


Measured memory_bytes: 9900
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[100][105];
int dp[105][105];

void solve()
{
    int h, w;
    scanf("%d%d", &h, &w);
    int i, j;
    for (i = 0; i < h; i++) {
        scanf("%s", str[i]);
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (i == 0 && j == 0) {
                dp[i][j] = (str[i][j] == '#' ? 1 : 0);
            }
            else {
                dp[i][j] = INF;
                if (i > 0) {
                    dp[i][j] = MIN(dp[i][j], dp[i - 1][j] + (str[i][j] == str[i - 1][j] ? 0 : 1));
                }
                if (j > 0) {
                    dp[i][j] = MIN(dp[i][j], dp[i][j - 1] + (str[i][j] == str[i][j - 1] ? 0 : 1));
                }
            }
        }
    }
    int ans = dp[h - 1][w - 1] + (str[h - 1][w - 1] == '#' ? 1 : 0);
    printf("%d\n", ans / 2);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;

int n;
vector<P>graph[100010];
int dist[100010];

void dfs(int x, int y, int z) {
	dist[x] = z;
	for (P p : graph[x]) {
		if (p.first != y) {
			dfs(p.first, x, z + p.second);
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	rep(i, n - 1) {
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		w = w % 2;
		graph[u].push_back({ v,w });
		graph[v].push_back({ u,w });
	}
	dfs(0, -1, 0);
	rep(i, n) {
		cout << dist[i] % 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 10240
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e5 + 20;



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

    long long a, b;
    cin >> a >> b;
    if(b == 1) cout << 0 << endl;
    else cout << (b - 1 - 1) / (a - 1) + 1 << endl;

    return 0;
}











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


int main() {
    string S;
    cin>>S;
    if(S.size()%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    rep(i,S.size()){
        if(i%2==0&&S[i]!='h'){
            cout<<"No"<<endl;
            return 0;
        }
        else if(i%2!=0&&S[i]!='i'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

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

int main()
{
    long long int k,a,b,i;
    cin >> k >> a >> b;
    int cnt=0;
    for(i=a ; i<=b ; i++)
    {
        if(i%k==0)
        {
            cout << "OK" << endl;
            break;
        }
        else
            continue;
    }
    if((i-1)==b)
    {
        cout << "NG" << endl;
    }

    return 0;
}


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

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

#define MAX_N 100000
#define MAX_Q 100000

int n, q, l[MAX_N], r[MAX_N];
std::string s;

int dp[MAX_N + 1];

int main() {
  std::cin >> n >> q >> s;
  for(int i = 0; i < q; ++i) {
    std::cin >> l[i] >> r[i];
  }

  dp[2] = (s[0] =='A' and s[1] == 'C') ? 1 : 0;
  for(int i = 3; i <= n; ++i) {
    if(s[i - 2] == 'A' and s[i - 1] == 'C') {
      dp[i] = dp[i - 1] + 1;
    } else {
      dp[i] = dp[i - 1];
    }
  }

  for(int i = 0; i < q; ++i) {
    int ans = dp[r[i]] - dp[l[i] - 1];
    if(s[l[i] - 2] == 'A' and s[l[i] - 1] == 'C') --ans;
    std::cout << ans << std::endl;
  }
}

Measured memory_bytes: 2176
import Data.List
import Data.Char
main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    ds<-map read.words<$>getLine::IO[Int]
    print.head $ dropWhile (chk ds) [n..]

chk ds n = any (flip elem ds.digitToInt) $ show n

Measured memory_bytes: 892
#include<stdio.h>
int S[20];
int A[200];
int n;


int solve(int i,int m){
    if (m==0) return 1;
    if(i >= n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-S[i]);
    return res;
}

int main(){
    int q,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&A[i]);
        x=solve(0,A[i]);
    if(x==1) printf("yes\n");
    if(x==0) printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int k=in.nextInt();
    long ar[]=new long[n];
    for(int i=0;i<n;i++)
    ar[i]=in.nextLong();
    int min=n-k;
    min=Math.max(0,min);
    long ans=0;
    for(int i=min;i<=n;i++)
    {
      for(int j=0;j<n;j++)
      {
        int e=j+i-1;
        if(e>=n)
        break;
        int done=n-i;
        int left=k-done;
        List<Long> li=new ArrayList<>();
        long sum=0;
        for(int kk=0;kk<j;kk++)
        {
        li.add(ar[kk]);
        sum+=ar[kk];
        }
        for(int kk=e+1;kk<n;kk++)
        {
        li.add(ar[kk]);
        sum+=ar[kk];
        }
        Collections.sort(li);
        int s=0;
        while(left-->0&&s<li.size()&&li.get(s)<0)
        {
          sum-=li.get(s);
          s++;
        }
        ans=Math.max(ans,sum);
      }
    }
    System.out.println(ans);

  }
}


Measured memory_bytes: 24916
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		for(int i=0; i<s.length(); i++){
			if(i%2==0){
				if(s.charAt(i)=='L'){
					System.out.println("No");
					return;
				}
			}else{
				if(s.charAt(i)=='R'){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

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)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  vl a(N);
  int c0,c1,c2;
  c0=c1=c2=0;
  rep(i,N){
    cin >> a[i] ;
    if(a[i]%2) c0++;
    else if(a[i]%4==0) c2++;
    else c1++;
  }
  if(c1==N) cout << "Yes" << endl;
  else if(c2==0) cout << "No" << endl;
  else if(c1==0){
    if(c0<=c2+1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if(c0>c2) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if(0 < a && a <= b) printf("Positive\n");
	else if(a <= b && b < 0) {
		if((b - a + 1) % 2 == 0) printf("Positive\n");
		else printf("Negative\n");
	}
	else printf("Zero\n");
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VI check(n+1, 0);
  VB flg(n+1, false);
  VI p(m);
  VS s(m);
  REP(i, m) cin >> p[i] >> s[i];
  int ac = 0, wa = 0;
  REP(i, m)
  {
    if (s[i] == "AC")
    {
      if (!flg[p[i]]) flg[p[i]] = true;
    }
    else
    {
      if (!flg[p[i]]) check[p[i]]++;
    }
  }
  REP(i, n+1)
  {
    if (flg[i])
    {
      ac++;
      wa += check[i];
    }
  }
  cout << ac << " " << wa << endl;

  return 0;
}


Measured memory_bytes: 6528
def dfs(n, m, s):
  if n == N:
    return 1 if s == S else 0
  ans = 0
  for i in range(m, 10):
    ans += dfs(n + 1, i + 1, s + i)
  return ans;

while 1:
  N, S = map(int, raw_input().split())
  if not N:
    break
  print dfs(0, 0, 0)

Measured memory_bytes: 4208
// 蟻本: 例題 2-1-1　部分和問題 の類題
/*
 与えられたのが 1234 のときは
 1234,
 1 +234, 1 +2 +34, 1 +2 +3 +4,
 12 +34, 12 +3 +4,
 123 +4
 の合計が聞かれてる
 ↑を
 [1] 234, [1, 2] 34, [1, 2, 3] 4
 [12] 34, [12, 3] 4,
 [123] 4
 のように+で区切り終えたものを配列で管理し,
 まだ+で区切る余地のあるものを文字列で扱いました(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
 */

func dfs(_ s: String) {
    if s.count==0 { return }    // ベースケース(・・？) (文字列が空("")なら終了)
    
    for i in 1..<s.count {
        let idx: String.Index = s.index(s.startIndex, offsetBy: i)  // +で区切る場所を指定
        seq.append(Int(s[..<idx])!) // +で区切り終わった部分を記憶
        res += seq.reduce(0, +) + Int(s[idx...])!   // 計算, .reduce(0, +)で配列の和を計算できる
        
        dfs(String(s[idx...]))  // 再帰呼び出し
        seq.removeLast()
    }
}

let S: String = readLine()!
var seq: [Int] = []
var res = Int(S)!

dfs(S)  // 再帰スタート٩(๑❛ᴗ❛๑)۶
print(res)  // (๑•ૅㅁ•๑)

Measured memory_bytes: 8120
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#define pi 3.14159265358979

using namespace std;

int main(void) {
	int n;
	cin >> n;
	int lim = 2;
	for (int i = 0; i < n; ++i) {
		lim += 3*(lim-1);
	}
	vector< pair<double,double> > p(lim,{-1,-1});
	p[0] = {0,0};
	p[lim-1] = {100,0};
	for (int count = 0; count < n; ++count) {
		int ind = 0;
		while (ind < lim-1) {
			if (p[ind].first >= 0) {
				int next = ind+1;
				while (p[next].first < 0) {
					++next;
				}
				int mid = (next+ind)/2;
				int left = (ind+mid)/2;
				int right = (next+mid)/2;
				p[left] = {(2*p[ind].first+p[next].first)/3,(2*p[ind].second+p[next].second)/3};
				p[right] = {(p[ind].first+2*p[next].first)/3,(p[ind].second+2*p[next].second)/3};
				int neg = 1;
				if (p[ind].first > p[left].first) {
					neg = -1;
				}
				double dis = sqrt(pow((p[right].first-p[left].first),2)+pow(p[right].second-p[left].second,2));
				double rad = atan((p[left].second-p[ind].second)/(p[left].first-p[ind].first));
				p[mid] = {p[left].first-(neg*dis*cos(pi-(rad+(pi/3)))),p[left].second+(neg*dis*sin(pi-(rad+(pi/3))))};
				ind = next-1;
			}
			++ind;
		}
	}
	for (int i = 0; i < lim; ++i) {
		cout << setprecision(20) << fixed << p[i].first << " ";
		cout << setprecision(20) << fixed << p[i].second << endl;
	}
	return 0;
}



Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  string s;
  char tmp;
  ll k, cnt = 0;
  cin >> s >> k;
  for (char x : s) {
    if (x == '1') {
      cnt++;
    } else {
      tmp = x;
      break;
    }
  }
  if (k <= cnt) {
    cout << 1 << endl;
  } else {
    cout << tmp << endl;
  }
  return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b;
  cin >> a >> b;

  if (a % 3 == 0) cout << "Possible" << "\n";
  else if (b % 3 == 0) cout << "Possible" << "\n";
  else if ((a + b) % 3 == 0) cout << "Possible" << "\n";
  else cout << "Impossible" << "\n";

  return 0;
}

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

int n;
vector<int> B,C;
int A[10];
bool flag; //是否有解

void dfs(int x) {
	if(x==10) { //球丢完了，递归要返回
		for(int i=1;i<B.size();i++) {
			if(B[i]<B[i-1]) return; //这个分支不行,有矛盾
		}
		for(int i=1;i<C.size();i++) {
			if(C[i]<C[i-1]) return; //这个分支不行,有矛盾
		}
		flag = true; 			 //这个分支走到最后是有解的
		return;
	}
	B.push_back(A[x]); 			//把第x个球丢给B
	dfs(x+1);  					//进入这个分支
	B.pop_back(); 				//撤销操作，弹出B的最后一个球
	
	C.push_back(A[x]); 			//把第x个球丢给C
	dfs(x+1);    				//进入这个分支
	C.pop_back(); 				//撤销操作，弹出C的最后一个球
}

int main() {
	int T;
    scanf("%d",&T);
	while(T--) {
		for(int i=0;i<10;i++) scanf("%d",&A[i]);
		flag = false;
		dfs(0);
		puts(flag ? "YES":"NO");
	}
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> s(n + 1, 0);
    int w;
    FOR(i, 1, n + 1) {
        cin >> w;
        s[i] = s[i - 1] + w;
    }
    int m = MOD;
    FOR(i, 1, n + 1) {
        chmin(m, abs(s[n] - s[i] - s[i]));
    }
    cout << m << endl;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 10000;
    rep(i,s.size()) {
        int cur = 0;
        int tmp = 0;
        if(i+t.size() > s.size())  break;
        for(int j = i;j<i+t.size();j++) {
            if(t[cur] != s[j])tmp++;
            cur++;
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int A[500000],cont=0;
void merge(int left,int mid,int right){
	int n1 = mid-left;
	int n2 = right-mid;
	int L[n1+1],R[n2+1];
	for(int i=0;i<n1;i++)
		L[i] = A[left+i];
	for(int i=0;i<n2;i++)
		R[i] = A[mid+i];
	L[n1] = R[n2] = 1e9+1;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]) A[k] = L[i++];
		else A[k] = R[j++];
		cont++;
	}
}
void ms(int left,int right){
	if(left+1<right){
		int mid = (left+right)/2;
		ms(left,mid);
		ms(mid,right);
		merge(left,mid,right);
	}
}
int main(){
	int n; cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	ms(0,n);
	for(int i=0;i<n;i++)
		if(i==0) printf("%d",A[i]);
		else printf(" %d",A[i]);
	printf("\n%d\n",cont);
    return 0;
}


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

#define ll long long

const ll MAX_N = 100001;
ll n;
ll one_jump_cost, two_jump_cost;
ll h[MAX_N];
ll cost[MAX_N] = {MAX_N};

void enableFastIO(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

void solve(){
	cin>>n;
  	for(ll i = 1; i <= n ; i++)
      	cin>>h[i];
  	for(ll i = 2; i <= n ; i++){
      	one_jump_cost = cost[i-1] + abs(h[i-1] - h[i]);
      	two_jump_cost = cost[i-2] + abs(h[i-2] - h[i]);
      	cost[i] = min(one_jump_cost, two_jump_cost);
    }
    cout<<cost[n];
}

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

Measured memory_bytes: 5208
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i, h) {
		cin >> s[i];
		REP(j,2)cout << s[i] << endl;
	}
}



Measured memory_bytes: 256
/*

    _____      _____     _____    __    __    _______    _____    _____    ______      _______      __
   |  _  \    |  _  \   |_   _|   \ \  / /   |   ____|  |_   _|  |  ___|  (   ___|    |__   __|    /  \
   | |_)  )   | |_)  )    | |      \ \/ /    |  |____     | |    | |__     \  (__        | |      / /\ \
   | ____/    | ____/     | |      / /\ \    |   ____|    | |    |  __|     \__   \      | |     / /__\ \
   | |        | |\ \     _| |_    / /  \ \   |  |        _| |_   | |___     ____)  )     | |    / /----\ \
   |_|        |_| \_\   |_____|  /_/    \_\  |__|       |_____|  |_____|   |______/      |_|   /_/      \_\
  */

  #include<bits/stdc++.h>
  using namespace std;
  #define ll  int
  #define M 200005
  #define mod 1000000007
  #define oo 100000000
  #define pii pair<ll,ll>
  #define fi first
  #define se second
  #define debug(x) cout<<" :"<<x<<"\n";
  #define debug2(x,y) cout<<#x<<" :"<<x<<"\t"<<#y<<": "<<y<<"\n";
  #define f(i,x,y) for(ll i=x;i<y;i++)
  #define boost ios::sync_with_stdio(0);cin.tie(0);
  #define in_arr0(a,n) f(i,0,n){cin>>a[i];}
  #define in_arr1(a,n) f(i,1,n+1){cin>>a[i];}
  #define pb(i) push_back(i)
  #define mp(x,y) make_pair(x,y)
    ll n;
    ll h[M/2];
    ll dp[100005];
    
  int main(){
    boost;
    cin>>n;
    f(i,0,100005){
    	dp[i] = -1;
    }
    int x;
    in_arr1(h,n);
    dp[0] = dp[1]  =0 ;
    f(i,1,n+1){
    	f(j,i+1,i+3){
    		if(j>n){
    			continue;
    		}
    		 x = abs(h[i]-h[j]);
    		if(dp[j]==-1){
    			dp[j] = x+dp[i];
    		}else 
    		{
    			dp[j] = min(dp[j],x+dp[i]);
    		}
    	}
    }
    cout<<dp[n];
      
    return 0;
  }


Measured memory_bytes: 1024