akhauriyash/Code-Regression huggingface dataset:
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
const int N = 1000001;
 
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x; 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 
 
 
void solve()
{
  int n;
  cin>>n;
  
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  
  int ans=0;
  for(int i=1;i<n;i++)
  {
      if(a[i]<a[i-1])
      {
          ans=ans+a[i-1]-a[i];
          a[i]=a[i-1];
      }
  }
  cout<<ans<<"\n";
}
 
int32_t main()
{ 
      
      
      int test;
      test=1;
      //cin>>test;
      while(test--)
      {
          solve();
      }
       
    
    return 0;
	}

Measured memory_bytes: 5184
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2



//Segtree
ll def = inf;
const int MAX_N = 1 << 18;
ll n, dat[2 * MAX_N - 1];

ll comp(ll a, ll b) {
	return min(a, b);
}

void init(ll n_) {
	n = 1;
	while (n < n_) {
		n *= 2;
	}
	rep(i, 0, 2 * n - 1)dat[i] = (1LL<<31)-1;
}
void update(ll k,ll a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = comp(dat[2*k+1],dat[2*k+2]);
	}
}
ll query(int a,int b,int k,int l,int r){
	if (r <= a || b <= l)return def;
	if (a <= l && r <= b)return dat[k];
	else {
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return comp(vl, vr);
	}
}
ll get(ll a,ll b) {
	return query(a,b+1,0,0,n);
}
//endSegtree


int main(){
	int N, Q;
	cin >> N >> Q;
	init(N);

	rep(i, 0, Q) {
		ll c, x, y;
		cin >> c >> x >> y;
		if (c) {
			cout << get(x, y) <<endl;
		}
		else {
			update(x,y);
		}
	 }

	return 0;
}




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


int main()
{
    int n;
    int sum=0;
    int temp=0;
    int ans;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
    }
    sum/=2;

    for(int i=0;i<(n-1)/2;i++)
    {
        temp+=a[2*i+1];
    }
    ans=sum-temp;
    cout<<ans*2<<" ";
    for(int i=1;i<n;i++)
    {
        ans=a[i-1]-ans;
        cout<<ans*2<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1664
N, X = map(int, input().split())
a = [1]
p = [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    if 1 < x <= a[n - 1] + 1:
        return f(n - 1, x - 1)
    if x == a[n - 1] + 2:
        return p[n - 1] + 1
    if a[n - 1] + 2 < x <= 2 * a[n - 1] + 2:
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])
    if x == 2 * a[n - 1] + 3:
        return 2 * p[n - 1] + 1


print(f(N, X))


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

int dp[100000][3];

int a[100000];
int b[100000];
int c[100000];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    cin >> a[0]>> b[0]>> c[0];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    //cout << "Debug " << dp[0][0] << ' ' << dp[0][1] << ' ' << dp[0][2] << " Debug" << endl;
    
    for (int i = 1; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];

        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
        //cout << i << endl;
        //cout << dp[i][0]<< ' ' << dp[i][1]<< ' ' << dp[i][2] << " Debug" << endl;

    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

a,b=map(int,input().split())
print(lcm(a,b))

Measured memory_bytes: 38384
"use strict";

var main = function main(input) {
  // 奇数進むには奇数秒、偶数進むには偶数秒必要
  // 秒数<距離は無理 -> 秒数>=距離 && 秒数の偶奇==距離の偶奇 ならいける
  // 次の点までの時間を秒数, 次の点までの総距離(x方向とy方向の和)を距離とする
  var args = input.split('\n');
  var T = [];
  var posX = [];
  var posY = [];
  args.forEach(function (element, i) {
    if (i > 0 && element != '') {
      T.push(element.split(' ')[0]);
      posX.push(element.split(' ')[1]);
      posY.push(element.split(' ')[2]);
    }
  });
  var X = 0;
  var Y = 0;
  var now = 0;
  var flag = true;
  T.forEach(function (element, i) {
    // 総移動距離の計算
    var distance = Math.abs(X - posX[i]) + Math.abs(Y - posY[i]);
    var time = element - now;

    if (distance > time || distance % 2 != time % 2) {
      flag = false;
    }

    X = posX[i];
    Y = posY[i];
    now = element;
  });

  if (flag) {
    console.log('Yes');
  } else {
    console.log('No');
  }
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 49448
#include <iostream>
using namespace std;
char c[10][10];
bool m[10][10];
bool dfs(int a,int b,int h,int w){
  m[a][b]=true;
  if(a==h-1&&b==w-1){
    bool flag = true;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++) 
        if(c[i][j]=='#'&&!m[i][j]){flag=false; break;}
    if(flag) return true;
    else return false;
  }
  if(a<h-1&&c[a+1][b]=='#'){
    if(dfs(a+1,b,h,w)) return true;
  }
  if(b<w-1&&c[a][b+1]=='#'){
    if(dfs(a,b+1,h,w)) return true;
  }
  m[a][b]=false;
  return false;
}

int main(){
  int h,w;
  cin >> h >> w;
  for(int i=0;i<h;i++) cin >> c[i];
  for(int i=0;i<10;i++) for(int j=0;j<10;j++) m[i][j] = false;
  if(dfs(0,0,h,w)) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
int a[N],n;

map<int,int> mp;
void ye(){
	cout << "Yes" << endl;
	exit(0);
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)cin >> a[i],mp[a[i]]++;
	vector<pair<int,int> > s;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)s.push_back(*it);
	if(s.size()==1){
		if(s[0].first==0){
			ye();
		}
	}
	if(n%3==0){
		if(s.size()==2){
			if(s[0].first==0&&s[0].second==n/3){
				ye();
			}
		}
		else{
			if((s[0].first^s[1].first^s[2].first)==0){
				if(s[0].second==s[1].second&&s[1].second==s[2].second){
					ye();
				}
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 5372
D=60
n,k,*l=map(int,open(0).read().split())
to=[[0]*n for _ in range(D)]
for i in range(n):
  to[0][i]=l[i]-1
for i in range(D-1):
  for j in range(n):
    to[i+1][j]=to[i][to[i][j]]
a=0
for i in range(D):
  if k%2:
    a=to[i][a]
  k//=2
print(a+1)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ull i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 0;
    FOR(i,0,n-2){
        //cout<<i<<endl;
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> len; 

    UnionFind(int N) : par(N), len(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
          par[i] = i;
          len[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        len[ry] += len[rx];
        len[rx] = 0;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int A, B; cin >> A >> B;
    A--;
    B--;
    uf.unite(A, B);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, uf.len[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4756
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int N,M;
int X[200000];
int Y[200000];
int main(){
  cin >> N >> M;
  REP(i,M) cin >> X[i];
  sort(X,X+M);
  if(M==1){
    cout << 0 << endl;
    return 0;
  }
  if(N>=M){
    cout << 0 << endl;
    return 0;
  }

  for(int i=0;i<M-1;i++){
    Y[i] = X[i+1]-X[i]-1;
  }
  sort(Y,Y+M-1);
  reverse(Y,Y+M-1);
  int kuuhaku = 0;
  for(int i=0;i<N-1;i++){
    kuuhaku += Y[i];
  }

  cout << X[M-1]-X[0]+1 - kuuhaku - N << endl;
  return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  char str[223];
  scanf("%s",str);
  int n = strlen(str);
  for(int i=n-2;i;i-=2){
    if(strncmp(str,str+i/2,i/2) == 0){
      printf("%d\n",i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

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

int main(void){

    char s[11];
    int sum,min;
    int x[3]={};
    min=1000;
    
    scanf("%s",s);
    
    for(int i=0; i<strlen(s)-2; i++){
        
        x[0]=s[i]-'0';
        x[1]=s[i+1]-'0';
        x[2]=s[i+2]-'0';
        
        sum=x[0]*100+x[1]*10+x[2];
        
        if(min>abs(sum-753))
            min=abs(sum-753);
    }
    
    printf("%d",min);
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int in;
  scanf("%d", &in);
  if (in == 3){
  printf("YES\n");
}else if (in == 5) {
  printf("YES\n");
}else if (in == 7) {
  printf("YES\n");
}else
printf("NO\n");
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void solveRGBCards() throws IOException {
		int r;
		int g;
		int b;
		String line;
		String[] split;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		line = br.readLine();
		split = line.split(" ");
		r = Integer.parseInt(split[0]);
		g = Integer.parseInt(split[1]);
		b = Integer.parseInt(split[2]);
		if ((g * 10 + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		br.close();
	}

	public static void main(String[] args) {
		try {
			solveRGBCards();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 22356
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn=500005;
typedef long long ll;

int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}

int n;
int sum;

int gcd(int x, int y)
{
	if(y==0) return x;
	else return gcd(y,x%y);
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				sum+=gcd(i,gcd(j,k));
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
A,B,C,D,E,F=$<.read.split.map(&:to_i)

ws = []

ws = Array.new(30,false)
ws[0] = true
1.upto(30) do |i|
    if (0<=i-A && ws[i-A]) || (0<=i-B && ws[i-B])
        ws[i] = true
    end
end

ss = Array.new(30*E,false)
ss[0] = true
0.upto(30*E) do |i|
    if (0<=i-C && ss[i-C]) || (0<=i-D && ss[i-D])
        ss[i] = true
    end
end

# p ws.map.with_index {|w,i| [w,i]}.select {|w,i| w}.map {|w,i| i}
# p ss.map.with_index {|w,i| [w,i]}.select {|w,i| w}.map {|w,i| i}

n = 0
wmax = 100*A
smax = 0
ws.each.with_index do |wb,i|
    next unless wb
    ss.each.with_index do |sb,s|
        next unless sb
        w = i*100
        if w + s <= F && s <= E*w/100
            m = s/(w+s).to_f
            if n < m
                wmax = w
                smax = s
                n = m
            end
        end
    end
end

puts [wmax+smax, smax].join(' ')

Measured memory_bytes: 14236
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    string W;
    cin >> W;
    map<int, int> cnt;
    rep(i,W.size()){
        cnt[W[i]-'a'] = 0;
    }
    rep(i,W.size()){
        cnt[W[i] - 'a'] += 1;
    }
    rep(i,W.size()){
        if (cnt[W[i]-'a']%2==1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


}


Measured memory_bytes: 256
n = gets.to_i
a= gets.strip.split.map(&:to_i)
ans = 1


(0..n-1).each do |i|
  if a[i]==0
    ans = 0
    break
  end
end

(0..n-1).each do |i|
  ans *= a[i]  
  if ans > 10**18
    ans=-1
    break
  end
end
puts ans


Measured memory_bytes: 23464
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#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(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll n;
    cin >> n;
    cout << n / 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,l,r,a;
    while (cin>>n>>l>>r) {
        if (n==0&&l==0&&r==0) {
            break;
        } else {
            int ans=0;
            std::deque<int> deq;
            for (int i=1;i<=n;i++) {
                cin>>a;
                deq[i]=a;
            }
            for (int j=l;j<=r;j++) {
                int flag=0;
                for (int k=1;k<=n;k++) {
                    if (j%deq[k]==0) {
                        if (k%2==1) {
                            ans++;
                        }
                        flag=1;
                        break;
                    }
                }
                if (flag==0) {
                    if (n%2==0) {
                        ans++;
                    }
                }
            }
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll x;
  cin>>x;
  ll n=100;ll p=0;ll f=0;
  while(n<=x)
  {
    if(n==x)
    {
      f=1;
      cout<<p<<kk;
      break;
    }
    n=n+(ll)(n/100);
    p++;
  }
  if(f==0)
    cout<<p<<kk;

  return 0;
}


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

int a[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3376
#include <stdio.h>

int main(void)
{
	int a, b, c, d, p, x, y = 0;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
	x = a * p;
	y += b;
	if (c < p)
		y += d * (p - c);
	printf("%d\n", x < y ? x : y);
	return 0;
}

Measured memory_bytes: 596
n,p=int(input()),list(map(int,input().split()))
k= n//2 if n%2==0 else n//2+1
a,b=list(range(0,k)),list(range(k-1,n))[::-1]
c=[]
for x,y in zip(a,b):
  c.append(x)
  c.append(y)
c= c if n%2==0 else c[:-1]
c=c[::-1]
l=list([])
for x,y in zip(c,list(range(n))):
  l.append([x,y])
l=sorted(l)
for i in range(n):
  print(p[l[i][1]],end=" ")

Measured memory_bytes: 52036
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

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


    vector<int> house(n);
    cin >> house.at(0);

    vector<int> distance(n);

    for (int i = 1; i < n; ++i) {
        cin >> house.at(i);
        distance.at(i) = house.at(i) - house.at(i - 1);
    }

    distance.at(0) = k - house.at(n - 1) + house.at(0);

    int ans = distance.at(0);
    int m = distance.at(0);

    for (int j = 1; j < n; ++j) {
        ans += distance.at(j);
        m = max(m, distance.at(j));
    }

    cout << ans - m;

}


Measured memory_bytes: 1792
from math import sqrt
from numpy import array 
import numpy as np

N,D = map(int,input().split())
Xlist = array([list(map(int,input().split())) for a in range(N)])
counter = 0
for j in range(N):
    for i in range(j):
        dis = sqrt(np.sum(np.power(Xlist[i]-Xlist[j],2)))
        if dis==int(dis):
            counter += 1

print(counter)

Measured memory_bytes: 12500
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto N = to!ulong(tokens[0]);

	if (N == 1) writeln("Hello World");
	else
	{
		auto a = to!int(chomp(readln()));
		auto b = to!int(chomp(readln()));
		writeln(a + b);
	}

	stdout.flush();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, r;
    cin >> n >> r;

    if (n >= 10) {
        cout << r << endl;
        return 0;
    }
    ll res = r + 100 * (10 - n);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

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

  cout << min(n, b-1)*a/b - a*(min(n, b-1)/b) << endl;
  
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N, Q;
  string S;
  cin >> N >> S >> Q;
  
  array<set<uint64_t>, 26> P;
  N_TIMES(n, N) {
    P[S[n] - 'a'].insert(n);
  }
  
  N_TIMES(q, Q) {
    uint64_t cmd;
    cin >> cmd;

    if (cmd == 1) {
      uint64_t i;
      char c;
      cin >> i >> c;
      --i;

      P[S[i] - 'a'].erase(i);
      S[i] = c;
      P[S[i] - 'a'].insert(i);
    } else { // cmd == 2
      uint64_t l, r;
      cin >> l >> r;
      --l; --r;

      uint64_t T = 0;
      N_TIMES(i, 26) {
        auto itr = P[i].lower_bound(l);
        if (itr == P[i].end()) { continue; }

        if (*itr <= r) { ++T; }
      }
      cout << T << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 26244
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n, m, cnt[7];

int d[maxn];
int fir[maxn], nxt[2 * maxn], to[2 * maxn], e = 1;
bool usd[2 * maxn];
void add(int x, int y) {
	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;
	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;
}

bool inz[maxn];
int zz[maxn], t;
void dfs(int pos, int f) {
	int y, z;
	if(inz[pos]) {
		do{
			usd[zz[t]] = usd[zz[t] ^ 1] = 1;
			//printf("%d, %d\n", to[zz[t]], to[zz[t] ^ 1]);
			--d[to[zz[t]]]; --d[to[zz[t] ^ 1]];
		}while(to[zz[t--] ^ 1] != pos);
		return;
	}
	inz[pos] = 1;
	for (y = fir[pos]; y; y = nxt[y]) {
		if(usd[y]) continue;
		if((z = to[y]) == f) continue;
		zz[++t] = y; dfs(z, pos); 
		return;
	}
}

bool check() {
	for (int i = 1; i <= n; ++i) if(d[i] & 1) return 0;
	for (int i = 1; i <= n; ++i) {
		if(d[i] >= 6) return 1;
		++cnt[d[i]];
	}
	//for (int i = 1; i <= n; ++i) printf("%d ", d[i]); printf("\n");
	if(cnt[4] > 2) return 1;
	if(cnt[4] < 2) return 0;
	dfs(1, 0);
	for (int i = 1; i <= n; ++i) inz[i] = 0; t = 0;
	//for (int i = 1; i <= n; ++i) printf("%d ", d[i]); printf("\n");
	for (int i = 1; i <= n; ++i) if(d[i]) {
		dfs(i, 0); break;
	}
	//for (int i = 1; i <= n; ++i) printf("%d ", d[i]); printf("\n");
	for (int i = 1; i <= n; ++i) if(d[i]) return 1;
	return 0;
}

int main() {
	scanf("%d%d", &n, &m);
	int x, y;
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", &x, &y);
		add(x, y);
		++d[x]; ++d[y];
	}
	if(check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 6540
#include <stdio.h>
#define mod 1000000007

int num(int N){
  if(N<0){
    return 1;
  }
  int n[7]={1,2,3,5,8,13,21};  
  return n[N];
}
  
int main(){
  int H,W,K,i,j;
  scanf("%d%d%d",&H,&W,&K);
  long long int A[W+1][H+1];
  A[1][0]=1;
  if(W==1){
    printf("1");
    return 0;
  }
  
  for(i=2;i<=W;i++){
    A[i][0]=0;
  }
  
  for(i=1;i<=H;i++){
    A[W][i]=(num(W-2)*A[W][i-1]+num(W-3)*A[W-1][i-1])%mod;
    A[1][i]=(num(W-2)*A[1][i-1]+num(W-3)*A[2][i-1])%mod;
    if(W>=3){
      for(j=2;j<=W-1;j++){
	A[j][i]=(num(j-3)*num(W-j-1)*A[j-1][i-1]+num(j-2)*num(W-j-1)*A[j][i-1]+num(j-2)*num(W-j-2)*A[j+1][i-1])%mod;
      }
    }
  }
  
  printf("%lld",A[K][H]);
  return 0;
}




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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using ll = long long;
using ull = unsigned long long;

#define F first
#define S second
#define all(x) begin(x), end(x)

template <class T>
void read_vector(vector<T>& arr) {
	const int size = arr.size();
	for (int i = 0; i < size; ++i) cin >> arr[i];
}

//template <class T>
//vector<T> create_vector(int n) {
//	vector<T> v(n);
//	for (int i = 0; i < size; ++i) cin >> v[i];
//	return v;
//}





void exec()
{
	int n;
	cin >> n;

	vector<vector<int>> arr(n, vector<int>(3));
	for (int i = 0; i < n; ++i) {
		cin >> arr[i][0];
		cin >> arr[i][1];
		cin >> arr[i][2];
	}
	vector<vector<int>> dp(3, vector<int>(n, 0));
	dp[0][0] = arr[0][0];
	dp[1][0] = arr[0][1];
	dp[2][0] = arr[0][2];

	for (int i = 1; i < n; ++i) {
		dp[0][i] = max(dp[0][i], arr[i][0] + max(dp[1][i - 1], dp[2][i - 1]));
		dp[1][i] = max(dp[1][i], arr[i][1] + max(dp[0][i - 1], dp[2][i - 1]));
		dp[2][i] = max(dp[2][i], arr[i][2] + max(dp[0][i - 1], dp[1][i - 1]));
	}

	cout << max(dp[0].back(), max(dp[1].back(), dp[2].back())) << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#define pb push_back
#define uint unsigned int
using namespace std;

#define MAXN 100100
int n;
vector<int> e[MAXN];

int dis1[MAXN];
void dfs1(int pos,int fa,int dis){
	dis1[pos] = dis;
	for(uint i = 0;i < e[pos].size();i++)
		if(e[pos][i] != fa)
			dfs1(e[pos][i],pos,dis+1);
}
int dis2[MAXN];
void dfs2(int pos,int fa,int dis){
	dis2[pos] = dis;
	for(uint i = 0;i < e[pos].size();i++)
		if(e[pos][i] != fa)
			dfs2(e[pos][i],pos,dis+1);
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i < n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		e[a].pb(b);
		e[b].pb(a);
	}
	
	dfs1(1,0,0);
	dfs2(n,0,0);
	
	int f = 0,s = 0;
	for(int i = 1;i <= n;i++){
		if(dis1[i] > dis2[i]) s++;
		else f++;
	}
	
	if(s < f) printf("Fennec\n");
	else printf("Snuke\n");
	
	return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>

int main(){
	int i[10];
	int a[10];
	int c,s,o=0;

	for(c=0;c<=9;c++){
		scanf("%d",&i[c]);
	}
	c=0;
	while(o<10){
		for(s=0;s<=9;s++){
			if(i[s]==c){
				a[o]=i[s];
				o++;
			}
		}
		c++;
	}
	for(c=9;c>6;c--){
		printf("%d\n",a[c]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
long double prob[3000];
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    long double p;
    prob[0] = 1;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>p;
        for(int j=n;j>=1;j--)
        {
            prob[j] = prob[j]*(1-p)+prob[j-1]*p;
        }
        prob[0] = prob[0]*(1-p);
    }
    long double ans = 0;
    for(int i=1+n/2;i<=n;i++)
        ans+=prob[i];
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 384
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
//#define rz(x) resize(x)
//#define rz(x,y) resize(x,y)



void mymain(){
    string a,b,c;
    cin >> a >> b;
    map<string,int> m;
    int x,y;
    cin >> x >> y >> c;
    m[a]=x;
    m[b]=y;
    m[c]--;
    cout << m[a] <<" "<<m[b] <<endl;
}

signed main(){
//IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    //ひとまず入力を受け取る
    int N;
    cin >> N;

    int d[100000];
    int i = 0;
    while(i < N){
        cin >> d[i];
        i++;
    }

    //答えを求める
    sort(d, d+N);
    cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N; cin >> N;
    int sum = 800 * N - 200 * (N / 15);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

long long  mod = 1000000007;
ll dp[210][210];

int main(){
	ll m;
	cin >> m;
	vector<int> v;
	v.push_back(0);
	for(ll i=0;i<m;i++){
		char s;
		cin >> s;
		if(s=='U'){
			v.push_back(-1);
		}
		if(s=='D'){
			v.push_back(1);
		}
	}
	int n = v.size()-1;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(v[i]==-1){
				dp[i][j] = (dp[i][j]+dp[i-1][j]*j)%mod;
				if(j>=1)dp[i][j] = (dp[i][j]+dp[i-1][j-1])%mod;
			}else{
				dp[i][j] = (dp[i][j]+dp[i-1][j]*j)%mod;
				dp[i][j] = (dp[i][j]+dp[i-1][j+1]*(j+1)*(j+1))%mod;
			}
		}
	}
	cout << dp[n][0] << endl;
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  int flag = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
  if (flag == 1) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
n,m=gets.split.map &:to_i
(p (m+1)%(10**9+7);exit)if n==1
r=(0..m+1).bsearch{|i|
	m<(n-1)*i
}
r-=1
p ((m+1)*r*2-(n-1)*r*(r+1)+m+1)%(10**9+7)

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

const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll n; cin >> n;
    map<ll, int> mp;
    static ll num = n;
    for (ll i = 2; i * i <= n; i++) {
        while (num % i == 0) mp[i]++, num /= i;
    }
    if (num != 1) mp[num]++;

    ll ans = 0;
    for (auto e : mp) {
        int k = e.second;
        int tmp = 1;
        while (k >= tmp) ans++, k -= tmp++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if ((A == B && A == C) || (A != B && B != C && C != A)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

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

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int result = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
#include<stack>
using namespace std;
stack<char>s;
string k;
int main(){
    cin>>k;
    int lk=k.length();
    for(int i=0;i<lk;i++)
	{
        s.push(k[i]);
    }
    bool flag=1;
    for(int i=0;i<lk;i++)
	{
        char top=s.top();
        if(top=='b') top='d';
        else if(top=='d') top='b';
        else if(top=='p') top='q';
        else if(top=='q') top='p';
        if(top==k[i])
		 {
            flag=1;
            s.pop();
        }
        else 
		{
            flag=0;
            break;
        }
    }
    if(flag==0) printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

const long MOD = 1000000007;

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

  map<char,long> dp;
  dp[s[0]] = 1;
  rep(i,1,n-1){
    long nv = (dp[t[i]] + dp[s[i]]) %MOD;
    dp[s[i]] = nv;
  }

  cout << dp[t[n-1]] %MOD << endl;

  return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <deque>
#include <vector>
#include <numeric>
#include <limits.h>
#include <algorithm>
using namespace std;

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;

int main() {
	int n, m, num;
	string s;
	cin >> s;
	num = 0;
	for (auto e: s) {
		if (e == '-') {
			num--;
		} else {
			num++;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
	n=input().split()
	n[0]=int(n[0])
	n[1]=int(n[1])
	if n[0]==0 and n[1]==0:
		break

	if n[0]>n[1]:
		c=n[0]
		n[0]=n[1]
		n[1]=c
	print(n[0],n[1])


Measured memory_bytes: 5612
#include <cstdio>
#include <algorithm>
using namespace std;
int n,i,a[200050];
inline int _(int x)
{
	return x>0?x:(-x);
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	long long ans=0;
	for (i=1;i<=n;i++) ans+=_(a[i]-a[n+1>>1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int a, b, x; readV(a, b, x);
  writeln(a <= x && x <= a+b ? "YES" : "NO");
}


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


int main() {

  int a, b, c;
  cin >> a >> b >> c;
  set<int> col;
  col.insert(a);
  col.insert(b);
  col.insert(c);
  
  cout << col.size();

  
  return 0;
}

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

int main(){
    int x,y,c=0;
    cin >> x >> y;
    rep(i,x){
        rep(j,x-i){
            if(i+j==x and 2*i+4*j==y){
                c=1; break;
            }
        }
    }
    if(c==1) cout << "Yes" << endl;
    else cout <<"No" << endl;
}

Measured memory_bytes: 3464
N, L = map(int, input().split())
ans = 0

if L >= 0:
	A = range(2,N+1)
elif L <= 0 and N <= abs(L):
	A = range(1,N)
else:
	A = range(1,N+1)

for i in A:
	ans += L + i - 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	a--;
	b--;
	c--;
	d--;

	string s; cin >> s;

	// a -> c
	{
		bool is_pb = false;
		FOR_LE(i, a + 1, c - 1) {
			if (s[i] == '#') {
				if (is_pb) {
					cout << "No" << endl;
					return 0;
				}
			}
			is_pb = (s[i] == '#');
		}
	}

	// b -> d
	{
		bool is_pb = false;
		FOR_LE(i, b + 1, d - 1) {
			if (s[i] == '#') {
				if (is_pb) {
					cout << "No" << endl;
					return 0;
				}
			}
			is_pb = (s[i] == '#');
		}
	}

	// クロス
	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}

	int c_w = 0;
	FOR_LE(i, b - 1, d + 1) {
		if (s[i] == '.') {
			c_w++;
			if (c_w == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			c_w = 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

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

int main() {
    int a, b;
    char op;

    for ( ;; ) {
        cin >> a >> op >> b;
        if ( op == '?' ) break;

        if ( op == '+' ) cout << a + b << endl;
        else if ( op == '-' ) cout << a - b << endl;
        else if ( op == '*' ) cout << a * b << endl;
        else if ( op == '/' ) cout << a / b << endl;
        else cout << "Invald Operator : " << op << endl;
    }

    return 0;
}

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
string S;
string sub_S;
int ans=0;
void solve(){
	cin>>S;
	for(int i=0;i<S.size();i++){
		for(int j=i;S.size();j++){
		    //sub_S=S.substr(i,j);
			if((S[j]!='T')&& (S[j]!='A') &&(S[j]!='G') &&(S[j]!='C')){
				//cout<<S.substr(i,j-1)<<endl;
				ans=max(ans,j-i);
				break;
			}
	      
		}
	}
	cout<<ans<<endl;
}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  int ng = 0;
  rep(i, n + 1) {
    if(s[i] == '1')
      ng++;
    else
      ng = 0;
    if(ng == m) {
      cout << -1 << endl;
      return 0;
    }
  }
  vi ans;
  while(n) {
    for(int i = m; i >= 1; i--) {
      int j = n - i;
      if(j >= 0 && s[j] == '0') {
        n = j;
        ans.push_back(i);
        break;
      }
    }
  }
  reverse(all(ans));
  for(auto v : ans) cout << v << ' ';
  cout << endl;
}

Measured memory_bytes: 1144
import java.util.ArrayList;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
 
	public static void main(String[] args) {
		FastScanner fScanner = new FastScanner();
		int N = fScanner.nextInt();
		int M = fScanner.nextInt();
		ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>() {
			{
				for (int i = 0; i < N; i++) {
					add(new ArrayList<String>());
				}
			}
		};
		for (int i = 0; i < M; i++) {
			int index = Integer.parseInt(fScanner.next()) - 1;
			list.get(index).add(fScanner.next());
		}
		int ans = 0;
		int penalty = 0;
		for (int i = 0; i < N; i++) {
			int tmpPenalty = 0;
			int correct = 0;
			for (int j = 0; j < list.get(i).size(); j++) {
				if (list.get(i).get(j).equals("WA")) {
					tmpPenalty++;
				}
				if (list.get(i).get(j).equals("AC")) {
					correct++;
					break;
				}
			}
			if (correct == 1) {
				ans++;
				penalty += tmpPenalty;
			}
		}
		System.out.println(ans + " " + penalty);
	}
}
 
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
 
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
 
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
 
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
 
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 54796
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    cout << (H2 - H1) * 60 - M1 + M2 - K << endl;

}


Measured memory_bytes: 3548
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int a, b, c, x, y;

int main() {
    fastio();

    cin >> a >> b >> c >> x >> y;

    if (a + b <= 2 * c) {
        cout << a * x + b * y << '\n';
    } else {
        int d = min(x, y);
        int ans = d * 2 * c;
        x -= d, y -= d;
        ans += min(a, 2 * c) * x;
        ans += min(b, 2 * c) * y;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
namespace prime {
  bool is_prime(ll n) {
    if(n < 2) return false;
    for(ll i = 2; i * i <= n; i++) {
      if(n % i == 0) return false;
    }
    return true;
  }
  vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++) {
      if(n % i == 0) {
        res.push_back(i);
        if(i != n / i) res.push_back(n / i);
      }
    }
    return res;
  }
  map<ll, int> prime_factors(ll n) {
    map<ll, int> res;
    if(n < 2) return res;
    for(ll i = 2; i * i <= n; i++) {
      while(n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
    if(n > 1) res[n] = 1;
    return res;
  }
};

void answer() {
  ll N;
  cin >> N;
  map<ll, int> factors = prime::prime_factors(N);
  ll ans = 0;
  for(auto& pr : factors) {
    int i = 1;
    while(pr.second >= i) {
      pr.second -= i;
      ans++;
      i++;
    }
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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


void solve(int n)
{
  int N = n;
  int count=0;
  string S;
  cin >> S;
  for(int i=0; i<N; i++)
  {
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
    {
      count++;
    }
  }
  cout << count << endl;
}
  
int main()
{
  int N;
  cin >> N;
  solve(N);
  return 0;
}
  

Measured memory_bytes: 3616