akhauriyash/Code-Regression huggingface dataset:
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dp[31][100010];
signed main(void)
{
  int n, C;
  cin >> n >> C;
  REP(i, n) {
    int s, t, c;
    cin >> s >> t >> c;
    dp[c-1][s]++;
    dp[c-1][t]--;
  }

  REP(j, C) {
    FOR(i, 1, 100010) {
      dp[j][i] += dp[j][i-1];
    }
  }
  //
  // REP(j, C) {
  //   REP(i, 10) {
  //     cout << dp[j][i] << " ";
  //   }
  //   cout << endl;
  // }

  int ret = 0;
  FOR(i, 1, 100010) {
    int cnt = 0;
    REP(j, C) {
      if(dp[j][i] == 1 || dp[j][i-1] == 1) cnt++;
    }
    // cout << "i:" << i << " " << cnt << endl;
    chmax(ret, cnt);
  }
  cout << ret << endl;

  return 0;
}


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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    vector<vector<int>> t(n),f(n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        for(int j=0;j<a;j++){
            int x,y;
            cin>>x>>y;
            x--;
            if(y==1){
                t[i].push_back(x);
            }
            else f[i].push_back(x);
        }
    }
    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        bool used[n]={};
        queue<int> q;
        int p[n]={};
        int cnt=0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                cnt++;
                p[j] = 1;
                q.push(j);
            }
        }
        bool pos = true;
        while(q.size()){
            int k = q.front();
            q.pop();
            used[k] = 1;
            for(auto j:t[k]){
                if(p[j] == -1){
                    pos = false;
                    break;
                }
                p[j] = 1;
                if(!used[j]){
                    q.push(j);
                }
            }
            for(auto j:f[k]){
                if(p[j] == 1){
                    pos = false;
                    break;
                }
                p[j] = -1;
            }
            if(!pos)break;
        }
        if(pos) ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int v[n],c[n],ans[n];
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n;i++)
    {
        ans[i]=v[i]-c[i];
    }
    sort(ans,ans+n,greater<int>());
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(ans[i]<0) break;
        sum+=ans[i];
    }
    // if(sum==0) sum=ans[0];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
			if(i*m+j*n-2*i*j==k)return puts("Yes"),0;
	puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (!n) break;
    int m; cin >> m;
    VV<> v(n);
    for (int i = 0; i < m; ++i) {
      int x, y; cin >> x >> y, --x, --y;
      v[x].push_back(y);
    }
    V< bitset<9> > a(n);
    int res = 0;
    auto dfs = [&](const auto& dfs, int i) -> void {
      if (i == n) {
        ++res;
        return;
      }
      int s = 0;
      for (int j = 0; j < i; ++j) {
        s += a[i][j] = !a[j][i];
      }
      if (s > n / 2 or i - s > n / 2) return;
      V<> p(n / 2 - s, 1);
      while (p.size() < n + ~i) p.push_back(0);
      sort(begin(p), end(p));
      do {
        for (int j = 0; j < n + ~i; ++j) {
          a[i][i + 1 + j] = p[j];
        }
        bool b = true;
        for (int j : v[i]) if (!a[i][j]) {
          b = false;
          break;
        }
        if (b) dfs(dfs, i + 1);
      } while (next_permutation(begin(p), end(p)));
    };
    dfs(dfs, 0);
    cout << res << '\n';
  }
}


Measured memory_bytes: 3144
import math
n = int(input())

def yakusu(n):
    a = []
    for i in range(1, int(math.sqrt(2*n))+2):
        if(2*n % i == 0):
            a.append(i)
    for i in range(len(a)):
        a.append(2*n // a[i])
    return sorted(list(set(a)))

def exgcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = exgcd(b % a, a)
        return g, x - (b // a) * y, y
    
def CRT(b1, m1, b2, m2):
    # 中国剰余定理
    # x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ r (mod m)
    # となる(r. m)を返す
    # 解無しのとき(0, -1)
    d, p, q = exgcd(m1, m2)
    if (b2 - b1) % d != 0:
        return 0, -1
    m = m1 * (m2 // d)  # m = lcm(m1, m2)
    tmp = (b2-b1) // d * p % (m2 // d)
    r = (b1 + m1 * tmp) % m
    return r, m
x = yakusu(n)
a = 1e16
for i in range(len(x)):
    r, m = CRT(-1, 2*n//x[i], 0, x[i])
    if(r > 0):
        a = min(a, r)
print(a)

Measured memory_bytes: 84296
import java.io.*
import java.util.*

fun solve(H: Int, W: Int, s: Array<String>){
    val queue = ArrayDeque<Pair<Int, Int>>()
    queue.addLast(Pair(0,0))
    val whiteSum = s.map{ str -> str.count{ chr -> chr == '.' } }.sum()
    val cache = Array(H){ IntArray(W) }
    var step = 1
    while(queue.size > 0){
        val yx = queue.removeFirst()
        var step = cache[yx.first][yx.second]
        var yx_next = listOf(
            Pair(yx.first - 1, yx.second),
            Pair(yx.first + 1, yx.second),
            Pair(yx.first, yx.second - 1),
            Pair(yx.first, yx.second + 1)
        )
        for (nyx in yx_next) {
            var y = nyx.first
            var x = nyx.second
            if (y < 0 || x< 0 || x >= W || y >= H) { continue }
            if (s[y][x] == '#') { continue }
            if (x == W - 1 && y == H - 1) {
                println(whiteSum - step - 2)
                return
            }
            if (cache[y][x] == 0) {
                cache[y][x] = step + 1
                queue.addLast(Pair(y, x))
            }
        }
    }
    println(-1)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    val (H, W) = readLine()!!.split(' ').map{ it.toInt() }
    val s = Array(H){ readLine()!! }
    solve(H, W, s)
}



Measured memory_bytes: 38196
#include <stdio.h>

int thereis(char* a,char c,int size){
  for(int i=0;i<size;i++){
    if(a[i]==c)return 1;
  }
  return 0;
}

int main(void){
  int size;
  scanf("%d",&size);
  char s[1000];
  scanf("%s",s);
  int max=0;
  int buf;
  for(int split=1;split<size;split++){
    buf=0;
    for(char c='a';c<='z';c++){
      buf+=thereis(s,c,split)&&thereis(s+split,c,size-split);
    }
    max=buf>max?buf:max;
  }
 
  printf("%d",max);
  return 0;
}


Measured memory_bytes: 128
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort(reverse=True)
y.sort()
ans = "War"
for i in range(X+1,Y+1):
    if x[0]<i<=y[0]:
        ans = "No War"
        break
    else:
        continue
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int N, L[101], max=-1, i, sum=0, count=0;

    scanf("%d", &N);


    for(i=0; i<N; i++){
        scanf("%d", &L[i]);

        if(L[i]>max)
            max=L[i];
    }

    for(i=0; i<N; i++){
        if(count==0)
            if(max==L[i]){
                count++;
                continue;
            }

        sum += L[i];
    }

    if(max < sum)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=998244353;
typedef long long ll;
typedef long double ld;
const int maxn=500005;
int dcmp(double x) {
	if(fabs(x)<=eps) return 0;
	return x<0?-1:1;
}
struct Point{
	ll x,y;
	Point(ll x=0,ll y=0):x(x),y(y) {}
	Point operator - (const Point &a)const { return Point(x-a.x,y-a.y); }
	bool operator < (const Point &a)const { if(a.x==x) return y>a.y; return x<a.x; }
};
ll Dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; }
ll Cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }
double len(Vector a) { return sqrt(Dot(a,a)); }
int n,m;
char s[200005],t[200005];
void solve() {
	cin>>n>>m;
	scanf("%s %s",s+1,t+1);
	ll x=__gcd(n,m),ans=n*1LL*m/x,i;
	if(s[1]!=t[1]) ans=-1;
	if(x!=1) {
		n/=x;m/=x;i=0;
		while(i*n+1<=n*x && i*m+1<=m*x){
			if(s[i*n+1]!=t[i*m+1]) ans=-1;
			i++;
		}
	}
	cout<<ans<<endl;
}
int main() {
	int tt=1;
	while(tt--) solve();
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];

    map<int, int> mp;
    REP(i, n) mp[a[i]]++;

    int ans = 0;
    REP(i, 100000) {
        int cnt = 0;
        cnt += mp[i - 1];
        cnt += mp[i];
        cnt += mp[i + 1];
        ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

#define MAX 5

int main()
{
	int data[MAX];

	for (int i = 0; i < 5; i++)
		scanf("%d", &data[i]);

	for (int i = 0; i < 5; i++) {
		if (data[i] == 0)
			printf("%d\n", i + 1);
	}

	return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint H(N);
    rep(i, N) cin >> H[i];
    int now_max = 0;
    rep(i, N) {
        if (H[i] < now_max - 1) {
            cout << "No" << endl;
            return 0;
        }
        now_max = max(H[i], now_max);


    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;

int main() {
	
	string s;
	cin >> s;

	int a, b;
	 a = stoi(s.substr(0, 2));
	 b = stoi(s.substr(2, 2));

	 if ((a == 0 || a > 12) && b > 0 && b <= 12) {
		 cout << "YYMM" << endl;
	 }

	 else if ((b == 0 || b > 12) && a > 0 && a <= 12) {
		 cout << "MMYY" << endl;
	 }

	 else if (a > 0 && a <= 12 && b > 0 && b <= 12) {
		 cout << "AMBIGUOUS" << endl;
	 }

	 else {
		 cout << "NA" << endl;
	 }

	return 0;
}




Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0)
		{
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0){ cout << "No" << endl;
		break;
		}
	}


	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
// using ll = long long;
#define int long long
 
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
map<int,int> GetPrimeFactors(int n) {
  map<int,int> mp;
  // dived by 2, 3, 5, ...
  for(int i=2; i*i<=n; i+=2) {
    if(i==4) i = 3;
    while(n%i == 0) {
      ++mp[i];
      n /= i;
    }
  }
  if(n!=1) ++mp[n];
 
  return mp;
}
signed main() {
  int n;
  cin >> n;
  int p;
  cin >> p;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }
  if(p == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<int, int> mp = GetPrimeFactors(p);
  int ans = 1;
  REPOBJ(itr, mp) {
    int tmp = itr->second / n;
    if(tmp) ans *= pow(itr->first, tmp);
  }
  cout << ans;
  cout << "\n";
  return 0;
}

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

long long int arr[22][22];
long long int dp[1LL<<22];
long long int n; 

long long int comp(long long int index, long long int mask){
    if(index == n+1) return 1;
    if(dp[mask]!=-1) return dp[mask];
    long long int ans = 0;
    for(long long int i = 1; i <= n; i++){
        if(arr[index][i] && (mask&(1LL<<i))==0){
            ans = ((ans%mod) + (comp(index+1, mask|(1LL<<i)))%mod)%mod;
        }
    }
    return dp[mask] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    
    for(long long int i = 1; i <= n; i++){
        for(long long int j = 1; j <= n; j++){
            cin >> arr[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << comp(1, 0);
   return 0;
}

Measured memory_bytes: 36404
#include <bits/stdc++.h>
using namespace std;
typedef string str;

int main(){
  int a, b; cin >> a >> b;
  int ans;
  str letter;
  if((a+b)%2 == 0){
    ans = (a+b)/2;
    cout << ans << endl;
    return 0;
  }else{
    letter = "IMPOSSIBLE";
    cout << letter << endl;
    return 0;
  }
}

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

using namespace std;

const int N = 1e5 + 8;
int a[N] , n , p , x , cnt , ans;

int main()
{
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	sort(a , a + n);
	while(p < n)
	{
		cnt = 1;
		x = a[p];
		while(a[p + 1] == x)
			p++ , cnt++;
		if(cnt > x)
			ans += (cnt - x);
		else if(cnt < x)
			ans += cnt;
		p++;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll n, k, h[200020];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h + n);

    ll ans = 0;
    for (int i = 0; i < n - k; i++) ans += h[i];
    cout << ans << endl;


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
    {  int n;
    cin>>n;
      string s;
      cin>>s;
      string t="ABC";
      string k;
      for(int i=0;i<3;i++)
      k+=s[i];
      ll int ans=0;
    if(k==t)
      ans++;
     for(int i=3;i<s.length();i++)
     {
       k.erase(k.begin());
       k.push_back(s[i]);
       if(k==t)
       ans++; 
     }
    cout<<ans<<endl;
  
  
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string s;
    cin >> s;

    string hi="hi";
    REP(i,5){
        if(s == hi){
            cout << "Yes" << endl;
            return 0;
        }
        hi += "hi";
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
import kotlin.comparisons.*
import java.util.*

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(' ').map(String::toInt)
  val a = BooleanArray(n)
  repeat(m) {
    a[readLine()!!.toInt() - 1] = true
  }
  val dp = IntArray(n + 1)
  dp[0] = 1
  for (i in 1..n) {
    if (a[i - 1]) continue
    dp[i] = dp[i - 1]
    if (i != 1) {
      dp[i] += dp[i - 2]
      dp[i] %= 1000000007
    }
  }
  println(dp[n])
}


Measured memory_bytes: 39604
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


class Node(object):
    __slots__ = ('parent', 'depth', 'type', 'children')

    def __init__(self):
        self.parent = -1
        self.type = ''
        self.depth = 0
        self.children = []


def dfs(node_idx, node_list, d=0):
    node_list[node_idx].depth = d
    for child in node_list[node_idx].children:
        dfs(child, node_list, d=d + 1)
    return None


def print_result(_node):
    print('parent = ' + str(_node.parent) + ',', end=' ')
    print('depth = ' + str(_node.depth) + ',', end=' ')
    print(_node.type + ',', end=' ')
    print(_node.children)
    return None


def generate_tree(_array, node_list):
    for each in _array:
        idx, k, *children = [x for x in each]
        node_list[idx].children = children
        if k:
            node_list[idx].type = 'internal node'
        else:
            node_list[idx].type = 'leaf'
        for child in children:
            node_list[child].parent = idx
    root_idx = [i for i, x in enumerate(node_list) if x.parent == -1][0]
    node_list[root_idx].type = 'root'
    dfs(node_idx=root_idx, node_list=node_list)
    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: list(map(int, x.split())), _input[1:]))
    assert len(array) == array_length

    init_node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array, node_list=init_node_list)
    for key, node in enumerate(ans):
        print('node ' + str(key) + ':', end=' ')
        print_result(_node=node)

Measured memory_bytes: 57952
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N ;
	string S, T;

	
	cin >>N>>S>>T;
	int i = 0;
	while (i < N) {
		
			cout << S.at(i);
		
			cout << T.at(i);
		
		i++;
	}

	
	
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if n>=2 and m>=2:
    print((n-2)*(m-2))
elif n==1 and m>=2:
    print(m-2)
elif m==1 and n>=2:
    print(n-2)
elif m==1 and n==1:
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, m, ans=0;
int a[N];
vector<int> v;

int32_t main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i];
	sort(a+1, a+m+1);
	for(int i=2;i<=m;i++)
	{
		ans+=(a[i]-a[i-1]);
		v.push_back(a[i]-a[i-1]);
	}
	sort(v.rbegin(), v.rend());
	int rem=min(m-1, n-1);
	for(int i=0;i<rem;i++)
		ans-=v[i];
	cout<<ans;
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    map<string, int> S;
    rep(i, N)
    {
        string a;
        cin >> a;
        S[a]++;
    }
    int max = 0;
    for (auto &x : S)
    {
        int value = x.second;
        if (value > max)
        {
            max = value;
        }
    }
    for (auto p : S)
    {
        int value = p.second;
        if (value == max)
        {
            cout << p.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

vector<P> e[500010];
int color[500010];
int flag[500010];

void dfs(int p,int c){
	int i = 1;
	for(auto x : e[p]){
		if(flag[x.first]) continue;
		if(c == i) i++;
		flag[x.first] = 1;
		color[x.second] = i;
		dfs(x.first,i);
		i++;
	}
}

int main() {
	int n;
	cin >> n;
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		e[a].emplace_back(b,i);
		e[b].emplace_back(a,i);
	}
	for(int i = 1; i <= n; i++){
		if(e[i].size() == 1){
			flag[0] = 1;
			color[e[i][0].second] = 1;
			dfs(e[i][0].first,1);
			break;
		}
	}

	int ma = 0;
	for(int i = 0; i < n; i++) ma = max(ma,color[i]);
	cout << ma << endl;
	for(int i = 0; i < n-1; i++) cout << color[i] << endl;

	return 0;
}

Measured memory_bytes: 18816
a, b, c, x = 4.times.map { gets.to_i}
count = 0

(0..a).each do |d|
  (0..b).each do |e|
    (0..c).each do |f|
      count += 1 if d * 500 + e * 100 + f * 50 == x
    end
  end
end

p count


Measured memory_bytes: 14260
#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    while(a<b && a,b>=0 && a,b<=n)
    {
        a++;
        if(a==b)
            {printf("Borys");
            break;
            }
        if(b-a ==1)
        {
            printf("Alice");
             break;
        }

        b--;

    }
    return 0;
}

Measured memory_bytes: 1716
# ####################################################################
# import io
# import sys

# _INPUT = """\
# 2 3 -10
# 1 2 3
# 3 2 1
# 1 2 2
# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def p(*_a):
  # return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
yn = lambda b: print('Yes') if b else print('No')
####################################################################
N,M,C = map(int, input().split())
B = [int(i) for i in input().split()]
AA = [[int(i) for i in input().split()] for _ in range(N)]

p(B)
p(AA)

ans = 0
for A in AA:
  x = C
  for a,b in zip(A,B):
     x += a * b

  if x > 0: ans += 1

print(ans)





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

int n,k,x,y;

int main(){
    cin>>n>>k>>x>>y;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i<=k)ans+=x;
        else ans+=y;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
//i64 mod = 1e9 + 7;


i64 T, n, m;
//vector <vector<i64>> a;
//vector <i64> a;
//vector <i64> b;
//vector <i64> dp;


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


    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        i64 x = 0;
        i64 k = 0;
        i64 d = 0;

        cin >> x >> k >> d;

        i64 res = 0;

        i64 st = abs(x) / d;
        if (st >= k) {
            res = abs(x) - k*d;
        }
        else {
            res = abs(x) - st*d;
            if ((k-st) % 2) {
                res = abs(res - d);
            }
        }

        cout << res << endl;

    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
	string s;
	cin >> s;
	string k = "keyence";
	string t = s.substr(0, k.size());
	string tt = s.substr(s.size() - k.size(), k.size());
	if (t == k || tt == k)
	{
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0; i < k.size(); i++)
	{
		string t = s.substr(0, i);
		string tt = s.substr(s.size() - k.size() + i, k.size() - i);
		string ttt = t + tt;
		if (k == ttt)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


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

int n, h[101010];

int main(){
  cin >> n;
  rep(i, n) cin >> h[i];
  h[n] = 1e9 + 100;
  int res = 0, cnt = 0;
  rep(i, n){
    if(h[i + 1] <= h[i]){
      cnt++;
    }else{
      res = max(res, cnt);
      cnt = 0;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;

int main(){
  vector<lli> a(3);
  std::cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  if(a[0]%2 == 1 and a[1]%2 == 1 and a[2]%2 == 1){
    std::cout << a[0]*a[1] << std::endl;
  }else{
    std::cout << 0 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Dic = {x:0 for x in set(A)}
    if len(Dic) <= k:
        print(0)
    else:
        for y in A:
            Dic[y] += 1
        DIcsort = sorted(Dic.items(), key=lambda x: x[1])

        cnt = 0
        for i in range(len(Dic) - k):
            cnt += DIcsort[i][1]

        print(cnt)
resolve()

Measured memory_bytes: 109384
n = int(input())
if n <600:
  print(8)
elif n < 800:
  print(7)
elif n < 1000:
  print(6)
elif n < 1200:
  print(5)
elif n < 1400:
  print(4)
elif n < 1600:
  print(3)
elif n < 1800:
  print(2)
else:
  print(1)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin >> N;
    long long ans = 0;
    for (long long i=1;i*i<N;i++) {
        if (N%i==0 && i<N/i-1) {
            ans += N/i - 1;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int n;
ll ans = 1, nodes;
ll l[N], r[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n + 1);
    for (auto& i : a) cin >> i;

    for (int i = n; i > 0; --i) {
        if (i == n) {
            l[i] = r[i] = a[i];
        } else {
            l[i] = ceil((long double)l[i + 1] / 2), r[i] = r[i + 1];
            l[i] += a[i], r[i] += a[i];
        }
    }

    if (a[0] > 1) {
        cout << -1;
        return 0;
    }

    nodes = !a[0];
    for (int i = 1; i <= n; ++i) {
        // cout << l[i] << ' ' << r[i] << '\n';
        if (nodes * 2 < l[i]) {
            cout << -1;
            return 0;
        }

        nodes = min(nodes * 2, r[i]);
        ans += nodes;
        nodes -= a[i];
    }

    cout << ans;
}



Measured memory_bytes: 5564
import java.util.*;

public class Main {
    public static void main(String[] args) {
           Scanner scanner = new Scanner(System.in);
           int N = scanner.nextInt();
           int bit = 0;
           for(int i = 0; i < N; i++) {
               bit |= scanner.nextInt();
           }
           System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

Measured memory_bytes: 21588
#include <iostream>

int main(){
  int n,q;
  int tmp;
  int cnt = 0;
  std::cin >> n;
  int s[n];
  for(int i=0;i<n;i++){
    std::cin >> s[i];
  }
  std::cin >> q;
  int t[q];
  for(int i=0;i<q;i++){
    std::cin >> t[i];
  }
  for(int i=0;i<q;i++){
    tmp = t[i];
    for(int j=0;j<n;j++){
      if(s[j]==tmp){
	cnt++;
	break;
      }
    }
  }
  std::cout << cnt << "\n";
  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<cassert>
 
struct Meirei{
    std::string mei;
    std::string str;
};

struct Node{
	Node(){
		umu=false;
		a=NULL;
		c=NULL;
		g=NULL;
		t=NULL;
	}
	bool umu;
	Node* a;
	Node* c;
	Node* g;
	Node* t;
};

class Tree
{
public:
	Tree(){
		m_root=new Node();
	}
	void insert(std::string moji);
	bool find(std::string moji);
	
private:
	Node* m_root;
};

void Tree::insert(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				node->a = new Node();
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				node->c =  new Node();
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				node->g = new Node();
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				node->t = new Node();
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	node->umu=true;
}

bool Tree::find(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				return false;
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				return false;
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				return false;
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				return false;
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	if(node->umu){
		return true;
	}
	return false;
}



//typedef std::vector<MEIREI> VecMeirei;
//typedef std::vector<std::string> WORDS;
//typedef std::vector<bool> ARINASHI;
//void input();
//bool find(WORDS jisho, std::string str);
void output(bool result);
//-------------------------------------------------------------------
int main()
{
    Tree tree=Tree();
    
    long n;
    std::cin >> n;
	for(int i=0; i<n; i++){
		std::string meirei;
	    std::cin >> meirei;
		std::string moji;
		std::cin >> moji;
		if(meirei=="insert"){
		    tree.insert(moji);
	    }else if(meirei=="find"){
	     	output(tree.find(moji));
	    }
	}
    return 0;
}
//-------------------------------------------------------------------
void output(bool result)
{
    if(result){
        std::cout << "yes" << std::endl;
    }else{
        std::cout << "no" << std::endl;
    }
    return;
}
//-------------------------------------------------------------------

Measured memory_bytes: 19444
#include <cstdio>

typedef long long ll;

int main(void){

    int N;
    scanf("%d",&N);

    int cnt = 0;
    for(int A = 1; A < N; A++){
        for(int AB = A; AB < N; AB+=A){
            if(N/AB)cnt++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

vi wt,val;

void solve(){    

    int n,W;
    cin>>n>>W;
    wt.resize(n);
    val.resize(n);

    fo(i,n) cin>>wt[i]>>val[i];

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

    for(int i = 1;i<n+1;i++){
        for(int j = 1;j<W+1;j++){
            if(wt[i-1]<=j)
                dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout<<dp[n][W];

}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 82524
#include <bits/stdc++.h>
#define ll long long

using namespace std;

string a;
int n;
ll ans=0;
void solve(int x,ll cnt){
    if(x==n){
        ans+=cnt;
        return;
    }
    ll o=0;
    for(int i=x;i<n;i++){
        o=(o*10)+(a[i]-'0');
        solve(i+1,cnt+o);
    }
}
int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin>>a;
    n=a.size();
    solve(0,0);
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    vector<int> cnt(2,0);
    rep(i,n){
        cnt[int(s[i]-'0')]++;
    }
    cout<<min(cnt[0],cnt[1])*2<<endl;
}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        
        while(true){
            int a=sc.nextInt();
        	String op=sc.next();
        	int b=sc.nextInt();
        
        	if(op.equals("?"))
                break;
            
            if(op.equals("+")){
                System.out.println(a+b);
            }else if(op.equals("-")){
                System.out.println(a-b);
            }else if(op.equals("*")){
                System.out.println(a*b);
            }else{
                System.out.println(a/b);
            }
        }
	}
}



Measured memory_bytes: 26408
import java.util.Scanner;

public class Main {


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

        int N = sc.nextInt();

        int[] A = new int[100000];
        int[] B = new int[100000];
        int[] C = new int[100000];

        int[][] dp = new int[100000][3];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }

        sc.close();

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                if (i == 0) {
                    if (j == 0) { dp[i][j] = A[i]; }
                    else if (j == 1) { dp[i][j] = B[i]; }
                    else { dp[i][j] = C[i]; }
                } else {
                    for (int k = 0; k < 3; k++) {
                        if (j == k) { continue; }
                        if (j == 0) { dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + A[i]); }
                        else if (j == 1) { dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + B[i]); }
                        else { dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + C[i]); }
                    }
                }
            }
        }

        int ret = 0;
        ret = Math.max(ret, dp[N-1][0]);
        ret = Math.max(ret, dp[N-1][1]);
        ret = Math.max(ret, dp[N-1][2]);

        System.out.println(ret);
    }
}

Measured memory_bytes: 98096
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};

int n,m;
vector<edge> G[105];
int cnt[101];


void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

vector<int> vec;
bool used[101];

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

void solve(){
	for(int i=0;i<n;i++){
		G[i].clear();
	}
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		add_edge(u,v,1);
		cnt[u]++;
	}
	bool update=true;
	while(update){
		update=false;
		int p_min=0,p_max=0;
		for(int i=1;i<n;i++){
			if(cnt[p_min]>cnt[i]){
				p_min=i;
			}
			if(cnt[p_max]<cnt[i]){
				p_max=i;
			}
		}

		for(int i=0;i<n;i++){
			if(!update && cnt[p_min]+1<cnt[i]){
				memset(used,false,sizeof(used));
				int val=dfs(i,p_min,1);
				if(val==1){
					update=true;
					cnt[i]--;
					cnt[p_min]++;
					break;
				}
			}
		}
		for(int i=0;i<n;i++){
			if(!update && cnt[i]+1<cnt[p_max]){
				memset(used,false,sizeof(used));
				int val=dfs(p_max,i,1);
				if(val==1){
					update=true;
					cnt[p_max]--;
					cnt[i]++;
					break;
				}
			}
		}
		if(!update){
			printf("%d %d\n",cnt[p_min],cnt[p_max]);
			return;
		}
	}
}

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		solve();
	}
	return 0;
} 


Measured memory_bytes: 3304
<?php
$input = explode(' ', trim(fgets(STDIN)));
 
$a = $input[0];
$b = $input[1];
$c = $input[2];
 
if (($a == $b && $b != $c) || ($a == $c && $b != $c)  || ($b == $c && $a != $c)) {
	echo 'Yes';
}else{
	echo 'No';
}

Measured memory_bytes: 4604
a, b, c = map(int,input().split())
if a == 7:
    if b==5 and c ==5:
        print ("YES")
    else:
        print ("NO")
elif b != 7 and c !=7:
    print ("NO1")
elif b ==7:
    if a==5 and c ==5:
        print ("YES")
    else:
        print ("NO")
elif a==5 and b ==5:
    print ("YES")
else:
    print ("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#define bound 200
using namespace std;

char map[bound][bound];
int run[bound][bound]={0};
int dir[8][2]={{1,0},{1,1},{1,-1},{0,1},{0,-1},{-1,1},{-1,0},{-1,-1}};

void BFS(int i,int j)
{
	int dx,dy,x;
	for(x=0;x<8;++x)
	{
		dx=i+dir[x][0];
		dy=j+dir[x][1];
		if(map[dx][dy]!='#')
		{
			run[dx][dy]++;
		}
	}
} 
int main()
{
	int h,w,i,j;
	cin>>h>>w;
	for(i=0;i<h;++i)
		cin>>map[i];
	for(i=0;i<h;++i)
	{
		for(j=0;j<w;++j)
		{
			if(map[i][j]=='#')
			{
				BFS(i,j);
			}
		}
	}
	for(i=0;i<h;++i)
	{
		for(j=0;j<w;++j)
		{
			if(map[i][j]=='#')cout<<'#';
			else cout<<run[i][j];
		}
		cout<<endl;
	}
}

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

void solve(std::string s, long long K) {
    for(int i= 0;i<s.size();i++){
      if(i == s.size()-1){K%=26;while(K--)if(s.back() == 'z')s.back() = 'a'; else s.back()++;}
      else if(s[i] == 'a')continue;
      else if('z'+1-s[i]<=K){
        K-='z'+1-s[i];
        s[i] = 'a';
        if(K == 0)break;
       // cout<<K;
      }
    }
    cout<<s;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string s;
  std::cin >> s;
  long long K;
  scanf("%lld", &K);
  solve(s, K);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 1; i < B; i++) {
		int X = A * i;
        
		X %= B;

		if (X == C) {
			cout << "YES" << endl;
			return 0;
		}

	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#define mod 1000000007;
using namespace std;
typedef long long ll;
int main()
{   ll n,m,sum=0,j,t,t1,i;
  cin>>n>>m;
   for(i=m;i<=n+1;i++)
   {   t=(i-1)*i/2;
       t1=(n-i+1+n)*i/2;
             sum=(sum+t1-t+1)%mod;
            
        
	} 
	cout<<sum<<endl;
}

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

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

    // 累積和を求める
    vector<int> c(N + 1, 0);
    for (int i = 1; i < N; ++i) {
        int a = 0;
        if (S[i - 1] == 'A' && S[i] == 'C') a = 1;
        c[i + 1] = c[i] + a;
    }

    // 各クエリに答える
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        --l;
        int result = c[r] - c[l];
        if (l > 0 && S[l - 1] == 'A' && S[l] == 'C') --result;
        cout << result << endl;
    }
}

Measured memory_bytes: 3804
import numpy as np
from itertools import accumulate
N =int(input())
S = input()

s = np.array(list(S))

k = np.where(s=="#", 1, 0)

l = [0] + list(accumulate(k))
ans = []
for i in range(N+1):
    p = l[i] +  N-i-l[N]+l[i]
    ans.append(p)

print(min(ans))


Measured memory_bytes: 31564