akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

namespace {

class Cube {
 private:
  enum Face {
    TOP,     // 1
    FRONT,   // 2
    RIGHT,   // 3
    LEFT,    // 4
    BACK,    // 5
    BOTTOM,  // 6
  };

 public:
  Cube() = default;
  Cube(const int* face) { copy(face, face + 6, face_); }

  // to east
  void rotate_x() { rotate(TOP, LEFT, BOTTOM, RIGHT); }
  // to north
  void rotate_y() { rotate(TOP, FRONT, BOTTOM, BACK); }

  void rotate_z() { rotate(FRONT, LEFT, BACK, RIGHT); }

  bool equal_faces(const Cube& other) const {
    return memcmp(face_, other.face_, sizeof(int) * 6) == 0;
  }

 private:
  void rotate(Face f1, Face f2, Face f3, Face f4) {
    const int t = face_[f1];
    face_[f1] = face_[f2];
    face_[f2] = face_[f3];
    face_[f3] = face_[f4];
    face_[f4] = t;
  }

  int face_[6];
};

// Check two dices are identical.
inline bool operator==(const Cube& a, const Cube& b) {
  Cube c = b;
  // http://www.prefield.com/algorithm/misc/dice.html
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (a.equal_faces(c))
        return true;
      c.rotate_z();
    }
    if (i % 2 == 1)
      c.rotate_x();
    else
      c.rotate_y();
  }
  return false;
}

bool FindIdentical(const Cube* cubes, int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (cubes[i] == cubes[j]) {
        return true;
      }
    }
  }
  return false;
}

}  // namespace

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

  int faces[100][6];
  Cube cubes[100];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 6; ++j)
      cin >> faces[i][j];
    cubes[i] = Cube(faces[i]);
  }

  if (FindIdentical(cubes, n))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = S % 3600 / 60;
	s = S%3600%60;
	cout << h << ':' << m << ':' << s << endl;
	return 0;
}






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

struct Card {
    char suit, value;
};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[minj].value > A[j].value) minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    rep(i, N) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    Card C1[N], C2[N];
    rep(i, N) cin >> C1[i].suit >> C1[i].value;
    rep(i, N) C2[i] = C1[i];
    bubble(C1, N);
    rep(i, N - 1) {
        cout << C1[i].suit << C1[i].value << " ";
    }
    cout << C1[N - 1].suit << C1[N - 1].value;
    cout << endl;
    puts("Stable");
    selection(C2, N);
    rep(i, N - 1) {
        cout << C2[i].suit << C2[i].value << " ";
    }
    cout << C2[N - 1].suit << C2[N - 1].value;
    cout << endl;
    isStable(C1, C2, N) ? puts("Stable") : puts("Not stable");
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T> &v) {return accumulate(all(v), (T)0LL);}
template<typename T> void sort(vector<T> &v){sort(all(v));}
template<typename T> void rsort(vector<T> &v){sort(all(v),greater<T>());}

int main(){
    ll n, k, ans = 0;
    cin >> n >> k;
    while(n>0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
require 'prime'

n, p = gets.split.map(&:to_i)
h = Prime.prime_division(p).to_h
if p == 1
  puts 1
elsif n == 1
  puts p
else
  ans = 1
  h.each do |k, v|
    while v >= n
      ans *= k
      v -= n
    end
  end
  puts ans
end

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b; cin >> a >> b;
    b *= 2;

    if( b >= a ) cout << 0 << endl;
    else cout << a - b << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値（人数）
    int ninzuu = Integer.parseInt(sc.nextLine());
    // 入力値（身長）
    String height[] = sc.nextLine().split(" ");

    long sum = 0;
    long preHeight = 0;
    for (int i=0; i<ninzuu; i++) {
      long nowHeight = Long.parseLong(height[i]);
      if (preHeight >= 0) {
        // 2人目以降は身長差を計算する
        if (preHeight > nowHeight) {
          // 前の人の方が大きい場合
          sum += preHeight - nowHeight;
        } else {
          // 変数の中身を更新する
          preHeight = nowHeight;
          continue;
        }
      } else {
        // 1人目なのでスキップ
        preHeight = nowHeight;
        continue;
      }
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 80600
H, W = map(int, input().split())
h, w = map(int, input().split())
ans = 0

masu = [[0] * W for i in range(H)]

for i in range(h):
    for j in range(W):
        masu[i][j] = 1

for i in range(H):
    for j in range(w):
        masu[i][j] = 1

for i in range(H):
    for j in range(W):
        if masu[i][j] == 0:
            ans += 1

print(ans)

Measured memory_bytes: 3064
imports System.Collections.Generic

Module Module1

    Sub Main()

        Dim S As String = Console.ReadLine()
        Dim t As New List(Of tbl)

        t.Add(New tbl("MON", 6))
        t.Add(New tbl("TUE", 5))
        t.Add(New tbl("WED", 4))
        t.Add(New tbl("THU", 3))
        t.Add(New tbl("FRI", 2))
        t.Add(New tbl("SAT", 1))
        t.Add(New tbl("SUN", 7))

dim n as tbl
        For Each n In t
            If n.youbi() = S Then
                Console.WriteLine(n.nissu)
            End If
        Next

    End Sub

     Class tbl

        Private _youbi As String
        Private _nissu As Integer

        Public Sub New(youbi As String, nissu As Integer)
            _youbi = youbi
            _nissu = nissu
        End Sub

        Public Property youbi() As String
            Get
                Return _youbi
            End Get
            Set(value As String)
                _youbi = value
            End Set
        End Property

        Public Property nissu() As Integer
            Get
                Return _nissu
            End Get
            Set(value As Integer)
                _nissu = value
            End Set
        End Property

    End Class

End Module


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

// abc141 E-Who Says a Pun?

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  vector<vector<int> > dp(5005, vector<int>(5005, 0));
  int ans = 0;
  for(int i = N-1; i >= 0; i--){
    for(int j = N-1; j >= 0; j--){
      if(S[i] == S[j]) dp[i][j] = dp[i+1][j+1] + 1;
      if(i < j){
        int tmp = min(j-i, dp[i][j]);
        ans = max(ans, tmp);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 98432
#include <iostream>
#include <map>

using namespace std;

const int N = 2e6 + 10;

int a[N];
map<int, int> s;
int n;

int main() {

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

  int found = 0;
  for (int i = 0; i+1 < n; ++i) {
    if (a[i] >= a[i+1]) {
      found = true;
    }
  }

  if (!found) {
    cout << 1 << endl;
    return 0;
  }

  int lo = 2, hi = n;

  while (lo < hi) {
    const int x = (lo + hi) / 2;

    int valid = 1;
    s.clear();
    for (int i = 1; i < n; ++i) {
      while (!s.empty() && prev(s.end())->first >= a[i]) {
        s.erase(prev(s.end()));
      }

      if (a[i-1] >= a[i]) {
        int l = a[i] - 1;
        while (l >= 0 && s[l] == x-1) {
          s[l--] = 0;
        }
        if (l < 0) {
          valid = 0;
          break;
        }
        s[l]++;
      }
    }

    if (valid) {
      hi = x;
    } else {
      lo = x + 1;
    }
  }

  cout << lo << endl;

  return 0;
}


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

typedef unsigned long long ll;

int main(int, char**)
{
	ll n, ans = 0;
	cin >> n;
	
	vector<ll> a(n +1);
	vector<ll> b(n);
	ll r;
	for (ll i = 0; i < n+1; ++i) {
		cin >> a[i];
	}
	for (ll i = 0; i < n; ++i) {
		cin >> b[i];
	}

	r = 0;
	for (ll i = 0; i < n; ++i) {
        ll y = b[i] + r;		
		if (y >= a[i]) { ans += a[i]; r = min(y - a[i], b[i]); }
		else { ans += y; r = 0; }
        // cerr << ans << "," << r << endl;
	}
    // cerr << r << "," << a[n] << endl;
	ans += min(r, a[n]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a<=b && b<=c) printf("%d %d %d\n",a,b,c);
  else if(a<=c && c<=b) printf("%d %d %d\n",a,c,b);
  else if(b<=a && a<=c) printf("%d %d %d\n",b,a,c);
  else if(b<=c && c<=a) printf("%d %d %d\n",b,c,a);
  else if(c<=a && a<=b) printf("%d %d %d\n",c,a,b);
  else printf("%d %d %d\n",c,b,a);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;

    int mx = (n-1) * (n-2) / 2;
    if (k > mx) {
        cout << -1 << endl;
        return 0;
    }
    vp ans;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        bool flag = false;
        for (int j = i + 1; j <= n; ++j) {
            if (i != 1 && mx - cnt == k) {
                break;
                flag = true;
            }
            ans.eb(i, j);
            if (i != 1) cnt++;
        }
        if (flag) break;
    }
    cout << sz(ans) << endl;
    rep(i, sz(ans)) cout << ans[i].fi << " " << ans[i].se << endl;
}

Measured memory_bytes: 384
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll k;
	cin>>k;
	deque<ll> q;
	for(ll i=1;i<=9;i++) q.push_back(i);
	for(ll i=1;i<k;i++){
		ll t=q.front();
		q.pop_front();
		ll x=t%10;
		if(x>0) q.push_back(10*t+x-1);
		q.push_back(10*t+x);
		if(x<9) q.push_back(10*t+x+1);
	}
	cout<<q.front();
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int k, x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> k >> x;

  FOR(i, x - k + 1, x + k) {
    cout << i << " ";
  }

  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll num;
	cin>>num;
	vector<ll>arr(num);
	map<int,ll>rel;
	for(int i=0; i<num; i++)
	{
		cin>>arr[i];
		rel[arr[i]]++;
	}
	ll sum=0;
	for(auto var : rel)
	{
		ll n=var.second;
		sum+=n*(n-1)/2;
	}
//	cout<<"sum : "<<sum<<"\n";
	for(int i=0; i<num; i++)
	{
		int temp=arr[i];
		if(rel[arr[i]]<2)
		 cout<<sum<<"\n";
		else
		 cout<<sum-rel[arr[i]]+1<<"\n";
	}
	return 0;
	
}

Measured memory_bytes: 12668
from collections import deque
import sys

S = input()
Q = int(input())
t = deque(S)
rev = False

for _ in range(Q):
  Query = input().split()
  if Query[0] == '1':
    rev = not rev
    
  else:
    F = Query[1]
    C = Query[2]
    if F == '1':
      if rev:
        t.append(C)
      else:
        t.appendleft(C)
    else:
      if rev:
        t.appendleft(C)
      else:
        t.append(C)

result = ''.join(t) 
if rev:
  print(result[::-1])
else:
  print(result)

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

int gcd(int p,int q)
{
    if(q==0) return p;
    return gcd(q,p%q);
}

int main(void)
{
    int k,sum=0,g;
    cin >> k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            g = gcd(i,j);
            for(int l=1;l<=k;l++)
            {
                sum+=gcd(g,l);
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  vector<int> list= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2,
      2, 5, 4, 1, 4, 1, 51};
  int a;
  cin >> a;
  cout << list[a-1];
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

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

typedef long long ll;

const ll MOD = 1e9 + 7;

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

int main() {
    ll N, K, ans = 0, x;
    cin >> N >> K;
    vector<ll> A(N), f(N + 1, 1);
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) f[i + 1] = (f[i] * (i + 1)) % MOD;
    sort(A.begin(), A.end());
    rep(i, N - K + 1) {
        x = (f[N - i - 1] * mod_pow(f[K - 1], MOD - 2, MOD)) % MOD;
        x *= mod_pow(f[N - i - K], MOD - 2, MOD);
        x %= MOD;
        x *= (A[N - 1 - i] - A[i] + MOD + MOD) % MOD;
        x %= MOD;
        ans += x;
        ans %= MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
    //rep(i, N) cout << f[i] << endl;
}

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

long long f(long long n){
  if(n==1){
    return 1;
  }else{
    return n*f(n-1)%1000000007;
  }
}

int main(){
  long long n,m,fn,fm,ans;
  cin>>n>>m;
  fn=f(n);
  fm=f(m);
  ans=(fn*fm)%1000000007;
  if(n==m){
    ans=(2*ans)%1000000007;
  }else if(1<n-m || 1<m-n){
    ans=0;
  }
  cout<<ans<<endl;

  return 0;
}


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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
        return 0;
    } else {
        cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2 << endl;                   
           // min(A − 1, N − B) stands for  the number of rounds needed to reach table 1 or table N 
          // 1 stands for a single round to change parity 
         //   (B−A−1)/2 stands for the number of rounds before the friends meet after changing parity
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') counter += 1;
    if (s[1] == '1') counter += 1;
    if (s[2] == '1') counter += 1;
    cout << counter;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define TRY(n) try{n}catch(...){}
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(n) n.begin(),n.end()
using namespace std;

int main(){
    int n;string s,t;cin>>n>>s>>t;
    if(s==t){cout<<s.size()<<endl;return 0;}
    string rt = "";
    rep(i,n)rt+=t[(n-1)-i];

    int ma = -999;

    for(int j=n-1;j>=0;j--){
        int c = 0;
        int b = n-1;
        for(int i=j;i<n;i++){
            if(s[i] == rt[b]){c++;b--;}
            else break;
        }
        if(ma < c)ma = c;
        b = n-1;
    }
    cout << s.size()-ma + t.size() << endl;
}

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

using namespace std;

int main()
{
  long long n;
  cin >> n;
  n++;
  int cnt = 0;
  long long tmp = n;
  while (tmp)
  {
    tmp /= 2;
    cnt++;
  }
  deque<int> deq;
  long long now = 1;
  int t = 1;
  for (int i = cnt - 2; i >= 0; i--)
  {
    deq.push_back(t);
    now *= 2;
    t++;
    if ((now + 1) << i <= n)
    {
      deq.push_front(t);
      now++;
      t++;
    }
  }
  int size = deq.size();
  cout << size * 2 << endl;
  for (int i = 1; i <= size; i++)
    cout << i << " ";
  for (int i = 0; i < size; i++)
    cout << deq[i] << (i + 1 == size ? "\n" : " ");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int N;cin>>N;
  int bits = 0;
  vector<int> A(N);

  rep(i,N){
    int x;cin>>x;
    A[i] = x;
    for(int c=0; c<32; c++){
      if(x & 1<<c){
        bits ^= 1<<c;
      }
    }
  }

  rep(i,N){
    cout<<(A[i]^bits)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<queue>
#include<cstdio>
#define INF 1<<28
using namespace std;

struct edge{
  int to;
  int cost; //ちょっと処理を楽にするために
};

typedef pair < int, int > P; // < 最短経路, ノードの番号 >

int V;
vector < edge > G[100]; //入力(iからjはコストG[i][j]でいける)
int d[100]; //答えを入れる(最小コストを入れる)

int dijkstra(int s){ //スタート地点
  priority_queue <P, vector<P>, greater<P> > que; //小さい順になるようにqueueに代入
  
  fill(d, d+V+1, INF); //全ノードのコストをINFで初期化(d[0]~d[V])
  d[s] = 0; //スタート地点のコストを0で初期化
  
  que.push(P(0, s)); //最短経路(0), 頂点の番号(スタート)
  
  while( !que.empty() ){ //queueの中身が空になるまでループ(行ける場所が無くなるまで)
    
    P p = que.top(); que.pop(); //最小コストを取得
    int v = p.second; //最小コストであるノードの番号
    
    if(d[v] < p.first) continue; //取り出した最小コストが大きかったらループの最初に戻る
    
    for(int i=0;i<G[v].size();i++){ //今居る頂点からつながってる辺の数だけループ
      edge e = G[v][i]; //i番目のvからいけるノードとそのコストを代入
      
      if(d[e.to] > d[v] + e.cost){ //最短経路が見つかった
	d[e.to] = d[v] + e.cost; //最短経路を更新
	que.push( P(d[e.to], e.to) ); //新しい最短経路をqueueにpush
      }
    }
  }
}

int main(){
  
  int m; //エッジ数
  int a,b,ca,cb; //abでつながっている cost_a cost_b
  int x1,x2,y1,y2; //スタート、ゴール、所持金、柱の代金
  
  cin >> V >> m;
  
  edge k;
  for(;m>0;m--){
    scanf("%d,%d,%d,%d",&a,&b,&ca,&cb);
    
    k.to = b, k.cost = ca;
    G[a].push_back( k );
    
    k.to = a, k.cost = cb;
    G[b].push_back( k );
  }
  
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  
  //行き
  dijkstra(x1);
  y1 -= d[x2];
  
  //帰り
  dijkstra(x2);
  y1 -= d[x1];
  
  //for(int i=1;i<=V;i++) cout << d[i] << endl; //確認
  
  cout << y1-y2 << endl;
  
}

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

int main(){

  int n;
  int sum=100000;

  cin>>n;

  for(int i=0;i<n;++i){
    sum=sum+sum*0.05;

    if(sum%1000!=0){
      sum=sum/1000;
      sum=sum+1;
      sum=sum*1000;
    }
  }
  cout<<sum<<endl;

}



Measured memory_bytes: 3064
n = int(input())
s = list(map(int, input().split()))
count = 0
maxcount = 0
for i in range(n-1):

    if (s[i+1] - s[i]) <= 0:
        #l.append(i)
        count += 1
    else:
        if count > maxcount:
            maxcount = count
        count = 0

if count > maxcount:
    maxcount = count
print(maxcount)


Measured memory_bytes: 14252
# encoding: utf-8
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i, "0" * 12] for i in range(M)] # P, Y, i, ID

PY.sort(key=lambda x: x[1])
PY.sort(key=lambda x: x[0])
# print("#", PY)

head = 0
for j, (Pi, Yi, i, dummy) in enumerate(PY):
    if Pi != head:
        tail = 0
        head = Pi
    tail += 1
    # print("##", head, tail)
    PY[j][-1] = "{0:06d}{1:06d}".format(head, tail)

PY.sort(key=lambda x: x[2])
for i in range(M): print(PY[i][-1])

Measured memory_bytes: 37124
#include<bits/stdc++.h>
typedef long long  ll ;
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}




int main() {
    fast()
    string s,s1;
    cin>>s>>s1;

    s1+=s;
    cout<<s1<<endl;




}


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

int main(){
	int m;
	cin>>m;
	for(int X=0;X<m;++X){
		int ans=0;
		int init_fund;
		int years;
		int n;

		cin>>init_fund>>years>>n;
		for(int i=0;i<n;++i){
			int final_fund=init_fund;
			int type;
			double interest;
			int charge;
			
			cin>>type>>interest>>charge;
			if( type == 0 ){
				int cumul=0;
				for(int j=0;j<years;++j){
					int B=final_fund*interest;
					final_fund-=charge;
					cumul+=B;
				}
				final_fund+=cumul;
			}else{
				for(int j=0;j<years;++j){
					int B=final_fund*interest;
					final_fund=final_fund+B-charge;
				}
			}
			ans=max(ans,final_fund);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
	}

	if n < 1000 {
		println!("ABC");
	}
	else {
		println!("ABD");
	}
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

const int N = 1e5 + 5;

vector<int> arr[N];
/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        arr[a].push_back(b);
    }
    priority_queue<int> q;
    int ans = 0;
    FOR(i, 1, m){
        //debug(arr[i]);
        for(int j = 0; j < arr[i].size(); j++) q.push(arr[i][j]);
        if(q.size() > 0) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans;


}



Measured memory_bytes: 5632
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  int w, h;
  in, w, h;

  auto p = in.Array(w);
  auto q = in.Array(h);

  vector<pair<int, int>> a;
  a.reserve(w + h);
  for (auto& i : p) {
    a.push_back({ i,0 });
  }
  for (auto& i : q) {
    a.push_back({ i,1 });
  }
  sort(all(a));

  ll ans = 0;
  int cnt[2] = { 0 };
  int wh[2] = { h + 1,w + 1 };
  for (auto& i : a) {
    ans += (ll) max(0ll, (ll) i.first *(wh[i.second] - cnt[1 - i.second]));
    cnt[i.second]++;
  }

  cout << (ans) << endl;

}


Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

#define dTolerance 1.0e-10

struct POINT{
    int x;
    int y;
};

bool LF_POINT_ON_EDGE(const POINT &zp, const POINT &zp0, const POINT &zp1){
    if( (zp0.x - zp.x) * (zp1.y - zp.y) - (zp1.x - zp.x) * (zp0.y - zp.y) != 0){
        return false;
    }
    if(zp0.x == zp.x){
        if(zp.y < min(zp0.y, zp1.y) || zp.y > max(zp0.y, zp1.y)){
            return false;
        }
    } else {
        if(zp.x < min(zp0.x, zp1.x) || zp.x > max(zp0.x, zp1.x)){
            return false;
        }
    }
    return true;
}

int LF_COUNTER_CLOCKWIZE(const POINT &zp, const POINT &zp0){    //zpを通る傾き30000の直線のどちら側にあるか
    if( (zp0.y - zp.y) - 30000 * (zp0.x - zp.x) > 0 ){
        return 1;
    } else if ( (zp0.y - zp.y) - 30000 * (zp0.x - zp.x) < 0 ){
        return -1;
    } else {
        return 0;
    }
}

bool LF_INTERSECT(const POINT &zp, const POINT &zp0, const POINT &zp1){    //zpを通る傾き30000の半直線が辺と交わるか
    if(LF_COUNTER_CLOCKWIZE(zp, zp0) * LF_COUNTER_CLOCKWIZE(zp, zp1) != -1){
        return false;
    }
    if(zp0.x == zp1.x){
        if(zp0.x - zp.x <= 0){
            return false;
        }
    } else if (zp0.x < zp1.x){
        if((zp1.x - zp.x) * (zp0.y - zp.y) - (zp0.x - zp.x) * (zp1.y - zp.y) <= 0){
            return false;
        }
    } else {
        if((zp1.x - zp.x) * (zp0.y - zp.y) - (zp0.x - zp.x) * (zp1.y - zp.y) >= 0){
            return false;
        }
    }
    return true;
}    

//与えられた点p(px,py)に対し、制約より半直線y=30000(x-px)+py (x > px) 上に頂点は存在しない。この直線と交差する辺の本数を数えればよい
int main(){
    int n;
    scanf("%d", &n);
    vector<POINT> vzVertex;
    POINT zVertex0;
    for(int i = 0; i < n; i++){
        POINT zVertex;
        scanf("%d %d", &zVertex.x, &zVertex.y);
        if(i == 0){
            zVertex0.x = zVertex.x;
            zVertex0.y = zVertex.y;
        }
        vzVertex.push_back(zVertex);
    }
    vzVertex.push_back(zVertex0);
    
    int q;
    scanf("%d", &q);
    for(int j = 0; j < q; j++){
        POINT zPoint;
        scanf("%d %d", &zPoint.x, &zPoint.y);
        int nCount = 0;
        bool bOnEdge = false;
        for (int i = 0; i < n; i++){
            if( LF_POINT_ON_EDGE(zPoint, vzVertex[i], vzVertex[i+1]) ){
                bOnEdge = true;
                break;
            } else {
                if( LF_INTERSECT(zPoint, vzVertex[i], vzVertex[i+1]) ){
                    nCount++;
                }
            }
        }
        if(bOnEdge == true){
            printf("1\n");
        } else {
            if(nCount %2 == 1){
                printf("2\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

const int INF = 2147483647;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

// セグメント木による RMQ (Range Minimum Query) の実装
// RMQ以外にする場合は、minの部分を全て他の関数に置換する

const int MAX_N = 1 << 17;

// セグメント木を持つグローバル配列
int n;
int dat[2 * MAX_N - 1];

// 初期化
void init(int n_) {
  // 簡単のため、要素数を2のべき乗に
  n = 1;
  while (n < n_) {
    n *= 2;
  }

  // すべての値をINFに
  for (int i = 0; i < 2 * n - 1; i++) {
    dat[i] = INF;
  }
}

// k番目の値 (0-indexed) をaに変更
void update(int k, int a) {
  // 葉の節点
  k += n - 1;
  dat[k] = a;
  // 登りながら更新
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

// [a, b) の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が [l, r) に対応づいていることを表す。
// したがって、外からは query(a, b, 0, 0, n) として呼ぶ。
int query(int a, int b, int k, int l, int r) {
  // [a, b) と [l, r) が交差しなければ INF
  if (r <= a || b <= l) {
    return INF;
  }

  // [a, b) が [l, r) を完全に含んでいれば、この節点の値
  if (a <= l && r <= b) {
    return dat[k];
  } else {
    // そうでなければ、2つの子の最小値
    int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}

int n_, q;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n_ >> q;
  init(n_);

  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;

    if (com == 0) {
      update(x, y);
    } else {
      cout << query(x, y + 1, 0, 0, n) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4132
def hou2(tarrs, s, N):
    def checkTestimony(s, t):
        scopy = s[:]
        for i in range(len(s)):
            if s[i] != t[i] and s[i] != 0 and t[i] != 0:
                return None
            if t[i]:
                scopy[i] = t[i]
        return scopy
 
    def search(pos, N, s, acc):
        if pos < N:
            check_tp = checkTestimony(s, tarrs[pos])
            if s[pos] == 1:
                s[pos] = -1
                if check_tp:
                    check_tp[pos] = 1
                    return search(pos + 1, N, check_tp, acc + 1)
                else:
                    return 0
            if check_tp and s[pos] == 0:
                s[pos] = -1
                check_tp[pos] = 1
                return max(search(pos + 1, N, check_tp, acc + 1), search(pos + 1, N, s, acc))
            else: # testimony unacceptable, assuming unkind
                s[pos] = -1
                return search(pos + 1, N, s, acc)
        else:
            return acc
 
    return search(0, N, s, 0)
    
 
if __name__ == "__main__":
    import sys
    in_arr = []
    for line in sys.stdin:
        in_arr.append([int(_) for _ in line.strip().split()])
    N = in_arr[0][0]
    i = 1
    tarrs = []
    s = [0] * N
    while i < len(in_arr):
        tnum = in_arr[i][0]
        tarr = [0] * N
        for j in range(tnum):
            x, y = in_arr[1 + j + i]
            tarr[x - 1] = 1 if y else -1 # -1 claimed unkind, 1 claimed honest
        if tarr[len(tarrs)] == -1: # claimed self to be unkind
            s[len(tarrs)] = -1
        tarrs.append(tarr)
        i += tnum + 1
    print(hou2(tarrs, s, N))


Measured memory_bytes: 3444
// Aizu 1120: Pile Up!
// 2017.9.18 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int pile, pos; } CU;
CU cu[102];
int pile[102][102], top[102];

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, i, j, k, p;

	while (scanf("%d", &n) && n) {
		for (i = 1; i <= n; i++) cu[i].pile = i, cu[i].pos = 0, pile[i][0] = i, top[i] = 1;
		while (scanf("%d%d", &i, &j) && i) {
			if (j == i) continue;
			if (j == 0 && cu[i].pos == 0) ;
			else if (cu[j].pile == cu[i].pile && cu[j].pos < cu[i].pos) ;
			else {
				p = cu[i].pile; 
				while ((k = pile[p][--top[p]]) != i)
					cu[k].pile = k, cu[k].pos = 0, pile[k][0] = k, top[k] = 1;
				if (j == 0) cu[i].pile = i, cu[i].pos = 0, pile[i][0] = i, top[i] = 1;
				else p = cu[j].pile, cu[i].pile = p, cu[i].pos = top[p], pile[p][top[p]++] = i;
			}
		}
		qsort(top+1, n, sizeof(int), cmp);
		for (i = 1; i <= n; i++) if (top[i] > 0) printf("%d\n", top[i]);
		puts("end");
	}
	return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	//これも解説みないと全くわからないなぁ

	int N;
	cin >> N;

	vector<pair<int, int>> eda[100000];

	rep1(i, N - 1) {
		if (i % 10 != 9) {
			int A = (i + 1) % N;
			eda[i].push_back(make_pair(A, 1));
		}
		int B = (i * 10) % N;
		eda[i].push_back(make_pair(B, 0));
	}

	int D[100000] = {};
	vector<pair<int, int>> que;

	que.push_back(make_pair(1, 1));

	rep(i, N) {
		vector<pair<int, int>> que2;
		for (pair<int, int> itr : que) {
			if (D[itr.first] == 0 || D[itr.first] > itr.second) {
				for (pair<int, int> itr2 : eda[itr.first]) {
					que2.push_back(make_pair(itr2.first, itr.second + itr2.second));
				}
				D[itr.first] = itr.second;
			}
		}
		que = que2;
	}

	co(D[0]);

	Would you please return 0;
}

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

const int INF = 1e9;

//Segment Tree
class SegmentTree{
public:
  int n;
  vi node;
  vi ofset;
  SegmentTree(vi a){
    int n_ = a.size();
    n=1;
    while(n<n_)n*=2;

    node = vi(2*n-1, INF);
    for(int i=0;i<n_;i++)node[i+n-1] = a[i];
    for(int i=n-2;i>=0;i--)node[i] = min(node[2*i+1], node[2*i+2]);

    ofset = vi(2*n-1,0);
  }

  //return minimum value in [a,b). ( [l,r) is interval in which k is.)
  int rmq(int a,int b,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return INF;
    if(a<=l && r<=b)return node[k]+ofset[k];
    int pl = rmq(a,b,2*k+1,l,(l+r)/2);
    int pr = rmq(a,b,2*k+2,(l+r)/2,r);
    return min(pl,pr) + ofset[k];
  }

  int search(int a,int b,int v,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return INF;
    if(a<=l && r<=b && node[k]+ofset[k] >= v)return l;
    if(r-l<=1)return INF;
    int vr = rmq(a,b,2*k+2,(l+r)/2,r);
    if(vr + ofset[k] >= v){
      int res = search(a,b,v-ofset[k],2*k+1,l,(l+r)/2);
      return min(res, (l+r)/2);
    }else{
      int res = search(a,b,v-ofset[k],2*k+2,(l+r)/2,r);
      return res;
    }
  }
 
  int update_range(int a,int b,int v,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return node[k];
    if(a<=l && r<=b){
      ofset[k] += v;
      return node[k]+ofset[k];
    }

    int vl = update_range(a,b,v,2*k+1,l,(l+r)/2);
    int vr = update_range(a,b,v,2*k+2,(l+r)/2,r);
    node[k] = min(vl,vr);
    return node[k]+ofset[k];
  }
};

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  set<int> minus;
  vi h(n,1);
  rep(i,n-1){
    if(s[i+1] == '(')h[i+1] = h[i] + 1;
    else{
      h[i+1] = h[i] - 1;
      minus.insert(i+1);
    }
  }
  SegmentTree st(h);

  while(q--){
    int p;
    cin >> p; p--;
    if(s[p] == '('){
      s[p] = ')';
      minus.insert(p);
      st.update_range(p,n,-2);

      p = *minus.begin();
      s[p] = '(';
      minus.erase(p);
      st.update_range(p,n,2);
    }else{
      s[p] = '(';
      minus.erase(p);
      st.update_range(p,n,2);

      p = st.search(0,p+1,2);
      s[p] = ')';
      minus.insert(p);
      st.update_range(p,n,-2);
    }
    /*
    for(int i=0;i<2*st.n-1;i++){
      cerr << st.node[i] << " " << st.ofset[i] << endl;
      }*/

    cout << p+1 << endl;
  }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, K;
ll x[60], y[60];

int main() {
   cin >> N >> K;
   rep (i, 0, N) {
      cin >> x[i] >> y[i];
   }

   ll area = 1LL << 62;
   rep (i, 0, N) {
      rep (j, 0, N) {
         rep (k, 0, N) {
            rep (l, 0, N) {
               if (x[i] <= x[j] && y[k] <= y[l]) {
                  int cnt = 0;
                  rep (p, 0, N) {
                     if (x[p] >= x[i] && x[p] <= x[j] && y[p] >= y[k] && y[p] <=y [l]) {
                        cnt++;
                     }
                  }
                  if (cnt >= K) {
                     area = min(area, (x[j]-x[i]) * (y[l]-y[k]));
                  }
               }
            }
         }
      }
   }
   cout << area << endl;

   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const long long MOD = 1000000007;

signed main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int k = 0;
    while(A >= B){
        B *= 2;
        k++;
    }
    while(B >= C){
        C *= 2;
        k++;
    }
    if(k <= K) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n; ll a[100000];
	ll out = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		out += a[i] / 2;
		if (a[i] % 2&&i+1<n&&a[i+1]>0) {
			out++; a[i + 1]--;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
void solve(int N){
	if(N==2){
		puts("-1");
		return;
	}
	if(N==7){
		puts("6");
		printf("1 0\n");
		printf("3 0\n");
		printf("9 0\n");
		printf("2 1\n");
		printf("3 2\n");
		printf("0 3\n");
		return;
	}
	int K=0;
	while(K*(K-1)/2<N) K++;
	if(K*(K-1)/2-N==1||K*(K-1)/2-N==3) K++;
	int off=K*(K-1)/2-N;
	vector<int> vc;
	if(off==9) vc.pb(5);
	if(off==10) vc.pb(4),vc.pb(4);
	if(off==11) vc.pb(3),vc.pb(5);
	if(off==12) vc.pb(3),vc.pb(4),vc.pb(4);
	if(off==13) vc.pb(3),vc.pb(3),vc.pb(5);
	if(off==14) vc.pb(6);
	if(off==15) rep(j,3) vc.pb(4);
	if(off==16) vc.pb(3),vc.pb(6);
	if(off==17) vc.pb(3),vc.pb(4),vc.pb(4),vc.pb(4);
	if(vc.empty()){
		if(off%2) vc.pb(4),off-=5;
		rep(i,off/14) vc.pb(6);
		off%=14;
		rep(i,off/2) vc.pb(3);
	}
	int sum=0;
	for(int a:vc) sum+=a;
/*	show(N);
	printf("vc.size()=%d     ",vc.size());
	rep(i,vc.size()) cout<<vc[i]<<" , ";
	puts("");
	show(K);
	puts("");*/
	if(sum>K){
//		printf("N=%d   K=%d  off=%d\n",N,K,offc);
		cout<<K<<endl;
		if(off==6){
			puts("0 0");
			puts("0 1");
			puts("0 2");
			puts("1 0");
			puts("1 1");
			puts("2 0");
			if(N==22){
				puts("114 514");
				puts("810 893");
			}
		}
		if(off==8){
			puts("0 0");
			puts("0 1");
			puts("0 2");
			puts("1 0");
			puts("1 2");
			puts("2 0");
			puts("2 1");
			puts("2 2");
			if(N>=37){
				puts("114 514");
				puts("810 893");
			}
			if(N==47){
				puts("114514 364364");
			}
		}
		if(off==12){
			puts("0 0");
			puts("0 1");
			puts("0 2");
			puts("0 3");
			puts("1 0");
			puts("2 0");
			puts("3 0");
			puts("2 1");
			puts("114 514");
			puts("810 893");
		}
		return;
	}
	cout<<K<<endl;
	rep(i,K-sum) vc.pb(1);
	int x=0;
	for(int a:vc){
		rep(i,a) printf("%d %d\n",x,x*x*10+i);
		x++;
	}
}
int main(){
	int N;
	cin>>N;
	solve(N);
}

Measured memory_bytes: 1264