akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
K = int(input())
ans = ''

for s in S:
	num = (123 - ord(s))%26
	if num <= K:
		ans = ans + 'a'
		K -= num
	else:
		ans = ans + s

if K > 0:
	ans = ans[:-1] + (chr((ord(ans[-1])-97+K)%26+97))

print(ans)


Measured memory_bytes: 4596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 T, A[101010];

int main()
{
	scanf("%d%lld", &N, &T);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);

	i64 best = 0;
	i64 cmn = A[0];
	for (int i = 0; i < N; ++i) {
		best = max(best, A[i] - cmn);
		cmn = min(cmn, A[i]);
	}
	int ret = 0;
	cmn = A[0];
	for (int i = 0; i < N; ++i) {
		if (A[i] - cmn == best) ++ret;
		cmn = min(cmn, A[i]);
	}
	printf("%d\n", ret);

	return 0;
}


Measured memory_bytes: 1024
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;

const int MAXN = 200005;
const int MOD = 2019;
int dp[2][2019];

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    memset(dp, 0, sizeof dp);
    long long ans = 0LL;
    int n = S.length();
    for(int i = 0; i < n; ++i) {
        int cur = i & 1;
        int pre = 1 - cur;
        int d = S[i] - '0';
        for(int j = 0; j < MOD; ++j) dp[cur][j] = 0;
        dp[cur][d % MOD] += 1;
        for(int j = 0; j < MOD; ++j) {
            int k = (j * 10 + d) % MOD;
            dp[cur][k] += dp[pre][j];
        }
        ans += dp[cur][0];
    }
    // for(int i = 1; i <= n; ++i) ans += dp[i][0];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3804
#include <stdio.h>
int main(){

  int m[6],r=1,blank,n,i;
  char hou[10];

  while(1){

    r=1;
  scanf("%d",&n);
  if(n == 0) break;
  
  for(i = 0; i < 6; i++) m[i]=i+1;

  for(i = 0; i < n; i++){

    scanf("%s",hou);

    if(hou[0] == 'N'){

      blank=m[0];
      m[0]=m[1];
      m[1]=m[5];
      m[5]=m[4];
      m[4]=blank;

    }

    if(hou[0] == 'E'){

      blank=m[0];
      m[0]=m[3];
      m[3]=m[5];
      m[5]=m[2];
      m[2]=blank;

    }

    if(hou[0] == 'S'){

      blank=m[0];
      m[0]=m[4];
      m[4]=m[5];
      m[5]=m[1];
      m[1]=blank;

    }


    if(hou[0] == 'W'){

      blank=m[0];
      m[0]=m[2];
      m[2]=m[5];
      m[5]=m[3];
      m[3]=blank;

    }

    if(hou[0] == 'R'){

      blank=m[1];
      m[1]=m[2];
      m[2]=m[4];
      m[4]=m[3];
      m[3]=blank;

    }

    if(hou[0] == 'L'){

      blank=m[1];
      m[1]=m[3];
      m[3]=m[4];
      m[4]=m[2];
      m[2]=blank;

    }

    r += m[0];

  }

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

  }
  
  return 0;

}

Measured memory_bytes: 604
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <string>

int main()
{

    std::string s1;
    std::cin >> s1;

    std::string s2;
    std::cin >> s2;

    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
    {
        std::cout << "YES"
                  << "\n";
    }
    else
    {
        std::cout << "NO"
                  << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  REP(i,n) a[i] = s[i] == 'o'; // 0: x, 1: o

  auto get_cur = [&](char animal, char c){
    return animal == 'S' ? c : c^1;
  };

  // 4パターンを固定して考える: SS, SW, WW, WS
  for (string ans: {"SS", "SW", "WW", "WS"}) {
    for (int i = 1; i < n; i++) {
      if (get_cur(ans[i], a[i])) ans += ans[i-1];
      else ans += ans[i-1] == 'S' ? 'W' : 'S';
    }

    int cur = get_cur(ans[0], a[0]);
    int ok = cur ? ans[1] == ans[n-1] : ans[1] != ans[n-1];
    if (ok && ans[0] == ans[n]) { COUT(ans.substr(0,n)); return 0; }
  }

  COUT(-1); // 存在しない
  return 0;
}

Measured memory_bytes: 4176
#include <stdio.h>
int main(void){
	double v,y;
	int i;
	while(scanf("%lf",&v)!=EOF){
		y=4.9*v*v/(9.8*9.8);
		for(i=1;;i++){
			if(5*i-5>=y)
			break;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 628
n,m = map(int,input().split())
p = []
for i in range(m):
    x1,y1,z1,=[int(i) for i in input().split()]
    p.append([x1-1,y1-1,z1])
cost = [[] for i in range(n)]
for path in p:
    cost[path[0]].append((path[1],path[2]))
    cost[path[1]].append((path[0],path[2]))
zan = [[float("inf"),float("inf")] for i in range(n)]
zan[0] = (1,0)
tan =[(0,0)]
e = 0
while len(tan):
  i,j = tan.pop()
  for a,b in cost[i]:
    if (zan[a][0] != float("inf")):
      if abs((j)-zan[a][1]) == 1:
        pass
      elif ((j)-zan[a][1])%2 == 1:
        if zan[a][0] != b - zan[i][0]:
          e=1
          tan = []
          break
      else:
        e = 2
        if zan[a][0] != b - zan[i][0]:
          e = 3
          x = zan[a][0] + zan[i][0]
          if (b-x)% 2 != 0:
            e = 4
            tan = []
            break
          ano = zan[a][0] + (b-x)//2
          ino = zan[i][0] + (b-x)//2
          iti = (j)-zan[a][1]
          zan = [[float("inf"),float("inf")] for i in range(n)]
          zan[a] = (ano,0)
          kime = a
          zan[i] = (ino,iti)
          tan = []
          break
    zan[a] = (b - zan[i][0],j+1)
    tan.append((a,j+1))
  cost[i] = []
if e == 1:
  print(0)
elif e == 2:
  f = 0
  for i in range(n):
    if zan[i][0]<= 0:
      f = 1
      break
  if f == 0:
    print(1)
  else:
    print(0)
elif e == 4:
  print(0)
elif e == 0:
  syou =0
  f = 0
  dai = float("inf")
  for a,b in zan:
    if b %2 ==0:
      if a < 1:
        syou = max(syou,-a+1)
    else:
      if a > 0:
        dai = min(dai,a-1)
      else:
        f = 1
        break
  if f == 1:
    print(0)
  else:
    if dai >= syou:
      print(dai-syou+1)
    else:
      print(0)
elif e == 3:
  tan =[(kime,0)]
  cost = [[] for i in range(n)]
  for path in p:
    cost[path[0]].append((path[1],path[2]))
    cost[path[1]].append((path[0],path[2]))
  while len(tan):
      i,j = tan.pop()
      for a,b in cost[i]:
        if (zan[a][0] != float("inf")):
          if abs((j)-zan[a][1]) == 1:
            pass
          elif ((j)-zan[a][1])%2 == 1:
            if zan[a][0] != b - zan[i][0]:
              e=1
              tan = []
              break
          else:
            if zan[a][0] != b - zan[i][0]:
              e = 1
              break
        zan[a] = (b - zan[i][0],j+1)
        tan.append((a,j+1))
      cost[i] = []
  if e == 1:
    print(0)
  else:
    f = 0
    for i in range(n):
      if zan[i][0]<= 0:
        f = 1
        break
    if f == 0:
      print(1)
    else:
      print(0)

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

using namespace std;
using ll = long long;

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

int main() {
  int a, p;
  cin >> a >> p;
  int sum = 3 * a + p;
  cout << sum / 2 << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>


int main() {
  int r, c;
  int value;
  int column_sum[100] = {0}, row_sum[100] = {0}, all_sum = 0;
  char deli = ' ';

  std::cin >> r >> c;
  for (int i = 0; i < r; i ++) {
    for (int j = 0; j < c; j ++) {
      std::cin >> value;
      row_sum[i] += value;
      column_sum[j] += value; 
      std::cout << value << deli;
    }
    std::cout << row_sum[i] << std::endl;
    all_sum += row_sum[i];
  }
  for (int j = 0; j < c; j ++) {
    std::cout << column_sum[j] << deli;
  }
  std::cout << all_sum << std::endl;

  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
bool seen[505][505];

//dpTable
//bool dp[100050];

int main(){
    int N,L;
    cin >> N >> L;
    int hoge = 10000,ans = 0;
    bool aa = false;
    for (int i = 1; i <= N; i++) {
        int a = L + i - 1;
        ans += a;
        if (hoge > abs(a)) {
            hoge = abs(a);
            if (a < 0) aa = false;
            else aa = true;
        }
    }
    cout << ans - (aa ? 1 : -1) * hoge << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n;
    vector<int> sticks;
    for0(i,n) {
        int x;
        read(x);
        sticks.pb(x);
    }
    sort(all(sticks));
    
    vector<ll> pairs;
    vector<ll> quads;
    for (int i=0; i<n;) {
        int j=i+1;
        while (j<n && sticks[j] == sticks[i])
            j++;
        if (j-i >= 2)
            pairs.pb(sticks[i]);  
        if (j-i >= 4) {
            quads.pb(sticks[i]);
        }
        i = j;
    }
    printv(pairs);
    
    ll ans1 = 0, ans2 = 0;
    if (sz(quads) > 0) {
        ans1 = quads.back() * quads.back();
    }
    if (sz(pairs) >= 2) {
        ans2 = pairs.back() * pairs[sz(pairs)-2];
    }
    cout<<max(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int a, b;

signed main() {
	cin >> a >> b;
	cout << max({ a + b,a * 2 - 1,b * 2 - 1 }) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int H, W, K;
    vector<string> s;
    cin >> H >> W >> K;
    s.resize(H);
    rep (i, H)
    {
        cin >> s[i];
    }

    vector< vs32 > pos(H);
    rep (i, H)
    {
        rep (j, W)
        {
            if (s[i][j] == '#')
            {
                pos[i].push_back(j);
            }
        }
        pos[i].push_back(W);
    }

    vector< vs32 > ans(H, vs32(W));
    int a = 1;
    int h = 0;
    int prevh = 0;
    while (true)
    {
        for (; h < H && pos[h].size() == 1; ++h);
        if (h == H) break;
        pos[h][0]  = 0;
        for (int i = 1; i < pos[h].size(); ++i)
        {
            for (int j = pos[h][i - 1]; j < pos[h][i]; ++j)
            {
                for (int k = prevh; k <= h; ++k)
                {
                    ans[k][j] = a;
                }
            }
            ++a;
        }
        ++h;
        prevh = h;
    }

    if (prevh < H)
    {
        for (int i = prevh; i < H; ++i)
        {
            ans[i] = ans[prevh - 1];
        }
    }

    rep (i, H)
    {
        rep (j, W)
        {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 1920
<?php
$a = trim(fgets(STDIN)); // 500
$b = trim(fgets(STDIN)); // 100
$c = trim(fgets(STDIN)); // 50
$x = trim(fgets(STDIN));

$count = 0;
for ($a_i = 0; $a_i <= $a; $a_i++) {
    for ($b_i = 0; $b_i <= $b; $b_i++) {
        for ($c_i = 0; $c_i <= $c; $c_i++) {
            if (500 * $a_i + 100 * $b_i + 50 * $c_i == $x) {
                $count++;
            }
        }
    }
}

print $count;


Measured memory_bytes: 4728
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int M=50*1000+10;
char buf[M+1];
char in[M+1];
void No(){
	cout << "no such property" << endl;
	exit(0);
}
int main() {
	cin.getline(in,M);
	int e=0;
	int indent=0;
	while(in[e]!=0){
		e++;
		int s=e;
		while(in[e]!='.'&&in[e]!=0){
			e++;
		}
		bool newIndent=true;
		while(cin.getline(buf,M)){
			int s0=0;
			while(buf[s0]==' '){
				s0++;
			}
			if(newIndent){
				indent=s0;
				newIndent=false;
			}
			else if(s0<indent){
				No();
			}
			else if(s0>indent){
				continue;
			}
			int e0=s0;
			while(buf[e0]!=':'){
				e0++;
			}
			if(e0-s0==e-s){
				bool ok=true;
				for(int i=0;i<e-s;i++){
					if(buf[i+s0]!=in[i+s]){
						ok=false;
						break;
					}
				}
				if(ok){
					if(in[e]==0){
						if(buf[e0+1]==0){
							cout << "object" << endl;
						}
						else
						{
							cout << "string \"" << (buf+e0+2) << "\"" << endl;
						}
						return 0;
					}
					else
					{
						if(buf[e0+1]==' '){
							No();
						}
						newIndent=true;
						break;
					}
				}
			}
		}
	}
	No();
}

Measured memory_bytes: 1176
N = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = make_divisors(N)
result = []
if len(ans)%2 == 0:
    for i, j in zip(range(0, int(len(ans)/2)), reversed(range(int(len(ans)/2), len(ans)))):
        result.append(int(ans[i]+ans[j])-2)
else:
    x = ans[int(len(ans)/2)]
    result.append((x-1)*2)
print(min(result))

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b+MOD) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t mod_inv(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int N, K, M, A[25000];

int64_t solve_distinct(){
    static int64_t dp[25001][401][2];
    dp[0][0][0] = 1;

    for(int i=0; i<N; i++){
        for(int k=0; k<2; k++){
            int64_t sum = 0;
            for(int j=K-1; j>=1; j--){
                add(sum, dp[i][j][k]);
                add(dp[i+1][j][k], sum + (K-j+1) * dp[i][j-1][k]);
                if(k==0 && j >= M) add(dp[i+1][j][1], dp[i+1][j][0]);
            }
        }
    }

    int64_t ret = 0;
    for(int j=1; j<K; j++) add(ret, dp[N][j][1]);
    for(int j=K-M+1; j<=K; j++) mul(ret, mod_inv(j));
    return ret;
}

int64_t solve_other(int L, int R){
    static int64_t dp[25001][401][2], dpsum[25001][2];
    dp[0][L][0] = dp[0][R][1] = dpsum[0][0] = dpsum[0][1] = 1;

    for(int i=0; i<N; i++){
        for(int k=0; k<2; k++){
            int64_t sum = 0;
            for(int j=K-1; j>=1; j--){
                add(sum, dp[i][j][k]);
                add(dp[i+1][j][k], sum + (K-j+1) * dp[i][j-1][k]);
                add(dpsum[i+1][k], dp[i+1][j][k]);
            }
        }
    }

    int64_t ret = 0;
    for(int i=0; i<=N-M; i++) add(ret, dpsum[i][0] * dpsum[N-M-i][1]);
    return ret;
}

int main(){
    cin >> N >> K >> M;
    for(int i=0; i<M; i++) cin >> A[i];

    int L = -1, R = 0, st = 0, mx = 0; 
    vector<int> last(K+1, -1);
    for(int i=0; i<M; i++){
        if(last[A[i]] >= st){
            if(L == -1) L = R;
            st = last[A[i]] + 1;
            R = i - last[A[i]];
        }else{
            R++;
        }
        last[A[i]] = i;
        mx = max(mx, R);
    }
    if(L == -1) L = R;

    int64_t ans = N-M+1, sub;
    for(int i=0; i<N-M; i++) mul(ans, K);
    if(mx == K){
        sub = 0;
    }else if(R == M){
        sub = solve_distinct();
    }else{
        sub = solve_other(L, R);
    }
    add(ans, MOD - sub);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 158336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

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

  int ans = 0;

  while(1){
    int MaxN = sqrt(X);
    bool isPrime = true;

    rep2(i,2,MaxN){
      if (X % i == 0) isPrime = false;
    }

    if(isPrime) break;
    else X++;
  }


  cout << X << endl;
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  int a;
  map<int,int> mp;
  if(N%2 == 1){
    for(int i=0;i<N;i++){
      cin >> a;
      if(a>N || (a%2 == 1) ){
        cout << 0 << endl;
        return 0;
      }
      mp[a]++;
    }
    if(mp[0] != 1){
      cout << 0 <<endl;
      return 0;
    }
    for(int i=2;i<N;i+=2){
      if(mp[i] != 2){
        cout << 0 <<endl;
        return 0;
      }
    }
  }
  if(N%2 == 0){
    for(int i=0;i<N;i++){
      cin >> a;
      if(a>N || (a%2 == 0) ){
        cout << 0 << endl;
        return 0;
      }
      mp[a]++;
    }
    for(int i=1;i<N;i+=2){
      if(mp[i] != 2){
        cout << 0 <<endl;
        return 0;
      }
    }
  }
  int x=N/2;
  int ans=1;
  for(int i=0;i<x;i++){
    ans *= 2;
    ans = ans%1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>

using namespace std;

const int N=200010;
int n,m,pre[N],sum[N],ans;

inline void re(int &x)
{
	x=0;
	bool flag=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') flag|=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=flag ? -x : x;
}

int find(int a)
{
    int r=a;
    while(pre[r]!=r) r=pre[r];
    int i=a,j;
    while(i!=r)
    {
        j=pre[i];
        pre[i]=r;
        i=j;
    }
    return r;
}

void merge(int a,int b)
{
    int i=find(a),j=find(b);
    if(i==j) return;
    if(sum[i]<sum[j])
    {
        pre[i]=j;
        sum[j]+=sum[i];
    }
    else
    {
        pre[j]=i;
        sum[i]+=sum[j];
    }
}

int main()
{
    int i,a,b;
    re(n); re(m);
    for(i=1;i<=n;i++) pre[i]=i, sum[i]=1;
    for(i=1;i<=m;i++)
    {
        re(a); re(b);
        merge(a,b);
    }
    for(i=1;i<=n;i++) if(sum[i]>ans) ans=sum[i];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC

#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

vector<string> vec_splitter(string s) {
	for(char& c: s) c = c == ',' ?  ' ': c;
	stringstream ss; ss << s;
	vector<string> res;
	for(string z; ss >> z; res.push_back(z));
	return res;
}

void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, Head H, Tail... T) {
		if(idx > 0) cerr << ", ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, T...);
	}

#ifdef DEBUGON
	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);	
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld n,v=100,ans=0;
	cin>>n;

	while(v<n)
	{
		v+=v*0.01;
		ans++;
	}

	cout<<ans;
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int ans[3005];
int main()
{
	int n,x,y,i,j,a,b,d;
	cin>>n>>x>>y;
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
		{
			a=j-i;
			b=(x>i?x-i:i-x)+(y>j?y-j:j-y)+1;
			d=min(a,b);
			ans[d]++;
		}
	for(i=1;i<n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int N, T[100000], A[100000];
int mx[100000];

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

  memset(mx, -1, sizeof(mx));
  mx[0] = T[0];
  for(int i = 1; i < N; i++) {
    if(T[i - 1] < T[i]) mx[i] = T[i];
  }
  for(int i = N - 1; i >= 0; i--) {
    if(i == N - 1 || A[i + 1] < A[i]) {
      if(~mx[i] && mx[i] != A[i]) {
        cout << 0 << endl;
        return (0);
      }
      mx[i] = A[i];
      if(mx[i] > T[i]) {
        cout << 0 << endl;
        return (0);
      }
    }
  }

  int ret = 1;
  for(int i = 0; i < N; i++) {
    if(~mx[i]) continue;
    ret = 1LL * ret * min(A[i], T[i]) % mod;
  }
  cout << ret << endl;
}

//

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int cumsum_R[4005];
int cumsum_G[4005];
int cumsum_B[4005];

int main(void) {
    int N; cin >> N;
    string s; cin >> s;
    string S = " " + s;

    for (int i = 1; i <= N; i++) {
        if (S[i] == 'R') cumsum_R[i]++;
        if (S[i] == 'G') cumsum_G[i]++;
        if (S[i] == 'B') cumsum_B[i]++;
    }

    for (int i = 1; i <= N; i++) {
        cumsum_R[i] += cumsum_R[i-1];
        cumsum_G[i] += cumsum_G[i-1];
        cumsum_B[i] += cumsum_B[i-1];
    }

    long long ans = 0;

    for (int i = 1; i <= N; i++) {
        long long tmp = 0;
        if (S[i] == 'G') {
            tmp += cumsum_R[i-1] * (cumsum_B[N] - cumsum_B[i]);
            tmp += cumsum_B[i-1] * (cumsum_R[N] - cumsum_R[i]);
            for (int j = 1; i - j >= 1 && i + j <= N; j++) {
                if (S[i-j] == 'R' && S[i+j] == 'B') tmp--;
                if (S[i-j] == 'B' && S[i+j] == 'R') tmp--;
            }
            ans += tmp;
        }
        if (S[i] == 'R') {
            tmp += cumsum_G[i-1] * (cumsum_B[N] - cumsum_B[i]);
            tmp += cumsum_B[i-1] * (cumsum_G[N] - cumsum_G[i]);
            for (int j = 1; i - j >= 1 && i + j <= N; j++) {
                if (S[i-j] == 'G' && S[i+j] == 'B') tmp--;
                if (S[i-j] == 'B' && S[i+j] == 'G') tmp--;
            }
            ans += tmp;
        }
        if (S[i] == 'B') {
            tmp += cumsum_R[i-1] * (cumsum_G[N] - cumsum_G[i]);
            tmp += cumsum_G[i-1] * (cumsum_R[N] - cumsum_R[i]);
            for (int j = 1; i - j >= 1 && i + j <= N; j++) {
                if (S[i-j] == 'R' && S[i+j] == 'G') tmp--;
                if (S[i-j] == 'G' && S[i+j] == 'R') tmp--;
            }
            ans += tmp;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    vector<int> a(6), b(6);

    int i;

    for (i = 0; i <= 5; ++i) {
        cin >> a.at(i);
    }

    string str;

    cin >> str;

    for (i = 0; i <= str.size()-1;++i) {
        if (str.at(i) == 'S') {
            b.at(0) = a.at(0);
            b.at(1) = a.at(1);
            b.at(2) = a.at(2);
            b.at(3) = a.at(3);
            b.at(4) = a.at(4);
            b.at(5) = a.at(5);
            a.at(0) = b.at(4); 
            a.at(1) = b.at(0);
            a.at(2) = b.at(2);
            a.at(3) = b.at(3);
            a.at(4) = b.at(5);
            a.at(5) = b.at(1);
        }
        else if (str.at(i) == 'N') {
            b.at(0) = a.at(0);
            b.at(1) = a.at(1);
            b.at(2) = a.at(2);
            b.at(3) = a.at(3);
            b.at(4) = a.at(4);
            b.at(5) = a.at(5);
            a.at(0) = b.at(1);
            a.at(1) = b.at(5);
            a.at(2) = b.at(2);
            a.at(3) = b.at(3);
            a.at(4) = b.at(0);
            a.at(5) = b.at(4);
        }
        else if (str.at(i) == 'E') {
            b.at(0) = a.at(0);
            b.at(1) = a.at(1);
            b.at(2) = a.at(2);
            b.at(3) = a.at(3);
            b.at(4) = a.at(4);
            b.at(5) = a.at(5);
            a.at(0) = b.at(3);
            a.at(1) = b.at(1);
            a.at(2) = b.at(0);
            a.at(3) = b.at(5);
            a.at(4) = b.at(4);
            a.at(5) = b.at(2);
        }
        else {
            b.at(0) = a.at(0);
            b.at(1) = a.at(1);
            b.at(2) = a.at(2);
            b.at(3) = a.at(3);
            b.at(4) = a.at(4);
            b.at(5) = a.at(5);
            a.at(0) = b.at(2);
            a.at(1) = b.at(1);
            a.at(2) = b.at(5);
            a.at(3) = b.at(0);
            a.at(4) = b.at(4);
            a.at(5) = b.at(3);
        }
    }

    cout << a.at(0) << endl;

}


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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int i;
    int poison = 0;
    long long counter = 0;
    if(b < c)
    {
        cout << b*2 + min(a + 1,c - b);
    }
    else if(b >= c)
    {
        cout << b + c;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int M;

using Num = long long;
vector<vector<Num>> combi;
vector<vector<Num>> precomputeCombination(int n) {
	vector<Num> a(1, 1), b(2, 1);
	combi = { a,b };
	for (int i = 3; i <= n + 1; i++) {
		swap(a, b);
		b.resize(i);
		b[0] = 1; b[i - 1] = 1;
		for (int j = 1; j < i - 1; j++)
			b[j] = (a[j - 1] + a[j]) % M;
		combi.emplace_back(b);
	}
	return combi;
}

vector<Num> fact;
vector<Num> precomputeFact(int n) {
	fact.emplace_back(1);
	rep(i, 2, n + 1) {
		fact.emplace_back(fact.back() * i);
	}
	return fact;
}

long long modpow(long long a, long long exponent, long long mod) {
	long long res = 1;
	while (exponent > 0) {
		if (exponent & 1)res = res * a % mod;
		a = a * a % mod;
		exponent >>= 1;
	}
	return res;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N >> M;

	int n = N + 2;
	vector<vector<int>> dp(n, vector<int>(n, -1));

	vector<int> power(n * n + 1);
	power[0] = 1;
	for (int i = 0; i < n * n; i++)
		power[i + 1] = (power[i] * 2) % M;

	precomputeCombination(n);
	precomputeFact(n);

	int ans = 0;
	rep(r, 1, N) {
		int b = N - r;
		int mr = r * (r - 1) / 2;
		int mb = b * (b - 1) / 2;
		int add = 0;

		rep(i, 0, b) {
			int x = 1;
			x *= combi[b][i];
			x *= modpow(power[b - i] - 1, r, M);
			x %= M;
			if (i % 2)x *= -1;
			x = (x + M) % M;
			(add += x) %= M;
		}
		(add *= power[mr]) %= M;
		(add *= power[mb]) %= M;
		(add *= combi[N][r]) %= M;
		(ans += add) %= M;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 96904
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define mpr make_pair
#define fr first
#define se second
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;
ll mdpower(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
bool is_check(int a,int b,int c,int d)
{
    if(b==0 && c==1 && d==2) return 1; //*AGC
    if(b==1 && c==0 && d==2) return 1; // *GAC
    if(b==0 && c==2 && d==1) return 1; // *ACG
    if(a==0 && c==1 && d==2) return 1; // A_GC
    if(a==0 && b==1 && d==2) return 1; // AG_C
    return 0;
}
signed main()
{
     Senky_Bansal
     IIIT_ALLAHABAD
     ll dp[110][4][4][4];
     dp[0][3][3][3]=1;
     ll n;
     cin>>n;
     // A-'0' G-'1' C-'2' T-'3'
     for(int i=0;i<=n;i++)
     {
         for(int x=0;x<4;x++)
         {
             for(int y=0;y<4;y++)
             {
                 for(int z=0;z<4;z++)
                 {
                     for(int w=0;w<4;w++)
                     {
                          if(is_check(x,y,z,w)) continue;
                          dp[i+1][y][z][w]+=dp[i][x][y][z];
                          dp[i+1][y][z][w]%=mod;
                     }
                 }
             }
         }
     }
     ll ans=0;
     for(int x=0;x<4;x++)
     {
         for(int y=0;y<4;y++)
         {
             for(int z=0;z<4;z++)
             {
                 ans+=dp[n][x][y][z];
                 ans%=mod;
             }
         }
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, ans = 0;
    cin >> N;
    vector<int64_t> A(5);
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if (S.at(0) == 'M'){
            A.at(0)++;
        }
        if (S.at(0) == 'A'){
            A.at(1)++;
        }
        if (S.at(0) == 'C'){
            A.at(2)++;
        }
        if (S.at(0) == 'R'){
            A.at(3)++;
        }
        if (S.at(0) == 'H'){
            A.at(4)++;
        }
    }
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += A.at(i) * A.at(j) * A.at(k);
            }
        }
    }
    cout << ans << endl;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int A,B;
    cin >> A >> B;
    cout << A*B-A-B+1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;

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

    int ans = 0;

    char pre = S[0];
    for(int i = 1; i<N; i++){
        if(S[i] != pre){
            ans ++;
        }
        pre = S[i];
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
const int maxn = 5007, mod = int(1e9) + 7;
typedef long long ll;
char str[maxn];
int ans[maxn][maxn], len, n;
ll power_mod(ll p, int q) {
    ll ret = 1;
    while (q) {
        if (q & 1) ret = ret * p % mod;
        p = p * p % mod;
        q >>= 1;
    }
    return ret;
}
int max(int a, int b) { return a > b ? a : b; }
void init() {
    len = int(strlen(str)), ans[0][0] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            ans[i + 1][j + 1] = int((1ll * ans[i][j] * 2 % mod + ans[i + 1][j + 1]) % mod);
            ans[i + 1][max(j - 1, 0)] = int((0ll + ans[i][j] + ans[i + 1][max(j - 1, 0)]) % mod);
        }
    }
}

int main() {
    scanf("%d%s", &n, str);
    init();
    printf("%d\n", int(power_mod(power_mod(2, len), mod - 2) * ans[n][len] % mod));
    return 0;
}


Measured memory_bytes: 96512
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){
    vector<int> value;

    int val;
    for( int ni = 0 ; ni <  3 ; ni++ ){
        cin >> val;
        value.push_back(val);
    }
    sort(value.begin(),value.end());
    cout << value[0]+value[1]+value[2]*10;

    

}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n;
    cin >> n;
    Int res = n / 2;
    if (n % 2 == 1) res++;
    dump(res);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

def dfs(x,y):
	for i in range(8):
		nx=x+dx[i]
		ny=y+dy[i]
		if 0<=nx<h and 0<=ny<w and C[nx][ny]==1 and D[nx][ny]==0:
			D[nx][ny]=d
			dfs(nx,ny)

dx=[1,1,0,-1,-1,-1,0,1]
dy=[0,1,1,1,0,-1,-1,-1]

while True:
	w,h=map(int,input().split())
	if w==0 and h==0:
		exit()
	d=0
	C=[list(map(int,input().split())) for i in range(h)]
	D=[[0]*w for i in range(h)]
	for x in range(h):
		for y in range(w):
			if C[x][y]==1 and D[x][y]==0:
				d+=1
				dfs(x,y)
	print(d)



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

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

  int a, b;
  cin >> a >> b;

  string A(b, '0' + a);
  string B(a, '0' + b);

  if (a < b) cout << A << endl;
  else cout << B << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())

#print(n)
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    exit(0)


ans = 1
for i in range(n):
    ans *= a[i]
    #if a[i]==0:
    #    print(0)
    #    exit(0)

    if ans > 1000000000000000000:
        print(-1)
        exit(0)

print(ans)
exit(0)

### C++と同じく、実行は、Opt + Ctl + N

'''
# -*- coding: utf-8 -*-
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print('{} {}'.format(a+b+c, s))
'''


Measured memory_bytes: 21572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  cin >> n >> k;

  ll ans = 1;
  rep(i, n) {
    ans = min(2*ans, ans+k);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n+1):
    s = str(i)
    c[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1, n+1):
    s = str(i)
    ans += c[int(s[-1])][int(s[0])]
print(ans)

Measured memory_bytes: 9196
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <22/Jun/2019 05:31:41 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    s = input()
    n = len(s)
    ans = 'Good'
    for i in range(1, n):
        if s[i] == s[i - 1]:
            ans = 'Bad'
            break
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end
int main() {
    string  S;
    cin >> S;
    vector<int>cnt(2,0);
//    vector<int> s();
//    vector<int> t();
    for(int i=0; i<S.size(); i++) {
        if(S[i] == '0')
            cnt[0]++;
        else
            cnt[1]++;
    }
    cout << 2*min(cnt[0],cnt[1]) <<endl;
    return 0;
}



Measured memory_bytes: 512
from sys import stdin

H, W = map(int, stdin.readline().split())
field = [1 for _ in range(H*W)]
for i in range(H):
    tmp = stdin.readline().rstrip()
    for j, c in enumerate(tmp):
        if c == '#':
            field[W*i+j] = 0

N = H*W
dp = [0 for _ in range(N)]
dp[0] = 1
for i in range(1, N):
    if field[i]:
        if i < W:
            dp[i] = dp[i-1]
        elif i % W == 0:
            dp[i] = dp[i-W]
        else:
            dp[i] = dp[i-1] + dp[i-W]
            dp[i] = dp[i] % 1000000007
print(dp[N-1])


Measured memory_bytes: 50428
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main(void){
  string s,p;
  char tmp[200];
  int base;
  cin >> s >> p;
  for (int i=0;i<s.size();i++) {
    base = i;
    for (int j=0;j<p.size();j++){
      if (s[base]==p[j]) {
        base++;
        if (base==s.size()) base = 0;
      } else { break; }
      if (j==p.size()-1){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int answer = 1;
  for (int i =0; i<N; i++) {
    if (answer < K) {
      answer*=2;
    } else {
      answer+=K;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9 + 7;

void main() {
    int n;
    int[] t, v;

    scan(n);
    t = readln.split.to!(int[]);
    v = readln.split.to!(int[]);

    t[] *= 2;
    v[] *= 2;

    v = [0] ~ v;

    auto ts = new int[](n + 1);
    foreach (i ; 1 .. n + 1) {
        ts[i] = ts[i - 1] + t[i - 1];
    }

    int f(int i, int x) {
        if (i == 0) return x;
        if (i == n + 1) return -x + ts[n];

        if (x <= ts[i - 1]) {
            return -x + ts[i - 1] +v[i]; 
        }
        else if (x <= ts[i]) {
            return v[i];
        }
        else {
            return x - ts[i] + v[i];
        }
    }

    int h, ans;

    foreach (ti ; 1 .. ts[n] + 1) {
        int hn = 10000;

        foreach (i ; 0 .. n + 2) {
            hn = min(hn, f(i, ti));
        }

        ans += h + hn;
        h = hn;
    }

    writefln("%.8s", ans / 8.0);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;

int a[3][3];
int n;
bool ok[9];

main(){
	for(int i=0;i<9;i++){
		cin >> a[i/3][i%3];
		ok[i] = false;
	}

	cin >> n;
	for(int i=0;i<n;i++){
		int b;
		cin >> b;
		for(int j=0;j<9;j++){
			if(a[j/3][j%3]==b) ok[j] = true;
		}
	}

	if(ok[0]&&ok[1]&&ok[2]){
		cout << "Yes" << endl;
	}else if(ok[3]&&ok[4]&&ok[5]){
		cout << "Yes" << endl;
	}else if(ok[6]&&ok[7]&&ok[8]){
		cout << "Yes" << endl;
	}else if(ok[0]&&ok[3]&&ok[6]){
		cout << "Yes" << endl;
	}else if(ok[1]&&ok[4]&&ok[7]){
		cout << "Yes" << endl;
	}else if(ok[2]&&ok[5]&&ok[8]){
		cout << "Yes" << endl;
	}else if(ok[0]&&ok[4]&&ok[8]){
		cout << "Yes" << endl;
	}else if(ok[2]&&ok[4]&&ok[6]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 3592