akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String result = s;
        // String result = s.replaceAll("(0|1)B|B", "");
        Pattern ptn = Pattern.compile("(0|1)B|B");
        Matcher match = ptn.matcher(s);
        while(match.find()){
            result = result.replaceFirst("(0|1)B|B", "");
        }
        System.out.println(result);
    }

    static 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: 21204
#include<bits/stdc++.h>
typedef int LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=4e3+9,mod=998244353,inf=0x3f3f3f3f;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
void add(LL &x,LL y){
	x+=y; x=(x>=mod?x-mod:x);
}
void dec(LL x,LL y){
	x-=y; x=(x<0?x+mod:x);
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
LL Pow(LL base,LL b){
	LL ret(1); while(b){
		if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;
	}return ret;
}
LL fac[maxn],fav[maxn];
LL C(LL N,LL M){
	if(M>N) return 0;
	return 1ll*fac[N]*fav[M]%mod*fav[N-M]%mod;
}
LL n;
LL f[maxn][maxn],a[maxn];
char s[maxn];
void Fir(){
	LL N(4000);
	fac[0]=1;
	for(LL i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
	fav[N]=Pow(fac[N],mod-2);
	for(LL i=N;i>=1;--i) fav[i-1]=1ll*fav[i]*i%mod;
}
int main(){
    scanf(" %s",s+1);
    n=strlen(s+1);
    Fir();
    for(LL i=1;i<=n;++i){
    	/*
    	sum[i]=sum[i-1];
    	if(s[i]=='1') sum[i]++;
    	if(s[i]=='2') sum[i]+=2;
		*/
    	a[i]=s[i]-'0';
	}
    f[0][0]=1;
    for(LL i=0;i<n;++i){
    	for(LL j=0;j<=2*i;++j){
    		if(j){
    			add(f[i+1][j-1+a[i+1]],f[i][j]);
			}else if(a[i+1]){
				add(f[i+1][j-1+a[i+1]],f[i][j]);
			}
			if(i-j){
				add(f[i+1][j+a[i+1]],f[i][j]);
			}else if(a[i+1]!=2){
				add(f[i+1][j+a[i+1]],f[i][j]);
			}
		}
	}
	//printf("%d %d\n",f[1][0],f[2][2]);
	LL ans(0);
	for(LL j=0;j<=2*n;++j){
		//printf("(%d,%d)",f[n][j],C(n,j));
		add(ans,1ll*f[n][j]*C(n,j)%mod);
	}
	//puts("");
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 26444
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int N,dp[225816],segtree[816225],pr[225816];
vector<int> ans;

void init(int l=0, int r=N, int i=0){
	int vl,vr;
	if(r-l>1){
		init(l,(l+r)>>1,i*2+1);
		init((l+r)>>1,r,i*2+2);
		vl = segtree[i*2+1];
		vr = segtree[i*2+2];
		if(dp[vl] < dp[vr]){
			segtree[i] = vl;
		}else if(dp[vl] > dp[vr]){
			segtree[i] = vr;
		}else{
			segtree[i] = vl;
		}
	}else{
		segtree[i] = l;
	}
}
 
void update(int p, int l=0, int r=N, int i=0){
	int vl,vr;
	if(p<l || r<=p){
		return;
	}else if(r-l>1){
		update(p,l,(l+r)>>1,i*2+1);
		update(p,(l+r)>>1,r,i*2+2);
		vl = segtree[i*2+1];
		vr = segtree[i*2+2];
		if(dp[vl] < dp[vr]){
			segtree[i] = vl;
		}else if(dp[vl] > dp[vr]){
			segtree[i] = vr;
		}else{
			segtree[i] = min(vl,vr);
		}
	}else{
		segtree[i] = p;
	}
}
 
int query(int p, int q, int l=0, int r=N, int i=0){
	int vl,vr;
	if(q<=l || r<=p){
		return N;
	}else if(p<=l && r<=q){
		return segtree[i];
	}else{
		vl = query(p,q,l,(l+r)>>1,i*2+1);
		vr = query(p,q,(l+r)>>1,r,i*2+2);
		if(dp[vl] > dp[vr]){
			return vr;
		}else if(dp[vl] < dp[vr]){
			return vl;
		}else{
			return min(vl,vr);
		}
	}
}

int main(void){
	int n,m,i,v;
	string s;
	fill(dp,dp+225816,INF);
	cin >> n >> m;
	N = n+m;
	cin >> s;
	dp[0] = 0;
	for(i=1; i<=m; ++i){
		if(i>n || s[i]=='1'){
			continue;
		}
		pr[i] = 0;
		dp[i] = 1;
	}
	init();
	for(i=m+1; i<=n; ++i){
		if(s[i]=='1'){
			continue;
		}
		pr[i] = query(i-m,i);
		dp[i] = dp[pr[i]]+1;
		update(i);
	}
	v = n;
	while(v){
		if(!(dp[v]<INF)){
			cout << "-1" << endl;
			return 0;
		}
		ans.push_back(v-pr[v]);
		v = pr[v];
	}
	for(i=(ans.l_ength()-1); i>=0; --i){
		cout << ans[i] << ((i)?" ":"");
	}
	cout << endl;
	return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, 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 = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn=1005;
vector<vll> G(maxn);
bool reachableFrom1[maxn];
void dfs(ll v){
    if(reachableFrom1[v]) return;
    reachableFrom1[v]=true;
    for(auto nv: G[v]){
        dfs(nv);
    }
}

vector<vll> rG(maxn);
bool reachableToN[maxn];
void rdfs(ll v){
    if(reachableToN[v]) return;
    reachableToN[v]=true;
    for(auto nv: rG[v]){
        rdfs(nv);
    }
}

ll n,m;
vector<tuple<ll,ll,ll>> es;
ll dist[maxn];
bool ok[maxn];

bool bellmanford(ll s){
    fill(dist,dist+n,INF);
    dist[0]=0;
    bool update=true;
    ll cnt=0;
    while(update){
        update=false;
        for(auto e: es){
            ll a,b,c;
            tie(a,b,c)=e;
            if(!ok[a]||!ok[b]) continue;
            if(chmin(dist[b],dist[a]+c)) update=true;
        }
        if(cnt>=n){
            return true; // has negative loop
        }
        cnt++;
    }
    return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    es.emplace_back(a,b,-c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachableFrom1[i]&&reachableToN[i];
  if(bellmanford(0)){
    puts("inf");
  }else{
    cout<<-dist[n-1]<<endl;
  }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define rep(i,n)    FOR(i,0,n)
#define rrep(i,n)   for(int i=n-1;i<=0;--i)
#define loop        while(true)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const ll MAX = 10000000;
const ll MIN = 0;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
    ll ans;
    string N;
    cin >> N;

    if( N.at(0) == 'R' && N.at(1) == 'R' && N.at(2) == 'R') cout << 3 << endl;
    else if( (N.at(0) == 'R' && N.at(1) == 'R') || (N.at(1) == 'R' && N.at(2) == 'R') ) cout << 2 << endl;
    else if( N.at(0) == 'R' || N.at(1) == 'R' || N.at(2) == 'R') cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
A = np.array([0] + [int(x) for x in input().split()])

A_abs = np.abs(A)

x = A_abs.argmax()
if x == 0:
  x = 1
value = A[x]

answer = []

for j in range(1,N+1):
  if j == x:
    continue
  answer.append((x,j))
# 符号がそろった

if value > 0:
  for j in range(1,N):
    answer.append((j,j+1))
else:
  for j in range(N,1,-1):
    answer.append((j,j-1))
    
print(len(answer))
for a,b in answer:
  print(a,b)


Measured memory_bytes: 12512
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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 dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    vector<ll> a(n+2, 0);
    REP(i, n){
        ll ain; cin >> ain;
        a[i+1] = ain;
    }
    //cout << a << endl;
    ll ac = 0;
    REP(i, n+1){
        ac += abs(a[i+1] - a[i]);
    }
    REP(i, n){
        cout << ac - (abs(a[i] - a[i+1]) + abs(a[i+1] - a[i+2])) + abs(a[i] - a[i+2]) << endl; 
    }
}

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

Measured memory_bytes: 2048
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
 int n;
 cin>>n;
 int h[n];
   for(int i=0;i<n;i++)
   cin>>h[i];
   int dp[n];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++){
       dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
   }
   cout<<dp[n-1];
   

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

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

using namespace std;
int N;
bool ok(int i, int m) {
    if (m == 0) return 1;
    if (m < 0) return 0;
    return ok(i + 1, m - i);
}
void solve() {
    int ans = 0;
    rep(i, N) if (i) {
        if (ok(i, N)) ans++;
    }
    cout << ans << endl;
}
int main() {
    while (cin >> N) {
        if (N == 0) break;
        solve();
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll A(N);
    bool p = true;
    bool m = true;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i]>=0){m = false;}
        else{p = false;}
    }
    if(N == 2){
        cout << max(A[0], A[1]) - min(A[0], A[1]) << endl;
        cout << max(A[0], A[1]) << " " << min(A[0], A[1]);
    }
    else{
    if(p == true){
        sort(A.begin(),A.end());
        ll ans = 0;
        for(int i=1; i<N; i++){
            ans+=A[i];
        }
        ans -= A[0];
        cout << ans << endl; cout << A[0] << " " << A[1] << endl;
        ll k = A[0] - A[1];
        for(int i=2; i<N-1; i++){
            cout << k << " " << A[i] << endl;
            k = k - A[i];
        }
        cout << A[N-1] << " " << k;
    }
    else if(m == true){
        sort(A.begin(),A.end());
        ll ans = 0;
        for(int i=0; i<N-1; i++){
            ans -= A[i];
        }
        ans += A[N-1];
        cout << ans << endl;
        cout << A[N-1] << " " << A[0] << endl;
        ll k = A[N-1] - A[0];
        for(int i=1; i<N-1; i++){
            cout << k << " " << A[i] << endl;
            k = k - A[i];
        }
    }
    else{
        sort(A.begin(),A.end());
        ll c;
        for(int i=0; i<N-1; i++){
            if(A[i]<0&&A[i+1]>=0){c = i;}
        }
        ll ans = 0;
        ll minus =0;
        for(int i=0; i<N; i++){
            ans += abs(A[i]);
            if(A[i] < 0){minus++;}
        }
        cout << ans << endl;
        ll k = A[N-1];
        for(int i=0; i<minus-1; i++){
            cout << k << " " << A[i] << endl;
            k = k -A[i];
        }
        ll l = A[c];
        for(int i=0; i<N-minus-1; i++){
            cout << l << " " << A[c+i+1] << endl;
            l = l - A[c+i+1];
        }
        cout << k << " " << l;
    }
    }
}

Measured memory_bytes: 2688
from itertools import accumulate

n, q = list(map(int, input().split()))
s = input()

calc = [0] * n
prev = None
for i, c in enumerate(s):
    if prev == 'A' and c == 'C':
        calc[i] = 1
    prev = c
calc = [0] + list(accumulate(calc))

ans = []
for _ in range(q):
    l, r = list(map(int, input().split()))
    ans.append(calc[r] - calc[l])
print('\n'.join(map(str, ans)))


Measured memory_bytes: 18024
use proconio::*;

// 2^18 = 2.6 * 10^5
// S がTに包含されてなければならない
// 含むと即条件に反するやつを除外する
// S=T なbitは全部等しいので除外した時点でOK
// S=0, T=1 なbitをどうするか
// つまり問題がS=0, T=2^18 - 1 で解ければ良い
// 初期値を決め打つと残りの要素は変換後のbitwise or を撮っていくDP で解ける
// 計算量2^18 * 50 * 50 * 50
// (始点 * 遷移数 * 要素数)
//
// 50を1, 2つ消し飛ばしたい
//
// 包除とかないか
// 求めたい結果は条件のANDだから無さげ?
// -> 補修号
//
// 0, 1 で解くには？
// これは0のみ、1のみ以外の選択をすれば良い
//
// 0, 2^2 - 1  で解くには？
//
// 全体の選び方からNGを引いていく
// ALL - (kbit目が0のみor1のみ) + (a, bbit目が~)
// なんか気合あれば解ける気がしてきた

#[fastout]
fn run() {
    input! {
        n: usize,
        k: usize,
        s: usize,
        t: usize,
        a: [usize; n],
    }
    let a: Vec<usize> = a.into_iter().filter(|a| a & s == s && a | t == t).collect();
    if a.is_empty() || s & t != s {
        println!("0");
        return;
    }
    let mut comb = vec![vec![0i64; n + 1]; n + 1];
    comb[0][0] = 1;
    for i in 1..=n {
        comb[i][0] = 1;
        for j in 1..=i {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }
    let mut bit = vec![];
    for i in 0..18 {
        if (s >> i) & 1 != (t >> i) & 1 {
            bit.push(i);
        }
    }
    let n = std::cmp::min(n, a.len());
    let k = std::cmp::min(k, n);
    let mut ans = 0i64;
    for b in 0..(1usize << bit.len()) {
        let sign = if b.count_ones() % 2 == 0 {1} else {-1};
        let mut mask = 0;
        for (i, &x) in bit.iter().enumerate() {
            if (b >> i) & 1 == 1 {
                mask |= 1 << x;
            }
        }
        let mut map = std::collections::BTreeMap::new();
        for a in a.iter() {
            *map.entry(*a & mask).or_insert(0) += 1;
        }
        for (_, v) in map {
            for i in 1..=std::cmp::min(v, k) {
                ans += sign * comb[v][i];
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2240
#include<bits/stdc++.h>
using namespace std;
int n;
void print_ans(string s){
	if(s.length() == n)
		{cout<<s<<"\n"; return;}
	int used[10] = {false};
	for(int i =0;i <s.length() ;i++){
		if(!used[s[i] - 'a'])
			print_ans(s+ s[i]);
		if(!used[char((int)s[i] + 1) - 'a'])
			print_ans(s + char((int)s[i] + 1));
		used[s[i] - 'a'] =  true;
		used[char((int)s[i] + 1) - 'a'] = true;
	}
}


int main(){
	cin>>n;

	if(n == 1)
		{cout<<"a"<<endl;
		return  0;}
	string s = "a";


	print_ans(s);

	return 0; 
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 4e5 + 200;
int k,n;
ll v[N], diff[N];
int main() {
    scanf("%d %d", &k, &n);
    for(int i = 0; i < n; ++i) scanf("%lld", &v[i]);
    v[n] = k;
    for(int i = 0; i < n; ++i) {
        int nxt = 0;
        if(i != n - 1) nxt = v[i + 1] - v[i];
        else nxt = v[0] + (k - v[n - 1]);
        diff[i] = nxt; 
    }
    for(int i = 0, j = n; i <= n; ++i, j++) {
        diff[j] = diff[i];
    }
    // for(int i = 0; i < 2 * n; ++i) cout<<diff[i]<<" ";
    // cout<<endl;
    ll acm = 0;
    ll ans = 0;
    for(int i = 0; i < n - 1; ++i) acm += diff[i];
    ans = acm;
    for(int i = n - 1, j = 0; i < 2 * n; ++i, j++) {
        acm = acm - diff[j] + diff[i], ans = min(ans, acm);
        // cout<<j<<" "<<i<<" - "<<diff[j]<<" "<<diff[i]<<" | "<<acm<<endl;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6400
#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    int x[N];
    int y[N];
    int h[N];
    int num;
    rep(i,N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]!=0)num=i;
    }
    bool flag;
    rep(i,101){
        rep(j,101){
            int hi=abs(x[num]-i)+abs(y[num]-j)+h[num];
            flag=true;
            rep(k,N){
                if(max(hi-abs(x[k]-i)-abs(y[k]-j),0)!=h[k]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cout << i << ' ' << j << ' ' << hi;
                break;
            }
        }
        if(flag)break;
    }

    


}

/*

久保

 */



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

void swap(int *x, int*y)
{
	int temp=0;

	temp = *x;

	*x = *y;

	*y = temp;
}

int main()
{
	int w=0, n=0;

	std::cin >> w >> n;

	std::vector<int> order;

	for(int i=0; i<=w; ++i)
	{
		order.push_back(i);//1〜wまで添え字を使用
	}

	int a=0,b=0;

	char c;

	for(int i=0; i<n; ++i)
	{
		std::cin >> a >> c >> b; 

		swap(&order[a], &order[b]);
	}

	for(int i=1; i<=w; ++i)
	{
		std::cout << order[i] << '\n';
	}

}

Measured memory_bytes: 1216
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
ll n,m;
ll a[1010];
int main()
{
  	cin>>n>>m;
  	ll tot=0;
  	rep(i,n)
  	{
  		cin>>a[i];
  		a[i]*=4*m;
  		tot+=a[i];
	}
	ll c=tot/(4*m);
	ll cnt=0;
	rep(i,n)
	{
		if(a[i]>=c)
		{
			cnt++;
		}
	}
	if(cnt>=m)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

ll T1, T2, A1, A2, B1, B2;

int main() {
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	A1 -= B1;
	A2 -= B2;
	if (A1*T1 + A2*T2 == 0) {
		cout << "infinity" << endl;
		return 0;
	}
	if (A1*T1 + A2*T2 > 0) {
		A1 = -A1;
		A2 = -A2;
	}
	if (A1*T1 < 0) {
		cout << 0 << endl;
		return 0;
	}
	ll X = A1*T1;
	ll Y = -(A1*T1 + A2*T2);
	if (X%Y == 0) {
		cout << X / Y * 2 << endl;
	}
	else {
		cout << X / Y * 2 + 1 << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in); 
		
		
		String s = sc.nextLine();
		
		int count = 0;
		int maxLength = 0;
		for(int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A' || s.charAt(i) == 'G'|| s.charAt(i) == 'C'|| s.charAt(i) == 'T'){
				count++;
				maxLength = Math.max(count, maxLength);
			}else {
				count = 0;
			}
		}

		System.out.println(maxLength);
		
	}

}

Measured memory_bytes: 22484
#include <cstdio>
const int Vmax = 2001;
const int Emax = Vmax*2;
struct Edge
{
	int to;
	Edge *next;
	Edge(){}
	Edge(int v, Edge *e):to(v),next(e){}
	void* operator new(size_t);
}Edata[Emax], *head[Vmax];
void* Edge::operator new(size_t)
{
	static Edge *P = Edata;
	return P++;
}
void addEdge(int a, int b)
{
	head[a] = new Edge(b, head[a]);
	head[b] = new Edge(a, head[b]);
}
int dfs(int p, int from, int dep, int lmt)
{
	int size = 1;
	for(Edge *e=head[p]; e; e=e->next)
		if(dep<lmt && e->to!=from)
			size += dfs(e->to, p, dep+1, lmt);
	return size;
}
#define max(a,b) ((a)>(b)?(a):(b))
int main()
{
	int N, K, i, x, y;
	scanf("%d%d", &N, &K);
	for(i=1; i<N; ++i)
	{
		scanf("%d%d", &x, &y);
		addEdge(x, y);
	}
	int ans = 0, tmp;
	if(K & 1)
	{
		K >>= 1;
		for(i=1; i<=N; ++i)
			for(Edge *e=head[i]; e; e=e->next)
				if(i > e->to)
				{
					tmp = dfs(i, e->to, 0, K) + dfs(e->to, i, 0, K);
					ans = max(ans, tmp);
				}
	}		
	else
	{
		K >>= 1;
		for(i=1; i<=N; ++i)
		{
			tmp = dfs(i, i, 0, K);
			ans = max(ans, tmp);
		}
	}
	printf("%d\n", N-ans);
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127/tasks/abc127_c
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    REP(i, M) cin >> L[i] >> R[i];
    int left = -1, right = N;
    REP(i, M)
    {
        left = max(left, L[i]);
        right = min(right, R[i]);
    }
    int ans = right - left >= 0 ? right - left + 1 : 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3988
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_D
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;
            int m = 0;
            int l = 0;
            long[][] a = null;
            long[][] b = null;
            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                    m = Integer.valueOf(inputs[1]);
                    l = Integer.valueOf(inputs[2]);
                    // ??????????´???¨??????
                    a = new long[n][m];
                    b = new long[m][l];
                } else if (stdReader.getLineNumber() <= 1 + n) {
                    // 2????????\??????????????????
                    // ??????????????°(0,1,2,...)
                    int i = stdReader.getLineNumber() - 2;
                    String[] inputs = sStr.split(SPACE);
                    for (int j=0; j<m; j++) {
                        a[i][j] = Long.parseLong(inputs[j]);
                    }

                } else if (stdReader.getLineNumber() <= 1 + n + m) {
                    int k = stdReader.getLineNumber() - (2 + n);
                    String[] inputs = sStr.split(SPACE);
                    for (int j=0; j<l; j++) {
                        b[k][j] = Long.parseLong(inputs[j]);
                    }
                    if (stdReader.getLineNumber() == 1 + n + m)
                        break;
                }
            }
            
            double c[][] = new double[n][l];
            
            // ?????? x ???????????????
            double temp = 0;
            for (int k = 0; k < l; k++) {
                for (int i = 0; i < n; i++) {
                    temp = 0;
                    for (int j = 0; j < m; j++) {
                        temp += a[i][j] * b[j][k];
                    }
                    c[i][k] = temp;
                }
            }
            
            // ??¢???????????????
            for (int i = 0; i < n; i++) {
                for (int k = 0; k < l; k++) {
                    System.out.print(String.format("%.0f",  c[i][k]));
//                    System.out.print( c[i][k]);
                    if (k < l - 1)
                        System.out.print(SPACE);
                }
                System.out.println();
            }
            
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}

Measured memory_bytes: 46048
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
template<typename T1,typename T2> inline bool chmax(T1& a,T2 b)
{if (a < b) {a = b; return true;} return false;}
template<typename T1,typename T2> inline bool chmin(T1& a,T2 b)
{if (a > b) {a = b; return true;} return false;}

int N;
Graph G;

int Tree_Diameter(const Graph &G){
    int MAX_D = -1, node = 0;
    vector<bool> seen(G.size(), false);
    stack<pair<int, int>> sta; sta.emplace(0, 0);
    while(!sta.empty()){
        int dep, v; tie(v, dep) = sta.top(); sta.pop();
        seen[v] = true;
        if (chmax(MAX_D, dep)) node = v;
        for (auto e : G[v]) {
            if (seen[e]) continue;
            sta.emplace(e, dep + 1);
        }
    }
    MAX_D = -1; seen.assign(G.size(), false);
    sta.emplace(node, 0);
    while(!sta.empty()){
        int dep, v; tie(v, dep) = sta.top(); sta.pop();
        seen[v] = true; chmax(MAX_D, dep);
        for (auto e : G[v]) {
            if (seen[e]) continue;
            sta.emplace(e, dep + 1);
        }
    }
    
    return MAX_D;
}

int main(){
    int N; cin >> N;
    Graph G(N, vector<int>());
    for (int i = 1; i < N; i++) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].emplace_back(b); G[b].emplace_back(a);
    }
  int R = Tree_Diameter(G);
  if (R % 3 == 1) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
  return 0;
}

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

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    let a = n `mod` k
    let b = abs $ a - k
    print $ min a b

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

ll t,i,x,j,y,z=0,k=0,n;
string s;
cin>>n;		ll a[n],b[n];

rep(i,0,n,1)	cin>>a[i]>>b[i];
t=0;
i=n-1;
while(i>=0){
	k = a[i]+t;
	k%=b[i];
	k=b[i]-k;
	k%=b[i];
	
	t+=k;
	i--;
}

// z=z&1;
ce(t)
}




Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int j;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		for(int i = 0; i < 2; i++){
			if(a > b){
				j = a;
				a = b;
				b = j;
			}
			if(b > c){
				j = b;
				b = c;
				c = j;
			}
		}
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26084
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+5;
int A[maxn],N;

bool P(const int mid)
{
    int cnt = 1;
    int i = 0, j = 1;
    for (int k = 2; k < N; ) {
        if (A[k] - A[k-1] >= 0 && A[j]-A[i] >= 0) {
            if (A[i] == A[j]) 
                i++, j++;
            k++;
        }
        else if (A[k] - A[k-1] <= 0 && A[j]-A[i] <= 0) {
            if (A[i] == A[j]) 
                i++, j++;
            k++;
        }
        else {
            cnt++;
            i = k; j = i+1; k = j+1;
        }
    }
    return cnt <= mid;
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> N) {
        FOR(i,0,N)
            cin >> A[i];
        int lo = 1, hi = 1e6;
        while (lo < hi) {
            const int mid = (lo+hi)/2;
            if (mid == 3)
                int blah = 90;
            if (P(mid))
                hi = mid;
            else
                lo = mid + 1;
        }
        cout << lo << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int ans;

int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        if(i%2==0)continue;
        int cnt=0;
        for(int j=1;j<=n;j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int main()
{
  int W, A[100002];
  int close[100002] = {};
  
  cin >> W;
  for(int i = 1; i <= W; i++) {
    cin >> A[i];
    if(A[i] == 0) close[i] = INF;
  }
  for(int i = 1; i <= W; i++) {
    close[i] = max(close[i], close[i - 1] - 1);
    if(A[i] < 0) close[i] = min(close[i], -A[i]);
  }
  for(int i = W; i >= 1; i--) {
    close[i] = max(close[i], close[i + 1] - 1);
    if(A[i] < 0) close[i] = min(close[i], -A[i]);
  }
  int ret = 0;
  for(int i = 1; i <= W; i++) {
    ret += max(0, min(close[i], A[i]));
  }
  cout << ret << endl;
}

Measured memory_bytes: 1948
import java.util.*;

public class Main {

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

        int count = 0;
        int idx = 0;
        for (char string : S.toCharArray()) {
            char x = T.charAt(idx);
            if (x != string) {
                count++;
            }
            idx++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 41620
#include<stdio.h>
#include <math.h>
int main(){
    int k, n, i;
    scanf("%d %d",&k,&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int max = a[1] - a[0];
    for(i=2;i<n;i++){
        if(max<a[i]-a[i-1]){
            max = a[i]-a[i-1];
        }
    }
    if(max<k-a[n-1]+a[0]){
        max = k-a[n-1]+a[0];
    }
    printf("%d",k-max);
    return 0;
}

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


int main() {
  int n;
  cin >> n;
  int rest = n % 10;
  if (rest == 2 || rest == 4 || rest == 5 || rest == 7 || rest == 9)
    cout << "hon\n";
  else if (rest == 0 || rest == 1 || rest == 6 || rest == 8)
    cout << "pon\n";
  else
    cout << "bon\n";
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#define REP(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
char m[16][16], buf[16];
int main()
{
	while (true) {
		bool done = false;
		rep(i, 8) if (scanf("%s", m[i]) == EOF) done = true;
		if (done) break;

		char res = 0;
		rep(i, 8) rep(j, 8) {
			if (m[i][j] == '1') {
				if (j < 5 && m[i][j+1]=='1'&&m[i][j+2]=='1'&&m[i][j+3]=='1') {
					res = 'C';
				}
				else if (j < 7 && i < 7 && m[i][j+1]=='1'&&m[i+1][j]=='1'&&m[i+1][j+1]=='1') {
					res = 'A';
				}
				else if (i < 5 && m[i+1][j]=='1'&&m[i+2][j]=='1'&&m[i+3][j]=='1') {
					res = 'B';
				}
				else if (i < 6 && j > 0 && m[i+1][j-1]=='1'&&m[i+1][j]=='1'&&m[i+2][j-1]=='1') {
					res = 'D';
				}
				else if (i < 7 && j < 6 && m[i][j+1]=='1'&&m[i+1][j+1]=='1'&&m[i+1][j+2]=='1') {
					res = 'E';
				}
				else if (i < 6 && j < 7 && m[i+1][j+1]=='1'&&m[i+1][j]=='1'&&m[i+2][j+1]=='1') {
					res = 'F';
				}
				else if (i < 7 && j < 7 && j > 0 && m[i][j+1]=='1'&&m[i+1][j]=='1'&&m[i+1][j-1]=='1') {
					res = 'G';
				}
			}
			if (res > 0) goto BREAK;
		}
BREAK:
		printf("%c\n", res);
	}
	return 0;
}

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

const int N = 2e5 + 10;

int n , sum , ans;
char s[N];

int main(){
	scanf("%d %s" , &n , s + 1);
	for(int i = 1; i <= n; i++) if(s[i] == 'R') sum++;
	for(int i = 1; i <= sum; i++) if(s[i] == 'W') ans++;
	printf("%d" , ans);
	return 0;
} 

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    rep(i,0,3){
        if(n%10==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}




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

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

  if( N<=K ){
    cout << 0 << endl;
  }
  else{
    vector<int> data(N);
    for(int i=0; i<N; i++){
      int a;
      cin >> data.at(i);
    }
    sort(data.begin(), data.end());

    int64_t ans= 0;
    for(int i=0; i<N-K; i++){
      ans+= data.at(i);
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
def solve(string):
    n = int(string)
    p = []
    c = [True] * 101
    c[0] = c[1] = False
    for i, f in enumerate(c):
        if f:
            p.append(i)
            t = 2
            while i * t <= 100:
                c[i * t] = False
                t += 1
    d = {_p: 0 for _p in p}
    for _p in p:
        t = 1
        while _p**t <= n:
            d[_p] += n // (_p**t)
            t += 1

    def f(n):
        return len(list(filter(lambda x: x >= n - 1, d.values())))

    f3, f5 = f(3), f(5)
    ans = 0
    # x**75
    ans += f(75)
    # x**25y**3
    ans += f(25) * (f3 - 1)
    # x**15y**5
    ans += f(15) * (f5 - 1)
    # x**5y**5z**3
    ans += f5 * (f5 - 1) // 2 * (f3 - 2)
    return str(ans)


if __name__ == '__main__':
    print(solve(input()))


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

int main() {
  int N , A , p=30 , q=0 ;
  cin >> N ;
  for (int i=0 ; i<N ; i++){
    cin >> A ;
    while ( A % 2 == 0 ){
      A /= 2 ;
      q++;
    }
    if ( p >= q ){
      p = q ;
    }
    q = 0 ;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input("").split(" ")))
b = list(map(int,input("").split(" ")))

assist = 0
kill = 0

for i in range(n):
    if assist+b[i] < a[i]:
        kill += assist+b[i]
        assist = 0
    else:
        if assist <= a[i]:
            kill += a[i]
            assist += b[i] - a[i]
        else:
            kill += a[i]
            assist = b[i]

if assist == 0:
    print(kill)
elif assist < a[-1]:
    print(kill + assist)
else:
    print(kill + a[-1])

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

#define ll long long int
#define endl '\n'

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

    #ifndef ONLINE_JUDGE 
        freopen("__input.txt", "r", stdin); 
        freopen("__output.txt", "w", stdout); 
    #endif 

    ll t;
    cin >> t;

    if(t >= 30) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3644
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int px[3],x[3];
    int dp[MAX],flag[MAX];
    int val,chin,maxi;
    void solve()
    {
        cin>>n;
        vector<int> dp(3),ndp(3),c(3);
        fo(day,0,n)
        {
            fo(i,0,3)
            cin>>c[i];
            
            // deb(c[1])
            
            fo(i,0,3)
            {
                fo(j,0,3)
                {
                    if(i!=j)
                    ndp[j]=max(ndp[j],dp[i]+c[j]);
                }
            }
            dp=ndp;
        }
            
        cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
        
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //

    int32_t main() 
      {
      	
      	// int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
      	ios_base::sync_with_stdio(0);
      	cin.tie(NULL);
      	
      	// cin>>t;while(t--)
      	solve();
      	
    	return 0;
      }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int solve(int x){
	if(x == 1) return 3;
	else if(x == 2) return 2;
	else if(x == 3) return 1;
	else return 0;
}
int main() {
	// your code goes here
	int x, y; cin>>x>>y;
	int answer = solve(x);
	answer += solve(y);
	if(x == y && x == 1) answer += 4;
	cout<<answer * 100000;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B&&B == C)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
import math
import copy
import sys


inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputaList = [int(n) for n in inputa]

inputb = input().split()
inputbList = [int(n) for n in inputb]
#
# inputList = []
# inputNumList = []
# for i in range(a):
#     inputNum = input()
#     inputNumList = list(inputNum)
#     inputList.append(inputNumList)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

flg = True

for i in range(a):
    if i == 0:
        inputbList[i] -= 1
    else:
        if inputbList[i] > inputbList[i-1]:
            inputbList[i] -= 1
        if inputbList[i] < inputbList[i-1]:
            flg = False
            break

if flg:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 15220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
//#define int ll
#define vvi vector<vector<int>>
using namespace std;
using namespace __gnu_pbds;
typedef tree <pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return (n*fact(n-1))%mod;
// }
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// }
void solve(){
    int n;
    cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
        string s;cin>>s;m[s]++;
    }
    cout<<m.size();
}
signed main(){
    boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 19200