akhauriyash/Code-Regression huggingface dataset:
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k;
    cin >> k;
    queue<ll> q;
    vector<ll> v;
    for (int i = 1; i <= 9; i++)
    {
        q.push(i);
        v.pb(i);
    }
    ll cnt = 0;
    while (cnt < 100009)
    {
        ll tp = q.front();
        q.pop();
        ll num = tp;
        num %= 10;
        tp *= 10;
        if (num != 0 && num != 9)
        {
            q.push(tp + num - 1);
            q.push(tp + num);
            q.push(tp + num + 1);
            v.pb(tp + num - 1);
            v.pb(tp + num);
            v.pb(tp + num + 1);
            cnt += 3;
        }
        else if (num == 0)
        {
            q.push(tp + num);
            q.push(tp + num + 1);
            v.pb(tp + num);
            v.pb(tp + num + 1);
            cnt += 2;
        }
        else if (num == 9)
        {
            q.push(tp + num - 1);
            q.push(tp + num);
            v.pb(tp + num - 1);
            v.pb(tp + num);
            cnt += 2;
        }
    }
    cout << v[k - 1];
}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  // 111
  int b = a / 100;
  // 111 / 100 = 1
  int c = a % 100;
  // 111 % 100 = 11

  int d = c / 10;
  // 11 / 10 = 1
  int e = c % 10;
  // 11 % 10 = 1
  cout << b + d + e << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;

	char num[6];
	int counter = 0;

	for (int i = 1; i < 10; i++){
		num[0] = num[4] = '0' + i;
		for (int j = 0; j < 10; j++){
			num[1] = num[3] = '0' + j;
			for (int k = 0; k < 10; k++){
				num[2] = '0' + k;

				int temp = strtol(num, NULL, 10);
				if(A <= temp && temp <= B){
					counter++;
				}
			}
		}
	}

	cout << counter << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<int> g[100010];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    queue<int> q;
    vector<int> dist(n + 1, -1);
    vector<int> pre(n + 1, -1);
    dist[0] = 0;
    q.push(1);

    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int u : g[v])
        {
            if (dist[u] != -1)
                continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    Rep(i, 2, n + 1)
    {
        int ans = pre[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 10564
#include <cstdio>
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x = a*b;
	int y = c*d;
	if (x >= y) printf("%d\n",x);
	else printf("%d\n",y);
	return 0;
}

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

typedef long long LL;
const int M=1e5+5;
int a[M],b[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&b[i]);
	LL ans=0;
	for(int i=0;i<n;i++)
	{
		int beat=min(a[i],b[i]);
		ans+=beat;
		b[i]-=beat;
		beat=min(a[i+1],b[i]);
		ans+=beat;
		a[i+1]-=beat;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) FOR(i, 0, n)
const int INF = 1001001001;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for (string &i : s) cin >> i;
  vvi l(h, vi(w, INF));
  priority_queue<vi, vvi, greater<vi>> q;
  q.push({0, ch, cw});
  while (!q.empty()) {
    int gl = q.top().at(0);
    int gh = q.top().at(1);
    int gw = q.top().at(2);
    q.pop();

    if (gl >= l[gh][gw]) continue;

    l[gh][gw] = gl;
    FOR(mh, -2, 3) FOR(mw, -2, 3)
      if ((mh != 0 or mw != 0) and
          (0 <= gh + mh and gh + mh < h) and 
          (0 <= gw + mw and gw + mw < w) and
          (s[gh + mh][gw + mw] == '.') and
          (gl + (abs(mh) + abs(mw) == 1 ? 0 : 1) < l[gh + mh][gw + mw]))
        q.push({gl + (abs(mh) + abs(mw) == 1 ? 0 : 1), gh + mh, gw + mw});
  }
  if (l[dh][dw] != INF) cout << l[dh][dw] << endl;
  else cout << -1 << endl;
  return 0;
}


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

int n, p, mayor[50], wan, basyo;

int main()
{
  while(true){
    
    cin >> n >> p;
    if(n == 0 && p == 0) break;
    
    for(int i = 0 ; i < n ; i++){
      mayor[i] = 0;
    }
    wan = p;
    basyo = 0;

    while(true){
      if(wan > 0){
	mayor[basyo]++;
	wan--;
	if(mayor[basyo] == p){
	  cout << basyo << '\n';
	  break;
	}
      }else{
	wan = mayor[basyo];
	mayor[basyo] = 0;
      }
	basyo++;
	if(basyo == n) basyo = 0;
    }
  }
}

Measured memory_bytes: 1160
input_data = input().split(" ")

N = int(input_data[0])
D = int(input_data[1])
cnt = 0
tree = [i+1 for i in range(N)]
#d_range = 2*D
while tree != []:
  if len(tree) > 2*D:
    del tree[0: 2*D+1]
    cnt += 1
  else:
    del tree[0:]
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    string s;
    cin >> s;
    ll n = s.size();

    auto sa = suffix_array(s);
    ll ans = n * (n + 1) / 2;
    for(auto i : lcp_array(s, sa)){
        ans -= i;
    }
    co(ans);

    return 0;
}

Measured memory_bytes: 15576
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;

vector<int> dijkstra(vector<vector<int>> es,int n,int s){
  
  vector<int> dist(n,LLONG_MAX);
  using Pi = pair<int,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    int cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto e : es[idx]){
      auto next_cost = cost + 1;
      if(dist[e] <= next_cost) continue;
      dist[e] = next_cost;
      q.emplace(dist[e],e);
    }
  }
  return dist;
}


main(){
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;

  vector<vector<int>> es(n);

  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    es[x].push_back(y);
    es[y].push_back(x);
  }

  vector<int> sv = dijkstra(es,n,s);
  vector<int> tv = dijkstra(es,n,t);

  int dist = sv[t];
  if(dist==LLONG_MAX){
    cout<<0<<endl;
    return 0;
  }
  sort(all(sv));
  sort(all(tv));
  int ans=0;
//  cout<<dist<<endl;

  for(int i=0;i<dist;i++){
    int d = dist-i-2;
    int res1 = upper_bound(all(sv),i) - lower_bound(all(sv),i);
    int res2 = upper_bound(all(tv),d)- lower_bound(all(tv),d);
    
//    cout<<res1<<' '<<res2<<endl;
    ans+=res1*res2;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 20416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main{
  public static void main(String[] args)throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int numAll = Integer.parseInt(br.readLine());
    
    String[] numsStr = br.readLine().split(" ");
  
    Set<String> numSet = new HashSet<>();
    
    for(int i=0; i<numAll; i++){
      numSet.add(numsStr[i]);
    }
    
    if(numAll == numSet.size()){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
#define int long long
// --------------------------------------------------------------------------------

void test_case(int tc)
{
	int n;cin>>n;
	int primes[1000009];
	mset(primes,0);
	primes[0]=1,primes[1]=1;
	for(int i=2;i*i<1000009;++i)
	{
		if(primes[i]==0)
		{
			for(int j=i*i;j<1000009;j+=i)
			{
				primes[j]=1;
			}
		}
	}
	int arr[n];frepi(0,n-1)cin>>arr[i];
	int gcd = arr[0];
	for(int i=1;i<n;++i)gcd=(__gcd(arr[i],gcd));
	if(gcd!=1){
		cout<<"not coprime";
		return;
	}
	set<int>factors;
	for(int j=0;j<n;++j){
		int x = arr[j];
		if(arr[j]==1)continue;
		if(x%2==0){
			if(factors.find(2)!=factors.end()){
				cout<<"setwise coprime";
				return;
			}
			factors.insert(2);
			while(x%2==0)x/=2;
		}
		if(x%3==0){
			if(factors.find(3)!=factors.end()){
				cout<<"setwise coprime";
				return;
			}
			factors.insert(3);
			while(x%3==0)x/=3;
		}
		for(int i=5;i*i<=x;i+=6){
			if((x%i)==0){
				if(primes[i]==0){
					if(factors.find(i)!=factors.end()){
						cout<<"setwise coprime";
						return;
					}
					factors.insert(i);
					while(x%i==0)x/=i;
				}
			}
			if((x%(i+2))==0){
				if(primes[i+2]==0){
					if(factors.find(i+2)!=factors.end()){
						cout<<"setwise coprime";
						return;
					}
					factors.insert(i+2);
					while(x%(i+2)==0)x/=(i+2);
				}
			}
		}
		if(x>1){
				if(factors.find(x)!=factors.end()){
					cout<<"setwise coprime";
					return;
				}
				factors.insert(x);
		}
	}
	cout<<"pairwise coprime";
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

Measured memory_bytes: 19248
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=50;


int main(){
    ll n,m;
    cin>>n>>m;
    ll p[m],y[m];
    vector<ll> v[n];
    for(ll i=0;i<m;i++){
        cin>>p[i]>>y[i];
        p[i]--;
        v[p[i]].push_back(y[i]);
    }
    for(ll i=0;i<n;i++){
        sort(v[i].begin(),v[i].end());
    }
    for(ll i=0;i<m;i++){
//        cout<<p[i]<<" "<<y[i]<<endl;
        vector<ll>::iterator it = lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]);
        cout << setw(6) << setfill('0') << p[i]+1 << setw(6) << setfill('0') << (it - v[p[i]].begin())+1<<endl;
    }
    //for(ll i=0;i<2;i++)cout<<v[0][i]<<endl;

    return 0;
}


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

int main() {
  int N,L;
  cin>>N>>L;
  vector<string> s(N);
  for(int i=0;i<N;i++) cin>>s.at(i);
  
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++) cout<<s.at(i);
  cout<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

int main(){
	int n;
	while(cin>>n,n){
		dice<int> d;
    d[TOP] = 0; d[FRONT] = 4; d[LEFT] = 2;
    d[RIGHT] = 3; d[BACK] = 1; d[BOTTOM] = 5;
		REP(i,n){
			string dir;
			cin>>dir;
			if(dir=="north"){
				REP(i,3)d.roll_x();
			}else if(dir=="south"){
				d.roll_x();
			}else if(dir=="west"){
				REP(i,3)d.roll_y();
			}else if(dir=="east"){
				d.roll_y();
			}

		}
		cout<<d[TOP]+1<<endl;
	}
}

Measured memory_bytes: 1212
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let r: usize = iterator.next().unwrap().parse().unwrap();

    return if n >= 10 {
        format!("{}", r)
    } else {
        format!("{}", r + (100 * (10 - n)))
    }
}


Measured memory_bytes: 4352
def solve():
    X = int(input())

    def get_time(target_x):
        x = 0

        for i in range(0, 10**9):
            x = x + i + 1
            if target_x <= x:
                return i + 1

    res = get_time(X)

    return res


if __name__ == '__main__':
    res = solve()
    print(res)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()


const long MAX = 310000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

vector<long> Data(32);

void BitInit(){
    Data.at(0) = 2;
    Data.at(1) = 4;
    for(int i=2;i<32;i++){
        Data.at(i) = Data.at(i-1)*Data.at(i-1);
        Data.at(i) %= MOD;
    }
}

long calca(long n){
    if(n == 1) return 2;
    else{
        if(n % 2 == 0) return calca(n/2)*calca(n/2)%MOD;
        else return 2*calca(n/2)*calca(n/2)%MOD;
    }
}

/*
int main(){
    long n,a,b;
    cin >> n >> a >> b;
    //COMinit();
    BitInit();
    bitset<32> s(n);
    long ans = 0;
    rep(i,32){
        if(s.test(i)) ans += Data.at(i);
        ans %= MOD;
    }
    long ans = calca(n);
    long tmp1 = 1;
    rep(i,a){
        tmp1 *= (n-i);
        tmp1 /= i+1;
        tmp1 %= MOD;
    }
    long tmp2 = 1;
    rep(i,b){
        tmp2 *= (n-i);
        tmp2 /= i+1;
        tmp2 %= MOD;
    }
    ans -= 1;
    ans -= tmp1;
    ans += MOD;
    ans %= MOD;
    ans -= tmp2;
    ans += MOD;
    ans %= MOD;

    cout << ans << endl;
}*/


int main(){
    long n,a,b;
    cin >> n >> a >> b;
    COMinit();
    BitInit();
    
    long ans = calca(n);
    long tmp1 = 1;
    rep(i,a){
        tmp1 *= (n-i);
        tmp1 %= MOD;
        tmp1 *= inv[i+1];
        tmp1 %= MOD;
    }

    long tmp2 = 1;
    rep(i,b){
        tmp2 *= (n-i);
        tmp2 %= MOD;
        tmp2 *= inv[i+1];
        tmp2 %= MOD;
    }
    ans -= 1;
    ans -= tmp1;
    ans += MOD;
    ans %= MOD;
    ans -= tmp2;
    ans += MOD;
    ans %= MOD;

    cout << ans << endl;

}

Measured memory_bytes: 7552
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Char
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,!k] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 2 <= n <= 10^5, 1 <= k <= 100
  h <- V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- 1 <= hi <= 10^4
  let dp = V.constructN n $ \dp ->
        if V.null dp
        then 0
        else let !i = V.length dp
                 !h_i = h V.! i
             in V.minimum $ V.map (\(dp_j, h_j) -> dp_j + abs (h_i - h_j)) $ V.drop (i-k) $ V.zip dp h
  print (V.last dp :: Int)


Measured memory_bytes: 3708
n = gets.to_i
x = []
x = gets.chomp.split.map(&:to_i)

m = gets.to_i
a = []
a = gets.chomp.split.map(&:to_i)

a.each{|i|
    cango = true
    cango = false if x[i-1] == 2019
    cango = false if !x[i].nil? && x[i] == x[i-1] + 1
    x[i-1] += 1 if cango
}
puts x


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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  }
  else {
    cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2 << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int c = 0;

        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                c = i * j;
                if(a == c){
                    System.out.println("Yes");
                    return;
                } 
            }
        }
        System.out.println("No");
    } 
}

Measured memory_bytes: 23636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int N, W;
    int value[105], weight[105];

    int dp[105][10005];

    cin >> N >> W;
    for(int i = 0; i < N; i++) cin >> value[i] >> weight[i];

    for(int w = 0; w < W; w++) dp[0][w] = 0;

    for(int i = 0; i < N; i++){
        for(int w = 0; w <= W; w++){
            if(w >= weight[i]){
                dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
            }else{
                dp[i+1][w] = dp[i][w];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



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

using namespace std;

void solve(void)
{
	string s;
	int k, n;
	cin >> s >> k;
	n = s.size();
	for (int i = 0; i < n; i++)
	{
		if (i == n-1)
		{
			cout << (char)((s[i]+k-'a')%26+'a');
			break;
		}
		int x = ('z'-s[i]+1)%26;
		if (k < x)
		{
			cout << s[i];
		}
		else
		{
			k -= x;
			cout << 'a';
		}
	}
	cout << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main() {
	int n, k, x, y, total;
	scanf("%d%d%d%d", &n, &k, &x, &y);
	if (k > n) k = n;
	total = k * x + (n - k) * y;
	
	printf("%d\n", total);
	return 0;
}

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

#define lint long long

lint MOD = 1000000007;

using namespace std;

int main(){
    string S;
    cin >> S;
    
    bool flag = false;
    flag = ((S[0] == S[1] && S[2] == S[3])||(S[0] == S[2] && S[1] == S[3]) || (S[0] == S[3] && S[1] == S[2]));
    if(flag){
        if(S[0] == S[1] && S[0] == S[2]) flag=false;
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
}

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


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    long long x;
    cin>>x;
    long long n=(x/500)*1000;
  	long long y=(x-n/2)/5;
    cout<<n+y*5<<"\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
# INF = 1<<32s


def solve(N: int, S: str):
    ans = 0
    for i in range(1000):
        si = format(i, '03')

        idx = 0
        for j in range(len(S)):
            if idx >= len(si):
                break
            elif si[idx] == S[j]:
                idx += 1

        if idx == len(si):
            ans += 1

    print(ans)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, S)

if __name__ == '__main__':
    main()


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

int col[205], dist[205][205];
vector<int> G[205];

bool dfs(int u, int d) {
	col[u] = d % 2;
	for (auto& v : G[u]) {
		if (col[u] == col[v] || (col[v] == -1 && !dfs(v, d + 1))) return false;
	}
	return true;
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) dist[i][j] = (i != j) * 1e9;
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			char c;
			cin >> c;
			if (c == '1') {
				G[i].push_back(j);
				dist[i][j] = 1;
			}
		}
	}

	memset(col, -1, 4 * N);
	if (!dfs(0, 0)) {
		cout << -1 << '\n';
		return 0;
	}	
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) ans = max(*max_element(dist[i], dist[i] + N), ans);
	cout << ans + 1 << '\n';
	return 0;
}

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

#define x first
#define y second

using namespace std;

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

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

const int maxn=100000;

bool ass[maxn];
string s;
int n;

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

	cin >> n >> s;
	for (int i=0;i<2;i++) for (int j=0;j<2;j++) {
		ass[0]=i;
		ass[1]=j;
		for (int k=1;k+1<n;k++) ass[k+1]=ass[k-1]^(s[k]=='x')^(ass[k]==1);
		bool suc=1;
		for (int k=0;k<n;k++) if (ass[(k+1)%n]^(ass[(n+k-1)%n])^(s[k]=='x')^(ass[k]==1)) suc=0;
		if (suc) {
			for (int k=0;k<n;k++) cout << (ass[k]?'W':'S');
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
int32_t main()
{
    _FAST
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<(int)s.size();i++)
        ans+=(s[i]!=t[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<int, int>;

bool comp(const P& a, const P& b)
{
  if(a.second!=b.second){
    return a.second > b.second;
  }else{
    return a.first > b.first;
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<P> red(n), blue(n);
  REP(i,n) cin >> red[i].first >> red[i].second;
  REP(i,n) cin >> blue[i].first >> blue[i].second;
  sort(ALL(red), comp);
  sort(ALL(blue));
  vector<bool> used(n, false);
  int ans = 0;
  REP(b,n){
    int bx = blue[b].first;
    int by = blue[b].second;
    REP(r,n){
      if(used[r]) continue;
      int rx = red[r].first;
      int ry = red[r].second;
      if(bx>rx && by>ry){
        used[r] = true;
        ans++;
        break;
      }
    }
  }

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


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

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  int ans = INF;
  ans = min(ans, abs(a-b)+abs(b-c));
  ans = min(ans, abs(a-c)+abs(c-b));
  ans = min(ans, abs(b-a)+abs(a-c));
  ans = min(ans, abs(b-c)+abs(c-a));
  ans = min(ans, abs(c-a)+abs(a-b));
  ans = min(ans, abs(c-b)+abs(b-a));
  cout << ans << endl;

}

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

int n;
int c[1001], w[1001];
bool done[1001][1001];
bool dp[1001][1001];

int sumw( int l, int r ){
	return w[r] - w[l-1];
}

//[l, r]???????????§???????????????????????????
bool isOk( int l, int r ){
	if( done[l][r] )
		return dp[l][r];
		
	if( l == r )
		return true;
	
	bool ans = false;
	//???l???????????????????????¨?????????
	ans |= isOk(l + 1, r) && sumw(l+1, r) <= c[l];
	//???r???????????????????????¨?????????
	ans |= isOk(l, r - 1) && sumw(l, r-1) <= c[r];
	done[l][r] = true;
	return (dp[l][r] = ans);
}

int main()
{
	cin >> n;
	for( int i = 0; i < n; i++ ){
		cin >> c[i+1] >> w[i+1];
		w[i+1] += w[i];
	}
	
	int l = 1;
	int ans;
	for( ans = 0; l <= n; ans++ ){
		int r;
		for( r = n; r > l; r-- ){
			if( isOk(l, r) )
				break;
		}
		l = r + 1;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int MSIZE  = 100100;

const long long inf = 1e18;

long long dp[MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    fill(dp, dp + MSIZE, inf);

    int N, W;
    cin >> N >> W;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        int v, w;
        cin >> w >> v;
        for (int j = MSIZE - 1; j >= 0; j--) {
            if (j + v > MSIZE) continue;
            dp[j + v] = min(dp[j + v], dp[j] + w);
        }
    }
    int ans = 0;
    for (int i = 0; i < MSIZE; i++) {
        if (dp[i] <= W) ans = i;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
s = input()
k = int(input())

ls = len(s)
l = []
tmp = 1
for i in range(ls-1):
    if (s[i] == s[i+1]):
        tmp += 1
    else:
        l.append(tmp)
        tmp = 1
l.append(tmp)

ans = 0
ss = 0
ll = len(l)
#文字列が1つの文字列で構成されていないとき
if (ll != 1) :
    #最初と最後の文字が同じとき
    if (s[0] == s[ls-1]):
        ans -= (l[0] // 2 + l[ll-1] // 2 - (l[0] + l[ll-1]) // 2) * (k-1)

    for i in range(ll):
        ss += l[i] // 2
    print(ans+ss*k)
else :
    print(ls * k // 2)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


 
int main() {
	int H, N;
	cin >> H >> N;
	
	vector<int> A(N);
	int sum = 0;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		sum += a;
		
	}
	
	if (H > sum) cout << "No" << endl;
	else cout << "Yes" << endl;

	
	
    return 0;
}





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

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

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  char b=in<char>();
  
  switch(b){
    case 'A':
      cout << 'T' << endl;
      return 0;
     case 'T':
      cout << 'A' << endl;
      return 0;
      case 'G':
      cout << 'C' << endl;
      return 0;
      default:
      cout << 'G' << endl;
      return 0;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char x[1001];
	int i;
	while(scanf("%s",x)!=EOF){
		i=0;
	while(i<1002){
		if(x[i]=='\0')
		break;
		if(x[i]==65||x[i]==66||x[i]==67)
		x[i]+=23;
		else
		x[i]-=3;
		i++;
	}
	printf("%s\n",x);
	}
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  int X = nextInt();

  if (A <= X && X <= A + B) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
zougen = 4 #0は変化無し、1は減少、２は増加、4は未決定
ans=1
for i in range(N-1):
    if zougen==4:
        if A[i]-A[i+1]<0:
            zougen = 2
        elif A[i]-A[i+1]>0:
            zougen = 1
        else:
            zougen =0
    if A[i]-A[i+1]<0:
        if zougen == 1:
            ans+=1
            zougen=4
        if zougen == 0:
            zougen =2
    if A[i]-A[i+1]>0:
        if zougen == 2:
            ans+=1
            zougen=4
        if zougen ==0:
            zougen = 1
print(ans)

Measured memory_bytes: 14428
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n;

int main(){
	cin >> n;
	vi a, b;
	int one = 0, zero = 0, t;
	rep(i, n){
		cin >> t;
		if(t < 2) b.pb(t);
		else a.pb(t);
		
		if(t == 0) zero++;
		if(t == 1) one++;
	}
	sort(all(a));
	sort(all(b));
	
	if(zero % 2 && one){
		swap(b[zero - 1], b[zero]);
	}
	if(zero % 2 && one == 0 && a.size()){
		b.insert(b.end() - 1, a[0]);
		a.erase(a.begin());
	}
	if(a.size() > 1 && a[a.size() - 1] == 3 && a[a.size() - 2] == 2){
		swap(a[a.size() - 1], a[a.size() - 2]);
	}
	rep(i, a.size()) cout << a[i] << endl;
	rep(i, b.size()) cout << b[i] << endl;
	
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e18 + 1;

ll n, m, k;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, x, y, z,  N;
	cin >> n >> k;
	ll p[n], c[n];
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	rep(i, n) cin >> c[i];
	ll ans = -INF;
	rep(j, n) {
		ll s = j;
		v<ll> pf;
		pf.pb(c[s]);
		s = p[s];
		while (s != j) {
			pf.pb(pf[pf.size() - 1] + c[s]);
			s = p[s];
		}
		ll sz = pf.size();
		if (k <= sz) {
			ll val = -INF;
			for (i = 0; i < k; i++) {
				val = max(val, pf[i]);
			}
			ans = max(val, ans);
		}
		else {
			if (pf[sz - 1] < 0) {
				ll val = -INF;
				for (i = 0; i < sz; i++) {
					val = max(val, pf[i]);
				}
				ans = max(val, ans);
			}
			else {
				y = k / (sz);
				ll val1 = (pf[sz - 1]) * (y);
				ll mx = -INF;
				x = k % sz;
				for (i = 0; i < x; i++) {
					mx = max(mx, pf[i]);
				}
				val1 += mx;
				ans = max(ans, val1);

				mx = -INF;
				ll val2 = (pf[sz - 1]) * (y - 1);
				for (i = 0; i < sz; i++) {
					mx = max(mx, pf[i]);
				}
				val2 += mx;
				ans = max(ans, val2);

			}
		}
		//cout << sz << '\n';
	}
	cout << ans;




	return 0;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#pragma region Library
using namespace std;

using ll = long long int; // int_fast64_t;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;

constexpr int INF = 1 << 30;  // 1073741824 2倍すると-2147483648
constexpr ll INFL = 1l << 62; // 4611686018427387904 2倍すると-0.9*10^18
constexpr int dx4[] = {0, 1, 0, -1};
constexpr int dy4[] = {1, 0, -1, 0};
constexpr int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy8[] = {0, -1, 0, 1, -1, -1, 1, 1};
// [a, b)
#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--)
// [a, b]
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
// [0, n)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) RFOR(i, 0, (n))

#pragma endregion
// === Library ===
// Vectors: vt vvt vi vvi vl vvl
// Consts:  INF INFL dx4 dy4 dx8 dy8
// Loops:   FOR FORR RANGE RANGER REP REPR

int main() {
  int n, x, m;
  cin >> n >> x;
  int mn = INF;
  REP(i, n) {
    cin >> m;
    x -= m;
    mn = min(mn, m);
  }
  cout << n + (x / mn) << endl;
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,pre[N],suf[N],ans;
char s[N];
int main(){
	n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;++i){
		pre[i]=pre[i-1]+(s[i]=='#');
	}
	for(int i=n;i>=1;--i){
		suf[i]=suf[i+1]+(s[i]=='.');
	}
	ans=n;
	for(int i=0;i<=n;++i){
		ans=min(ans,pre[i]+suf[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 5556
n = int(input())
nums = list(map(int, input().split()))
nums.sort()

counts = 0

for i in range(n):
  start, end = 0, i - 1
  while start < end:
    if nums[start] + nums[end] > nums[i]:
      counts += end - start
      end -= 1
    else:
      start += 1
print(counts)


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

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

  int count = 0;
  bool breakf = false;
  while (true)
  {
    for (int i = 0; i < N;i++){
      if(a[i]%2==0)
        a[i] = a[i] / 2;
      else
        breakf = true;
    }
    if(breakf == true)
      break;
    count++;
  }

  cout << count;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int v = Integer.valueOf(br.readLine());
		ArrayList<Integer> amida = new ArrayList<Integer>(v);
		for(int i=0; i<v; i++)
			amida.add(i+1);

		int h = Integer.valueOf(br.readLine());
		
		for(int i=0; i<h; i++){
			String swapInd = br.readLine();
			int swap1 = Integer.valueOf(swapInd.split(",")[0]);
			int swap2 = Integer.valueOf(swapInd.split(",")[1]);
			Collections.swap(amida,swap1-1,swap2-1);
		}

		for(int i=0; i<v; i++)
			System.out.println(amida.get(i));
	}
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  vector<vector<int64_t>> C(26);
  for(int i=0; i<S.size(); i++){
    int x = S.at(i) - 'a';
    C.at(x).push_back(i+1);
  }
  for(int i=0; i<26; i++){
    C.at(i).push_back(10000000);
  }
  
  int64_t cnt = 0;
  int64_t pos = 0;
  vector<int64_t>::iterator itr;
  int64_t idx;
  for(int i=0; i<T.size(); i++){
    int x = T.at(i) - 'a';
    itr = upper_bound(C.at(x).begin(), C.at(x).end(), pos);
    idx = distance(C.at(x).begin(), itr);
    if(idx == 0 && C.at(x).at(idx) == 10000000){
      cnt = 0;
      pos = -1;
      break;
    }
    else if(C.at(x).at(idx) == 10000000){
      cnt++;
      pos = C.at(x).at(0);
    }
    else{
      pos = C.at(x).at(idx);
    }
  }
  if(pos != -1){
    cout << cnt * S.size()+ pos << endl;
  }
  else{
    cout << pos << endl;
  }
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,x;cin>>n>>x;
  vector<ll>slime(n);
  for(int i=0;i<n;i++)cin>>slime[i];
  ll ans=llINF;
  vector<ll>ser(n+10,llINF);
  for(ll i=0;i<n;i++){
    ll sum=0;
    for(ll j=0;j<n;j++){
      ser[j]=min(ser[j],slime[(j-i+n)%n]);
      sum+=ser[j];
    }
    sum+=i*x;
    ans=min(sum,ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
//#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}


int main(){
	ios_base::sync_with_stdio(false);
	string s; cin >> s;
	const string t = "AKIHABARA";
	const int n = s.size(), m = t.size();
	int i = 0, j = 0;
	while(true){
		if(i < n and j < m and s[i] == t[j]){++i; ++j;}
        else if(j < m && t[j] == 'A') ++j;
		else break;
	}
	cout << (i == n and j == m ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    int cnt = 0;
    rep(i,h)rep(j,w){
        if(a[i][j] =='#') cnt++;
    }
    if(cnt == h+w-1) cout << "Possible" <<endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

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

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

		int c[] = new int[n];
		for(int i = 0; i < n-1; i++){
			c[i] = sc.nextInt();
		}
		// System.out.println(Arrays.toString(c));

		int manzoku = 0;
		for(int i = 0; i<n; i++){
			// System.out.println("i="+i);
			if(i != 0 && a[i] == a[i-1]+1){
				manzoku = manzoku + b[a[i]-1] + c[a[i]-2];
				// System.out.println("*b="+b[a[i]-1]);
				// System.out.println("c[a[i]]="+c[a[i]-2]);
			}else{
				manzoku += b[a[i]-1];
				// System.out.println("b="+b[a[i]-1]);
			}
		}

		// 出力
		System.out.println(manzoku);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;
    rep(i, n) as[i] = -as[i];

    vl clr;
    rep(i, n) {
        auto it = upper_bound(clr.begin(), clr.end(), as[i]);
        if (it == clr.end()) clr.push_back(as[i]);
        else *it = as[i];
    }
    cout<<sz(clr)<<endl;
}

Measured memory_bytes: 2168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int temp[1048577]={};
int x[4]={0,3,5,7};
int tempnum= 0;
void puttotemp(int k){
	temp[tempnum] = k;
	tempnum++;
}
void maketemp(int n){
	int a,b,c,d,e,f,g,h,i,j;
	for(a=0;a<4;a++){
		for(b=0;b<4;b++){
			for(c=0;c<4;c++){
				for(d=0;d<4;d++){
					for(e=0;e<4;e++){
						for(f=0;f<4;f++){
							for(g=0;g<4;g++){
								for(h=0;h<4;h++){
									for(i=0;i<4;i++){
										puttotemp(
												x[a]*(100000000)+
												x[b]*(10000000)+
												x[c]*(1000000)+
												x[d]*(100000)+
												x[e]*(10000)+
												x[f]*(1000)+
												x[g]*(100)+
												x[h]*(10)+
												x[i]*(1)
											);
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

int main(void){
	int N;
	scanf("%d",&N);
	int i,j,x;
	int flag,threeflag,fiveflag,sevenflag;
	char s[11];
	snprintf(s,11,"%d",N);//sにはNが入る
	int n = strlen(s);//nにはNの桁数が入る
	int ans = 0;
	maketemp(n);
	//printf("n = %d\n",n);
	for(i=0;i<1048576;i++){
		if( N >= temp[i]){
		}else{
			continue;
		}
		//sの0行目から753かどうか調べる
		snprintf(s,11,"%d",temp[i]);//
		flag = 0;threeflag=0;fiveflag=0;sevenflag=0;
		for(j=0;j<strlen(s);j++){
			if(s[j]=='7'){
				sevenflag=1;
			}else if(s[j]=='5'){
				fiveflag = 1;
			}else if(s[j]=='3'){
				threeflag= 1;
			}else{
				flag = -1;
			}
		}
		if(flag == 0 && sevenflag==1 && fiveflag ==1 && threeflag ==1){
			ans++;
		}
		
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans = 0;
		int tmp = 0;
		for (int i=0;i<S.length();i++) {
			if (S.charAt(i)=='A') {
				tmp++;
			} else if (S.charAt(i)=='T') {
				tmp++;
			} else if (S.charAt(i)=='G') {
				tmp++;
			} else if (S.charAt(i)=='C') {
				tmp++;
			}else {
				tmp=0;
			}
			ans = Math.max(ans,tmp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764