akhauriyash/Code-Regression huggingface dataset:
import math
import copy
 
def secize(n, k):
    n2=bin(n)
    n3=n2[2:]
    for i in range(k-len(n2)+2):
        n3='0'+n3
    return n3
 
 
n=int(input())
alist = list(map(int,input().split()))
saidai=max(alist)
keta=math.ceil(math.log(saidai+1, 2))
blist=[]
for i in range(n):
    kaz=secize(alist[i], keta)
    blist.append(kaz)
 
now1=0
now2=0
nowarr=[]
for bl in blist[0]:
    nowarr.append(int(bl))
answer=0
swit=0
while now1<=n-2 and now2<=n-2:
    """
    maearr=copy.deepcopy(nowarr)
    for i in range(keta):
        if blist[now2+1][i]=='1':
            if nowarr[i]==1:
                swit=1
            else:
                nowarr[i]=1
    """
    for i in range(keta):
        if blist[now2+1][i]=='1':
            if nowarr[i]==1:
                swit=1
            else:
                nowarr[i]=2
    if swit==1:
        for i in range(keta):
            if nowarr[i]==2:
                nowarr[i]=0
        answer+=(now2-now1+1)
        #nowarr=maearr
        for i in range(keta):
            if blist[now1][i]=='1':
                nowarr[i]=0
        if now1==now2:
            nowarr=[]
            for bl in blist[now1+1]:
                nowarr.append(int(bl))
            now1+=1
            now2+=1
            if now1==n-1:
                answer+=1
        else:
            now1+=1
        swit=0
    else:
        for i in range(keta):
            if nowarr[i]==2:
                nowarr[i]=1
        if now2!=n-2:
            now2+=1
        else:
            wa=now2-now1+2
            answer+=(wa*(wa+1)//2)
            now2+=1
 
#print(now1, now2)
if n!=1:
    print(answer)
else:
    print(1)

Measured memory_bytes: 108016
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int A,B;
int X[101][101];
int main(){
	REP(i,101){
		REP(j,101){
			if(i<51){
				X[i][j]=0;
			}else{
				X[i][j]=1;
			}
		}
	}
	cin>>A>>B;
	A--;
	B--;
	int r=0;
	int c=0;
	while(A>0){
		A--;
		X[r][c]=1;
		if(c<96){
			c+=2;
		}else{
			r+=2;
			c=0;
		}
	}
	
	r=60;
	c=0;
	while(B>0){
		B--;
		X[r][c]=0;
		if(c<96){
			c+=2;
		}else{
			r+=2;
			c=0;
		}
	}
	
	cout<<100<<" "<<100<<endl;
	REP(i,100){
		string s="";
		REP(j,100){
			if(X[i][j]==1){
				s.push_back('.');
			}else{
				s.push_back('#');
			}
		}
		cout<<s<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define REP(i,n) for (int i = 0; i <(n); ++i)
  #define ALL(v) v.begin(), v.end()
  using namespace std;
  using ll = long long;
  using P = pair<int,int>;
  static const double PI = acos(-1);



  int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> point(n);

    REP(i,q){
      int a;
      cin >> a;
      --a;
      ++point[a];
    }

    REP(i,n){
      if(k - q + point[i] > 0) cout << "Yes" << endl;
      else cout << "No" << endl;
    }

    return 0;
  }

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

struct Edge {
    long long to, id;
};
using Graph = vector<vector<Edge>>;

vector<int> path;
bool dfs(const Graph &G, int u, int v, int p) {
    if (u == v) {
        return true;
    }
    for (auto e : G[u]) {
        if (e.to != p) {
            if (dfs(G, e.to, v, u)) {
                path.push_back(e.id);
                return true;
            }
        }
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
    }

    int M;
    cin >> M;

    // 制約ごとに、白くなる辺を入れておく
    vector<ll> cons(M);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        path = vector<int>();
        dfs(G, u, v, -1);  // 制約ごとに、白くなる辺をDFSで見つけ、pathに格納する
        for (auto e : path) {
            cons[i] |= 1LL << e;
        }
    }

    // 包除原理
    ll ans = 0;
    rep(bit, 1LL << M) {
        ll eset = 0;
        rep(i, M) {
            if (bit & (1LL << i)) {
                eset |= cons[i];
            }
        }
        int white = __builtin_popcountll(eset);  // 白くなるべき辺の数
        ll num = 1LL << (N - 1 - white);
        if (__builtin_popcountll(bit) % 2 == 0) {  // 制約が偶数か奇数か
            ans += num;
        } else {
            ans -= num;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 100000000;

void solve()
{
	int a, b, x;
	scanf ("%d%d%d", &a, &b, &x);
	printf("%d\n", b/x - (a-1) / x);
}

int main()
{		
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

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

int main(){
  long long n,m;
  cin >> n >> m;
  cout << n*m/gcd(n,m) << endl;
}

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

using namespace std;

namespace {
    typedef long long ll;

    int N;
    string s, t;
    void input() {
        cin >> N;
        cin >> s;
        cin >> t;
    }

    const ll MOD = 1e9 + 7;

    void solve() {
        ll ans = (s[0] == t[0] ? 3 : 6);
        for (int i = (s[0] == t[0] ? 1 : 2); i < N; i++) {
            if (s[i - 1] == t[i - 1]) {
                if (s[i] == t[i]) {
                    ans *= 2;
                } else {
                    i++;
                    ans *= 2;
                }
            } else {
                if (s[i] == t[i]) {
                    ans *= 1;
                } else {
                    i++;
                    ans *= 3;
                }

            }
            ans %= MOD;
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i;
  cin >> n;
  vector<int> d(n,0);
  for (i=0;i<n;i++) cin >> d.at(i);
  sort(d.begin(),d.end());
  cout << d.at(n/2)-d.at(n/2-1) << endl;
  return 0;
}

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

int main(void){
  ll x; cin >> x;
  for(ll a = -1000;a<=1000;a++){
    for(ll b = -1000;b<=1000;b++){
      ll t1 = a*a*a*a*a;
      ll t2 = b*b*b*b*b;
      if(x==t1-t2){
	cout << a << " " << b << endl;
	return 0;
      }
    }
  }
  
  return 0;
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<ll,pair<int,int>> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int a[100010];

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

//    map<char,char> mp;
//    mp['A'] = 'T';
//    mp['T'] = 'A';
//    mp['C'] = 'G';
//    mp['G'] = 'C';
//
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    REP(i,sz(s)-1) {
        if (s[i] == 'A' && s[i+1] == 'C') a[i]++;
    }
    REP(i,n) {
        a[i+1] += a[i];
    }
    REP(i,q) {
        int aa,b;
        cin >> aa >> b;
        aa--;
        b--;
        cout << a[b-1] - a[aa-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>
#include <vector>
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;
 
signed main() {
    FAST_IO;
 
    int n, k;
    cin >> n >> k;
    vector<int> stones(n);
    for (int i = 0; i < n; i++) cin >> stones[i];
 
    vector<int> dp(n, INF); 
    dp[0] = 0; 
 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j <= i + k; j++) { 
            if (j < n)
                
                dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        h.push_back(x);
    }
    vector<int> a(n, 0);
    a[0] = 0;
    for (int i = 1; i < n; i++) {
        int m = INT_MAX;
        for (int j = max(i - k, 0); j < i; j++) {
            m = min(m, abs(h[i] - h[j]) + a[j]);
        }
        a[i] = m;
    }
    cout << a[n - 1] << endl;
}


Measured memory_bytes: 1144
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = min(a)
a += [p]
ans,i,temp = 0,0,0
while i<n:
  if a[i]==p:
    m = -(-(i-temp)//(k-1))
    ans += m
    temp += m*(k-1)+1
    i = temp
  else:
    i += 1
ans += -(-(n-temp)//(k-1))
print(ans)

Measured memory_bytes: 20456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
int main()
{
       ll k,n;
       cin>>k>>n;
       ll a[n];
       arrin(a,n);
       ll xx[n];
       xx[0] = a[0];
       ll maxi = 0;
       fri(i,1,n){
              xx[i] = a[i]-a[i-1];
              maxi = max(xx[i],maxi);
       }
       maxi = max(k-a[n-1]+a[0],maxi);
       cout<<k-maxi<<endl;


}


Measured memory_bytes: 3968
#include<cstdio>
#include<map>
using namespace std;
map<pair<int,int>,int>M;
char buf[2000];
int sz;
int N;
int x[50],y[50];
main()
{
	fread(buf,1,2000,stdin);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(int i=0;i<N;i++)
	{
		bool neg=buf[sz]=='-'?++sz:false;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			x[i]=x[i]*10+k-'0';
		}
		if(neg)x[i]=-x[i];
		neg=buf[sz]=='-'?++sz:false;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			y[i]=y[i]*10+k-'0';
		}
		if(neg)y[i]=-y[i];
	}
	int ans=N;
	M[make_pair(0,0)]=-N;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			int now=N-++M[make_pair(x[i]-x[j],y[i]-y[j])];
			if(ans>now)ans=now;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<stdbool.h>
using namespace std;
int main(){
    int n,i,u,iii;
    char c;
    bool cards[4][13]={false};//true=??? false=???
    cin>>n;
        for(i=0;i<n;++i){
            cin>>c>>u;
            if(c=='S'){cards[0][u-1]=true;}
        else if(c=='H'){cards[1][u-1]=true;}
        else if(c=='C'){cards[2][u-1]=true;}
        else if(c=='D'){cards[3][u-1]=true;}
        }
            for(iii=1;iii<=13;++iii){
            if(cards[0][iii-1]==false){c='S';
                cout<<c<<" "<<iii<<endl;
            }}
        for(iii=1;iii<=13;++iii){
            if(cards[1][iii-1]==false){c='H';
                cout<<c<<" "<<iii<<endl;
            }}
        for(iii=1;iii<=13;++iii){
            if(cards[2][iii-1]==false){c='C';
                cout<<c<<" "<<iii<<endl;
            }}
        for(iii=1;iii<=13;++iii){
            if(cards[3][iii-1]==false){c='D';
                cout<<c<<" "<<iii<<endl;
            }}

    


return 0;}

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

int main() {
  int n; 
  cin >> n;
  int arr[] = {0, 0, 0, 0};
  string str;
  while(cin >> str) {
    if (str == "AC") {
      (arr[0])++;
    }
    if (str == "WA") {
      (arr[1])++;
    }
    if (str == "TLE") {
      (arr[2])++;
    }
    if (str == "RE") {
      (arr[3])++;
    }
  }
  
  cout << "AC x " << arr[0] << endl;
  cout << "WA x " << arr[1] << endl;
  cout << "TLE x " << arr[2] << endl;
  cout << "RE x " << arr[3] << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 10;
int n, l[N], id[N], a[3], ans;

void calc() {
	int cnt[3] = {0, 0, 0}, len[3] = {0, 0, 0};
	Foz(i, n) if (id[i] != -1) {
		cnt[id[i]]++; len[id[i]] += l[i];
	}
	int t = 0;
	Foz(i, 3) {	
		if (!cnt[i]) return;
		t += (cnt[i] - 1) * 10 + abs(a[i] - len[i]);
	}
	ans = min(ans, t);
}

void f (int i) {
	if (i == n) { calc(); return; }
	For(j, -1, 3) { id[i] = j; f(i + 1); }
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n;
	Foz(i, 3) cin >> a[i];
	Foz(i, n) cin >> l[i];
	ans = (int)1e9;
	f(0);
	cout << ans << '\n';
}



Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
pair<int,int> a[11000],b[11000];
int sm,l;
int fi(int i,int p){
  for(;sm<p;++i)
    sm+=a[i].second;
  if(sm>p){
    copy_backward(a+i,a+l,a+l+1);
    ++l;
    a[i-1].second-=sm-p;
    a[i]=make_pair(a[i-1].first+a[i-1].second,sm-p);
    sm=p;
  }
  return i;
}
int main(){
  int i,j,k;
  int n;
  while(cin>>n,n){
    int m,p,q,r;
    cin>>m>>p>>q>>r;
    if(r==n){
      for(i=0;i<m;++i){
	int x,y;
	cin>>x>>y;
      }
      cout<<q-p+1<<endl;
      continue;
    }else{
      a[0]=make_pair(1,r);
      a[1]=make_pair(r+1,n-r);
      l=2;
    }
    for(i=0;i<m;++i){
      int x,y;
      cin>>x>>y;
      sm=0;
      j=fi(0,x);
      k=fi(j,y);
      copy(a+k,a+l,b);
      copy(a+j,a+k,b+l-k);
      copy(a,a+j,b+l-j);
      copy(b,b+l,a);
    }
    sm=0;
    j=fi(0,p-1);
    k=fi(j,q);
    int ct=0;
    for(i=j;i<k;++i){
      if(a[i].first<=r)
	ct+=a[i].second;
    }
    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    if(n>=400&&n<=599){cout<<8<<endl;}
    if(n>=600&&n<=799){cout<<7<<endl;}
    if(n>=800&&n<=999){cout<<6<<endl;}
    if(n>=1000&&n<=1199){cout<<5<<endl;}
    if(n>=1200&&n<=1399){cout<<4<<endl;}
    if(n>=1400&&n<=1599){cout<<3<<endl;}
    if(n>=1600&&n<=1799){cout<<2<<endl;}
    if(n>=1800&&n<=1999){cout<<1<<endl;}
}


Measured memory_bytes: 3648
#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);
  int n; cin >> n;
  string s; cin >> s;
  V<> b(n + 1), w(n + 1);
  for (int i = 0; i < n; ++i) {
    b[i + 1] = b[i] + (s[i] == '#');
    w[i + 1] = w[i] + (s[i] == '.');
  }
  int res = 1e9;
  for (int i = 0; i <= n; ++i) {
    res = min(res, b[i] + w[n] - w[i]);
  }
  cout << res << '\n';
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q;
	vector<long long> S(n);
	long long T;
	cin >> n;
	int roop;
	for(roop=0;roop<n;roop++){
		cin >> S[roop];
	}
	int roop2,count=0;
	S.erase(unique(S.begin(),S.end()),S.end());
	n=(int)S.size();
	cin >> q;
	for(roop=0;roop<q;roop++){
		cin >> T;
		if(S[n/2]<T){
			for(roop2=n/2+1;roop2<n;roop2++){
				if(S[roop2]!=T){
					continue;
				}else{
					count++;
					break;
				}
			}
		}else if(S[n/2]>T){
			for(roop2=0;roop2<n/2;roop2++){
				if(S[roop2]!=T){
					continue;
				}else{
					count++;
					break;
				}
			}
		}else{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 35396
#include<stdio.h>

double h(double x1,double y1,double x2,double y2){
	if((x1-x2)==0)return 65535;
	else return (y1-y2)/(x1-x2);
}

int main(){
	int i,j,n;
	double x[4],y[4],ab,cd;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<4;j++)scanf("%lf%lf",&x[j],&y[j]);
		ab=h(x[0],y[0],x[1],y[1]);
		cd=h(x[2],y[2],x[3],y[3]);
		if(ab==cd)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int arr[105][105];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, w, n;
	cin >> h >> w;
	int i = 1, j = 1;
	cin >> n;
	for(int c = 1; c <= n; c++)
	{
		int a;
		cin >> a;
		while(a--)
		{
			arr[i][j] = c;
			if(i & 1)
			{
				if(j == w)
					i++;
				else
					j++;
			}
			else
			{
				if(j == 1)
					i++;
				else
					j--;
			}
		}
	}
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
			cout << arr[i][j] << ' ';
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i)cin>>vec[i];
	vector<int> table(n, 0);
	table[0] = 0;
	for(int i = 1; i < n; ++i){
		if(vec[i] <= vec[i - 1])table[i] = table[i - 1] + 1;
		else table[i] = 0;
	}
	int res = 0;
	for(int i = 0; i < n; ++i)res = max(res, table[i]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<20;
ll n,dat[2*MAX_N-1] = {},lazy[2*MAX_N-1] = {},dp[200010];
bool flag[2*MAX_N-1];
vector<pair<ll,ll>> v[200010];
void init(int m){
	n = 1;
	while(n<m) n *= 2;
	for(int i=0;i<2*n - 1;i++) flag[i] = false;
}
void eval(int k, int l, int r){
	if(flag[k]){
		dat[k] += lazy[k];
		if(r - l>1){
			lazy[2*k+1] += lazy[k]; flag[2*k+1] = true;
			lazy[2*k+2] += lazy[k]; flag[2*k+2] = true;
		}
		lazy[k] = 0; flag[k] = false;
	}
}

void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
	if(r<0) r = n;
	eval(k,l,r);
	if(b<=l || r<=a) return;
	if(a<=l && r<=b){
		lazy[k] += x; flag[k] = true;
		eval(k,l,r);
	}else{
		add(a,b,x,2*k+1,l,(l+r)/2); add(a,b,x,2*k+2,(l+r)/2,r);
		dat[k] = max(dat[2*k+1],dat[2*k+2]);
	}
}

ll query(int a, int b, int k, int l, int r){
	eval(k,l,r);
	if(r<=a || b<=l){
		return 0;
	}
	if(a<=l && r<=b){
		return dat[k];
	}else{
		ll vl = query(a,b,k*2+1,l,(l+r)/2);
		ll vr = query(a,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
}

int main(){
	ll i,j,m,q;
	cin >> m >> q;
	for(i=0;i<q;i++){
		int l,r,a;
		cin >> l >> r >> a;
		v[r].push_back({l,a});
	}
	init(m + 1);
	dp[0] = 0;
	for(i=1;i<=m;i++){
		dp[i] = query(0,i,0,0,n);
		add(i,i + 1,dp[i],0,0,n);
		for(auto x:v[i]){
			add(x.first,i + 1,x.second,0,0,n);
		}
	}
	cout << query(0,m + 1,0,0,n) << endl;
}

Measured memory_bytes: 22912
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    bool abc=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0){
            if(!(a[i]%3==0||a[i]%5==0))
                abc=0;
        }
    }
    if(abc==0)cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
using namespace std;
#define dbg(x) cerr << #x " = " << x <<endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		if((i >= 1 && i <= 9) || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999))
		{
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

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



int main(){
    long int n;
    cin >> n;
    if (n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    long int num2 = 0;
    long int p = 2;
    while(p <= n){
        num2 += n / p;
        p *= 2;
    }
    long int num5 = 0;
    p = 5;
    while(p <= n){
        num5 += (n / p) / 2;
        p *= 5;
    }
    long int ans = min(num2, num5);
    cout << ans << endl;
}

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

int main() {
  ll n;
  cin >> n;
  ll d1,d2;
  ll sum=0;
  for (ll i=0;i<n;i++) {
    cin >> d1 >> d2;
    if (d1==d2) sum++;
    else sum=0;
    if (sum==3) break;
  }
  if (sum==3) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 3632
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long
#define pii pair<intt,intt>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;

/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

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

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

intt n, m, source;
intt a, b, c;
vector <pii> g[maxx];
intt used[maxx], dis[maxx];
priority_queue <pii, vector <pii>, greater <pii> > pq;
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    cin >> n >> m >> source; source++;
    for (intt i = 1; i <= m; i++) {
        cin >> a >> b >> c; a++, b++;
        g[a].pb ({b, c}); //g[b].pb ({a, c}); delete "//" if graph is undirected
    }
    for (intt i = 1; i <= n; i++) dis[i] = INF;
    dis[source] = 0;
    pq.push ({0, source});
    while (!pq.empty()) {
        a = pq.top().S; pq.pop();
        if (used[a]) continue; used[a] = 1;
        for (auto u : g[a]) {
            b = u.F, c = u.S;
            if (dis[a] + c < dis[b]) {
                dis[b] = dis[a] + c;
                pq.push ({dis[b], b});
            }
        }
    }
    for (intt i = 1; i <= n; i++) {
        if (dis[i] == INF)
            cout << "INF" << endl;
        else
            cout << dis[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 20256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (n, m, q): (usize, usize, usize),
        abcds: [(usize, usize, usize, usize); q]
    };

    let mut ans = 0;
    let mut v = vec![0; n + 1];
    f(1, 1, m, &mut v, &mut ans, &abcds);

    println!("{}", ans);
}

fn f(
    i: usize,
    s: usize,
    m: usize,
    v: &mut Vec<usize>,
    ans: &mut usize,
    abcds: &Vec<(usize, usize, usize, usize)>,
) {
    if i == v.len() {
        let mut acc = 0;
        for abcd in abcds {
            if v[abcd.1] - v[abcd.0] == abcd.2 {
                acc += abcd.3;
            }
        }

        if acc > *ans {
            *ans = acc;
        }
        return;
    }

    for j in s..=m {
        v[i] = j;
        f(i + 1, j, m, v, ans, abcds);
    }
}


Measured memory_bytes: 2208
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

import sys

# input = sys.stdin.readline
sys.setrecursionlimit(400*400*10)
MOD = 10 ** 9 + 7

H, W = [int(x) for x in input().split()]
S = []
for _ in range(H):
    S.append(input())

T = [[0] * W for _ in range(H)]

t = 1


def f(h, w):
    cb = cw = 0
    dh = [1, -1, 0, 0]
    dw = [0, 0, 1, -1]

    for i in range(4):
        h2 = h + dh[i]
        w2 = w + dw[i]
        if h2 >= 0 and h2 < H and w2 >= 0 and w2 < W:
            # 未調査 かつ 色違い
            if T[h2][w2] == 0:
                if S[h][w] != S[h2][w2]:
                    T[h2][w2] = 1
                    if S[h2][w2] == "#":
                        cb += 1
                    if S[h2][w2] == ".":
                        cw += 1
                    cb2, cw2 = f(h2, w2)
                    cb += cb2
                    cw += cw2
    return cb, cw


area = []
for h in range(H):
    for w in range(W):
        if S[h][w] == "#" and T[h][w] == 0:
            tmp = f(h, w)
            if tmp[0]*tmp[1] != 0:
                area.append(tmp)

ans = 0
for a in area:
    ans += a[0]*a[1]

print(ans)



Measured memory_bytes: 188508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

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

  string s;
  cin >> s;
  int n = s.size();
  for(int i = 2; i < n; i+=2){
    string ss = s.substr(0,n-i);
    int nn = ss.size();
    string s1 = ss.substr(0,nn/2);
    // cout << "s1 = " << s1 << endl;
    string s2 = ss.substr(nn/2,nn/2);
    // cout << "s2 = " << s2 << endl;
    if(s1 == s2){
      cout << nn << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  for(Int i=0;i<max(a,b);i++) cout<<min(a,b);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 384
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた!

# 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン
# 愚直にやると2^Nを調べねばならず無理。
# したがって「一部を調べればよい」に帰着するのが多いだろう。
# 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。

# 今回は全体集合から1つずつ取り去るのを考えるとできる。
# 全体集合である競技m0が最多の人数p0人を集めたとする。
# すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。
# ここで「m0を含む集合」について一気に計算できていることに注意! 一撃で多数の集合について計算が終わる。
# 次に全体集合からm0を取り去ったものを考える。
# ここである競技m1が最多の人数p1人を集めたとする。すると……以下同様。
# なお複数種目の競技が同率1位になった場合は全て一度に取り除いて良い。
# これで空集合までやって、最大が最小のものを出力すればOK! 

n, m = list(map(int, input().split()))
preference = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)] # 1-index → 0-index

ans = n
held_sports = set(range(m))

while held_sports:
    # 各競技に参加する人数を求める
    parti = [0] * m
    for person in range(n):
        for s in range(m):
            if preference[person][s] in held_sports:
                parti[preference[person][s]] += 1
                break
    
    temp = max(parti)
    ans = min(ans, temp)
    # 集合から最大人数を取った要素を除外
    for idx, par in enumerate(parti):
        if par == temp:
            held_sports.remove(idx)

print(ans)

Measured memory_bytes: 10164
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

struct edge {
    int u;
    int v;
    int cost;
    bool operator<(const edge& r) const {
        return cost < r.cost;
    }
};

const int MAXM = 10000;
const int MAXN = 110;
edge es[MAXM];

int par[MAXN];
int rankrank[MAXN];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rankrank[i] = 0;
    }
}

int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rankrank[x] < rankrank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rankrank[x] == rankrank[y]) rankrank[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int kruskal(int m) {
    sort(es, es+m);
    int ret = 0;
    for (int i = 0; i < m; i++) {
        edge e = es[i];
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            ret += e.cost;
        }
    }
    return ret;
}

int main(void) {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        for (int i = 0; i < m; i++) {
            int a, b, cost;
            cin >> a >> b >> cost;
            edge e;
            e.u = a; e.v = b; e.cost = cost;
            es[i] = e;
        }
        init(n);
        cout << kruskal(m) << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll s, ans = 1;
    set<ll> st;
    cin >> s;
    while(st.count(s)==0){
        st.insert(s);
        if(s%2) s = 3*s+1;
        else s /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n;
        n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        int dp[]=new int[40050];
        for(int i=0;i<40050;i++)dp[i]=0;
        dp[0]=1;
        for(int i=0;i<n;i++){
            for(int j=40010;j>=0;j--){
                if(dp[j]>0)dp[j+a[i]]=1;
            }
        }
        int q;
        q=sc.nextInt();
        int c;
        while(q>0){
            q--;
            c=sc.nextInt();
            if(dp[c]==1) System.out.println("yes");
            else  System.out.println("no");
        }
       }
}


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

int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    if (q*2 < h) h = q*2;
    if (h*2 < s) s = h*2;
    if (s*2 < d) d = s*2;

    cout << d*(n/2)+s*(n%2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int ans=0;
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m,vector<int>(0));
    for (int i=0; i<m; i++){
            int k;
            cin>>k;
            for (int j=0; j<k; j++){
                    int a;
                    cin>>a;
                    s[i].push_back(a);
                }           
        }
    vector<int> p(m);
    for (int i=0; i<m; i++){
            cin>>p[i];
        }

    for (int bit=0;bit< (1<<n) ;bit++){
        vector<int> t;
        for (int i=0; i<n ; i++){
            if(bit & (1<<i)){
                t.push_back(i);
                }
            }
        //tの中には、どのスイッチがついているかの情報が入っている
        vector<int> count(m,0);
        for (int j=0; j<t.size(); j++){//onじょうたいの各スイッチに対する捜査
                for (int h=0; h<m; h++){//各電球に対しての調査
                        for (int l=0; l<s[h].size(); l++){
                                if (t[j]==s[h][l]-1){//スイッチと電球がつながっているなら
                                        count[h]++;
                                    }
                            }
                    }
            }
        bool ansflg=true;
        for (int i=0; i<m; i++){
                if(count[i]%2!=p[i])ansflg=false;
            }
        if(ansflg==true){
          ans++;
      	}
        }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 1;
int dp[maxN] [3];
int main( ){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n] [3];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++)
            cin >> arr[i] [j];
    }
    dp[0] [0] = arr[0] [0];
    dp[0] [1] = arr[0] [1];
    dp[0] [2] = arr[0] [2];
    for(int i = 1; i < n; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i] [j] = max(dp[i] [j], dp[i - 1] [k] + arr[i] [j]);
    int ans = 0;
    for(int i = 0; i < 3; i++)
        ans = max(ans, dp[n - 1] [i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6000
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d",&a,&b);
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>d)
    {
        if(c>e)
            printf("%d",c);
        else
            printf("%d",e);
    }
    else
        if(d>e)
        printf("%d",d);
    else
        printf("%d",e);
    return 0;
}


Measured memory_bytes: 1736
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
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;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int dp[1000000] = {};
int main() {
	int n;
	cin >> n;
	dp[300] = {};
	for (int i = 2; i <= 220; i++) {
		if (dp[i] == 0) {
			for (int j = i + i; j <= 220; j = j + i) {
				dp[j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i = i + 2) {
		int sum = 1;
		int a = i;
		for (int j = 2; j <= 220; j++) {
			if (dp[j] == 0) {
				int b = 0;
				while (a % j == 0) {
					a = a / j;
					b ++;
				}
				sum = sum * (b+1);
			}
		}
		if (sum == 8) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 5488
ichiman::Int->Int->[(Int,Int,Int)]
ichiman y m = concat [  map (\(y,z)-> (i,y,z))  (gosen (y - i*10000) (m-i))  | i<-[0 .. (div y 10000)] ]
gosen::Int->Int->[(Int,Int)]
gosen y m =  [ (\ z -> (j,z))  (div  (y - j*5000) 1000)  | j<-[0 .. (div y 5000)], div (y - j*5000) 1000 == m-j]

adjust::[(Int,Int,Int)]->(Int,Int,Int)
adjust [] = (-1,-1,-1)
adjust xs = head xs

main::IO()
main=do
  str<-getLine
  let m:y:[]=map read (words str)
  let (a,b,c)=adjust (ichiman y m)
  putStr (show a)
  putStr "\t"
  putStr (show b)
  putStr "\t"
  putStr (show c)
  putStr "\n"

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

int main(){
vector<int> vec(3);
  for(int i =0;i<3;i++){
    cin >> vec.at(i);
  }
  int K;
  cin >> K;
  sort(vec.begin(),vec.end());
  
  int sum = vec.at(0)+vec.at(1);
  int c = vec.at(2);
  for(int i =0;i<K;i++){
    c *= 2;
  }
  sum = sum + c;
  cout << sum << endl;

  
}


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

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

    cin >> N >> Q;
    cin >> S;

    int counter[N+1];
    counter[0] = 0;

    int Ls[Q], Rs[Q];
    for(int i = 0; i < Q; i++){
        cin >> Ls[i] >> Rs[i];
    }

    for(int i = 0; i < N; i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            counter[i] = counter[i-1] + 1;
        }
        else{
            counter[i] = counter[i-1];
        }
    }

    for(int i = 0; i < Q; i++){
        cout << (counter[Rs[i] - 1] - counter[Ls[i] - 1]) << '\n';
    }

    return 0;
}


Measured memory_bytes: 2176
N, M=map(int, input().split())
switches=[list(map(int, input().split())) for _ in range(M)]
p=list(map(int, input().split()))
ans=0
for i in range(2**N):
  on=[0 for _ in range(N)]
  tmp=i
  for j in range(N):
    if tmp%2==1:
      on[j]=1
    tmp=tmp//2
  flag=True
  for j in range(M):
    switch=switches[j]
    cnt=0
    for k in range(1, switch[0]+1):
      cnt+=on[switch[k]-1]
    if cnt%2!=p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

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

#define N 500

int c[N];
int s[N];
int f[N];

int wait( int i, int t )
{
	if( t <= s[i] ) {
		return s[i];
	}
	else {
		int r = (t - s[i]) % f[i];
		if( r != 0 ) {
			r = f[i] - r;
		}
		return t + r;
	}
}

int main()
{
	int ans;
	int n;

	cin >> n;
	n--;
	for( int i = 0; i < n; i++ ) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for( int i = 0; i < n; i++ ) {
		ans = 0;
		ans = s[i];
		for( int j = i; j < n; j++ ) {
			ans = wait( j, ans );
			ans += c[j];
		}
		cout << ans << endl;
	}
	cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int H, W;
  char s[105];

  cin >> H >> W;
  rep(i, 0, H) {
    cin >> s;
    puts(s);
    puts(s);
  }
  return 0;
}



Measured memory_bytes: 256
// AOJ GRL_1_C All Pairs Shortest Path
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}

#define INF (int)(10e9)

int main() {
    int NV, NE; cin >>NV>>NE;
    vvi d(NV, vi(NV, INF));
    rep(i, NV) d[i][i] = 0;
    rep(i, NE) {
        int _s, _t, _d; cin >> _s >> _t >> _d;
        d[_s][_t] = _d;
    }

    rep(k, NV) rep(i, NV) rep(j, NV) {
        if (d[i][k] != INF && d[k][j] != INF)
            chmin(d[i][j], d[i][k] + d[k][j]);
    } 

    rep(i, NV) {
        if (d[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    rep(i, NV) {
        rep(j, NV) {
            if (d[i][j] == INF) {
                cout << "INF";
            } else {
                cout << d[i][j];
            }
            cout << (j==NV-1?"\n":" ");
        }
    }
}



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

using namespace std;

int change(char a,char b,char c){
  if(a==b&&a==c) return 0;
  else {
    if(a==b) return 1;
    if(a==c) return 1;
    if(b==c) return 1;
    else return 2;
  }
}

int main(int argc,char* argv[]){
  int N,count=0;
  string A,B,C;
  cin >> N;
  cin >> A >> B >> C;
  for(int i=0;i<N;i++){
    count+=change(A[i],B[i],C[i]);
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256