akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 2e5 + 10;
map<ll,ll> freq;
ll a[MAXN];
bool flag[MAXN];

void solve(){
    ll n,k; cin>>n>>k;

    FOR(i,1,n) cin>>a[i];

    FOR(i,1,k) {
        freq[a[i]]++;
    }
    deque<ll> dq;
    {
        ll i = 1;
        while(i<=n){
            if(dq.size() < k){
                while(dq.size() && dq.back() > a[i]){
                    dq.pop_front();
                }
                dq.push_back(a[i++]);
                
                if(dq.size() == k){
                    dq.pop_front();
                    flag[i-1] = 1;
                }
            }
        }
    }   

    ll ans = 0,orig = 0;
    if(flag[k] == 1) orig++;
    else ans++;

    FOR(i,k+1,n){
        freq[a[i]]++;
        freq[a[i-k]]--;
        if(freq[a[i-k]] == 0) freq.erase(a[i-k]);

        if(a[i] == freq.rbegin()->first && a[i-k] < freq.begin()->first){

        }else {
            if(flag[i] == 0) ans++;
            else orig++;
        }
    }
    // clog<<ans<<" "<<orig<<endl;
    ans = ans + (orig!=0);
    cout<<ans<<endl;
}   

signed main(){
 
   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 16000
N, M = map(int, input().split())
x = list(map(int, input().split()))
if N >= M:
    print(0)
    quit()


x.sort()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = x[i + 1] - x[i]

s.sort(reverse=True)

res = sum(s)
if M == 1:
    print(0)
    quit()
else:
    for i in range(N - 1):
        res -= s[i]

print(res)


Measured memory_bytes: 13960
#include <stdio.h>
#include <string.h>

int main(void)
{
	int pr_flag[10001];
	int prime[5000];
	int i, j;
	int sum;
	int n;
	int twin[2] , max;
	
	for (i = 0; i < 10001; i++){
		pr_flag[i] = 1;
	}
	
	pr_flag[0] = pr_flag[1] = 0;
	
	for (i = 0; i <= 100; i++){
		if (pr_flag[i] == 1){
			for (j = 2; j <= 10000 / i; j++){
				pr_flag[i * j] = 0;
			}
		}
	}
	
	memset(prime, 0, sizeof(prime));
	
	j = 0;
	
	for (i = 0; i < 10001; i++){
		if (pr_flag[i] == 1){
			prime[j] = i;
			j++;
		}
	}
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		max = twin[0] = twin[1] = 0;
		
		for (i = 0; i < 5001; i++){
			if (prime[i] == 0){
				break;
			}
			
			else if (prime[i + 1] == 2 + prime[i] && max < prime[i + 1] + prime[i] && prime[i + 1] <= n){
				twin[0] = prime[i];
				twin[1] = prime[i + 1];
				max = prime[i] + prime[i + 1];
			}
		}
		
		printf("%d %d\n", twin[0], twin[1]);
	}
	
	return (0);
}

Measured memory_bytes: 468
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost


if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
        if iU - iL <= iX :
            iTotalCost = min(iLCost,iUCost)
            for iK in range(iL+1,iU) :
                iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
            return iTotalCost
        else:
            iM = (iU + iL) // 2
            iMCost = fCalcCost(iN,iX,aCum,iM)
            if iLCost < iUCost :
                return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
            else :
                return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

    print(fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum))
else:
    print(2*iX + 5*aX[0])


Measured memory_bytes: 27244
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

ll gcd(ll a, ll b) {
  return b==0 ? a : gcd(b,a%b);
}
ll lcm(ll a, ll b) {
  return a / gcd(a,b) * b;
}
ll lcm(vector<ll> v) {
  ll res = 1;
  FOR(it,v) {
    res = lcm(res, *it);
    if (res > 1e9) return res;
  }
  return res;
}

int rhythm[8][1024];
string str[8];
int ans[1024];

int main() {
  int T;
  cin >> T;
  while(T--) {
    int n;
    cin >> n;
    vector<ll> size;
    REP(i, n) {
      cin >> str[i];
      int sz = str[i].size()/2;
      int g = sz;
      REP(j,sz) {
        int tmp = strtol(str[i].substr(j*2,2).c_str(), NULL, 16);
        //cout << i << " " << j << " " << tmp << endl;
        rhythm[i][j] = tmp;
        if (tmp) {
          g = gcd(g, j);
        }
      }
      for (int j=0; j*g<sz; ++j) {
        rhythm[i][j] = rhythm[i][j*g];
      }
      size.push_back(sz/g);
    }
    //FOR(it, size) cout << *it << " ";cout << endl;
    ll l = lcm(size);
    if (l > 1024) {
      cout << "Too complex." << endl;
      continue;
    }
    memset(ans,0,sizeof(ans));
    REP(i, n) {
      int p = l/size[i];
      REP(j,size[i]) {
        ans[j*p] |= rhythm[i][j];
      }
    }
    REP(i, l) {
      printf("%02X", ans[i]);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1028
S = str(input())

N = len(S)
palinBool = "No"

if S== S[::-1] and S[:((N-1)//2)] == S[((N-1)//2)-1::-1] and S[((N+3)//2)-1:] == S[N-1:((N+3)//2)-2:-1]:
	palinBool = "Yes"

print(palinBool)

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

int main() {

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

    vl A(N);
    rep(i, N) cin >> A[i];
    FOR(i, K, N) {
        if (A[i] > A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	ll ans = 0, n;
	cin >> n;
	ans = n * (n+1) / 2;
	ans -= 3 * (n/3) * (n/3+1) / 2;
	ans -= 5 * (n/5) * (n/5+1) / 2;
	ans += 15 * (n/15) * (n/15+1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>

int main() {
  bool b1 = false;
  bool b9 = false;
  bool b7 = false;
  bool b4 = false;

  for (size_t i=0; i<4; i++) {
    size_t N;
    std::cin >> N;

    switch (N) {
    case 1:
      b1 = true;
      break;
    case 9:
      b9 = true;
      break;
    case 7:
      b7 = true;
      break;
    case 4:
      b4 = true;
      break;
    }
  }

  auto ans = b1 & b9 & b7 & b4;

  std::cout << (ans ? "YES" : "NO") << std::endl;

  return 0;
}


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

int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for(int i=0; i<N; i++){
    cin >> T.at(i);
  }
  sort(T.begin(), T.end());
  int ans=0;
  for(int i=0; i<N;){
    int p=1;
    for(int j=1; p<C && i+j<N; j++){
      if(T.at(i+j)<=T.at(i)+K && p<C){
        p++;
      }else{
        break;
      }
    }
    i=i+p;
    ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3668
package main

import (
	"bytes"
	"fmt"
)

func rv(b []byte)  {
	for i,j:=0,len(b)-1;i<j;i,j=i+1,j-1{
		b[i],b[j]=b[j],b[i]
	}
}



func main() {


	var s string
	fmt.Scan(&s)

	sb:=[]byte(s)
	rv(sb)

	w:=[][]byte{
		[]byte("dream"),
		[]byte("dreamer"),
		[]byte("erase"),
		[]byte("eraser"),
	}

	for i:=range w {
		rv(w[i])
	}

	i:=0
	for i<len(sb){
		var ok bool
		for _,t:=range w{
			if bytes.HasPrefix(sb[i:],t){
				ok=true
				i+=len(t)
				break
			}
		}

		if !ok{
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

Measured memory_bytes: 1408
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,sse,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
const int maxn = 306, mod = 119<<23|1;
int n, S = 0, a[maxn], dp[maxn][2*maxn*maxn];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	dp[0][0] = 3;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i], S += a[i];
	for(int i = 0; i < n; i++) {
		for(int sm = 0; sm < maxn*maxn; sm++)
			if(dp[i][sm]) {
				add(dp[i+1][sm+a[i]], dp[i][sm]);
				add(dp[i+1][sm], dp[i][sm]);
				add(dp[i+1][sm], dp[i][sm]);
			}
	}
	int ans = 1;
	for(int i = 0; i < n; i++) ans = ans*3ll%mod;
	for(int sm = 0; sm < maxn*maxn; sm++)
		if(dp[n][sm]) {
			if(sm >= (S+1)/2) ans = (mod + ans - dp[n][sm])%mod;
		}
	memset(dp, 0, sizeof dp);
	dp[0][maxn*maxn] = 1;
	for(int i = 0; i < n; i++) {
		for(int sm = 0; sm < 2*maxn*maxn; sm++)
			if(dp[i][sm]) {
				add(dp[i+1][sm+a[i]], dp[i][sm]);
				add(dp[i+1][sm-a[i]], dp[i][sm]);
			}
	}
	ans = (ans + 3ll*dp[n][maxn*maxn])%mod;
	cout << ans;
}


Measured memory_bytes: 224128
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  static int[] A;
        static void Main(string[] args)
        {
          //入力を受け取る
          var N = long.Parse(Console.ReadLine());
          var txy = new int[N+1][];
          
          txy[0] = new int[3]; 
          for(int i = 1;i <= N; i++){
            txy[i] = new int[3];
            txy[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          }
          
          var ans = true;
          
          for(int i = 1;i <= N; i++){
            var time = txy[i][0]-txy[i-1][0];
            var dis  = Math.Abs(txy[i][1]-txy[i-1][1])+Math.Abs(txy[i][2]-txy[i-1][2]);
            var rest = time - dis;
            if(rest < 0 || rest%2 == 1){
              ans = false;
              break;
            }
          }
          if(ans){
            Console.WriteLine("Yes");
          }else{
            Console.WriteLine("No");
          }
          
        }
  
}


Measured memory_bytes: 22452
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int D, L;
    cin >> D >> L;
    if(D>L){
        if(D/L==0)
            cout << D/L << endl;
        else
            cout << D/L+D%L << endl;
    }
    else if(D==L)
        cout << "1" << endl;
    else
        cout << D << endl;
}



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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;
const LL INF = 1LL << 50;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}



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

    int N, M;

    cin >> N >> M;

    int NMAX = 1000;
    int MMAX = 2000;

    int a[M], b[M];
    int c[M];

    REP(i, M) cin >> a[i] >> b[i] >> c[i];

    LL dist[N];
    REP(i, N) dist[i] = -INF;
    dist[0] = 0;

    REP(roop, N - 1) {
        REP(i, M) {
            if (dist[a[i] - 1] == -INF) continue;

            if (dist[a[i] - 1] + c[i] > dist[b[i] - 1]) {
                dist[b[i] - 1] = dist[a[i] - 1] + c[i];
            }
        }
    }

    LL ans = dist[N-1];

    bool flag[N];
    REP (i, N) flag[i] = false;

    REP(i, N) {
        REP(i, M) {
            if (dist[a[i] - 1] == -INF) continue;

            if (dist[a[i] - 1] + c[i] > dist[b[i] - 1]) {
                dist[b[i] - 1] = dist[a[i] - 1] + c[i];
                flag[b[i] - 1] = true;
            }
        }
    }

    cout << fixed << setprecision(20);

    if (flag[N-1]) cout << "inf" << endl;
    else cout << ans << endl;

}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int[] X = nextIntArray(sc, 3);

		sc.close();

		Arrays.sort(X);
		int ans = 0;

		//最大と2番目に大きいものが一致するまで最小と2番目を2こ+1する
		while (X[1] != X[2]) {
			X[0]++;
			X[1]++;
			ans++;
		}

		//最小と最大の偶奇が違うなら、最大と2番目を2個+1する
		if (X[0] % 2 != X[2] % 2) {
			X[1]++;
			X[2]++;
			ans++;
		}

		//最小を最大と同じになるまで+2する
		while (X[0] != X[2]) {
			X[0] += 2;
			ans++;
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


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


int main()
{
  long double a, b, x;
  cin >> a >> b >> x;
  long double ans;
  if (a * a * b < 2 * x)
    ans = atan2(2 * b - 2 * x / a / a, a);
  else
    ans = atan2(b, 2 * x / a / b);
  ans = ans * 180 / M_PI;
  printf("%.8llf\n", ans);
  return 0;
}

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

typedef unsigned long long ll;

ll md = 1000000007;

int main(int, char**) 
{
	ll n, ans = 0;
	ll bp = 100001;
	cin >> n;

	cin >> bp;
	ans += bp;
	for (ll i = 0; i < n - 1; i++) {
		ll b;
		cin >> b;
		ans += min(b,bp);
		bp = b;
	}

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


Measured memory_bytes: 256
a,b,K = map(int,input().split())
def exchange(A,B):
    if A%2 == 1:
        A -= 1
    C = A//2
    B += C
    A -= C
    return((A,B))
for i in range(K):
    if i%2 == 0:
        a,b=exchange(a,b)
    else:
        b,a=exchange(b,a)
print(a,b)

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

int main(int argc, const char * argv[]) {

    int n,i;
    double x[100],y[100];
    double p1,p2,p22,p3,p33,p4;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++) scanf("%lf",&x[i]);
    for(i=0; i<n; i++) scanf("%lf",&y[i]);
    
    p1=0;
    for(i=0; i<n; i++) p1 += fabs(x[i]-y[i]);
    
    p2=0;
    for(i=0; i<n; i++) p2 += pow(fabs(x[i]-y[i]),2);
    
    p3=0;
    for(i=0; i<n; i++) p3 += pow(fabs(x[i]-y[i]),3);
    
    p4=0;
    
    for(i=0; i<n; i++) {
        double a = fabs(x[i]-y[i]);
        if(a>p4) p4=a;
    }
    
    
    p22 = sqrt(p2);
    p33 = pow(p3, 1.0/3.0);

    
    printf("%lf\n%lf\n%lf\n%lf\n", p1, p22, p33 , p4);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(all(a));
	ll ans = INF;
	for(int i = k-1; i < n; i++){
		ans = min(ans,abs(a[i]-a[i-k+1]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , L , a[N];

int main(){
  cin >> n >> L;
  rep(i,1,n+1) cin >> a[i];
  vector<pair<int,ll> > v;
  vi ans;
  rep(i,1,n+1) {
    v.pb(mp(i,a[i]));
    while(sz(v) >= 2 && v[sz(v)-1].se + v[sz(v)-2].se >= L) {
      ans.pb(v[sz(v)-2].fi);
      v[sz(v)-2].se+=v[sz(v)-1].se;
      v[sz(v)-2].fi=v[sz(v)-1].fi;
      v.pop_back();
    }
  }
  if(sz(v) == 1) {
    cout << "Possible" << endl;
    per(i,0,sz(ans)) cout << ans[i] << endl;
  } else
    cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
	if (n & 1) res = res * a;
	a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int x;cin>>x;
  if((x+104)/105 <= x/100)cout<<1<<endl;
  else cout<<0<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N,D;
  cin>>N>>D;
  int count=0;
  while(N--)
  {
    long x,y;
    double distance;
    cin>>x>>y;
    distance=sqrt(x*x+y*y);
    if(distance<=D)
      count++;
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 3660
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  vector<int> a(4);
  for(int i=0;i<4;++i) a.at(i)=S.at(i)-'0';

  vector<char> op(3);
  if     (a[0]+a[1]+a[2]+a[3]==7){
    op[0]='+'; op[1]='+'; op[2]='+';
  }
  else if(a[0]+a[1]+a[2]-a[3]==7){
    op[0]='+'; op[1]='+'; op[2]='-';
  }
  else if(a[0]+a[1]-a[2]+a[3]==7){
    op[0]='+'; op[1]='-'; op[2]='+';
  }
  else if(a[0]+a[1]-a[2]-a[3]==7){
    op[0]='+'; op[1]='-'; op[2]='-';
  }
  else if(a[0]-a[1]+a[2]+a[3]==7){
    op[0]='-'; op[1]='+'; op[2]='+';
  }
  else if(a[0]-a[1]+a[2]-a[3]==7){
    op[0]='-'; op[1]='+'; op[2]='-';
  }
  else if(a[0]-a[1]-a[2]+a[3]==7){
    op[0]='-'; op[1]='-'; op[2]='+';
  }
  else if(a[0]-a[1]-a[2]-a[3]==7){
    op[0]='-'; op[1]='-'; op[2]='-';
  }

  for(int i=0;i<3;++i) cout << a.at(i) << op.at(i);
  cout << a.at(3) << "=7" << endl;

  return 0;
}


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

int main() {
    int I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;

    if (J > 0 && L > 0 && I > 0) {
        long long x = (long long)((I - 1) / 2) * 2 + O + ((J - 1) / 2) * 2 + ((L - 1) / 2) * 2 + 3;
        long long y = (long long)(I / 2) * 2 + O + (J / 2) * 2 + (L / 2) * 2;
        cout << max(x, y) << endl;
    } else {
        cout << ((I / 2) * 2 + O + (J / 2) * 2 + (L / 2) * 2) << endl;
    }
}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    S = input()
    res = 0
    max_res = 0
    for i in range(len(S)):
        if S[i] in ['A', 'C', 'G', 'T']:
            res += 1
        else:
            res = 0
        max_res = max(max_res, res)
    print(max_res)
if __name__ == "__main__":
    resolve()


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


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


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


strings = [0 if s == 'R' else 1 for s in input()]
n = len(strings)

target = 0
rle01 = [0]
for i, masu in enumerate(strings):
    if target != masu:
        rle01.append(i)
        target = 1 - target
rle01.append(n)

ans = [0 for _ in range(n)]
last_idx = rle01[0]
for i in range(1, len(rle01)):
    idx = rle01[i]
    length = idx - last_idx

    if i % 2 == 1:
        target_idx = idx
        ans[target_idx - 1] += length % 2
    else:
        target_idx = rle01[i - 1]
        ans[target_idx] += length % 2

    ans[target_idx] += length // 2
    ans[target_idx - 1] += length // 2
    last_idx = idx

print(" ".join([str(i) for i in ans]))

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

s=k=kn=0;n=N
while k<n:
	k += 1
	n = N//k
	kn = k*n*(n+1)
	s += 4*kn
s -= (k+1)*kn
if n<k:
	s -= 2*kn 
print(s//4)


Measured memory_bytes: 9096
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,a,x,b;
    	cin>>x;
    	while(true)
    	{
    		if(prime_check(x)==true)
    		break;
    		x++;
		}
		cout<<x;
    } 
	return 0;
}

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

int main() {
  int a;
  int kekka = 1;
  cin >> a;
  vector<int> vec(1010,0);
  
  for(int i = 2; i <= 1000; i++){
    for(int j = 2; pow(i, j) <= 1000; j++){
      vec.at(pow(i, j)) = 1;
    }
  }
  
  for(int i = a; i >= 0; i--){
    if(vec.at(i) == 1){
      kekka = i;
      break;
    }
  }
  
  cout << kekka << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
Ai = list(map(int, input().split()))

idx = 0
for i, a in enumerate(Ai):
    if a == 1:
        idx = i
        break
K2 = K - 1
left_num = idx
left_count = left_num // K2
if left_num % K2 > 0:
    left_count += 1

right_idx = K2 * (left_count - 1) + K

right_num = N - right_idx
right_count = right_num // K2
if right_num % K2 > 0:
    right_count += 1

print(left_count + right_count)

Measured memory_bytes: 13880
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	for(int s = 0;s < S.size();s++){
		for (int t = s + 1; t < S.size(); t++) {
			if (S[s] == 'C' && S[t] == 'F') {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3040
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

static const int NMAX = 1e5;
static const int MOD = 1e9+7;

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

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

    string s;
    cin >> s;
    int n = (int) s.size();
    ll dp[n+1][13];

    for(int i = 0; i<= n; ++i)
    {
		for(int j = 0; j< 13; ++j)
		{
			dp[i][j] = 0;
		}
    }
	dp[0][0] = 1;

	for(int i = 0; i< n; ++i)
	{
		for(int j = 0; j< 10; ++j)
		{
			int nxt = s[i] - '0';
			if(s[i] == '?')
			{
				nxt = j;
			}
			for(int k = 0; k < 13; ++k)
			{
				int rem = (10*k+nxt) % 13;
				dp[i+1][rem]+=dp[i][k];
				dp[i+1][rem]%=MOD;
			}
			if(s[i] != '?')
			{
				break;
			}
		}	
	}

	cout<< dp[n][5];


    return 0;
}

Measured memory_bytes: 10604
def find_most_rightup(c,d):
  tmpA = []
  for i in range(len(AB)):
    a,b = AB[i]
    if a<c and b<d:
      tmpA.append([b,i])
  if len(tmpA) > 0:
    return sorted(tmpA, reverse=True)[0][1]
  else: return None

N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

CD = []
for _ in range(N):
  c,d = map(int,input().split())
  CD.append([c,d])

AB.sort(reverse=True)
CD.sort()
ans = 0
for c,d in CD:
  min_i = find_most_rightup(c,d)
  if min_i is not None:
    del AB[min_i]
    ans += 1
print(ans)    


Measured memory_bytes: 38896
import java.util.*;
import java.io.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static InputStreamReader reader = new InputStreamReader(System.in);
    static int n, a, b, c;//prepare "number" and "Edge".
    static int A,B,C;
    public static void main(String[] args) {
	
	read();
	
    }
    
    static boolean read(){
	//	System.out.println("Input the nummber.");
	    n = sc.nextInt();//read "number".
	    int i;
	    for(i = 0; i < n; i++){
		a = sc.nextInt();//read "edge".
		b = sc.nextInt();//read "edge".
		c = sc.nextInt();//read "edge".

		if(a == 0 || b == 0 || c == 0){
		    System.out.println("NO");
		}//end of if

		
		if(a != 0 && b != 0 && c!= 0){
		    A = a * a;//calculate the power of edge of A.
		    B = b * b;//calculate the power of edge of B.
		    C = c * c;//calculate the power of edge of C.
		    if(A == B + C){//compare
			System.out.println("YES");//output
		    }else if(B == A + C){//compare
			System.out.println("YES");//output
		    }else if(C == A + B){//compare
			System.out.println("YES");//output
		    }else{
			System.out.println("NO");
		    }
		}//end of if		    
	    }//end of for
	    return true;
    }//brock of read()
}//brock of Main()

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

long pow2flower(long x,int n){\
  long x2=x%1000000007;
  if(n==1){
    return x2;
  } else if(n%2==0){
    return pow2flower(x2*x2,n/2)%1000000007;
  } else if(n%2!=0){
    return (pow2flower(x2*x2,n/2)*x2)%1000000007;
  }
}

long combination(long n, long r) {  
  long i;
  long x=1,y=1;
  for(i=n;i>n-r;i--){
    x=(x*i)%1000000007;
  }
  for(i=1;i<=r;i++){
    y=(y*i)%1000000007;
  }
  return (x*pow2flower(y,1000000005))%1000000007;
}

int main(){
  long n,a,b,i;
  long flowers,allflowers=1;
  long nca,ncb;
  
  scanf("%ld %ld %ld",&n,&a,&b);
  
  allflowers=pow2flower(2,n)-1;
  nca=combination(n,a);
  ncb=combination(n,b);
 
  flowers=(allflowers-nca-ncb)%1000000007;
  if(flowers<0)flowers+=1000000007;
  printf("%ld",flowers);
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> ls(n); cin >> ls;
    auto calc = [&](int i, int a){ 
        int len = 0;
        int ret = - 10;
        for(int l = 0; l < n; l++){
            if(i >> l & 1){
                len += ls[l];
                ret += 10;
            }
        }
        return ret + abs(len - a);
    };
    int ans = M;
    for(int i = 1; i < (1 << n); i++){
        for(int j = 1; j < (1 << n); j++){
            for(int k = 1; k < (1 << n); k++){
                if(i & j || j & k || k & i){ continue; }
                ans = min(ans, calc(i, a) + calc(j, b) + calc(k, c));
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
import numpy as np

N = int(input())  
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)

ans = np.sum(B)

for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]
        
print(int(ans))

Measured memory_bytes: 21380
n = int(input())
line2 = input().split()
h_list = [int(x) for x in line2]
 
max_count = 0
size = len(h_list)

i = 0
while True: 
    if i == size-1:
        break
    now = h_list[i]
    count = 0
    for j in range(i+1,size):
        if now >= h_list[j]:
            count += 1
            now = h_list[j]
        else:
            break
    if max_count < count:
        max_count = count
        
    if max_count >= size - i:
        break
        
    i = j
    
print(max_count)

Measured memory_bytes: 14252
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Maybe
import Data.Char

solve :: [(Int,Int)] -> Int -> Int
solve [] memo = 0 
solve ((to,from):xs) memo
  | from <= memo = solve xs memo
  | otherwise = 1 + solve xs (to-1) 

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  xs <- replicateM m $ do 
      s <- BS.getLine
      let (from, s') = fromJust $ BS.readInt s
      let (to, _) = fromJust $ BS.readInt $ BS.dropWhile isSpace s'
      return (to, from)
  
  print $ solve (sort xs) 0 

Measured memory_bytes: 47868
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    int n, k; cin >> n >> k;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    int ans = 0;
    int is_win[T.size()];
    rep(i,0,T.size()){
        is_win[i] = 0;
    }
    rep(i,0,T.size()){
        if(i < k ){
            if(T[i] == 'r'){ ans += P; is_win[i] = 1;}
            else if(T[i] == 'p'){ ans += S; is_win[i] = 1;} 
            else if(T[i] == 's'){ ans += R; is_win[i] = 1;}
        }
        else{
            if(T[i] != T[i-k] || is_win[i-k] == 0){
                if(T[i] == 'r'){ ans += P; is_win[i] = 1;}
                else if(T[i] == 'p'){ ans += S; is_win[i] = 1;} 
                else if(T[i] == 's'){ ans += R; is_win[i] = 1;}
            }
        }
    }
    cout << ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 848
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//木の直径 verified AOJ GRL_5_A
#define MAX_V 2000

struct edge{ int to,cost; };
pii dfs(int prev, int v, const vector<edge> graph[MAX_V]){   //searching farthest node
    pii r(0,v);
    
    rep(i,graph[v].size()){
        struct edge e = graph[v][i];
        if(e.to == prev) continue;
        pii tmp = dfs(v,e.to,graph);
        tmp.first += e.cost;
        if(r.first < tmp.first) r = tmp;
    }
    return r;
}

int diameter( const vector<edge> graph[MAX_V] ) {
    pii r = dfs(-1, 0, graph);
    pii t = dfs(-1, r.second, graph);
    return t.first;
}


vector<edge> G[MAX_V];

int dfs(int cur, int prev, int dist){
    if(dist==0)return 1;
    
    int ret = 1;
    for(auto e:G[cur]){
        if(e.to==prev)continue;
        ret += dfs(e.to,cur,dist-1);
    }
    
    return ret;
}

int main(){
    int n,k;
    cin>>n>>k;
    
    vector<pii> edges;
    rep(i,n-1){
        int u,v;
        cin>>u>>v;
        u--,v--;
        edges.pb(pii(u,v));
        G[u].pb(edge{v,1});
        G[v].pb(edge{u,1});
    }
    
    int d = diameter(G);
    if(d<=k){
        cout<<0<<endl;
        return 0;
    }

    int ans = INF;
    if(k%2==0){
        rep(i,n){
            int t = dfs(i,-1,k/2);
            ans = min(ans,n-t);
        }
    }else{
        for(pii e : edges){
            int u,v;
            tie(u,v) = e;
            int t = dfs(u,v,(k-1)/2) + dfs(v,u,(k-1)/2);
            ans = min(ans,n-t);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define M 1000000007



int main ()
{
    ll T;
   T=1;
   //cin>>T;
    while(T--)
    {	
    ll n;
    cin>>n;
    vector<long double>v(n+1);
    fori(i,1,n+1)cin>>v[i];
    vector<vector<long double>>dp(n+1,vector<long double>(n+1,0.0));
    dp[0][0]=1.0;
    for(int i=1;i<n+1;i++){
    	for(int j=0;j<n+1;j++){
    		if(j-1>=0){
    		dp[i][j]=v[i]*dp[i-1][j-1] +(1.0-v[i])*dp[i-1][j];
    		}
    		else{dp[i][j]=dp[i-1][j]*(1.0-v[i]);}
    	}
    }
    long double ans=0;
    ll j=(n+1)/2;
    for(;j<=n;j++){
    	ans+=dp[n][j];
    }
    cout<<fixed<<setprecision(12)<<ans;
    
   		
   
    
    }
    return 0;
}


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

int cnt;
string l,r;

void check(){
  int x = atoi(l.c_str()) ,y = atoi(r.c_str());
  if(l.size() > r.size() || x > y || l[0] == '0' || r[0] == '0') return;  
  if((x + y) % 2 == 0 || (x - y) % 2 == 0) cnt++;
}

int main(){
  string a;

  cin >> a;
  int size = a.size();
  int z = atoi(a.c_str());

  if(z % 2 == 0) cnt++;

  for(int i = 1 ; i < size ; i++){
    l = a.substr(0,i);
    r = a.substr(i);
    check();
  }
  cout << cnt << endl;

  return 0;
}

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

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

  vector<int> cnt(n);
  for(int i = 1;i < n;i++){
    cnt[i] = cnt[i-1];
    if(s[i-1] == 'A' && s[i] == 'C'){
      cnt[i]++;
    }
  }

  while(q--){
    int l,r;
    cin >> l >> r;
    
    cout << cnt[r-1] - cnt[l-1] << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;


int n, p;
vector<int> E[maxn];
int vis[maxn], mid;

int dfs(int u, int step){
    int val=(u==n);
    vis[u]=1;
    if(u==n) mid=step/2+1+step%2;
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            val|=dfs(v, step+1);
            if(step==mid&&val) p=u;
        }
    }
    return val;
}

int dfs2(int u){
    vis[u]=1;
    if(u==p)return 0;
    int add=0;
    for(int i=0;i<E[u].size();i++){
        int v=E[u][i];
        if(!vis[v]){
            add+=dfs2(v);
        }
    }
    return add+1;
}

int main() {
    while(~scanf("%d", &n)){
        int u, v;
        for(int i=1;i<=n;i++)E[i].clear();
        for(int i=0;i<n-1;i++){
            scanf("%d%d", &u, &v);
            E[u].push_back(v);
            E[v].push_back(u);
        }
        memset(vis, 0);
        dfs(1, 1);
        memset(vis, 0);
        int sum=dfs2(1);
        printf("%s\n", sum>n-sum&&n!=2?"Fennec":"Snuke");
    }
    return 0;
}


Measured memory_bytes: 13952
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e9+7;

int main()
{
    vector<ll> a(5);
    rep(i,5){
        cin >> a[i];
    }
    ll ans=0;
    ll m=10;
    ll pos=-1;
    rep(i,5){
        if(a[i]%10==0) continue;
        if((a[i]%10)<m){
            pos=i;
            m=(a[i]%10);
        }
    }
    //cout << pos << endl;
    rep(i,5){
        if(a[i]%10==0){
            ans+=a[i];
        }
        else if(i==pos){
            ans+=a[i];
        }
        else{
            ans+=((a[i]/10)+1)*10;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n;
string w[101];
bool b = true;
signed main() {
    cin >> n;
    set<string> unq;
    for (int i=0;i<n;i++) {
        cin >> w[i];
        unq.insert(w[i]);
    }
    for (int i=0;i<n-1;i++) {
        char e = w[i].back();
        char s = w[i+1].front();
        b &= (e==s);
    }
    if (unq.size() != n) b = false;
    cout << (b?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline


N,K = map(int,input().split())
used = [0] * N
mod = 10 ** 9 + 7

edge_dic = {i:[] for i in range(N)}
for i in range(N-1):
    a , b = map(int,input().split())
    a -= 1
    b -= 1
    edge_dic[a].append(b)
    edge_dic[b].append(a)

# print(edge_dic)

node_queue = deque()

node_queue.append(0)
ans = K
while len(node_queue):
    node = node_queue.pop()
    used[node] = 1
    if node == 0:
        can_use = K - 1
    else:
        can_use = K - 2
    for node_next in edge_dic[node]:
        if used[node_next] == 0:
            node_queue.append(node_next)
            if can_use <= 0:
                print(0)
                exit()
            ans = ans * can_use % mod
            can_use -= 1
print(ans)


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

using namespace std;

const int N = 3005;
const int mod = 1e9 + 7;

int n, f[N][N], g[N][N];
string s;

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> s; s = "#" + s;
    f[1][1] = 1;
    for (int i = 1; i <= n; i++) g[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            if (s[i - 1] == '<') add(f[i][j], g[i - 1][j - 1]);
            else add(f[i][j], g[i - 1][i - 1] - g[i - 1][j - 1]);
            if (f[i][j] < 0) f[i][j] += mod;
            g[i][j] = f[i][j];
        }

        for (int j = 1; j <= n; j++) add(g[i][j], g[i][j - 1]);
    }

    if (g[n][n] < 0) g[n][n] += mod;
    cout << g[n][n];
    return 0;
}


Measured memory_bytes: 70784
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 K = sc.nextInt();

		int kcd = gcd(A,B);
		int count = 0;

		for(int i=kcd;i>0;i--) {
			if(kcd%i == 0) {
				count++;
			}

			if(count == K) {
				System.out.println(i);
				break;
			}
		}

	}

	public static int gcd(int m,int n){
		if(n == 0){
			return m;
		}else{
			return gcd(n,m%n);
		}
	}

}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}

int main()
{
    lli n,weight;
    cin >> n >> weight;
    vector<lli> dp(100001 , 100000000000);
    dp[0] = 0;
    for(int i1 = 0 ; i1 < n ; i1++) {
        int w, v;
        cin >> w >> v;
        for(int i = (dp.size() - 1 - v) ;i >= 0; --i){
            dp[i+v] = min(dp[i+v] , dp[i] + w);
        }
    }
    lli wans = 0;
    for(int i = dp.size() - 1 ; i >= 0 ; i--) if(dp[i] <= weight) {wans = i;break;}
    cout << wans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    
    Scanner sc=new Scanner(System.in);
    String str1=sc.next();
    String str2=sc.next();
    int count=0;
    for(int i=0;i<str1.length();i++)
    {
        if(str1.charAt(i)!=str2.charAt(i))
          count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 41304
package main

import (
	"fmt"
)

func main() {
	var h, w int
	for {
		fmt.Scan(&w, &h)
		if w == 0 && h == 0 {
			return
		}
		matrix := make([][]int, h)
		Sean := make([][]bool, h)
		for i := 0; i < h; i++ {
			matrix[i] = make([]int, w)
			Sean[i] = make([]bool, w)
			for j := 0; j < w; j++ {
				fmt.Scan(&matrix[i][j])
			}
		}
		var count int
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if matrix[i][j] == 1 && Sean[i][j] == false {
					search(i, j, h, w, matrix, Sean)
					count++
				}
			}
		}
		fmt.Println(count)
	}
}
func search(x int, y int, h int, w int, matrix [][]int, Sean [][]bool) {
	if x < 0 || y < 0 || x >= h || y >= w || matrix[x][y] == 0 {
		return
	}
	if Sean[x][y] == true {
		return
	}

	Sean[x][y] = true

	search(x+1, y, h, w, matrix, Sean)
	search(x-1, y, h, w, matrix, Sean)
	search(x, y+1, h, w, matrix, Sean)
	search(x, y-1, h, w, matrix, Sean)
	search(x+1, y-1, h, w, matrix, Sean)
	search(x-1, y+1, h, w, matrix, Sean)
	search(x+1, y+1, h, w, matrix, Sean)
	search(x-1, y-1, h, w, matrix, Sean)
}



Measured memory_bytes: 2780