akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll k,a,b;
    std::cin >> k>>a>>b;
    if( b-a <= 2  || k <= a -1){
        std::cout << 1 + k << std::endl;
        return 0;
    }else{
        if( ( k-(a-1) ) %2 == 0){
            std::cout << a + (( k-(a-1) )/2)*(b-a) << std::endl;
            return 0;
        }else{
            std::cout << a + (( k-(a-1) -1 )/2)*(b-a)+1 << std::endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 50
char s[N]; int ch[N],n,x;
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	scanf("%s",s+1); n=strlen(s+1);
	if (n==26){
		rep (j,0,25) ch[j]=1;
		per (i,n,1){
			int t=s[i]-'a'+1;
			while (t<=25 && ch[t]){
				t++;
			}
			if (t<=25){
				rep (j,1,i-1) putchar(s[j]);
				putchar(t+'a');
				exit(0);
			}
			ch[s[i]-'a']=0;
		}
		puts("-1"); exit(0);
	}
	rep (i,1,n) ch[s[i]-'a']=1;
	rep (i,0,26) if (!ch[i]){ x=i; break; }
	s[++n]=x+'a';
	rep (i,1,n) putchar(s[i]);
	return 0;
}
// sample data:
/*

atcoder

abc

zyxwvutsrqponmlkjihgfedcba

abcdefghijklmnopqrstuvwzyx
*/

// rest:
/*

*/

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

int main() {
    vector<int> vec(3);
    int K;
    rep(i, 3) cin >> vec[i];
    cin >> K;
    sort(vec.begin(), vec.end());
    cout << vec[0] + vec[1] + vec[2]*pow(2, K) << endl;
    return 0;
}

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

int64_t lucas(int n) {
  vector<int64_t> a;
  // n => 0
  a.push_back(2);
  // n => 1
  a.push_back(1);
  
  if (n > 1) {
    for (int i = 2; i <= n; i++) {
      int64_t x = a.at(i - 2) + a.at(i - 1);
      a.push_back(x);
    }
  }
  
  return a.at(n);
}

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

  cout << lucas(N) << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> cnt(m);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int x;
            cin>>x;
            cnt[x-1]++;
        }
    }
    int ans=0;
    rep(i,m)ans+=(cnt[i]>=n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;
const ll MOD = 1000000007; 
using plong = pair<ll,ll>;


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


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

using LL = long long;
#define DB(x) cout<<#x<<'='<<x<<endl;

using P = pair<LL,LL>;

struct state{
	LL x,y;
	bool s;//false:right true:down
	int ind;//?????????
	bool operator<(const state& o)const{
		if(x==o.x){
			if(y==o.y){
				if(s==o.s){
					return ind<o.ind;
				}
				return s<o.s;
			}
			return y<o.y;
		}
		return x<o.x;
	}
};

LL W,H,N;
map<LL,vector< state >>cash;

int main(){
	cin>>W>>H>>N;
	for(int i=0;i<N;++i){
		LL x,y;char d;
		cin>>x>>y>>d;
		--x;--y;
		cash[x+y].push_back({x,y,(d=='S'),i+1});
	}
	set<P>ans;//first:time second:ant
	for(auto p:cash){
		LL depth = p.first;
		auto& vec = p.second;
		bool color = (depth%2);//false:white true:black
		//y????????????x???????????????????????????
		sort(vec.begin(),vec.end());
		queue<int>ant[2];//?????????(0:even 1:odd)
		for(auto elm:vec){
			LL x=elm.x,y=elm.y;
			bool s=elm.s;int ind=elm.ind;
			if(!s){
				//right
				ant[y%2].push(ind);
			}else{
				//up
				bool par = (y%2)^(color);
				ant[par].push(ind);
				int pop = ant[par].front();
				ant[par].pop();
				ans.insert({H-y,pop});
			}
		}
		for(auto elm:vec){
			LL x=elm.x,y=elm.y;
			bool s=elm.s;int ind=elm.ind;
			if(s)continue;
			int id = ant[y%2].front();
			ant[y%2].pop();
			ans.insert({W-x,id});
		}
	}
	for(auto p : ans){
		//cout<<p.first<<" "<<p.second<<endl;
		cout<<p.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 37412
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	int M1,D1,M2,D2;
	cin>>M1>>D1>>M2>>D2;
	
	if(M1==M2)cout<<0<<endl;
	else cout<<1<<endl;
	
	return 0;
}

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

bool visited[2 * 100000 + 10];
unordered_map<int, int> mp;

//-------------------------↓↓↓↓↓↓------------------------

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

    int h, w, n, x[2 * 100000 + 10], y[2 * 100000 + 10], ans, lim = 1;

    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        if(!visited[x[i]])mp[x[i]] = y[i], visited[x[i]] = true;
        else mp[x[i]] = min(mp[x[i]], y[i]);
    }

    ans = h;
    for(int i = 2; i <= h; i++){
        if(!visited[i])lim++;
        else{
            if(lim + 1 == mp[i])continue;
            else if(lim + 1 < mp[i])lim++;
            else{
                ans = i - 1;
                break;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string a,b,c;cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	while (true) {
		int n, a, b, c, x;
		cin >> n >> a >> b >> c >> x;
		if (!n) break;
		int d[110];
		for (int i = 0; i < n; i++) {
			cin >> d[i];
		}
		int u = 0;
		int i = 0;
		for (i = 0; i < 10001; i++) {
			if (d[u] == x) {
				u++;
				if (u == n) break;
			}
			x = (a*x+b)%c;
		}
		if (i == 10001) {
			printf("-1\n");
		} else {
			printf("%d\n", i);
		}
	}
}

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

int solve(int cost){
  int count=0;
  cost=1000-cost;
  while(cost>=500)count++,cost-=500;
  while(cost>=100)count++,cost-=100;
  while(cost>=50)count++,cost-=50;
  while(cost>=10)count++,cost-=10;
  while(cost>=5)count++,cost-=5;
  while(cost>=1)count++,cost-=1;
  return count;
}

int main(){
  int input;
  cin>>input;
  while(input){
    cout<<solve(input)<<endl;
    cin>>input;
  }
  return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;

int H,W;
char field[50][50];
queue<pair<int,int>> Q;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(int init_x,int init_y,int end_x,int end_y){

    Q.push(mp(init_x,init_y));

    int dist[50][50];
    rep(i,H){
        rep(j,W){
            dist[i][j]=-1;
        }   
    }
    dist[0][0]=1;

    while(!Q.empty()){
        auto val=Q.front();
        int x=val.first;
        int y=val.second;
        Q.pop();
        
        
        rep(i,4){
        int _x=x+dx[i];
        int _y=y+dy[i];
        if(dist[_y][_x]>0)continue;
        if(_x<0||_x>end_x||_y<0||_y>end_y)continue;
        if(field[_y][_x]=='#')continue;

        dist[_y][_x]=dist[y][x]+1;
        if(_x==W-1 && _y==H-1){
            break;
        }

        Q.push(mp(_x,_y));
        }
    }

    return dist[end_y][end_x];
}


int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>H>>W;
int all_cnt=0;
rep(y,H){
    rep(x,W){
        cin>>field[y][x];
        if(field[y][x]=='.')all_cnt++;
    }
}

int d=bfs(0,0,W-1,H-1);
int score=d>0 ? all_cnt-d:d;

cout<<score<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define doubleloop(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define tripleloop(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

int main(){
    long long ans = 0, N, nums[200009];
    
    memset( nums, 0, sizeof(nums));
    
    scnd1( N );
    
    rep(i,N) scnd1(nums[i]);
    
    int light = 0, right = 0;
    long long sum = 0;
    
    while( right<N ) {
        
        if ( (sum^nums[right]) == (sum+nums[right])) {
            ans += right-light+1;
            sum += nums[right++];
        } else {
            sum -= nums[light++];
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    bool res = false;
    ll needb = 0, sum = 0;
    for(int i = 0; i < N; i++){
        if(b[i] > a[i]){
            int temp = b[i] - a[i];
            if(temp % 2 == 1){
                needb += temp / 2 + 1;
                sum++;
            }
            else needb += temp / 2;
        }
        else sum += a[i] - b[i]; 
    }
    if(sum <= needb) res = true;
    else res = false;
    
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	rep(i, h) {
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def find_root(root, size, x):
    y = root[x]
    if y is None:
        root[x] = x
        size[x] = 1
        return x
    if x == y:
        return y
    z = find_root(root, size, y)
    root[x] = z
    return z


def merge(root, size, cnt, x, y):
    rx = find_root(root, size, x)
    ry = find_root(root, size, y)
    if rx == ry:
        return
    sx = size[rx]
    sy = size[ry]
    if sx > sy:
        root[ry] = rx
        size[rx] += sy
        cnt[rx] += cnt[ry]
    else:
        root[rx] = ry
        size[ry] += sx
        cnt[ry] += cnt[rx]
    return


def main():
    N = int(input())
    U = 10 ** 5
    root_x = [None] * (U + 1)
    root_y = [None] * (U + 1)
    size_x = [0] * (U + 1)
    size_y = [0] * (U + 1)
    cnt_x = [0] * (U + 1)
    cnt_y = [0] * (U + 1)
    x_to_y = [None] * (U + 1)
    y_to_x = [None] * (U + 1)

    for _ in range(N):
        x, y = map(int, input().split())
        rx = find_root(root_x, size_x, x)
        ry = find_root(root_y, size_y, y)
        cnt_x[rx] += 1
        cnt_y[ry] += 1
        if x_to_y[rx] is None:
            x_to_y[rx] = ry
        if y_to_x[ry] is None:
            y_to_x[ry] = rx
        merge(root_y, size_y, cnt_y, x_to_y[rx], ry)
        merge(root_x, size_x, cnt_x, y_to_x[ry], rx)
        x_to_y[root_x[rx]] = root_y[ry]
        y_to_x[root_y[ry]] = root_x[rx]

    ans = 0
    for x in range(1, U + 1):
        if root_x[x] is None:
            continue
        rx = find_root(root_x, size_x, x)
        if x != rx:
            continue
        y = x_to_y[x]
        ry = find_root(root_y, size_y, y)
        sx = size_x[rx]
        sy = size_y[ry]
        cnt = cnt_x[rx]
        ans += sx * sy - cnt
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 94956
#include<stdio.h>
#include<math.h>

int main(){
	int n;
	int val;
	int count = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&val);
		
		if(val == 2){ 
			count++;
		}else if(val < 2 || val % 2 == 0){
			
		}else{
			for(int u = 3; u <= sqrt(val); u += 2){
				if(val % u == 0){
					count--;
					u = val;
				}
			}
			count++;
		}
	}
	
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2040
//アルファベットということを忘れ数字とする
#include<bits/stdc++.h>
#define AMARI 1000000007
using namespace std;
long long n,r;
long long numbers[100005];
struct BIT{
  vector<long long> bit;
  BIT(long long n){
    bit.resize(n+1);
  }
  long long sum(long long i){
    long long sum=0;
    while(i>0){
      sum+=bit[i];
      i=i&(i-1);
    }
    return sum;
  }
  void add(long long i,long long x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
};
main(){
  long long fact[100005]={0};
  fact[0]=1;
  for(int i=1;i<=100000;i++){
    fact[i]=fact[i-1]*i;
    fact[i]%=AMARI;
  }
  while(1){
    cin>>n;
    BIT b(n);
    if(n==0) break;
    cin>>r;
    for(int i=0;i<n;i++){
      numbers[i]=i+1;
    }
    for(int i=0;i<r;i++){
      long long s,t;
      cin>>s>>t;
      s--;
      t--;
      swap(numbers[s],numbers[t]);
    }
    long long ans=0;
    long long sum=0;
    for(int i=0;i<n;i++){
      sum=b.sum(numbers[n-1-i]);//n-1-iより後にnumbers[n-1-i]より小さい数字がある場合、その数字がn-1-iの位置に来ればそれは今の単語より順序が先の単語となる。その数字をn-i-1に置いた場合その後(n-i)の組み合わせはiの階乗分(i==0のときのみ1とする)あることになり、これを足す。
      ans+=fact[i]*sum;
      ans%=AMARI;
      b.add(numbers[n-1-i],1);//BITは1からiまでの合計を足す。sumでiを指定した際1からiまでの間にここでaddした値がある場合、それは今見ている数字より後に自分自身より小さい数字があるということになる。
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 5400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	n := 0
	if sc.Scan() {
		num, _ := strconv.Atoi(sc.Text())
		n = num
	}
	btns := []int{}
	for i := 0; i < n; i++ {
		if sc.Scan() {
			num, _ := strconv.Atoi(sc.Text())
			btns = append(btns, num)
		}
	}

	next := 1
	count := 0
	for _, _ = range btns {
		next = btns[next-1]
		count++

		if next == 2 {
			break
		} else if count == len(btns) {
			count = -1
			break
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 5888
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	void reverse(string& s){
		reverse(all(s));
	}

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	void reverse(vector<T>& v){
		reverse(all(v));
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	template<typename T>
	inline set<T>& operator+=(set<T>& v, const T& e){
		v.insert(e);
		return v;
	}

	template<typename T1, typename T2>
	inline set<T1>& operator+=(set<T1>& v1, const set<T2>& v2){
		for(const auto& e : v2) v1.insert(e);
		return v1;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);
	
	
	int A,B;cin>>A>>B;
	for(int i=B*10;i<=B*10+9;i++){
		if((int)(i*0.08) == A){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	if(s[2]==s[3] and s[4]==s[5]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import numpy as np
import functools
import operator

prod2 = functools.partial(functools.reduce, operator.mul)

n = int(input())
nums = list(map(int, input().split()))

# val = prod2(nums)

val = 1
if 0 in nums:
    val = 0

else:
    for num in nums:
        val *= num
    
        if val > 1e18:
            val = -1
            break


print(val)


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;

ll my_pow(ll n, ll m) {
    if (m == 0) return 1;
    ll now = my_pow(n, m / 2);
    if (m % 2 == 0) return (now * now) % mod;
    else return (((now * now) % mod) * n) % mod;
}

ll fact(ll n) {
    if (n == 0) return 1;
    return (n * fact(n - 1)) % mod;
}

ll C(ll n, ll k) {
    ll now = 1;
    for (int i = n; i >= n - k + 1; i--) {
        now *= i;
        now %= mod;
    }
    return (now * my_pow(fact(k), mod - 2)) % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << (my_pow(2, n) - 1 - C(n, a) - C(n, b) + 3 * mod) % mod;
    return 0;
}


Measured memory_bytes: 6668
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
K = 0 
for i in range(N):
  if i == 0:
    K += B[A[i] - 1]
  else:
    K += B[A[i] - 1]
    if A[i] == A[i - 1] + 1:
      K += C[A[i - 1] - 1]
print(K)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<algorithm>
#include<cassert>
using namespace std;
typedef pair<int,int> P;
class state{
	public:
	char f[11][11],c,l;
	state(){}
	state(int c,int l):c(c),l(l){};
};
char in[11][11];
state ne;
bool used[11][11];
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
int n,m;
int res;

void dfs(int next,int prev,int x,int y){
	if(x==0 && y==0){
		memset(used,false,sizeof(used));
	}
	ne.f[x][y]=next;
	used[x][y]=true;
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>=0 && nx<n && ny>=0 && ny<m){
			if(!used[nx][ny]){
				used[nx][ny]=true;
				if(ne.f[nx][ny]==next){
				}
				if(ne.f[nx][ny]==prev){
					dfs(next,prev,nx,ny);
				}	
			}
		}
	}
}

void cnt(int prev,int x,int y){
	if(x==0 && y==0){
		ne.l=0;
		memset(used,false,sizeof(used));
	}
	ne.l++;
	used[x][y]=true;
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>=0 && nx<n && ny>=0 && ny<m){
			if(!used[nx][ny]){
				used[nx][ny]=true;
				if(ne.f[nx][ny]==prev){
					cnt(prev,nx,ny);
				}	
			}
		}
	}
}

void bfs(state init){
	queue<state> que;
	//map<state, bool> v;
	res=50;
	//v[ne]= true;
	que.push(init);
	while(que.size()){
		state p=que.front();
		que.pop();
		if(p.c>=res)break;
		ne.c=p.c+1;
		for(int i=0;i<=2;i++){
			memcpy(ne.f,p.f,sizeof(ne.f));
			dfs(i,ne.f[0][0],0,0);
			cnt(ne.f[0][0],0,0);
			//if(!V[ne.f]){
				if(ne.l==n*m)res=min(res,p.c+1);
				else if(ne.l>p.l)que.push(ne);
			//	V[ne.f]=true;
			//}
		}
	}
}

int main(void){
	while(1){
		res=100;
		scanf("%d%d\n",&n,&m);
		if(n==0 && m==0)break;
		state init=state(0,1);
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				cin >> in[j][i];
				if(in[j][i]=='R')init.f[j][i]=0;
				if(in[j][i]=='G')init.f[j][i]=1;
				if(in[j][i]=='B')init.f[j][i]=2;
			}
		}
		memcpy(ne.f,init.f,sizeof(ne.f));
		cnt(ne.f[0][0],0,0);
		if(ne.l==n*m)printf("0\n");
		else{
			bfs(init);
			printf("%d\n",res);
		}
	}
	return 0;
}

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for(int64_t i=0; i<N; ++i) {
        cin >> A[i];
        A[i] -= i+1;
    }

    sort(A.begin(), A.end());
    vector<int64_t> psum(N);
    partial_sum(A.begin(), A.end(), psum.begin());
    int64_t ans = INT64_MAX;
    for(int i=0; i<N; ++i) {
        ans = min(ans, (A[i]*(i+1) - psum[i]) + (psum[N-1] -psum[i] - A[i]*(N-i-1)));
    }

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


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

#define int long long
#define MOD 1000000007
#define maxlen 9223372036854775807
#define minlen -9223372036854775807
#define fin(n) for(int i=0;i<n;i++)

int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
vector<int> primeFact(int n){vector<int> ans;for(int t=2;t<=sqrt(n);t++){if(n%t==0){ans.push_back(t);while(n%t==0){n=n/t;}}}if(n>2)ans.push_back(n);return ans;}
vector<int> fact(int n){vector<int> ans;for(int i=1;i<=sqrt(n);i++){if(n%i==0){if( i*i == n ){ans.push_back(i);}else{ans.push_back(i);ans.push_back(n/i);}}}return ans;}
int powerr(int base,int exp,int mod) { if(exp==0)return 1;int t = powerr(base,exp/2,mod)%mod;if(exp%2==0){return (t%mod*t%mod)%mod;}else{return (t%mod*t%mod*base%mod)%mod;}} 
void fastio(){ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}



int32_t main(){
	fastio();

	int k,l,r;
	cin >> k >> l >> r;

	for(int i=l;i<=r;i++){
		if( i%k==0 ){
			cout << "OK" << "\n";
			return 0;
		}else{
			
		}
	}
	cout << "NG" << "\n";

	

	return 0;
}






Measured memory_bytes: 3640
#include<stdio.h>

int main(void){
    int a,b,c,tmp;

scanf("%d %d %d",&a,&b,&c);

    if (a > b){

    tmp = a,a = b,b = tmp;
    }
    if (b > c){
        tmp = b,b = c,c = tmp;
    }
    if(a > b){
        tmp = a,a = b,b = tmp;
    }

printf("%d %d %d\n",a,b,c);

    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int x, y, ans = 0;
  std::cin >> x >> y;
  while (x <= y)
    x *= 2, ans++;
  print(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> query;
typedef pair<ll, pii> key;

int maxR[4005];
int maxB[4005];
int n;

ll dp[4005];
ll ndp[4005];
const int MOD = 998244353;
void realsolve() {
  dp[0] = 1;
  for(int i = 1; i <= n; i++) {
    memset(ndp, 0, sizeof(ndp));
    for(int j = 0; j < i; j++) {
      int currR = j;
      if(currR + 1 <= maxR[i]) {
        ndp[j+1] += dp[j];
        ndp[j+1] %= MOD;
      }
      int currB = i - 1 - j;
      if(currB + 1 <= maxB[i]) {
        ndp[j] += dp[j];
        ndp[j] %= MOD;
      }
    }
    memcpy(dp, ndp, sizeof(dp));
  }
  cout << dp[maxR[n]] << "\n";
}

// 0 is 2 red 0 blue
// 1 is 1`red 1 blue
// 2 is 0 red 2 blue
void solve() {
  string s;
  cin >> s;
  n = 2 * s.size();
  {
    int currR = '2' - s[0];
    int usedR = 0;
    for(int i = 1; i <= 2*s.size(); i++) {
      if(currR) {
        usedR++;
        currR--;
      }
      maxR[i] = usedR;
      if(i < s.size()) {
        currR += '2' - s[i];
      }
    }
  }
  {
    int currB = s[0] - '0';
    int usedB = 0;
    for(int i = 1; i <= 2*s.size(); i++) {
      if(currB) {
        usedB++;
        currB--;
      }
      maxB[i] = usedB;
      if(i < s.size()) {
        currB += s[i] - '0';
      }
    }
  }
  realsolve();
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 384
l = input().split()
N = int(l[0])
P = list(map(int, input().split()))
# print(N, P)

ans = 0
for i in range(len(P) - 2):
    Q = sorted(P[i:i+3])
    if Q[1] == P[i + 1]:
        ans += 1
print(ans)


Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new []{1,3,5,7,8,10,12 };
            var b = new []{4,6,9,11 };
            var xy = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Console.WriteLine(xy.All(x=>a.Contains(x))||xy.All(x=>b.Contains(x))?"Yes":"No");
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 2e3 + 10;
const int MOD = 1e9 + 7;
 
long long dp[MAXN][MAXN];
long long fac[MAXN * MAXN];
int n, k;
 
// asdjgfsadjkgfjksdgjfka
// sadjkgfasjdgfjasdgfjgasdgfaskjdf
// asdjgfajsdgfjasgdfgasdkjfgsadgfkjasdgfkjasdgfksadgf
#define fsgdfjasgdfgsadkjfg asdkjgfkjsagdfsgadjfgasdkjfaksjdf
#define hdgfhadfhasdhfgasjdgfjadgsjfkgsajdfgsadhjgfjksgadfj jsdgfjkasdgjfksgadkjfa
#define hafsdhfashfh ashdfshgadfadsjhgfashgdfshgadfshadfjshgadfj
int fsdgasdjkfjajksadgfkjags = 213213123;
long long fdashf = 13243543;
long long sdajdgjdfasfasfadsfsdafsadfasdfasdfadsf = 21232213;


void wtf() {
   cout << "WTF !!" << endl;
}

long long po(long long v, long long u)
{
	return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1;
}
 
long long ente(int i, int j)
{
	long long res = po(fac[i], MOD - 2) * po(fac[j - i], MOD - 2);
	res %= MOD;
	res *= fac[j];
	return res % MOD;
}
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
if (0 == 1)
wtf();
	cin >> n >> k;
	fac[0] = 1;
	for (int i = 1; i < MAXN * MAXN; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	if (k == 1)
		return cout << 1 << '\n', 0;
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			if (i)
				dp[i][j] = dp[i - 1][j];
			if (j)
				dp[i][j] += dp[i][j - 1] * ente(k - 2, i + j * (k - 1) - 1);
			dp[i][j] %= MOD;
		}
	}
	dp[n][n] = (dp[n][n] * fac[n]) % MOD;
	cout << dp[n][n] << '\n';
	return 0;
}

Measured memory_bytes: 62080
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  int ans = T.size();
  for(int i = 0; i <= S.size() - T.size(); i++) {
    int count = 0;
    for(int j = 0; j < T.size(); j++) {
      if(S.at(i + j) != T.at(j)) {
        count++;
      }
    }
    if(count < ans) {
      ans = count;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> m;
    ll sum = 0ll;
    rep(i,0,n){
        cin >> a[i];
        m[a[i]]++;
        sum += a[i];
    }
    int q; cin >> q;
    rep(i,0,q){
        ll b,c; cin >> b >> c;
        sum -= b*m[b];
        sum += c*m[b];
        m[c] += m[b];
        m[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 10116
program otoshidama
  implicit none
  integer i,j,man,sen,gosen
  integer*8 n,total

  read(*,*) n,total
  total=total/1000

  do man = 0,n
     do gosen = 0,n-man
        sen = n - man - gosen
        select case(total-sen-5*gosen-10*man)
        case(0)
           write(*,*) man,gosen,sen
           stop
        end select
     end do
  end do

  write(*,*) -1,-1,-1
    
end program otoshidama


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


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

  int n;
  string str;
  ll count = 0;
  map<string, int> mp;
  cin >> n;
  vector <string> a(n);
  for(int i = 1; i <= n; i++) {  
    cin >> str;
    sort(str.begin(), str.end());
    //cout << str << endl;
	count += mp[str];
    mp[str]++;
  }

  cout << count << endl;
}


Measured memory_bytes: 12032
#include <iostream>
#include <cstring>
 
using namespace std;
 
#define MAX 15
 
int H,W;
char field[MAX][MAX];
string ans;
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
const char mark[] = {'U','R','D','L'};
 
bool inField(int y,int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
int getDir(char ch){
    if(ch == 'U') return 0;
    if(ch == 'R') return 1;
    if(ch == 'D') return 2;
    if(ch == 'L') return 3;
    return -1;
}
 
void solve(int y,int x,int dir,int cnt,string s){
    if(cnt == 0){
	ans = s;
	return;
    }
 
    for(int i = 0 ; i < 4 ; i++){
	int nx = x, ny = y;
	if(dir == 0 && i == 2) continue;
	if(dir == 1 && i == 3) continue;
	if(dir == 2 && i == 0) continue;
	if(dir == 3 && i == 1) continue;
 
	while(inField(ny,nx)){
	    nx += dx[i];
	    ny += dy[i];
	    if(field[ny][nx] == 'o'){
		field[ny][nx] = '.';
		solve(ny,nx,i,cnt-1,s+mark[i]);
		field[ny][nx] = 'o';
		break;
	    }
	}
    }
}
 
int main(){
    int x,y,dir,cnt = 0;
    cin >> H >> W;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> field[i][j];
	    int num = getDir(field[i][j]);
	    if(num != -1){
		x = j, y = i; dir = num;
	    }else if(field[i][j] == 'o'){
		cnt++;
	    }
	}
    }
    field[y][x] = '.';
    solve(y,x,dir,cnt,"");
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int N = 1054, mod = 1000000007, pmod = mod - 1;

int R, C;
ll K;
char s[N][N];

inline int & reduce(int &x) {return x += x >> 31 & mod;}
inline ll & preduce(ll &x) {return x += x >> 63 & pmod;}
ll PowerMod(ll a, ll n, ll c = 1) {for (preduce(n %= pmod); n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

int main() {
	int i, j, v, V = 0, r = 0, hor = 0, ver = 0, ans = 0;
	scanf("%d%d%lld", &R, &C, &K), --K;
	for (i = 0; i < R; ++i)
		for (scanf("%s", s[i]), j = 0; j < C; ++j) V += s[i][j] &= 1;
	for (i = 0; i < R; ++i) hor += s[i][0] && s[i][C - 1];
	for (j = 0; j < C; ++j) ver += s[0][j] && s[R - 1][j];
	if (hor && ver) return putchar(49), putchar(10), 0;
	if (!(hor || ver)) return printf("%lld\n", PowerMod(V, K)), 0;
	v = hor + ver;
	for (i = 0; i < R; ++i)
		for (j = 0; j < C; ++j)
			r += s[i][j] && (hor ? s[i][j + 1] : s[i + 1][j]);
	ans = PowerMod(V - v, -1, r) * (PowerMod(V, K) - PowerMod(v, K)) % mod;
	printf("%d\n", reduce(ans = PowerMod(V, K) - ans));
	return 0;
}

Measured memory_bytes: 1280
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <bits/stdc++.h>
#include <complex>
#include <numeric>
#include <climits>
#include <stack>
#include <locale.h>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <ctime>
#include <deque>
#include <queue>
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define rept(i,n)for(int i=0;i<(int)(n);i++)
#define fi first
#define se second
#define mod 1e9+7
using namespace std;
int n;
bool p[1000];
long long t,x=1;
void devise(int d)
{
	t=0;
	int n1=n;
	while(n1)
	{
		t=t+n1/d;
		n1/=d;
	}
	return ;
}
int main()
{
	cin>>n;
	for(int i=2;i<=n;i++){
		if(!p[i]){
			for(int j=i*i;j<=n;j+=i)
			   p[j]=true;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(!p[i])
		{
			devise(i);
			x=(x*(t+1))%1000000007;
		}
	}
	cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int k;
    cin>>k;
    int ans=0;
    rep(i,k){
        rep(j,k){
            rep(w,k){
                ans+=gcd(gcd(i+1,j+1),w+1);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
<?php
fscanf(STDIN,"%d",$n);


$chars = array();
$march = array('M','A','R','C','H');
$index = '';

$D = array_fill(0);

$P =array(0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2);
$Q =array(1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3);
$R =array(2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4);

for($i=0;$i<$n;$i++){
  	$s = trim(fgets(STDIN));
   	if ( $s[0]== 'M') $m++;
    if ($s[0]=='A') $a++;
    if ($s[0]== 'R') $r++;
    if ($s[0]=='C') $c++;
    if ($s[0]== 'H') $h++;         
}

$D[0] = $m;
$D[1] = $a;
$D[2] = $r;
$D[3] = $c;
$D[4] = $h;

$res = 0;

for($i=0;$i<10;$i++){
  $res+=$D[$P[$i]]*$D[$Q[$i]]*$D[$R[$i]];
}
echo $res;


  

Measured memory_bytes: 4604
n,k = map(int,input().split())
a_ls = list(map(int,input().split()))
f_ls = list(map(int,input().split()))

a_ls.sort(reverse=True)
f_ls.sort()

l=-1
r=a_ls[0] * f_ls[-1]
while(l+1<r):
    c=(l+r)//2
    total = 0
    for i in range(n):
        a = max(a_ls[i] * f_ls[i] - c, 0)
        b = f_ls[i]
        total += (a+b-1)//b
    if total > k:
        l=c
    else:
        r=c
print(r)



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

#define ll long long int

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int ans, x;
  for(int i = 0; i < 5; i++){
    cin >> x;
    if(x == 0){
      ans = i+1;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
int n;

int main(){
	IOS
	cin >> n;
	ll ans=n;
	int arr[n+5];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	int mins=arr[0];
	for(int i=1;i<n;i++){
		if(arr[i]<=mins){
			mins=arr[i];
		}
		else{
			ans--;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 4440
#include<stdio.h>
#define N 101

int main(){

  int i,j,n,key = 0,count = 0,array[N],mini;

  scanf("%d",&n);

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

  for(i = 0; i < n; i++){
    mini = i;
    for(j = i; j < n; j++){
      
      if(array[j] < array[mini]){
	mini = j;
      }
    }

    key = array[i];
    array[i] = array[mini];
    array[mini] = key;
    if(mini != i) count++; // 処理してないということ！
    
  }

  for(i = 0; i < n; i++){
    if(i < n-1) printf("%d ",array[i]);
    if(i == n-1) printf("%d\n",array[i]);
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 0
#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;
  int t = N, c = 0;
  while(t > 0){
    c += t % 10;
    t /= 10;  
  }
  if(N % c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s,t;
    getline(cin,s);
    getline(cin,t);
    int m = s.length(),n = t.length() ;
    int dp[m+1][n+1],i,j;
    for(i=0;i<=m;i++) {
        for(j=0;j<=n;j++){
            if(i==0||j==0)
            dp[i][j]=0;
            else {
                if(s[i-1]==t[j-1])
                    dp[i][j] = dp[i-1][j-1]+1;
                else
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    i=m;
    j=n;
    string st;
    while(i>0&&j>0){
            if(s[i-1]==t[j-1]){
                st=s[i-1]+st;
                i--;
                j--;
            }
            else if (dp[i-1][j] > dp[i][j-1]) 
                i--; 
            else
             j--; 
        }
        cout<<st;
}

Measured memory_bytes: 38792
#include<stdio.h>

int main(){
    int i, j;
    int count = 0;
    int N, minj, tmp;
    scanf("%d",&N);
    int A[N];

    for(i = 0; i < N; i++){
        scanf("%d",&A[i]);
    }

    for(i = 0; i < N; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        if(minj != i){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            count++;
        }
        
    }

    for(j = 0; j < N; j++){
        if(N - 1 == j)printf("%d\n",A[j]);
	else printf("%d ",A[j]);
    }
    
    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

int dist(vi a,vi b){
    int ans=0;
    for(int i=0;i<a.size();i++){
        ans+=((a[i]-b[i])*(a[i]-b[i]));
    }
    return ans;
}

int main(){
    ll l,r;
    cin>>l>>r;
    ll mini=2018;
    ll idx=-1;
    for(ll i=l;i<=min(l+2019,r);i++){
        for(ll j=i+1;j<=min(i+2019,r);j++){
            ll t1=i%2019;
            ll t2=j%2019;
            ll t=(t1*t2)%2019;
            mini=min(mini,t);
        }
    }
    out(mini);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,K; cin >> A >> B >> K;
    for(int i = A; i <= min(A + K - 1,B); i++)
    {
        cout << i << endl;
    }
    for(int i = max(B - K + 1, A + K); i <= B; i++)
    {
        cout << i << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();
        int H = scanner.nextInt();
        int W = scanner.nextInt();

        int yoko = N - W + 1;
        int tate = N - H + 1;

        System.out.println(yoko * tate);
    }

}


Measured memory_bytes: 21716
import java.util.*;

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

        int N = sc.nextInt();
        
        int onesPlace = N % 10;

        Integer[] honList = {2, 4, 5, 7, 9};
        Integer[] ponList = {0, 1, 6, 8};
        Integer[] bonList = {3};
        
        if (Arrays.asList(honList).contains(onesPlace)){
            System.out.println("hon");
        } else if (Arrays.asList(ponList).contains(onesPlace)) {
            System.out.println("pon");
        } else if (Arrays.asList(bonList).contains(onesPlace)) {
            System.out.println("bon");
        } 
        
    }
}

Measured memory_bytes: 35820