akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[101][101];
bool x[101],y[101];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')	
				x[i]=true;
		}
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			if(a[j][i]=='#')
			{
				y[i]=true;
				break;
			}
	for(int i=1;i<=n;i++)
	{
		if(!x[i])
			continue;
		for(int j=1;j<=m;j++)
		{
			if(!y[j])
				continue;
			printf("%c",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void read(T &x)
{
    x=0; char c=getchar();  int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int main()
{
	ll K,A,B; read(K),read(A),read(B);
	if(B-A>2&&A-1<=K)
	{
		K-=A-1;
		ll ans=A;
		ans+=(K/2)*(B-A);
		if(K&1) ans++;
		printf("%lld",ans);
	}
	else printf("%lld",K+1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
//xが0以外なら、GCD(y % x, x) の結果を返し
//xが0ならyを返す
}
int main() {
	string s;
	cin >> s;
	if (s <= "2019/04/30") {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  ll miv = a*(n-1) + b;
  ll mxv = a + b*(n-1);
  ll ans = mxv - miv + 1;
  if (ans >= 0) cout << ans << endl;
  else cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import sys

#S = input()
#N = int(input())
#n = [list(map(int,input().split())) for i in range(N)]
#n, y = map(int, input().split())

X, N = map(int, input().split())

p = sorted(list(map(int,input().split())) )
#print(X, N, p)

r = 999
for _p in range(0,102):
    if _p in p:
        continue
    if (abs(_p - X) < abs(r-X)):
        r = _p


print(r)








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

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

    int minimum = 1e9;
    int maximum = 0;
    vector<int> A(N);

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] < minimum) {
            minimum = A[i];
        }
        if (A[i] > maximum) {
            maximum = A[i];
        }
    }
    cout << maximum - minimum << endl;
    return 0;
}


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

using namespace std;

int n,m;
int h[100001];
int kol[100001];

int main()
{
	//TODO make some code
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (int i=0;i<n;++i)
    {
        cin>>h[i];
        ++kol[h[i]];
    }
    for (int x=1;x<100000;++x) m=max(m,kol[x]+kol[x+1]+kol[x-1]);
    cout<<m<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int h,w,i,j,sq;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h == 0 && w == 0) break;
		
		for(i=0;i < h;i++){
			for(j=0;j < w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,P,Pm,sum=1;
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> P;
    if(i==1){
      Pm=P;
      continue;
    }else{
      if(P<Pm){
        sum++;
        Pm=P;
      }else{
        continue;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "No" ;
		String[] ss = s.split("");
		int cnt = 0;
		if(ss[0].equals(ss[2]) && ss[3].equals(ss[1])) {
			ans = "Yes";
			cnt ++;
		}
		if(ss[0].equals(ss[1]) && ss[3].equals(ss[2])) {
			ans = "Yes";
			cnt ++;
		}
		if(ss[0].equals(ss[3]) && ss[1].equals(ss[2])) {
			ans = "Yes";
			cnt ++;
		}
		if(cnt != 1) {
			ans = "No";
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21844
div=10**9+7
def modinv(a, m=div):
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t*b 
        a = a^b
        b = a^b
        a = a^b
        u -= t*v
        u = u^v
        v = u^v
        u = u^v
    u %= m 
    if u < 0: u += m
    return u

N,A,B,C=list(map(int,input().split()))
ncr_memo = {}

def ncr(n, r):
    if r == 0: return 1
    if n in ncr_memo:
        return ncr_memo[n]
    if n-1 in ncr_memo:
        ncr_memo[n] = (ncr_memo[n-1]*n*modinv(n-(N-1))) % div
        return ncr_memo[n]
    orn = n

    res = 1
    for i in range(1, r+1):
        res = res*n*modinv(i, div) % div
        n = n-1
    res %= div
    ncr_memo[orn] = res
    return res

for i in range(N, 2*N):
    ncr(i-1, N-1)

res = 0
inv100 = modinv(A+B)

reveven = (modinv(100-C)*100) % div
memoA = [1]*(N+1)
memoB = [1]*(N+1)

for i in range(1, N+1): memoA[i] = (memoA[i-1]*A*inv100) % div
for i in range(1, N+1): memoB[i] = (memoB[i-1]*B*inv100) % div

for i in range(N, 2*N):
    kitai1 = (
        (((ncr(i-1, N-1)*memoA[N]))*memoB[i-N]) + 
        (((ncr(i-1, N-1)*memoB[N]))*memoA[i-N])) % div
    res += kitai1*reveven*i % div

print(res  % div)

Measured memory_bytes: 79324
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int H, W;
    string S;
    cin >> H >> W;
    char map[50][50];
    REP(i, H) {
        cin >> S;
        REP(j, W) {
            map[i][j] = S[j];
        }
    }
    char res[50][50];
    REP(i, H) {
        REP(j, W) {
            if (map[i][j] == '#') {
                res[i][j] = '#';
                continue;
            }
            int cnt = 0;
            FOR(p, -1, 2, 1) {
                if (i + p < 0 || i + p >= H) {
                    continue;
                }
                FOR(q, -1, 2, 1) {
                    if (j + q < 0 || j + q >= W) {
                        continue;
                    } else if (p == 0 && q == 0) {
                        continue;
                    }
                    if (map[i + p][j + q] == '#') {
                        cnt++;
                    }
                }
            }
            res[i][j] = '0' + cnt;
        }
    }
    REP(i, H) {
        REP(j, W) {
            cout << res[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

int 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;
	}
}
int main() { 
  long long int A;
  char a[4];
  cin >> A ;
  for (int i = 0; i < 4; i++)
  {
    cin >> a[i];
  }
  long long int B = 
  100*ctoi(a[0]) + 10 * ctoi(a[2]) + ctoi(a[3]);

  cout << A*B/100;
}


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

using namespace std;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    long long  res ;
    res = (long) min(k, a) - min ((k-a - b)* (k-a - b > 0), c) ;
    cout << res;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,c; cin >> a >> b >> c;
	cout << ((a*100+b*10+c)%4 == 0? "YES": "NO") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    private static int n;
    private static int m;
    private static int x;
    private static PriorityQueue<Integer> q;
    private static int[][] a;
    private static int[] c;

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

        n = sc.nextInt();
        m = sc.nextInt();
        x = sc.nextInt();

        c = new int[n];
        a = new int[n][m];

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

        q = new PriorityQueue<>();
        int[] sum = new int[m + 1];
        check(0, sum);
        Integer ans = q.poll();
        System.out.println(ans != null ? ans : -1);

    }

    static void check(int num, int[] sum){
        //System.out.print(num);
        check2(sum);
        if(num == n){
            return;
        }
        check(num + 1, sum);
        for(int i = 0; i < m; i++){
            sum[i] += a[num][i];
        }
        sum[m] += c[num];
        check(num + 1, sum);
        for(int i = 0; i < m; i++){
            sum[i] -= a[num][i];
        }
        sum[m] -= c[num];
    }

    static void check2(int[] sum){
        //System.out.println(Arrays.toString(sum));
        for(int i = 0; i < m; i++){
            if(sum[i] < x){
                return;
            }
        }
        q.add(sum[m]);
    }
}


Measured memory_bytes: 39736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
    int a,b,k;
    scanf("%d%d%d",&k,&a,&b);
    int x = abs(a-k);
    int y = abs(b-k);
    if(x > y) printf("B\n");
    else printf("A\n");
}

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

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

    vector<long> l(n+1);

    l.at(0) = 2;
    l.at(1) = 1;

    for(int i=2; i<=n; i++){
        l.at(i) = l.at(i-1) + l.at(i-2);
    }

    cout << l.at(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}

int main() {
    
    string s;
    cin >> s;
    map<string, int> m;
    m.emplace("MON", 6);
    m.emplace("TUE", 5);
    m.emplace("WED", 4);
    m.emplace("THU", 3);
    m.emplace("FRI", 2);
    m.emplace("SAT", 1);
    m.emplace("SUN", 7);
    
    cout << (m[s]);

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
using namespace std;

int main() {
	FIO;
	ll n, a, b; cin >> n >> a >> b;
	ll ans = (n / (a + b)) * a;
	n %= (a + b);
	ans += min(a, n);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  set<char> s;
  for (int i = 0; i < n; i++) {
    char t; cin >> t;
    s.insert(t);
  }
  if (s.size() == 3) cout << "Three" << '\n';
  else cout << "Four" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3552
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll a, b, x;
  cin>>a>>b>>x;
  ll k = (x - (a%x))%x;
  if(a+k>b) cout<<0<<endl;
  else cout<<(b-(a+k))/x+1<<endl;
}



Measured memory_bytes: 3636
n=int(input())
h=list(map(int,input().split()))
k=list()
sum=0
ans=0
if n==1: print(0)
else:
	for i in range(n-1):
		if h[i] < h[i+1]:
			sum=0
		else:
			sum+=1
			ans=max(ans,sum)
	print(ans)

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn 100000+5

//structure

//declaration
int arr[maxn];
//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	int n, tmp;
	scanf("%d", &n);

	ll ans = 1;
	MSET(arr, 0);

	arr[0] = 3;


	REP(i, 1, n)
	{
		scanf("%d", &tmp);
		ans *= arr[tmp];
		ans %= 1000000007;

		arr[tmp]--;
		arr[tmp+1]++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
! 2019.11.16
!
      program answer
      implicit none
      integer :: N
      character(len=100) :: S
      integer :: just
      intrinsic mod
      read(*,*) N
      read(*,*) S
!
      if( mod(N,2) == 1) then
        write(*,*) 'No'
      else
        if( S(1:N/2) == S((N/2+1):N) ) then
          write(*,*) 'Yes'
        else
          write(*,*) 'No'
        end if
      end if
!
      end program answer

Measured memory_bytes: 768
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n,min,now,ans,temp,i;
    cin >> n;
    cin>>min;
    ans=-pow(10,9);
    for(i = 1; i < n; i++) {
        cin >> now;
        temp = now - min;
        if (temp>ans) swap(temp,ans);
        if (now<min) swap(now,min);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  string s; cin >> s;
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    string type; cin >> type;
    if(type == "print"){
      int a, b; cin >> a >> b;
      cout << ::string(s.begin() + a, s.begin() + b + 1) << endl;
    }
    else if (type == "reverse"){
      int a, b; cin >> a >> b;
      reverse(s.begin() + a, s.begin() + b + 1);
    }
    else if (type == "replace"){
      int a, b; cin >> a >> b;
      string p; cin >> p;
      s.replace(s.begin() + a, s.begin() + b + 1, p);
    }
  }
}



Measured memory_bytes: 3188
import java.util.*;
class Main{
    public static void main(String[] args){
	new Main().run();
    }

    void run(){
	Scanner sc = new Scanner(System.in);
	setCities();
	while(sc.hasNext())
	    solve(sc.next().toCharArray());
    }

    void solve(char[] c){
	if(c[0]=='#') return;
	City now = A;
	for(int i=0; i<c.length; i++){
	    now = now.getCity(c[i]);
	    if(now==null){
		System.out.println("No");
		return;
	    }
	}
	System.out.println(now.getName()=='B' ? "Yes":"No");
    }

    City A, X, Y, Z, W, B;

    void setCities(){
	A = new City('A');
	X = new City('X');
	Y = new City('Y');
	Z = new City('Z');
	W = new City('W');
	B = new City('B');

	A.setCity('0', X);
	A.setCity('1', Y);

	X.setCity('1', Z);

	Y.setCity('0', X);

	Z.setCity('0', W);
	Z.setCity('1', B);

	W.setCity('0', B);
	W.setCity('1', Y);
	
	B.setCity('0', Y);
	B.setCity('1', X);
	
    }

    class City{
	private char name;
	private City zero, one;
	City(char n){
	    name = n;
	    zero = null;
	    one = null;
	}

	void setCity(char num, City c){
	    if(num=='0') zero = c;
	    else one = c;
	}
	char getName(){ return name; }
	City getCity(char i){
	    if(i=='0') return zero; 
	    else return one;
	}
    }
}

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

using namespace std;

int main() {
    string s;
    getline(cin, s);

    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c >= 'A' && c <= 'Z')
            s[i] = c - 'A' + 'a';
        else if (c >= 'a' && c <= 'z')
            s[i] = c - 'a' + 'A';
    }

    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3160
s = input()
q = int(input())
s1 = ""
s2 = ""
cnt = 1
for i in range(q):
  l1 = list(input().split())
  if len(l1) == 1:
    cnt *= -1
  else:
    if (cnt == 1 and l1[1] == "1") or (cnt == -1 and l1[1] == "2"):
      s1 = l1[2] + s1
    else:
      s2 = s2 + l1[2]
if cnt == 1:
  print(s1+s+s2)
else:
  print(s2[::-1]+s[::-1]+s1[::-1])

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

int main() {
  int N,K;
  int ans = 0;
  cin >> N >> K;
  vector<int> height(N);
  
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
    if (height.at(i) >= K) {
      ans++;
    }
  }  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    string S; cin >> S;
    ll cnt=0;
    rep(i,S.size()-1) if (S[i]!=S[i+1]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
import itertools
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))

    all_pattern = list(itertools.permutations(range(1, N + 1)))
    p_index = all_pattern.index(P) + 1
    q_index = all_pattern.index(Q) + 1

    print(abs(p_index - q_index))


if __name__ == "__main__":
    main()


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

using namespace std;

#define ll long long
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%ld",n)
#define prln(n) printf("%ld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)




int main()
{
    char s[100000];
    scanf("%s",s);
    int len=strlen(s);
    stack<char>stk;
    fo(i,0,len)
    {
        if(s[i]=='1')stk.push('1');
        else if(s[i]=='0')stk.push('0');
        else{
            if(!stk.empty())
            {
                stk.pop();
            }
        }
    }
    vector<char>v;
    while(!stk.empty())
    {
        int temp=stk.top();
        v.push_back(temp);
        stk.pop();
    }
    reverse(v.begin(),v.end());
    fo(i,0,sz(v))
    printf("%c",v[i]);
    puts("");
    return 0;
}
















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	if (B == 0) return 1;
	if (B % 2) return A * modpow(A, B - 1) % mod;
	ll half = modpow(A, B / 2);
	return half * half % mod;
}

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

	
	int N, M, K;
	cin >> N >> M >> K;

	int kei = N + M;

	ll pea = 1ll * K * (K - 1) / 2 % mod;
	
	ll masu = N * M;
	ll kumi = 1;
	rep(i, K) {
		kumi *= masu - i;
		kumi %= mod;
	}
	ll waru = 1;
	rep1(i, K) {
		waru *= i;
		waru %= mod;
	}
	kumi = kumi * modpow(waru, mod - 2) % mod;

	kumi = kumi * pea % mod;
	kumi = kumi * kei % mod;
	kumi = kumi * modpow(3, mod - 2) % mod;

	co(kumi);

	Would you please return 0;
}

Measured memory_bytes: 256
from fractions import gcd

class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

mod = 998244353
n,a,b,k = map(int, input().split())
if k % gcd(a,b) != 0:
    print(0)
    exit()
hoge = PERM_COMB_MOD(max_n=n+10, mod=mod)
ans = 0
for i in range(n+1):
    tmp = k-a*i
    if tmp % b:
        continue
    j = tmp//b
    if j < 0 or n < j:
        continue
    ans += hoge.comb(n, i)*hoge.comb(n, j)
    ans %= mod
print(ans)

Measured memory_bytes: 74216
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		string a = Console.ReadLine();
    string b = Console.ReadLine();
    string c = Console.ReadLine();
    long answer = 0;

    for(int i = 0; i < n; i++)
    {
      if(a[i] == b[i] && a[i] == c[i]) answer = answer;
      else if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) answer += 2;
      else answer += 1;
    }

		Console.WriteLine(answer);
	}
}

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

#define V_MAX 15
int d[V_MAX][V_MAX];
int INF = 10000;
int dp[1<<V_MAX][V_MAX];
int V, E;

int solve(int T, int u) {
  if(dp[T][u] != -1) return dp[T][u];
  int res = INF;
  for(int v = 1; v < V; v++) {
    if((T & (1 << v)) && u != v) res = min(res, solve(T & ~(1 << u), v) + d[v][u]);
  }
  dp[T][u] = res;
  return res;
}

int main () {
  REP(i, 1<<V_MAX)REP(j,V_MAX) dp[i][j] = -1;
  REP(i,V_MAX)REP(j,V_MAX) d[i][j] = INF;
  int s, t, w, res;
  cin >> V >> E;
  REP(i, E) {
    cin >> s >> t >> w;
    d[s][t] = w;
  }

  dp[1][0] = 0;
  for(int i = 1; i < V; i++) dp[1 | (1<<i)][i] = d[0][i];

  res = INF;
  for(int v = 1; v < V; v++) {
    res = min(res, solve((1<<V) - 1, v) + d[v][0]);
  }
  if(res == INF) res = -1;

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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 long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    int ind;
    int sum = 0;
    repd(i, 1, N + 1) {
        sum += i;
        if (sum >= N) break;
    }

    int ct = sum;
    repd(i, 1, N + 1) {
        ct -= i;
        if (sum - N == i) continue;
        cout << i << endl;
        if (ct == 0) break;
    }

    return 0;
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;


long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
	vector<long long> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
	}long long ans = data.at(0);
	for (int i = 0; i < n; i++) {
		ans = lcm(ans, data.at(i));
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int n, a[100];
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> a[i];
    }

    int x;
    int flag = 1;
    int count = 0;

    while (flag){
        flag = 0;
        for (int j=n-1; j>0; j--){
            if (a[j] < a[j - 1]) {
                x = a[j - 1];
                a[j-1] = a[j];
                a[j] = x;
                flag = 1;
                count ++;
            }
        }
    }

    for (int k=0; k<n-1; k++){
        cout << a[k] << " ";
    }
    cout << a[n-1] << endl;
    cout << count << endl;
}

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl


int main() {

	fast_cin;
	
    string s;
    cin >> s;

    int sum = 0;

    for(int i = 0; i < (int)s.size(); i++) {
        sum += s[i]-'0';
    }
	
    sum %= 9; 

    cout << (sum == 0 ? "Yes" : "No") << endl;
	
	
	return 0;
}

Measured memory_bytes: 3640
// https://atcoder.jp/contests/abc160/tasks/abc160_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    int ans = 0;
    ans += 1000 * (X / 500);
    ans += (X % 500) / 5 * 5;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, T, A, *H = map(int, read().split())

    diff = INF
    for i, h in enumerate(H, 1):
        if diff > abs(T - h * 0.006 - A):
            diff = abs(T - h * 0.006 - A)
            ans = i

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
#include <iostream>
#include <string>
#include <algorithm>

class Solver {
public:
    void solve();
    int countOf(std::string& s, char target);
};

void Solver::solve() {
    std::string s;
    std::cin >> s;
    int count_0 = countOf(s, '0');
    int count_1 = countOf(s, '1');
    int ans = std::min(count_0, count_1) * 2;
    std::cout << ans << std::endl;
}

int Solver::countOf(std::string& s, char target) {
    return std::count(s.begin(), s.end(), target);
}

int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

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

int main(){
int n;
cin >> n;
int a=0;
int b=0;
vector<int> vec(n);
vector<int> ve(n);
for(int i=0; i<n; i++){
    cin >> vec.at(i);
}
for(int i=0;i<n;i++){
    cin >> ve.at(i);
}
for(int i=0;i<n;i++){
    if(vec.at(i)>ve.at(i)){
        a+=vec.at(i);
        b+=ve.at(i);
    }
}
cout << a-b <<endl;
}

Measured memory_bytes: 256
import math

def solve():
    N, K = map(int, input().split())
    result = 0
    for i in range(1, N + 1):
        cn = 0
        if i >= K:
            cn = (1 / N)
        else:
            cn = (1 / N) * ((1 / 2) ** math.ceil(math.log2(K / i)))
        # print(i, '得点の時:', cn)
        result += cn
    print(result)


if __name__ == '__main__':
    solve()


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

using namespace std;

using ll = long long;


ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}


vector<int> primes;


void build(int n = 1e5 + 7)
{
	vector<bool> er(n);

	for (int i = 2; i < n; i++)
		if (!er[i])
		{
			primes.push_back(i);
			for (ll j = i * (ll)i; j < n; j += i)
				er[j] = true;
		}
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	build ();

	int n;

	cin >> n;

	vector<ll> arr(n + 1);

	for (auto &it : arr)
		cin >> it;

	reverse(arr.begin(), arr.end());

	ll g = 0;

	for (auto it : arr)
		g = gcd(g, abs(it));

	assert(g != 0);

	vector<int> ans;

	for (auto p : primes)
		if (g % p == 0)
		{
			ans.push_back(p);

			while (g % p == 0)
				g /= p;
		}

	if (g > 1)
		ans.push_back(g);

	for (auto p : primes)
	{
		if ((int)arr.size () + 10 < p)
			break;

		vector<ll> md(p);

		md[0] = arr[0];

		for (int i = 1; i < (int) arr.size(); i++)
			md[((i - 1) % (p - 1)) + 1] += arr[i];

		for (auto &it : md)
			it %= p;

		if (count(md.begin(), md.end(), 0) == p)
			ans.push_back(p);
	}

	sort(ans.begin(), ans.end());
	ans.resize(unique(ans.begin(), ans.end()) - ans.begin());

	for (auto it : ans)
		cout << it << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	solve(fin);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
string str;
int fie[151][151];
int dp[151][151];
int main(void){
	memset(fie,-1,sizeof(fie));
	int j=0;
	while(cin >> str){
		int cnt=0,num=0;
		for(int i=0;i<str.size();i++){
			if(str[i]==','){
				fie[cnt++][j]=num;
				num=0;
			}
			else{
				num*=10;
				num+=str[i]-'0';
			}
		}
		fie[cnt++][j]=num;
		j++;
	}
	dp[0][0]=fie[0][0];
	int res=dp[0][0];
	for(int i=0;i<j/2;i++){
		for(int k=0;k<j;k++){
			dp[k+1][i+1]=max(dp[k+1][i+1],dp[k][i]+fie[k+1][i+1]);
			dp[k][i+1]=max(dp[k][i+1],dp[k][i]+fie[k][i+1]);
			res=max(res,dp[k+1][i+1]);
			res=max(res,dp[k][i+1]);
		}
	}
	for(int i=j/2;i<j;i++){
		for(int k=0;k<j;k++){
			if(k>=1){
				dp[k-1][i+1]=max(dp[k-1][i+1],dp[k][i]+fie[k-1][i+1]);
				res=max(res,dp[k-1][i+1]);
			}
			dp[k][i+1]=max(dp[k][i+1],dp[k][i]+fie[k][i+1]);
			res=max(res,dp[k][i+1]);
		}
	}
	printf("%d\n",res);
}

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

int main(){
    int n,we;
    cin >> n >> we;
    vector<long long> w(n+1),v(n+1);
    for(int i=0;i<n;i++) cin >> w[i+1] >> v[i+1];
    vector<vector<long long>> dp(n+1,vector<long long>(we+1,0));
    for(int i=1;i<=n;i++){
        for(int j=0;j<=we;j++){
            if(j-w[i]>=0){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout << dp[n][we] << endl;
}

Measured memory_bytes: 83236
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for(int i=0; i<2; ++i) {
        for(int j=0; j<N; ++j) cin >> A[i][j];
    }

    int ans = 0;
    for(int i=0; i<N; ++i) {
        int tmp = 0;
        for(int j=0; j<N; ++j) {
            if(j < i) tmp += A[0][j];
            else if(j > i) tmp += A[1][j];
            else tmp += A[0][j] + A[1][j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define lint long long

using namespace std;

int dic(int a,int b){
  if(a>b){
    dic(b,a);
  }else{
    for(int i=0;i<b;i++){
      cout << a;
    }
    cout << endl;
  }
  return 0;
}

int main()
{
  int a,b;
  cin >> a >> b;

  dic(a,b);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
int main()
{
	using namespace std;
    long long int a,b;
    char c;
    cin>>a>>c>>b;
    {
        if(c=='-')
        {
            cout<<a-b<<endl;
        }
        else
        {
            cout<<a+b<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

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

}

Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d",&n)
	var a [100100]int
	for i:=0;i<n-1;i++{
		fmt.Scanf("%d",&a[i])
	}
	var sum int
	for i:=0;i<n;i++{
		if i==0{
			sum+=a[0]
		}else if i==n-1{
			sum+=a[n-2]
		} else{
			if a[i]<=a[i-1]{
				sum+=a[i]
			}else {
				sum+=a[i-1]
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
using P5=tuple<ll,ll,ll,ll,ll>;
int main(){
    ll h,w,k;cin>>h>>w>>k;
    ll sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
    sx--;sy--;gx--;gy--;
    
    vector<string> s(h);rep(i,h)cin>>s[i];
    vector<vector<vector<l_l>>> dp(h,vector<vector<l_l>>(w,vector<l_l>(5,l_l(LINF,LINF))));
    priority_queue<P5,vector<P5>,greater<P5>> pq;
    pq.emplace(P5(1,0,sx,sy,4));
    rep(i,5){
        dp[sx][sy][i]={1,0};
    };
    ll d,nd,x,y,dir;
    while(sz(pq)){
        tie(d,nd,x,y,dir)=pq.top();pq.pop();
        if(dp[x][y][dir]<l_l(d,nd))continue;
        //cout<<x<<" "<<y<<" "<<dir<<" "<<dp[x][y][dir].fi<<" "<<dp[x][y][dir].se<<endl;
        if(dir<=3){
            ll nx=x+dx[dir],ny=y+dy[dir];
            if(nx<0||nx>=h||ny<0||ny>=w){}
            else if(nd<k&&s[nx][ny]!='@'){
                if(chmin(dp[nx][ny][dir],l_l(d,nd+1))){
                    pq.emplace(d,nd+1,nx,ny,dir);
                }
            }
            if(chmin(dp[x][y][4],l_l(d+1,0))){
                pq.emplace(d+1,0,x,y,4);
            }
        }else{
            rep(i,4){
                ll nx=x+dx[i],ny=y+dy[i];
                if(nx<0||nx>=h||ny<0||ny>=w)continue;
                if(s[nx][ny]=='@')continue;
                //cout<<nx<<" "<<ny<<endl;
                if(chmin(dp[nx][ny][i],l_l(d,nd+1))){
                    pq.emplace(d,nd+1,nx,ny,i);
                }
            }
        }
    }
    ll ans=LINF;
    rep(i,5)chmin(ans,dp[gx][gy][i].fi);
    if(ans==LINF)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 238648
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n;
    cin>>n;
    
    for(int i=n;;++i) {
        if(check(i)) {
            n=i;
            break;
        }
    }
    cout<<n<<endl;


    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3660
from math import factorial
def comb(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
N=int(input())
A=list(map(int,input().split()))
ANS=[0 for i in range(N)]
for i in range(N):
  a=A[i]-1
  ANS[a]+=1
ans=0  
for i in range(N):
  if ANS[i]>=2:
    ans+=comb(ANS[i],2)
for i in range(N):
  a=A[i]-1
  ans2=ans-ANS[a]+1
  print(ans2)  

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

ll x[200005], y[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b; ll k; cin >> a >> b >> k;
    rep1(i, a) {
    	cin >> x[i];
    	x[i] += x[i-1];
    }
    rep1(i, b) {
    	cin >> y[i];
    	y[i] += y[i-1];
    }
    int pt = b, ans = 0;
    rep(i, a+1) {
    	while(x[i] + y[pt] > k && pt) pt--;
    	if(x[i] + y[pt] <= k) ans = max(ans, i+pt);
    }
    cout << ans << endl;
}



Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
//long long in(){long long x; scanf("%d",&x); return x;}
static const int MAX = 10000;

long long lcm(long long x,long long y){
	return x*y/__gcd(x,y);
}

int main(){
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long l = lcm(C, D), c, d, cd, ans;

  
  c = B/C - (A-1)/C;
  d = B/D - (A-1)/D;
  cd = B/l - (A-1)/l;

  ans = (B-A+1) - (c+d-cd);
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

void solve(int tc) {
	ll x;
	cin>>x;
	ll n = 0;
	ll total = 100;
	while((ll)total < x) {
		total = total * (1.01);
		++n;
	}
	cout<<n<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    for(int tc=1; tc<=t; ++tc) {
        solve(tc);
    }    
    return 0;
}

Measured memory_bytes: 3688
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 105;
bool vis[maxn + 5];
int n, x, m;
int main() {
	scanf("%d%d%d", &n, &m, &x);
	for(int i = 1; i <= m; i++) {
		int a;
		scanf("%d", &a);
		vis[a] = 1;
	}
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	for(int i = 1; i <= n - 1; i++) {
		if(vis[i]) {
			if(i <= x)cnt1++;
			else cnt2++;
		}
	}
	printf("%d\n", min(cnt1, cnt2));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n,m;cin>>n>>m;
    vi a(n);rep(i,n) cin>>a[i];
    int sum=0;
    rep(i,n) sum+=a[i];
    double check=(double)sum/(4*m);
    //cout<<check<<endl;
    sort(a.rbegin(),a.rend());
    for(int i=0;i<n;i++){
        if((double)a[i]>=check){
            m--;
        }
        if(m==0) break;
    }
    if(m==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def ln():
    return map(int, input().split())

A,B,C,D = ln()

L = A+B
R = C+D

if L == R:
    print('Balanced')
elif L > R:
    print('Left')
else:
    print('Right')


Measured memory_bytes: 6056