akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        //System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int n=s.nextInt();
        String str = s.nextLine();
        int r=0,w=0;
        int count=0;
        for(int i=0;i<n;i++){
            if(str.charAt(i)=='R') r++;
            else w++;
        }
        for(int i=0;i<r;i++){
            if(str.charAt(i)!='R') count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 29492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1];
}

Measured memory_bytes: 256
#include<stdio.h>
const int maxn=10000000;
int main()
{
	int a,b,s[4],max=-maxn;
	scanf("%d %d",&a,&b);
	s[0]=a+b;
	s[1]=a-b;
	s[2]=a*b;
	for(int i=0;i<3;i++)
	{
		if(s[i]>max)   max=s[i];
	}
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void _main() {
    int K;
    cin >> K;
    cout << A[K - 1] << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
list_a = list(map(int, input().split()))
max_distance = 0
for i in range(n):
    now_pos = list_a[i]
    prev_pos = list_a[i-1]
    distance = now_pos - prev_pos
    if(now_pos < prev_pos):
        distance += k
    if(max_distance < distance):
        max_distance = distance
print(k - max_distance)


Measured memory_bytes: 26100
n, m = map(int, input().split())
ans = [0] * n
cklist = [0] * n
result = True
for x in range(m):
    s, c = map(int, input().split())
    if n != 1 and s == 1 and c == 0: 
        print(-1)
        result = False
        break
    elif cklist[s - 1] == 1 and ans[s - 1] != c:
        print(-1)
        result = False
        break
    else:
        ans[s - 1] = c
        cklist[s - 1] = 1
if(cklist[0] == 0 and n != 1): ans[0] += 1
ans_str = [str(n) for n in ans]
if(result == True): print(''.join(ans_str))

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

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

    vector<int> vec(N);

    rep(i, N){
        cin >> vec.at(i);
    }

    int count = 0;
    rep(i, N){
        if (i % 2 == 0 && vec.at(i) % 2 == 1){
            count += 1;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	int T;
	cin >> T;
	rep(t, T) {
		vll a(9);
		ll K = 0;
		rep(i, 9) {
			cin >> hex >> a[i];
		}
		rep(d, 32) {
			ll sum = 0;
			rep(i, 8)sum += a[i];
			if ((sum & (1LL << d)) != (a[8] & (1LL << d))) {
				K += 1LL << d;
				rep(i, 8) {
					a[i] = a[i] ^ (1LL << d);
				}
			}
		}
		cout << hex << K << endl;
	}


	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    const int MAX = 1010;
    int sum[MAX][MAX];
    rep(i, MAX)rep(j, MAX) sum[i][j] = 0;
    int n;
    scanf("%d", &n);
    while(n--){
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        ++sum[a][b];
        --sum[a][d];
        --sum[c][b];
        ++sum[c][d];
    }
    rep(i, MAX)rep(j, MAX-1) sum[i][j+1] += sum[i][j];
    rep(j, MAX)rep(i, MAX-1) sum[i+1][j] += sum[i][j];
    int ans = 0;
    rep(i, MAX)rep(j, MAX) ans = max(ans, sum[i][j]);
    printf("%d\n", ans);
}


Measured memory_bytes: 7212
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=len(list(input()))

print("".join(["x"]*s))


Measured memory_bytes: 65516
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,N;
  cin>>N;
  VL A(N),ans(N);
  rep(i,N-1)cin>>A[i];
  rep(i,N-1)ans[A[i]-1]++;
  rep(i,N)cout<<ans[i]<<endl;
}


Measured memory_bytes: 6352
rests = {}
for i in range(int(input())):
    S,P = input().split()
    P = int(P)
    if S in rests:
        rests[S] += [[P,i]]
    else:
        rests[S] = [[P,i]]
        
r = sorted(rests.items()) #市の名前でソート
for city in r:
    city[1].sort()
    city[1].reverse()
    
    for score,i in city[1]:
        print(i+1)
       

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

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	if(abs(n-m) > 1LL){
		cout << 0 << endl;
		return 0;
	}
	mint ans = 0;
	mint N = 1, M = 1;
	for(ll i = 1; i <= max(n, m); ++i){
		if(i <= n) N *= i;
		if(i <= m) M *= i;
		ans = N * M;
	}
	if(n == m) ans = ans * 2;
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
 
using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
 
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007
 
typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc104_c(){
    //入力
    string s;
	cin >> s;
  
    //処理
  
    //出力
    if(s<="2019/04/30") cout << "Heisei" << ENT;
    else cout << "TBD" << ENT;
    return 0;
}

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


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> W(N+1,0), B(N+1,0);
  for(int i = 0; i < N; ++i){
    if(S[i] == '#') ++B[i+1];
    else ++W[i+1];
  }
  for(int i = 0; i < N; ++i) W[i+1] += W[i], B[i+1] += B[i];
  int ans = B[N];
  for(int i = 0; i < N; ++i){
    if(S[i] == '.') continue;
    int t = B[i] + W[N] - W[i];
    ans = min(ans,t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
	int t;
     t=1;
	while(t--)
	{
       int n;
       cin>>n;
       int arr[n];
       for(int i=0;i<n;i++)
       {
       	cin>>arr[i];
       }
       long long int ans=0;
       for(int i=1;i<n;i++)
       {
         if(arr[i-1]>arr[i])
         {
         	ans=ans+arr[i-1]-arr[i];
         	arr[i]=arr[i-1];
         }
       }
       cout<<ans<<endl;

	}
}

Measured memory_bytes: 4348
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, M = map(int,input().split())
P = list(map(int, input().split()))
X = [0] * M
Y = [0] * M

for i in range(M):
    x, y = map(int, input().split())
    X[i] = x-1
    Y[i] = y-1

class UnionFind:
    def __init__(self, N):
        self.rank = [0] * N
        self.parent = [i for i in range(N)]
        self.n = N

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if (x == y):
            return

        if (self.rank[x] < self.rank[y]):
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_parents(self):
        count = 0
        for i in range(self.n):
            if self.find(i) == i:
                count += 1

        return count


uf = UnionFind(N)
for i in range(M):
    uf.unite(X[i], Y[i])

#print(uf.parent)

ans = 0
for i in range(len(P)):
    p = P[i]-1
    if i==p or uf.same(i, p):
        ans += 1

print(ans)      

Measured memory_bytes: 20132
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

// using
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long long ull;

// assert
template <typename T>
void assert_between(T val, T min, T max)
{
    assert(min <= val && val <= max);
}

// math
// 最大公約数(Gratest Common Divisor)を求める.
template <typename T>
T gcd(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : gcd(num2, mod);
}

// 最小公倍数(Least Common Multiple)を求める.
template <typename T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}


int D;
ll G;
vector<ll> p, c;

int main ()
{
    scanf("%d %lld", &D, &G);
    p.resize(D); c.resize(D);
    for (int i = 0; i < D; i++) 
        scanf("%lld %lld", &p[i], &c[i]);

    
    ll ans = (ll) INT_MAX;
    for (int bit = 0; bit < (1<<D); ++bit) { // bit全探索.
        
        ll sum = 0;
        ll num = 0;

        // フラグが立っているiについては､全問解く.
        for (int i = 0; i < D; ++i) {
            if (bit & (1<<i)) {
                sum += (100 * (i+1) * p[i]) + c[i];
                num += p[i];
            }
        }
        //printf ("bit:%d sum:%lld num:%lld\n", bit, sum, num);

        if (sum >= G) {
            // 必要な点数を既に超えた.
            ans = min(ans, num);
        } else {
            // 必要な点数に満たない場合､高い配点のものから順に足しこんでいく.
            for (int i = D-1; i >= 0; --i) {
                // フラグが立っているのは全問解いた扱いなので無視.
                if (bit & (1<<i)) continue;

                // 必要な点数を満たすまで1問づつ足し続ける.
                for (int j = 0; j < p[i]; ++j) {
                    if (sum >= G) break;
                    sum += 100 * (i+1);
                    num++;
                }
            }
            ans = min(ans, num);
        }
    }

    printf("%lld\n", ans);
}



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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int calc_pw(ll n, ll p){
    if(n/p==0){
        return 0;
    }else{
        return calc_pw(n/p,p)+1;
    }
}


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    if(A%K==0 || B%K==0){
        cout << "OK" << "\n";
    }else{
        if(A/K!=B/K){
        cout << "OK" << "\n";
        }else{
        cout << "NG" << "\n";
        }
    }
}   




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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  int result = 0;
  rep1(i, n){
    int c = 0;
    rep1(j, i) if(i%2 && i%j==0)c++;
    if(c==8)result++;
  }
  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;cin>>n>>m;
  vector<int> ans(n);
  for(int i=0;i<m;i++){
    int a, b;cin>>a>>b;
    ans.at(a-1)++;
    ans.at(b-1)++;
  }
  for(int i=0;i<n;i++){
    cout << ans.at(i)++<<endl;
  }
}

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

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

int N;
string W[101];
string ans;

void resolve()
{
    cin >> N;
    RPT1(i, N) cin >> W[i];

    ans = "Yes";
    RPT(i, 2, N)
    {
        if (W[i][0] != W[i - 1][W[i - 1].length() - 1]) {
            ans = "No";
            break;
        }
        RPT(j, 1, i - 1) if (W[i] == W[j])
        {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>

using namespace std;

int R, C, n;

int toIdx(int x, int y)
{
    if (x == 0) return y;
    if (y == C) return C + x;
    if (x == R) return C + R + C - y;
    if (y == 0) return C + R + C + R - x;
    return -1;
}

signed main()
{
    scanf("%d %d %d", &R, &C, &n);

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int idx1 = toIdx(x1, y1);
        int idx2 = toIdx(x2, y2);
        if (idx1 < 0 || idx2 < 0) continue;

        mp[idx1] = i;
        mp[idx2] = i;
    }

    stack<int> st;
    for (auto a : mp) {
    	int i = a.second;
        if (!st.empty() && st.top() == i) st.pop();
		else st.push(i);
    }
    cout << (st.empty() ? "YES" : "NO");
}


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

int main(){
  int N,A,B,C;cin >> N >> A >> B >> C;
  vector<int> P(N+1,1);
  for(int i=1;i<=N;i++){
    P[i] = P[i-1]*4;
  }
  vector<int> L(N,0);
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  int ans = 1000000;
  for(int bit=0;bit<P[N];bit++){
    int Atmp=0,Btmp=0,Ctmp=0;
    int As=0,Bs=0,Cs=0;
    for(int i=0;i<N;i++){
      int S = (bit/P[i])%4;
      if(S==1){
        Atmp += L[i];
        As ++;
      }else if(S==2){
        Btmp += L[i];
        Bs ++;
      }else if(S==3){
        Ctmp += L[i];
        Cs ++;
      }
    }
    int syn = (As+Bs+Cs-3)*10;
    if(As>0&&Bs>0&&Cs>0){
      ans = min(ans,abs(A-Atmp)+abs(B-Btmp)+abs(C-Ctmp)+syn);
    }
  }
  cout << ans << endl;
}

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

using namespace std;


int main() {
	string s;
	cin >> s;
	bool flag;
	for (int i = s.length();i > 0;i--) {
		for (int j = 0;j <= s.length() - i;j++) {
			flag = true;
			for (int k = 0;k < i;k++) {
				if (s[j + k] == 'A' || s[j + k] == 'C' || s[j + k] == 'G' || s[j + k] == 'T')continue;
				flag = false;
				break;
			}
			if (flag) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << "0\n";
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N;
	cin >> N;
	ll A[N];
	rep(i,N) cin >> A[i];
	map<ll,int> cnt;
	rep(i,N) cnt[A[i]]++;
	int ans = 0;
	for(auto itr=cnt.begin(); itr!=cnt.end(); itr++){
		if((itr->second) % 2) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <cstdio>

const long long inf=1000000000000000LL;

struct treenode
{
	int left,right,num;
};

treenode tree[10000000];
int root,sum_node;
long long g[300000];
int i,m,n;
long long s;

inline void inserttree(long long l,long long r,long long x,int& node)
{
	if (! node)
		sum_node++,node=sum_node;
	if (l==r)
		tree[node].num++;
	else
	{
		long long mid=(l+r+2*inf)/2-inf;
		if (x<=mid)
			inserttree(l,mid,x,tree[node].left);
		else
			inserttree(mid+1,r,x,tree[node].right);
		tree[node].num=tree[tree[node].left].num+tree[tree[node].right].num;
	}
	return;
}

inline int asktree(long long l,long long r,long long x,long long y,int node)
{
	if (! node)
		return 0;
	if ((l==x) && (r==y))
		return tree[node].num;
	long long mid=(l+r+2*inf)/2-inf;
	if (y<=mid)
		return asktree(l,mid,x,y,tree[node].left);
	if (x>mid)
		return asktree(mid+1,r,x,y,tree[node].right);
	return asktree(l,mid,x,mid,tree[node].left)+asktree(mid+1,r,mid+1,y,tree[node].right);
}

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%lld",&g[i]);
	for (i=1;i<=n;i++)
		g[i]=g[i]-m;
	for (i=1;i<=n;i++)
		g[i]=g[i-1]+g[i];
	for (i=0;i<=n;i++)
	{
		s=s+asktree(-inf,inf,-inf,g[i],root);
		inserttree(-inf,inf,g[i],root);
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 73472
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        input: String,
    }

    println!(
        "{}",
        input
            .chars()
            .enumerate()
            .map(|(i, x)| {
                match i {
                    5 | 13 => ' ',
                    _ => x,
                }
            })
            .collect::<String>()
    );
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2==0) cout << (b-a) / 2;
    else{
        int disa = min(n - a, a - 1), disb = min(n - b, b - 1);
        int r = min(disa, disb) + 1;
        cout << r + (b - a) / 2;
    }
}

Measured memory_bytes: 256
//!!WA
//consider the case of 2 2 3 4
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

ll n,k;
ll x[100000];
ll ans=linf;
int main() {
    cin>>n>>k;
    REP(i,n){
        cin>>x[i];
    }
    REP(i,n-k+1){
        ans=min({ans,abs(x[i])+x[i+k-1]-x[i],abs(x[i+k-1])+x[i+k-1]-x[i]});
    }
    if(n==k){
        ans=x[n-1]-x[0]+min(abs(x[n-1]),abs(x[0]));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>


using namespace std;

struct point{
    int x,y;
    long h;
}points[100];

long height;

bool check_validity(int x, int y, int p, int n){
    int i,j,len;
    long h,cur_h;
    h = points[p].h + abs(points[p].x - x) + abs(points[p].y - y);
    for(i = 0; i < n; i++){
        cur_h = h - abs(points[i].x - x) - abs(points[i].y - y);
        cur_h = max(cur_h,long(0));
        if(cur_h != points[i].h) return false;
    }
    points[p].h = h;
    return true;
}

int main(){
    int i,j,k,n,x,y,p,break_flag;
    long h;
    while(cin >> n){
        memset(points,-1,sizeof(points));
        break_flag = 0;
        p = -1;
        for(i = 0; i < n; i++){
            cin >> x >> y >> h;
            points[i].x = x;
            points[i].y = y;
            points[i].h = h;
            if(p == -1 && h > 0) p = i;
        }
        for(j = 0; j < 101; j++){
            for(k = 0; k < 101; k++){
                if(check_validity(j,k,p,n)){
                    break_flag = 1;
                    break;
                }
            }
            if(break_flag) break;
        }
        cout << j << " " << k << " " << points[p].h << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
pow2 = [1]
for i in range(31):
    pow2.append(pow2[-1] * 2)
a = sorted(a, reverse=True)
d = defaultdict(int)
for i in a:
    d[i] += 1


num = 0
for i in range(N):
    if d[a[i]] == 0:
        continue
    for k in range(30, -1, -1):
        inv = pow2[k] - a[i]
        if inv < 0 or inv > a[i]:
            continue
        if inv != a[i]:
            if d[inv] > 0 and d[a[i]] > 0:
                p = min(d[inv], d[a[i]])
                num += p
                d[inv] -= p
                d[a[i]] -= p
                break
        else:
            if d[a[i]] >= 2:
                num += d[a[i]] // 2
                d[a[i]] %= 2
                break
print(num)


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

int main() {
  int N, K, ans = 1000000007;
  int maxn = 0, minn = 1 << 29, tmp;
  cin >> N >> K;

  vector<int> h(N + 5);
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    h[i] = tmp;
  }
  sort(h.begin(), h.begin() + N);

  int right;
  for (int left = 0; left <= N - K; left++) {
    right = left + K - 1;
    ans   = min(ans, h[right] - h[left]);
  }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1000005, M = 101;
int n, m;
int dp[M][N];
const int inf  = 1e9+5;
int W[M], P[M];


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

  cin >> n >> m;

	forn(i, 1, n+1){
		cin >> W[i] >> P[i];
	}

	int ans = 0;
	forn(i, 0, n+1){
		forn(j, 0, N){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	forn(i, 1, n+1){
		for(int j = N-P[i]; j >= 0; j--){
			dp[i][j] = dp[i-1][j];
			if(j+P[i] < N){
				int &ans = dp[i][j+P[i]];
				ans = min(ans, dp[i-1][j+P[i]]);
				ans = min(ans, dp[i-1][j]+W[i]);
			}
		}
	}
	forn(i, 0, N)if(dp[n][i] <= m)ans = max(ans, i);
	cout << ans << endl;


}





Measured memory_bytes: 398156
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
        int n = sc.nextInt(),m = sc.nextInt(),x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m+1];
        for(int i=0;i<n;i++){
            for(int j =0;j<=m;j++){
                a[i][j]=sc.nextInt();
            }
        }
        int INF = 1001001001;
        int ans = INF;
        for(int i =1;i<(1<<n);i++){
            boolean f = true;
            int cost = 0;
            int[] skil = new int[m];
            for(int j =0;j<n;j++){
                if((1&(i>>j))==1){
                    cost += a[j][0];
                    for(int k = 0;k<m;k++){
                        skil[k]+=a[j][k+1];
                    }
                }
            }
            for(int j =0;j<m;j++){
                if(skil[j]<x){
                    f = false;
                }
            }
            if(f){
                ans = Math.min(ans,cost);
            }
        }
        if(ans==INF){
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
	}
}


Measured memory_bytes: 37252
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0
for row in range(1 << H):
  for col in range(1 << W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (row & (1 << i)) or (col & (1 << j)):
          continue
        if C[i][j] == '#':
          #print(i, j)
          cnt += 1
    #print("row={}, col={}, cnt={}".format(row, col, cnt))
    if cnt == K:
      ans += 1

print(ans)

Measured memory_bytes: 9196
#include<stdio.h>
int main()
{
int n;
int i;
int m;
int sum;
int a[21],b[21],c[21];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}

for(i=0;i<n;i++)
{
scanf("%d",&b[i]);

}

for(i=0;i<n-1;i++)
{
scanf("%d",&c[i]);

}
m=0;sum=0;
for(i=0;i<n;i++)
{
 m=a[i];
 sum+=b[m-1];
 //printf("%d ",b[m]);
}

//printf("%d\n",sum);

for(i=0;i<n;i++)
{
	m=a[i];
	if(m==a[i+1]-1)
	{
	sum+=c[m-1];
	}

}
printf("%d\n",sum);
/**/
return 0;
}


Measured memory_bytes: 128
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cerr << "\n"; }
#define PI 3.14159265358979323846

int main(){
	FASTIO;
	ll n, x, y; cin >> n >> x >> y;
	ll occ[n + 1]; memset(occ, 0, sizeof occ);
	ll d = y - x;
	for ( ll k = 1; k <= n; k++ ){
		for ( ll j = k + 1; j <= n; j++ ){
			if (k <= x && j >= y) {
				occ[j - k - d + 1]++;
			}else if (k <= x && j >= x) {
				occ[x - k + min(j - x, y - j + 1)]++;
			}else if (k >= x && j >= y && k < y) {
				occ[j - y + min(y - k, k - x + 1)]++;
			}else if (k >= x && j <= y) {
				occ[min(j - k, k - x + 1 + y - j)]++;
			}else {
				occ[j - k]++;
			}
		}
	}
	for ( int k = 1; k < n; k++ )
		cout << occ[k] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;


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

string S; cin >> S;
int N = S.size();

VI cnt(3, 0);
for (char c: S) ++cnt[c - 'a'];

if (*max_element(ALL(cnt)) - *min_element(ALL(cnt)) <= 1)
    cout << "YES\n";
else 
    cout << "NO\n";

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    double ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        double a;
        cin>>a;
        ans+=1/a;
    }
    cout<<1/ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
    int n, k;
    int d;
    int x;
    bool D[10] = {true, true, true, true, true, true, true, true, true, true};
    cin >> n >> k;
    for(int i = 0; i < 10; i++){
        cin >> d;
        D[d] = false;
    }
    for(int i = n; i < n*10; i++){
        int c = i;
        while(c != 0){
            x = c % 10;
            if(D[x] == false){
                break;
            }
            c /= 10;
            if(c == 0){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int N,Q;cin >> N >> Q;
    string s;cin >> s;
    int l,r;
    vector<int>t(N);
    t[0]=0;
    for(int i=0;i<N;i++){
        t[i+1]=t[i];
        if(s[i]=='A' && s[i+1]=='C')t[i+1]+=1;
    }
    
    for(int i=0;i<Q;i++){
        cin >> l >> r;
        cout << t[r-1]-t[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
import std.stdio, std.conv, std.array,std.string,std.algorithm;

void main()
{
    auto n=readln.chomp.to!int,k=readln.chomp.to!int;
    int i,ans=1;
    for(i=0;i<n;i++){
        ans=min(2*ans,ans+k);
    }
    writeln(ans);
}

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    cout<<3*pow(n,2)<<endl;
}


Measured memory_bytes: 256
#list(map(int, input().split()))
import sys
count = 0
n, m = list(map(int, input().split()))
temp_l, temp_r = list(map(int, input().split()))
for i in range(m-1):
  l,r = list(map(int, input().split()))
  if temp_r < l or r < temp_l:
    print(0)
    sys.exit()
  else:
    temp_l = max(temp_l, l)
    temp_r = min(temp_r, r)
print(temp_r - temp_l +1)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
local n = io.read("*n")
for i = 1, 3500 do
  for j = i, 3500 do
    --[[
    4ijk = Njk + Nik + Nij
    k(4ij - Nj - Ni) = Nij
    ]]
    local a = n * i * j
    local b = 4 * i * j - n * (i + j)
    if 0 < b and a % b == 0 then
      local k = a // b
      print(i .." " .. j .. " " .. k)
      os.exit()
    end
  end
end


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= n; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll B[110];
ll ans;
int main(){
	cin >> N;
	REP(i,0,N-1){
		cin >> B[i];
	}
	ll prev = B[0];
	ans += prev;
	REP(i,1,N-1){
		prev = min(B[i-1], B[i]);
		ans += prev;
	}
	p(ans += B[N-2]);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string S;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> S) {
        int num = 0;
        for (int i = 0; i < S.size()/2; ++i) {
            if (S[i] != S[S.size()-i-1]) ++num;
        }
        cout << num << endl;
    }
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){

    int n; cin >> n;
    int cnt1 = 0, ans = 1;
    for (int i = 1; i <= n; i++){
        int j = i, cnt2 = 0;
        while (j % 2 == 0){
            j /= 2;
            cnt2++;
        }
        if ( cnt2 > cnt1){
            ans = i;
            cnt1 = cnt2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long double PI=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int read() {
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    int a=read(),b=read(),c=read();
    printf("%d %d %d\n%d %d %d\n%d %d %d",a,b,c+c+c-a-b,c+c+c-a-a-b+c,c,a+a+b-c-c,a+b-c,c+c-b,c+c-a);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N, M;
const ll DIV = ll(1e9) + 7;

ll factorial(ll n) {
    if (n == 1) return n % DIV;
    return ((n % DIV) * factorial(n - 1)) % DIV;
}

void solve() {
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return;
    }
    if (N == M) {
        cout << (2 * factorial(N) * factorial(M)) % DIV << endl;
    } else {
        cout << (factorial(M) * factorial(N)) % DIV << endl;
    }
}

int main() {
    cin >> N >> M;
    solve();
    return 0;
}

Measured memory_bytes: 1792