akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
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 = 1e10

#solve
def solve():
    b = 0
    N, A, B =LI()
    s = S()
    PASS = 0
    for i in range(N):
        if s[i] == "c":
            print("No")
            continue
        if PASS < A + B:
            if s[i] == "a":
                PASS += 1
                print("Yes")
            else:
                if b < B:
                    PASS += 1
                    b += 1
                    print("Yes")
                else:
                    print("No")
        else:
            print("No")

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 50520
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int x;
  cin >> x;
  int a = x / 100;
  double b = x / (double)a;
  if (a < 1) {
    cout << 0 << endl;
  } else if (b > 105) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char n[5];
    scanf("%s", n);
    if (n[1] == n[2])
        if (n[0] == n[1] || n[2] == n[3])
            printf("Yes\n");
        else
            printf("No\n");
    else
        printf("No\n");
    return 0;
}

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

typedef long long ll;

const int N = 2e5 + 7;
const int SS = 4 * N;
const ll INF = 1e17 + 7;
int n;

ll x[N], s[N];
ll lazy[SS];
ll seg[SS];

void update(int v, ll val)
{
    lazy[v] += val;
    seg[v] += val;
    return;
}

void shift(int v)
{
    update(2 * v, lazy[v]);
    update(2 * v + 1, lazy[v]);
    lazy[v] = 0;
}

void add(int l, int r, ll val, int s = 0, int e = n, int v = 1)
{
    if (l >= e || r <= s)
        return;
    if (l <= s && e <= r)
    {
        update(v, val);
        return;
    }
    int mid = (s + e) / 2;
    shift(v);
    add(l, r, val, s, mid, 2 * v);
    add(l, r, val, mid, e, 2 * v + 1);
    seg[v] = max(seg[2 * v], seg[2 * v + 1]);
}


int main()
{
    ios::sync_with_stdio(false);

    cin >> n;
    for (int i=0; i<n; i++)
        cin >> x[i] >> s[i];

    for (int i=0; i<n; i++)
        add(i, i+1, -x[i]);
    for (int i=0; i<n; i++)
        add(i, n, s[i]);
    ll ans = 0;
    for (int i=0; i<n; i++)
    {
        ans = max(ans, x[i] + seg[1]);
        add(i, n, -s[i]);
        add(i, i+1, -INF);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	ll n; cin >> n;
	ll temp,ans = 10000000000000;
	for (ll i = 1; i*i <= n; i++) {
		//cout << "i: " << i << endl;
		if (n%i == 0) {
			temp = (n/i) + i -2;
			//cout <<"temp: "<< temp << endl;
			if (temp < ans)ans = temp;
		}
	}
	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,A,B;
	cin >> N>>A>>B;
	
	// 解法
	ll ans = min(N*A, B);
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int a,b,c;cin>>a>>b>>c;
    int mi=min(a,min(b,c));
    int ma=max(a,max(b,c));
    int me=a+b+c-mi-ma;
    if((me-mi)%2)cout<<(2*ma-me-mi+3)/2<<endl;
    else cout<<(2*ma-me-mi)/2<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> pi(n + 1, -1);
  vector<vector<int>> ps(n + 1);
  rep(i, n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi, q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r, qi);
  }

  vector<int> ans(q);

  BIT<int> d(n);
  for (int x = n-1; x >= 0; --x) {
    for (int y : ps[x]) d.add(y, 1);
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r - x + 1) - d.sum(r);
    }
  }

  rep(i, q) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 59848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//約数列挙
template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int sum=0;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	vector<int> ret=divisor(sum); 
	sort(begin(ret),end(ret),greater<int>());
	for(auto x:ret){
		vector<int> now;
		rep(i,n){
			int r=a[i]%x;
			if(r){
				now.push_back(r);
			}
		}
		sort(begin(now),end(now));
		int m=now.size();
		vector<int> sum(m+1,0);
		rep(i,m){
			sum[i+1]=sum[i]+now[i];
		}
		rep(i,m+1){
			if(sum[i]==x*(m-i)-(sum[m]-sum[i]) && sum[i]<=k){
				cout<<x<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll N = 100000;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		int v;cin>>v;
		arr[i] = v;
	}
	vector<pair<int,int> > v1;
	vector<pair<int,int> > v2;
	for(int i=0;i<N;i++){
		v1.push_back(make_pair(0,0));
		v2.push_back(make_pair(0,0));
	}
	for(int i=0;i<n;i++){
		if(i%2==0){
			v1[arr[i]-1].first++;
			v1[arr[i]-1].second = arr[i];
		}
		else{
			v2[arr[i]-1].first++;
			v2[arr[i]-1].second = arr[i];
		}
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	int ans=0;
	if(v1[v1.size()-1].second!=v2[v2.size()-1].second){
		ans = n-v1[v1.size()-1].first-v2[v2.size()-1].first;
	}
	else{
		int p = n-v1[v1.size()-2].first-v2[v2.size()-1].first;
		int q = n-v1[v1.size()-1].first-v2[v2.size()-2].first;
		ans = min(p,q);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	string a, b;
	cin >> a;
	cin >> b;
	int len1 = a.length();
	int len2 = b.length();
	int work = len1;
	bool flag = true;
	if(len1 > len2){
		work = len2;
		flag = false;
	}
	for(int i = 0; i < work; i++){
		cout << a[i] << b[i];
	}

	if(flag){
		for(int i = work; i < len2; i++){
			cout << b[i];
		}
	}else{
		for(int i = work; i < len1; i++){
			cout << a[i];
		}
	}
	cout << endl;

	return 0;
}


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

int main() {
  int H,W,C1,C2,D1,D2;
  cin>>H>>W>>C1>>C2>>D1>>D2;
  C1--,C2--,D1--,D2--;
  vector<char> p(H*W);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>p[i*W+j];
    }

  }
  vector<int> seen(H*W,-1);
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
  pq.push(make_pair(0,C1*W+C2));
  seen[C1*W+C2]=0;
  while(!pq.empty()){
    int a,b;
    tie(a,b)=pq.top();
    pq.pop();
    if(seen[b]<a){
      continue;
    }
    int x=b/W,y=b%W;
    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        int c=x+i,d=y+j;
        if(c<0||H<=c||d<0||W<=d){
          continue;
        }
        else{
          int E=c*W+d;
          if(i==0&&j==0){
            continue;
          }
          else if(abs(i)+abs(j)==1){
            if((seen[E]==-1||seen[E]>a)&&p[E]=='.'){
              seen[E]=a;
              pq.push(make_pair(a,E));
            }
          }
          else{
            if((seen[E]==-1||seen[E]>a+1)&&p[E]=='.'){
              seen[E]=a+1;
              pq.push(make_pair(a+1,E));
            }
          }
        }
      }
    }
  }
  cout<<seen[D1*W+D2]<<endl;
}

Measured memory_bytes: 8372
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>


typedef long long ll;


#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;


ll a[3007], b[3007], c[3007];
ll d[3007], e[3007], f[3007];
int ngx[3007][3007]; int ngy[3007][3007];
bool visit[3007][3007];

ll ind(int key, const vector<int>& v) {
    return lower_bound(all(v), key) - v.begin();
}



int main()
{
    int n, m; cin >> n >> m;
    vector<int> x, y;

    rep(i, n) {
        cin >> a[i] >> b[i] >> c[i];
        x.push_back(a[i]); x.pb(b[i]); y.push_back(c[i]);
    }
    rep(i,m) {
        cin >> d[i] >> e[i] >> f[i];
        x.push_back(d[i]); y.pb(e[i]); y.push_back(f[i]);
    }

    sort(all(x)); sort(all(y));
    x.erase(unique(all(x)), x.end()); y.erase(unique(all(y)), y.end());

    rep(i, n) {
        int from = ind(a[i],x);
        int to = ind(b[i], x);
        int ycor = ind(c[i], y);
        FOR(j, from, to) {
            ngx[j][ycor] = true;
        }        
    }

    rep(i, m) {
        int from = ind(e[i], y);
        int to = ind(f[i], y);
        int xcor = ind(d[i], x);
        FOR(j, from, to) {
            ngy[xcor][j] = true;
        }
    }

    int xs = ind(0, x) - 1;
    int ys = ind(0, y) - 1;
    queue<pair<int, int>> q;
    q.emplace(xs, ys);
    ll res = 0;

    int w = x.size();
    int h = y.size();

    while (!q.empty()) {      
        int xx = q.front().first;
        int yy = q.front().second;
        q.pop();

        if (xx < 0 || yy < 0 || xx >= w - 1 || yy >= h - 1) {
            cout << "INF" << endl;
            return 0;
        }

        if (visit[xx][yy])
            continue;

        res +=  ((ll) x[xx + 1] - x[xx]) * ((ll) y[yy + 1] - y[yy]);

        if (!ngx[xx][yy])
            q.emplace(xx , yy - 1);
        if (!ngx[xx][yy + 1])
            q.emplace(xx, yy + 1);
        if (!ngy[xx][yy])
            q.emplace(xx - 1, yy);
        if (!ngy[xx + 1][yy])
            q.emplace(xx + 1, yy);

        visit[xx][yy] = 1;
     }

    cout << res << endl;

    return 0;
}




Measured memory_bytes: 50068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N,ans = INF,sum;
    string S;
    
    cin >> N >> S;
    map<char,int>rsum,lsum;
    REP(i,N){
        rsum[S[i]]++;
    }
    char x;
    x = S[0];
    rsum[x]--;
    ans = rsum['E'];

    for(int i=1;i<N;i++){
        lsum[x] ++;
        x = S[i];
        rsum[x] --;
        sum = lsum['W'] + rsum['E'];
        ans = min(ans,sum);
    }

    cout << ans <<endl;
}

Measured memory_bytes: 900
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		for (int i = 111; i < 1000; i = i + 111) {
			if(n <= i) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 21588
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd<T>(a: T, b: T) -> T
where
    T: Copy + std::cmp::PartialEq + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if b == T::from(0u8) {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        x: i64,
        xs: [i64; n],
    }
    let mut xs = xs.iter().map(|i| (*i - x).abs() as i64).collect::<Vec<_>>();
    xs.sort();
    let ans = xs.iter().skip(1).fold(xs[0], |sum, x| gcd(sum, *x));
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<stdio.h>
#include<iostream>
#define ll long long
std::string str;
ll mypow(ll a,ll b){
    ll ret = 1;
    for(ll i = 1;i<=b;i++){
        ret *= a;
    }
    return ret;
}
int main(){
    std::cin >> str;
    
    int s = str.size();
    ll sum = 0;
    for(int i = 1,e=s;i<=s;i++){
        int d = str[e-i] -'0';
        for(int j = 1,je=i; j<=je;j++){
            ll po = s-1 - (j == je ? j-1:j);
            ll pe = mypow(2,po);
            ll dig =  mypow(10,j-1);
            ll add = pe*dig*d;
            sum += add;
        }
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<40;

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

    int N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    REP(i, N+1){
        cin >> A[i];
    }
    REP(i, N){
        cin >> B[i];
    }
    ll cnt = 0;
    ll minus = 0;
    for(int i = 0; i < N; i++){
        minus = min(B[i], A[i]);
        cnt+= minus;
        B[i] -= minus;
        A[i] -= minus;

        minus = min(B[i], A[i+1]);
        cnt+= minus;
        B[i] -= minus;
        A[i+1] -= minus;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
		
	int n, d;
	cin >> n;
	cin >> d;
	
	int numGuardLooking = 2*d + 1;
	int answer = n / numGuardLooking;
	if(n % numGuardLooking != 0) answer++;
	
	cout << answer  << endl;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int N,P;
  cin>>N>>P;
  int count0=0,count1=0,temp;
  for(int i=0;i<N;i++){
    cin>>temp;
    if(temp%2) count1++;
    else count0++;
  }
  ll ans=1;
  for(int i=0;i<N-1;i++){
    ans*=2;
  }
  if(count1==0){
    if(P==0) ans*=2;
    if(P==1) ans=0;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    ll n;scanf("%lld",&n);
    vector<ll> a(n);
    for(int i = 0;i < n;i++)scanf("%lld",&a[i]);

    int can[100010];fill(can,can+100010,0);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            can[a[i]+j]++;
        }
    }
    int maxi,maxn;maxi=maxn=0;
    for (int i = 0; i < 100010; ++i)
    {
        if(can[i] > maxn)maxn = can[i],maxi = i;
    }
    cout << maxn << endl;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int ans = 0;
  int n;
  cin >> n;
  rep(i, 1, n + 1, 1) {
    int x;
    cin >> x;
    if (x % 2 && i % 2) ans++;
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
cost = [0] * n
cost[1] = abs(a[1]-a[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]))

print(cost[n-1])

Measured memory_bytes: 85040
import java.util.Scanner;

public class Main{
  static int n;
  static long a, b;
  static int[] x;

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

    n = sc.nextInt();
    a = sc.nextInt();
    b = sc.nextInt();
    x = new int[n];
    for(int i = 0; i < n; i++){
      x[i] = sc.nextInt();
    }

    if(a > b){
      System.out.println(b * (n - 1));
      return;
    }

    long sum = 0;
    for(int i = 0; i + 1 < n; i++){
      int diff = (x[i + 1] - x[i]);
      if(a * diff < b){
        sum += a * diff;
      }
      else{
        sum += b;
      }
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 48476
import re
import numpy as np

N, Q = [int(item) for item in re.split(r"\s", input())]
S = input()

l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = [int(item) for item in re.split(r"\s", input())]

# ACの場所を探す
p_list = [0] * (N + 1)
i = 0
while i < N - 1:
    if S[i:i + 2] == "AC":
        p_list[i + 1] = 1
        i += 2
    else:
        i += 1


cumsum = np.cumsum(p_list)

out_list = []
for q in range(Q):
    # qに答える
    l_i = l[q] - 1
    r_i = r[q] - 1

    if l_i >= 0:
        c_l = cumsum[l_i]
    else:
        c_l = 0
    c_r = cumsum[r_i]
    out_list.append(str(c_r - c_l))

print("\n".join(out_list))


Measured memory_bytes: 29692
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int n;
  vector<int> a;
  int tmp;
  int count = 0;

  cin >> n;
  a.resize(n);
  REP( i, n){
    cin >> a[i];
  }

  bool f = true;

  while(f){
    f = false;
    for( int j = n-1; j >= 1; --j){
      if( a[j] < a[j-1] ){
        tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;
        f = true;
        ++count;
      }
    }
  }

  REP( i, n-1){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << count << endl;
}

Measured memory_bytes: 3120
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

vector<vector<ll>> conbination(int n) {
	auto ans = vector<vector<ll>>(n + 1);
	ans[0].push_back(1);
	rep(i, n) {
		rep(j, i + 2) {
			if (j == 0 || j == i + 1) {
				ans[i+1].push_back(1);
			}
			else {
				ans[i + 1].push_back(ans[i][j - 1] + ans[i][j]);
			}
		}
	}
	return ans;
}



int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c1 = 0, c2 = 0, addF = 0;
	rep(i, n) {
		char a;
		a = s[i];
		if (a == '(') c1++;
		else c2++;
		if (c1 < c2) {
			addF++;
			c1++;
		}
	}
	rep(i, addF) {
		cout << '(';
	}
	cout << s;
	rep(i, c1 - c2) {
		cout << ')';
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <vector>
using namespace std;
const int maxn = 2e6+10;
typedef pair<int,int> pii;
typedef long long ll;

string S;
int main(){
    cin>>S;
    for(int i = 0;i<S.length();i++){
        cout<<'x';
    }
    return 0;
}

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

int main(){
	int n,W;
	int v[100],w[100];
	int dp[101][10001] = {};
	cin >> n >> W;
	for(int i = 0;i < n;i++){
		cin >> v[i] >> w[i];
	}
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= W;j++){
			if(j - w[i - 1] < 0) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = max(dp[i - 1][j],dp[i][j - w[i - 1]] + v[i - 1]);
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int used[3][3];

int main(){
  int a[3][3], n;
  for(int i = 0; i < 3; ++i){
  	for(int j = 0; j < 3; ++j){
  		cin >> a[i][j];
  	}
  }
  cin >> n;
  vector<int> b(n);
  for(int i = 0; i < n; ++i){
  	cin >> b[i];
  	for(int j = 0; j < 3; ++j){
  		for(int k = 0; k < 3; ++k){
  			if(b[i] == a[j][k])used[j][k] = 1;
  		}
  	}
  }

  int flg = 0;
  if(used[0][0]){
  	if((used[0][1] && used[0][2]) || 
  	   (used[1][0] && used[2][0]) ||
  	   (used[1][1] && used[2][2])){
  		flg = 1;
  	}
  }
  else if(used[1][1]){
  	if((used[1][0] && used[1][2]) ||
  	   (used[0][1] && used[2][0]) ||
  	   (used[0][2] && used[2][0])){
  		flg = 1;
  	}
  }
  else if(used[2][2]){
  	if((used[2][0] && used[2][1]) ||
  	   (used[0][2] && used[1][2])){
  		flg = 1;
  	}
  }

  if(flg)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_A 200000
#define MAX 60

signed main(){
    ll n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    vector<vector<ll>> dp(MAX + 1, vector<ll>(n));
    int nxt[MAX_A + 1];
    for(int i = 2 * n - 1; i >= 0; i--){
        dp[0][i % n] = nxt[a[i % n]] - i + 1;
        nxt[a[i % n]] = i;
    }
    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < n; j++){
            dp[i + 1][j] = dp[i][j] + dp[i][(dp[i][j] + j) % n];
            dp[i + 1][j] = min(dp[i + 1][j], n * k + 1);
        }
    }
    int now = 0;
    ll sum = n * k;
    while(sum > 0){
        for(int i = MAX; i >= 0; i--){
            if(dp[i][now] < sum){
                sum -= dp[i][now];
                now = (now + dp[i][now]) % n;
                goto ok;
            }
        }
        break;
        ok:;
    }
    bool exist[MAX_A + 1] = {};
    vector<int> ans;
    for(int i = now; i < n; i++){
        if(exist[a[i]]){
            while(exist[a[i]]){
                exist[ans.back()] = false;
                ans.pop_back();
            }
        }else{
            ans.emplace_back(a[i]);
            exist[a[i]] = true;
        }
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 100452
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int num[31];

int main(){
    rep(i,31)num[i]=i;
    int x,y;
    cin>>x>>y;
    
    int n,m;
    char b;
    rep(i,y){
        cin>>n>>b>>m;
        swap(num[n],num[m]);
    }
    for(int i=1;i<x+1;i++){
        cout<<num[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P_;
typedef pair<P_, ll> P;
P p[100000];


const ll INF = 1e+15;
vector<int> G[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int l, r;
        ll c;
        cin >> l >> r >> c;
        l--; r--;
        p[i] = P(P_(l, r), c);
    }
    sort(p, p+M);
    map<int, ll> mp;
    mp[0] = 0;
    mp[N-1] = INF;
    for(int i = 0; i < M; i++){
        int l = p[i].first.first;
        int r = p[i].first.second;
        ll c = p[i].second;
        auto ptr = mp.lower_bound(l);
        auto ptrr = mp.lower_bound(r);
        if(mp.count(r) == 0){
            mp[r] = min(ptr->second+c, ptrr->second);
        }else{
            mp[r] = min(ptr->second+c, ptrr->second);
        }
        
        ll tmp = mp[r];
        while(true){
            auto ptr2 = mp.find(r);
            ptr2--;
            int idx = ptr2->first;
            if(ptr2->second < tmp) break;
            else mp.erase(idx); 
        }
    }
    // for(auto itr = mp.begin(); itr != mp.end(); itr++){
    //     cout << itr->first << ' ' << itr->second << endl;
    // }
    if(mp[N-1] >= INF){
        cout << -1 << endl;
    }else{
        cout << mp[N-1] << endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    long long ans = 0;
    cin >> n;
    vector<long long> a(n), b(n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a[i], &b[i]);
    }
    for(int i = n-1; i >= 0; i--){
        a[i] += ans;
        if(a[i] % b[i] != 0) ans += b[i] - a[i] % b[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll K, X;
    cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
	
	int a,b,c;
	int a1=0,a2=0;
	
	while(scanf("%d,%d,%d",&a,&b,&c) == 3){
		
		if(a*a + b*b == c*c){
			a1++;
		}
		if(a == b){
			a2++;
		}
		
	}
	
	printf("%d\n%d\n",a1,a2);
	
	return 0;
	
}


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

int main()
{
  string str[3];
  
  for(int i = 0; i < 3;i++){
    cin >> str[i];
    
  }
  for(int i = 0; i < 3; i++){
    cout << str[i][i];
    
  }
  cout << endl;
  
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        SimekiriCost[] simekiriCost = new SimekiriCost[N];
        for(int i=0;i<N;i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            simekiriCost[i] = new SimekiriCost(b, a);
        }
        sc.close();
        
        System.out.println(isYes(simekiriCost)? "Yes":"No");
    }
    
    private static boolean isYes(SimekiriCost[] target) {
        Arrays.sort(target, (x, y) -> x.simekiri - y.simekiri);
        int sumCost=0;
        for(int i=0;i<target.length;i++) {
            sumCost += target[i].cost;
            if(sumCost > target[i].simekiri) {
                return false;
            }
        }
        return true;
    }

}

class SimekiriCost{
    int simekiri;
    int cost;
    public SimekiriCost(int simekiri, int cost) {
        super();
        this.simekiri = simekiri;
        this.cost = cost;
    }
    
    
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

int dp[100005];
int v[100005], n, k;
bool mark[100005];

int f(int i) {
	if(i == n-1) return 0;
	if(mark[i]) return dp[i];
	mark[i] = true;
	int ret = 1e9;
	for(int j = i+1; j <= i+k; j++) {
		if(j >= n) break;
		ret = min(ret, f(j) + abs(v[j] - v[i]));
	}

	return dp[i] = ret;
}

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

	for(int i = 0; i < n; i++)
		scanf("%d", &v[i]);
	printf("%d\n", f(0));
    
    return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int cnt[n+1];
	memset(cnt,0,sizeof(cnt));
	vector<int> v;
	int num=1;
	while(1)
	{
		if(!cnt[num])
		{
			v.pb(num);
			cnt[num]=1;
			num=a[num];
		}
		else
		{
			break;
		}
	}
	reverse(v.begin(),v.end());
	k++;
	while(v.back()!=num)
	{
		int res=v.back();
		v.pop_back();
		k--;
		if(k==0)
		{
			cout<<res<<endl;
			return 0;
		}
	}
	reverse(v.begin(),v.end());
	ll p=v.size();
	ll val=(k%p);
	if(val==0)
	{
		cout<<v.back()<<endl;
	}
	else
	{
		cout<<v[val-1]<<endl;
	}
	return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	
	vector<vector<int> > sw(M);
	
	rep(i,M){
		vector<int> k(M);
		cin >> k[i];
		rep(j,k[i]){
			int s;
			cin >>s;
			s--;
			sw[i].push_back(s);
		}
	}
	
	vector<int> p(M);
	rep(i,M){
		cin >> p[i];
	}
	
	ll ans = 0;
	
	rep(bit, 1<<N){
		bool ok = true;
		rep(i,M){
			int count = 0;
			for(auto v: sw[i]){
				if(bit & (1 << v)){
					count++;
				}
			}
			if(count % 2 != p[i]){
				ok = false;
			}
		}
		if(ok){
			ans++;
		}
	}
	
	cout << ans << endl;
}




Measured memory_bytes: 256
N, M = map(int, input().split())
zahyou = list(map(int,input().split()))
zahyou.sort()
difference = []
ans = 0

if N >= M:
    ans = 0
else:
    for i in range (M-1):
        difference.append(zahyou[i+1] - zahyou[i])
    difference.sort()
    ans = sum(difference[:M-N])

print(ans)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b=1,c,d[100000001],e=0,f,i,g[100000001],h=100000000000,j,m,n,z,x=1,k=0,y=1,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s1,s2="Yes";
    cin>>s>>s1;
    for(i=0;i<s.size();i++){
        if(s[i]!=s1[i]){
            s2="No";
            break;
        }
    }
    cout<<s2;
}

Measured memory_bytes: 3628
import math

if __name__ == "__main__":
    n = int(input())
    A = list(map(int,input().split()))

    zantei = A[0]
    goukei = 0
    for a in A[1:]:
        if zantei>a:
            goukei += zantei - a
        elif zantei<a:
            zantei = a
    print(goukei)


Measured memory_bytes: 33008
using System;
using System.Linq;

class prog{
  static void Main(){
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    Console.WriteLine(n[2] <= n[1] ? "delicious" : n[2] > n[1]&&n[2] <= n[1] + n[0] ? "safe" : "dangerous");
  }
}

Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string a,b; cin>>a>>b;
    a=a+b; reverse(al(a));
    int n=0,c=1;
    rep(i,a.size()){
        n+=c*(a[i]-'0');
        c*=10;
    }
    for(int i=1;i<=1000;i++){
        if(i*i==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    ans = N-1
    ans = ans // 2
    print(ans)
    
    
if __name__ == "__main__":
	main()


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

int N,M;
set<string> S;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    string s; cin >> s; S.insert( s );
  }
  cin >> M;
  bool f = false;
  for(int i=0;i<M;i++){
    string s; cin >> s;
    if( S.find( s ) != S.end() ){
      if( !f ){
        cout << "Opened"; f = true;
      } else {
        cout << "Closed"; f = false;        
      }
      cout << " by ";
    } else
      cout << "Unknown ";
    cout << s << endl;
  }
}

Measured memory_bytes: 1232
def f(s, a)
  [s, a].transpose.count { |l, r| l != r }
end
s = STDIN.readline.chomp.split('').map(&:to_i)
n = s.size()
puts [f(s, ([0, 1] * n).take(n)), f(s, ([1, 0] * n).take(n))].min()


Measured memory_bytes: 22908
#include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    int M = 1000000007;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin>>n;
        std::vector<int> v(n);
        fr(i,n)
        cin>>v[i];
        int ans=v[0];
        fr(i,n-1)
        {
            if(v[i+1]>=v[i])
                ans+=(v[i+1]-v[i]);
            else
                continue;
        }
        cout<<ans<<endl;
        return 0; 
    }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
ll mtx[16][16];
ll dp[1 << 16];
ll res[1 << 16];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> mtx[i][j];
		}
	}
	for (int bit = 0; bit < (1 << N); bit++) {
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (((bit >> i) & 1) && ((bit >> j) & 1)) {
					res[bit] += mtx[i][j];
				}
			}
		}
	}

	for (int bit = 0; bit < (1 << N); bit++) {
		dp[bit] = res[bit];
		for (int T = (bit - 1) & bit; T > 0; T = (T - 1) & bit) {
			dp[bit] = max(dp[bit], dp[T] + dp[bit - T]);
		}
	}

	cout << dp[(1 << N) - 1] << endl;

	return 0;
}

Measured memory_bytes: 1280
// 本番中に書いてTLEになったコード
//
// A->B, B->Aを別々に考える。
//
// (1)A->Bに行くとき、
//    Aにて金に何グラム変えるか、銀に何グラム変えるかを全探索して、
//    Bでのドングリの数を最大化。
//
// (2)B->Aも同様。
//
// 本番ではドングリの数を最大化するところでTLEした。
// https://atcoder.jp/contests/diverta2019-2/submissions/5926907
// を参考にDPで解き直した。
//
// 最初のドングリの数をナップサックの容量と考える。
// ドングリP個をドングリQ個に変えられるというのを、
// 容量Pで価値Qの品物だと読み替える。

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll solve(ll Ga, ll Sa, ll Ba,
         ll Gb, ll Sb, ll Bb,
         ll N) { 
    vector<ll> dp(N + 1);
    FOR(i, 1, N + 1) {
        dp[i] = dp[i - 1] + 1;  // ドングリから金属に変えない場合
        if (i >= Ga) dp[i] = max(dp[i], dp[i - Ga] + Gb);
        if (i >= Sa) dp[i] = max(dp[i], dp[i - Sa] + Sb);
        if (i >= Ba) dp[i] = max(dp[i], dp[i - Ba] + Bb);
    }
    return dp[N];
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll N;
    cin >> N;
    ll Ga, Sa, Ba;
    ll Gb, Sb, Bb;
    cin >> Ga >> Sa >> Ba;
    cin >> Gb >> Sb >> Bb;

    ll acorns1 = solve(Ga, Sa, Ba, Gb, Sb, Bb, N);
    cerr << acorns1 << endl;
    ll acorns2 = solve(Gb, Sb, Bb, Ga, Sa, Ba, acorns1);
    cout << acorns2 << endl;
    return 0;
}


Measured memory_bytes: 195584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] list = scanner.nextLine().toCharArray();
		for(char a:list)
			if(Character.isLowerCase(a))
				System.out.print(Character.toUpperCase(a));
			else
				System.out.print(Character.toLowerCase(a));
		System.out.println();
	}
}

Measured memory_bytes: 17252
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b = sc.nextInt();
    int t = sc.nextInt();

    double d =  t/a;
    double ans =(int) b*d;
    int mainans = (int) ans;
    System.out.println(mainans);


    }
  }


Measured memory_bytes: 21844