akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#define max(a,b) (a>b ? a : b)
#define min(a,b) (a<b ? a : b)
using namespace std;
typedef long long int lli;
lli mod=1000000007;
vector < lli> primes;

void Sieve(lli n) 
{ 
    bool prime[n+1];
	for(lli i=0;i<n+1;++i)
		prime[i]=true;
    for (lli p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (lli i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(lli p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
lli gcd(lli a,lli b)  
 {
    if(b>a)
        swap(a,b);
    if (a%b==0)  
        return b;  
    else 
        return gcd(a%b,b);  
 }
lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b);    
}
lli power(lli x,lli y,lli m)   
{ 
    lli res = 1; 
    x=x%m;   
    while (y > 0) 
    {  
        if (y%2==1) 
            res =(res*x)%m;  
        y=y/2; 
        x=(x*x)%m; 
    } 
    return res; 
}
bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) 
{ 
	return v1[0] < v2[0]; 
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	lli a,b,c;
	cin>>a>>b>>c;
	lli t=a-b;
	lli ans=c-min(t,c);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;

    int clear=0, pena=0, p;
    string s;
    map<int, int> ac;
    map<int, int> wa;
    
    while(m--){
        cin>>p>>s;
        if(ac[p])   continue;
        if(s=="AC"){
            clear++;
            ac[p]=1;
            pena+=wa[p];
        }else if(s=="WA"){
            wa[p]++;
        }
    }
    
    cout<<clear<<" "<<pena<<endl;
    return 0;
}

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

int n;
char s[100005];
int main()
{
   cin >> s + 1;
   n = strlen(s + 1);
   int minim = n;
   for (int i = 1; i <= n; i++)
      if (s[i] != s[i + 1])
         minim = min(minim, max(i, n - i));
   cout << minim;
   return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin >> s
#define pr(r) cout << r << endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout << a[j] << " "
#define wh(t) ll t; cin >> t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define arr(a,n) vl a(n, 0); fab(i, 0, n) cin >> a[i]
#define prs(u) cout << u << " "
#define fab(i,a,b) for(ll i = a; i < b; i++)
#define fba(i,b,a) for(ll i = b; i >= a; i--)
#define fa(i, x) for(auto i: x)
#define mem(s, j) memset(s, j, sizeof(s))
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pl>
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define vvl vector<vl>
#define vvpl vector<vpl>
#define mxe(x, n) *max_element(x, n)
#define mne(x, n) *min_element(x, n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N = (ll)3e5;
const ll inf = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.second > b.second);}
bool sort2(const pair<ll, ll> &a,const pair<ll, ll> &b){ return (a.second < b.second);}

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}

ll sm(vl a) {
    ll sum = 0;
    for(auto i: a)
        sum += i;
    return sum;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}


int main()
{
	sup;
    
    
    ll a, b;
    cin >> a >> b;
    fab(i, 1, (ll)1e6 + 100) {
        if(floor((float)i * 0.08) == a && floor((float)i * 0.1) == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int A[100000], B[100000], C[100000];

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    int N, T;
    std::cin >> N >> T;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }
    
    int mx = 0;
    {
        set<int> s;
        s.insert(A[0]);
        for(int i=1;i<N;++i){
            auto it = s.lower_bound(0);
            mx = max(mx, A[i] - *it);
            s.insert(A[i]);
        }

        // printf("mx: %d\n", mx);
        
        s.clear();
        s.insert(A[0]);
        for(int i=1;i<N;++i){
            auto it = s.lower_bound(A[i] + 1 - mx);
            if(it != s.end() && *it == A[i] + 1 - mx){
                B[i] = 1;
            }
            s.insert(A[i]);
        }

        s.clear();
        s.insert(A[N-1]);
        for(int i=N-2;i>=0;--i){
            auto it = s.lower_bound(A[i] - 1 + mx);
            if(it != s.end() && *it == A[i] - 1 + mx){
                C[i] = 1;
            }
            s.insert(A[i]);
        }

        // for(int i=0;i<N;++i){
        //     printf("(B, C) = (%d, %d)\n", B[i], C[i]);
        // }
    }
    
    int res = 0;
    {
        set<P> s;

        s.emplace(A[0], 0);
        for(int i=1;i<N;++i){
            auto it = s.lower_bound(std::make_tuple(0, 0));
            if(A[i] - fst(*it) == mx){
                res += min(B[snd(*it)], C[i]) + 1;
            }
            s.emplace(A[i], i);
        }
    }

    printf("%d\n", res);
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

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

    ll N;
    cin >> N;

    vector<ll> A(N);
    for (auto&& a : A) {
        cin >> a;
    }

    sort(A.begin(), A.end());

    auto ptr = lower_bound(A.begin(), A.end(), A.back() / 2);
    if (*ptr == A.back()) {
        cout << A.back() << " " << *(ptr - 1) << endl;
    } else {
        ll r = abs(A[N - 1] / 2 - *(ptr));
        ll l = abs(A[N - 1] / 2 - *(ptr - 1));
        if (l < r) {
            cout << A.back() << " " << *(ptr - 1) << endl;
        } else {
            cout << A.back() << " " << *ptr << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 1024
S = list(input())
G = 0
P = 0
w = 0
l = 0
d = 0
for i in range(len(S)):
    if G == P: #G only
        G += 1
        if S[i] == "p":
            l += 1
        if S[i] == "g":
            d += 1
    elif S[i] == "g":
        P += 1
        w += 1
    elif S[i] == "p":
        P += 1
        d += 1
print(w - l)


Measured memory_bytes: 3956
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1000000007;

const int MAX = 300005;
using namespace std;

	

//Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1
///    *check mod
///    *check input file  
///    *NO IDIOT SUBMISSION
int main(){
	IOS ;
	int n ; cin >> n ;
	vll a(n + 1) ; vll b(n) ;
	for(int i = 0 ;  i< n + 1 ; i++) cin >> a[i] ;
	for(int i = 0 ; i < n ; i++) cin >> b[i] ;
	ll sum = 0 ; 
	for(int i = 0 ;  i < n ; i++){
		if(b[i] >= a[i]){
			sum += a[i] ; 
			b[i] -= a[i] ;
			a[i] = 0 ;
			
		}
		else {sum += b[i] ; b[i] = 0 ; continue ;}
		sum += min(b[i] , a[i + 1]) ;
		a[i + 1] = max(0ll , a[i + 1] - b[i]) ;
		
	}
	cout << sum << endl ;
	return 0;
}





Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	string s;
	cin >> s;
	int n;
	cin >> n;

	string ans = "";
	rep(i, s.length()){
		if(i % n == 0){
			ans += s[i];
		}
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);
$a_monstar=explode(" ",trim(fgets(STDIN)));
$b_attack=explode(" ",trim(fgets(STDIN)));
$kill_c=0;
$attack_n_1=0;
$leaving_attack=0;
for($i=0;$i<$n+1;$i++){

  if($a_monstar[$i]>$leaving_attack){
    $a_monstar[$i] =  $a_monstar[$i]-$leaving_attack;
    $kill_c+=$leaving_attack;

  }else{
    $kill_c+=$a_monstar[$i];
    $a_monstar[$i]=0;
  }

  if($a_monstar[$i]>=$b_attack[$i]){
    $kill_c+=$b_attack[$i];
    $leaving_attack=0;
  }else{
    //echo "a_monstar ".$a_monstar[$i]."\n";
    $kill_c+=$a_monstar[$i];
  
    $leaving_attack=$b_attack[$i]-$a_monstar[$i];
    // echo "leaving_attack ".$leaving_attack."\n";

  }
 }



echo $kill_c."\n";

Measured memory_bytes: 20980
#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;

int32_t main()
{
	IOS;
	int x, y;
	cin >> x >> y;
	int ans = 0;
	int m = 1e5;
	vector<int> v = {0, 3 * m, 2 * m, 1 * m};
	if(x <= 3)
		ans += v[x];
	if(y <= 3)
		ans += v[y];
	if(x == 1 && y == 1)
		ans += 4e5;
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int Q;cin >> Q;
  while(Q--){
    ll x,y;cin >> x >> y;
    if(x>y)swap(x,y);
    if(x==y || x+1==y) cout << 2*x-2 << endl;
    else{
      ll c = sqrt(x*y);
      if(c*c == x*y)c--;
      if(c*(c+1) >= x*y) cout << 2*c-2 << endl;
      else cout << 2*c-1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 18888
#define mp make_pair
using namespace std;
char s[22];
int n, Ans, dis[N], vis[N], id[1005][18], tot, l[1050], a[1050], pw[22];
vector<pair<int, int> > ed[N];
void add(int u, int v, int w){ed[u].push_back(mp(v, w));}
bool chk(int x1, int p1, int x2, int p2, int len){
	return ((a[x1] >> (p1 - 1)) & (pw[len] - 1)) == ((a[x2] >> (p2 - 1)) & (pw[len] - 1));
}
priority_queue<pair<int, int> > q;
void dijkstra(){
	memset(dis, 0x3f, sizeof dis);
	for(int i = 1; i <= n; i++){
		dis[id[i][0]] = 0;
		q.push(mp(0, id[i][0]));
	}
	while(!q.empty()){
		int x = q.top().second; q.pop();
		if(vis[x]) continue;
		vis[x] = 1;
		for(int i = 0; i < (int)ed[x].size(); i++){
			int v = ed[x][i].first, w = ed[x][i].second;
			if(dis[x] + w < dis[v]){
				dis[v] = dis[x] + w;
				q.push(mp(-dis[v], v));
			}
		}
	}
}
int main(){
	pw[0] = 1;
	for(int i = 1; i <= 17; i++)
		pw[i] = pw[i - 1] << 1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%s", s);
		l[i] = strlen(s);
		for(int j = 0; j < l[i]; j++)
			a[i] |= (s[j] - '0') * pw[j];
	}
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= l[i]; j++)
			id[i][j] = ++tot;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < l[i]; j++){
			for(int k = 1; k <= n; k++)if(k != i || j != 0){
				int now = min(l[k], l[i] - j);
				if(chk(i, j + 1, k, 1, now)){
					if(l[i] - j < l[k]) add(id[i][j], id[k][now], now);
					else add(id[i][j], id[i][j + now], now);
				}
			}
		}
	}
	dijkstra();
	Ans = dis[0];
	for(int i = 1; i <= n; i++)Ans = min(Ans, dis[id[i][l[i]]]);
	if(Ans == dis[0]) puts("0");
	else printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 15352
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<string> split(string str, string pat) {
    int pos;
    vector<string> ret;
    while ((pos = str.find(pat)) != string::npos) {
        ret.push_back(str.substr(0, pos));
        str = str.substr(pos + pat.size());
    }
    ret.push_back(str);
    return ret;
}

string strip(string str) {
    return str.substr(1, str.size() - 2);
}

int parse(string str) {
    int ans = 0;
    for (int i = 0; i < str.size(); i++) {
        ans = ans * 10 + (str[i] - '0');
    }
    return ans;
}

int solve(string str) {
    if ('0' <= str[0] && str[0] <= '9') {
        return (parse(str) + 1) / 2;
    } else {
        vector<string> ss;
        while (!str.empty()) {
            int acc = 0;
            for (int i = 0; i < str.size(); i++) {
                if (str[i] == '[') {
                    acc += 1;
                } else if (str[i] == ']') {
                    acc -= 1;
                }

                if (acc == 0) {
                    ss.push_back(str.substr(0, i + 1));
                    str = str.substr(i + 1);
                    break;
                }
            }
        }

        vector<int> ns;
        for (int i = 0; i < ss.size(); i++) {
            ns.push_back(solve(strip(ss[i])));
        }

        sort(ns.begin(), ns.end());
        int ans = 0;
        int m = (ns.size() + 1) / 2;
        for (int i = 0; i < m; i++) {
            ans += ns[i];
        }
        return ans;
    }
}

int main(int argc, char** argv) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        printf("%d\n", solve(strip(str)));
    }
}

Measured memory_bytes: 1368
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
	int x = 1;
	while (b) {
		if (b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	string s; cin >> s;
	int n = s.length();

	int ans=0,blacks=0;
	for(int i=0;i<n;i++) {
		if(s[i]=='W') ans += blacks;
		else blacks++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    const long int mod = 1000000007;
    const long int pal = 1000000000;
    long int n, m;
    cin >> n >> m;
    long int x[n], y[m];
    rep(i, n) {
        cin >> x[i];
        x[i] += pal;
    }
    rep(i, m) {
        cin >> y[i];
        y[i] += pal;
    }

    long int xsum[n+1], ysum[m+1];
    xsum[0] = 0;
    ysum[0] = 0;
    rep(i, n) {
        xsum[i+1] = xsum[i] + x[i];
        xsum[i+1] %= mod;
    }

    rep(i, m) {
        ysum[i+1] = ysum[i] + y[i];
        ysum[i+1] %= mod;
    }
    long int xans = 0;
    rep(i, n - 1){
        xans += (2 * mod) + (xsum[n] - xsum[i+1]) - (((n - (i + 1)) * x[i]) % mod);
        xans %= mod;
    }
    long int yans = 0;
    rep(i, m - 1){
        yans += (2 * mod) + (ysum[m] - ysum[i+1]) - (((m - (i + 1)) * y[i]) % mod);
        yans %= mod;
    }
    long int ans = (xans * yans) % mod;

    // rep(i, n) cout << x[i] << " ";
    // cout << endl;
    // rep(i, m) cout << y[i] << " ";
    // cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	queue<pair<string, int> > ple;
	int n,q;
	string name;
	int time;
	cin >> n>>q;
	for(int i = 0; i< n; i++)
	{
		cin >> name>>time;
		ple.push(make_pair(name,time));	
	}
	
	
	pair<string, int> u;
	int elapse  = 0, a;
	while(!ple.empty())
	{
		u = ple.front(); ple.pop();
		a = min(u.second, q);
		u.second -= a;
		elapse +=a;
		if(u.second>0)
			ple.push(u);
		else
			cout << u.first<<" "<<elapse<<endl;		
	}
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SSS")
    cout<<0<<"\n";
  if(s=="RRR")
    cout<<3<<"\n";
  if(s=="RRS")
    cout<<2<<"\n";
  if(s=="RSR")
    cout<<1<<"\n";
  if(s=="SRR")
    cout<<2<<"\n";
  if(s=="SSR")
    cout<<1<<"\n";
  if(s=="SRS")
    cout<<1<<"\n";
  if(s=="RSS")
    cout<<1<<"\n";
  return 0;
}

Measured memory_bytes: 3620
import math
from fractions import gcd

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [1]
    else:
        factor.append(n)
        return factor

n1, n2 = [int(i) for i in input().split()]

n4 = gcd(n1, n2)
n3 = trial_division(n4)

n3.sort()

r1 = 1
c1 = 1
f1 = 1
for i1 in range(len(n3)):
    if c1 != n3[i1]:
        r1 += 1
        c1 = n3[i1]
    if n4 % n3[i1] == 0 and n3[i1] != 1:
        f1 = 0

if f1 == 1 and n4 != 1 :
    r1 += 1

print(r1)

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans=0;
    cin>>s;
    REP(i,s.size()){
        if(s[i]=='1')ans++;
    }
    cout<<ans<<endl;
}

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

int n;
vector<long long> a;

bool f(int j) {
  if (j < 0)
    return false;
  long long s = a[j];
  for (int i = 0; i < n; i++) {
    if (i == j)
      continue;
    if (s * 2 >= a[i]) {
      s += a[i];
    } else {
      return false;
    }
  }
  return true;
}

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  if (!f(n - 1)) {
    cout << 0 << endl;
    return 0;
  }
  int l = -1, r = n - 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[r] <= a[i])
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", a * b);
	return 0;
}


Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		int a, b, c;
		std::cin >> a >> b;
		if (a % 2 == 0) {
			c = a / 2;
		}
		else {
			c = a / 2 + 1;
		}
		if (c >= b) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
		return 0;
	}

Measured memory_bytes: 256
import java.util.HashMap;

import java.util.Map;
import java.util.Scanner;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int N = sc.nextInt();
		int[] candSet = new int[N];
		for (int i = 0; i < N; i++) {
			candSet[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int[] MSet = new int[M];
		for (int i = 0; i < M; i++) {
			MSet[i] = sc.nextInt();
		}
		String res = helper(candSet, MSet);
		System.out.println(res);
	}

	private static String helper(int[] candSet, int[] mSet) {
		// TODO Auto-generated method stub
		if (candSet.length < mSet.length)
			return "NO";
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for (int i : candSet)
			m.put(i, m.getOrDefault(i, 0) + 1);
		for (int i : mSet) {
			if (!m.containsKey(i))
				return "NO";
			int k = m.get(i);
			if (k == 1)
				m.remove(i);
			else
				m.put(i, k - 1);

		}
		return "YES";

	}
}

Measured memory_bytes: 100024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] ta = convInt(sc.nextLine().split(" "));
		int t = ta[0], a = ta[1];
		int[] hA = convInt(sc.nextLine().split(" "));
		int result = 0;
		double tmp = Double.MAX_VALUE;
		for (int i = 0; i < hA.length; i++) {
			double ave = t - hA[i] * 0.006;
			double diff = Math.abs(a - ave);
			if (diff < tmp) {
				tmp = diff;
				result = i;
			}
		}
		System.out.println(++result);
	}

	private static int[] convInt(String[] args) {
		int len = args.length;
		int[] intA = new int[len];
		for (int i = 0; i < len; i++) {
			intA[i] = Integer.parseInt(args[i]);
		}
		return intA;
	}
}

Measured memory_bytes: 23636
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String nn = String.valueOf(n);
		for (int i = 0; i < nn.length(); i++) {
			if (nn.charAt(i) == '7') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

static const int MAX = 100;
static const ll INFTY = (1LL << 32);

int n;
vector<vector<ll>> d(MAX, vector<ll>(MAX));

void floyd() {
  rep(k, 0, n) {
    rep(i, 0, n) {
      if (d[i][k] == INFTY) {
        continue;
      }
      rep(j, 0, n) {
        if (d[k][j] == INFTY) {
          continue;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
};

int main() {
  int e, u, v, c;
  cin >> n >> e;
  rep(i, 0, n) {
    rep(j, 0, n) {
      d[i][j] = ((i == j) ? 0 : INFTY);
    }
  }
  rep(i, 0, e) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  rep(i, 0, n) {
    if (d[i][i] < 0) negative = true;
  }

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    rep(i, 0, n) {
      rep(j, 0, n) {
        if (j)  cout << " ";
        if (d[i][j] == INFTY) cout << "INF";
        else cout << d[i][j];
      }
      cout << endl;
    }
  }
};



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<queue<ll>> A(N);

    REP(i, N){
        REP(j, N-1){
            ll a;
            cin >> a;
            A[i].push(a-1);
        }
    }

    ll ans = 0;
    ll total = N*(N-1)/2;
    bool check = true;
    while(total>0 && check){
        vector<bool> B(N, false);

        check = false;
        REP(i, N){
            // もう全ての試合が終わっているとき
            if(A[i].empty()) continue;
            
            // 自分が今日すでに試合済みのとき
            if(B[i]) continue;

            // 相手が今日すでに試合済みのとき
            if(B[A[i].front()]) continue;
            
            // 次の試合相手と両思いのとき
            if(A[A[i].front()].front() == i){
                // 試合を抜き出しで今日を試合済みに
                A[A[i].front()].pop();
                B[A[i].front()] = true;
                A[i].pop();
                B[i] = true;

                // 総試合数のカウントを引く 
                total--;

                // 今日試合が行われたことのチェック
                check = true;
            }
        }
        ans++;
        // 1試合も行えなかったとき
        if(check == false){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12268
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define debug(x) cout<<#x<<": "<<x<<" "
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
int main()
{
    IO;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(b<=a)
    {
        b*=2;
        cnt++;
    }
    while(c<=b)
    {
        c*=2;
        cnt++;
    }
    if(cnt<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  cin>>n;
  int ma=-1e9;
  int id;
  int mi=1e9;
  int mid;
  vector<int> a(n);
  vector<pair<int,int> > ans;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(ma<a[i]){
      ma=a[i];
      id=i;
    }
    if(mi>a[i]){
      mi=a[i];
      mid=i;
    }
  }

  if(abs(ma)>abs(mi)){
    for(int i=1;i<n;i++){
      if(a[i-1]>a[i]){
        a[i]+=ma;
        ans.push_back(make_pair(id+1,i+1));
      }
      if(a[i-1]>a[i]){
        a[i]+=ma;
        ans.push_back(make_pair(id+1,i+1));
      }
      if(ma<a[i]){
        ma=a[i];
        id=i;
      }
    }
  }else{
    for(int i=n-2;i>=0;i--){
      if(a[i+1]<a[i]){
        a[i]+=mi;
        ans.push_back(make_pair(mid+1,i+1));
      }
      if(a[i+1]<a[i]){
        a[i]+=mi;
        ans.push_back(make_pair(mid+1,i+1));
      }
      if(mi>a[i]){
        mi=a[i];
        mid=i;
      }
    }
  }

  /*
  int x=0;
  for(int i=1;i<n;i++)if(a[i]<a[i-1])x++;
  for(int i=0;i<n;i++)cout<<a[i]<<" ";
  cout<<endl;
  cout<<x<<endl;
  */

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }
}


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

int main(void){
		
  	int A,B;
  	cin >> A >> B;
  	if (A < 10 && B < 10) cout << A*B << endl;
  	else cout << -1 << endl;
  	
  	
	return 0;
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#define LOOP(i,s,e) for(int i=s;i<e;i++)
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MAX3(a,b,c) (a>b)?MAX(a,c):MAX(b,c)
#define MIN3(a,b,c) (a>b)?MIN(b,c):MIN(a,c)

int intcmp(const int *a,const int *b) {return (*a - *b);}

int intrcmp(const int *a,const int *b) {return (*b - *a);}

int dblcmp(const double *a,const double *b) { return (*a < *b) ? -1 : (*a == *b) ? 0 : 1; }

int stcmp(const char *a[],const char *b[]) { return(strcmp(*a, *b)); }

int main() {
	int N=0;
	int i=0,j=0;
	bool flag=false;
	scanf("%d",&N);
	LOOP(i,1,10){
		LOOP(j,1,10){
			if((i*j)==N){
				printf("Yes\n");
				flag=true;
				break;
			}
		}
		if(flag) break;
	}
	if(!flag) printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0 };
static const int dy[] = { 0, 0, 1, -1 };

string str;
int n, r, p, c;

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


int main() {
	while ( ~scanf("%d %d", &n, &r) && n && r ) {
		str.resize( n + 2 );
		for ( int i = 0; i < n + 2; i++ ) {
			str[ i ] = n - ( i );
		}
		for ( int i = 0; i < r; i++ ) {
			scanf( "%d %d", &p, &c );
			str = str.substr( p - 1, c ) + str.substr( 0, p - 1 ) + str.substr( p + c - 1, str.size() - ( p + c - 1 ) );
		}
		printf( "%d\n", str[ 0 ] );
		str.clear();
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <algorithm>

long long int N, T, Q;
long long int A[112345], D[112345];
long long int X[1123];
long long int t[112345];

int main(void) {
	scanf("%lld%lld%lld", &N, &T, &Q);
	for (long long int i = 0; i < N; ++i) { scanf("%lld%lld", &A[i], &D[i]); }
	for (long long int i = 0; i < Q; ++i) { scanf("%lld", &X[i]); }

	for (long long int i = 0; i < N - 1; ++i) {
		if (D[i] == 1 && D[i + 1] == 2) {
			long long int t_mem = (A[i] + A[i + 1]) / 2;
			t[i] = t_mem;
			t[i + 1] = t_mem;
			for (long long int j = i - 1; j >= 0; --j) {
				if (D[j] == 1) {
					t[j] = t_mem;
				}
				else { break; }
			}
			for (long long int j = i + 1; j < N; ++j) {
				if (D[j] == 2) {
					t[j] = t_mem;
				}
				else { break; }
			}
		}
	}

	for (long long int i = 0; i < N; ++i) {
		if (t[i] == 0) {
			if (D[i] == 1) {
				t[i] = A[i] + T;
			}
			if (D[i] == 2) {
				t[i] = A[i] - T;
			}
		}
		if(T<std::llabs(A[i]-t[i])){
			if (D[i] == 1) {
				t[i] = A[i] + T;
			}
			if (D[i] == 2) {
				t[i] = A[i] - T;
			}
		}
	}

	for (long long int i = 0; i < Q; ++i) {
		printf("%lld\n", t[X[i] - 1]);
	}
	
	return 0;
}

Measured memory_bytes: 5084
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	static void solve() {
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int p;
			long pipe = 0;
			for (int i = 0; i < n; i++) {
				p = sc.nextInt();
				pipe += p;
			}
			int[] j = new int[n - 1];
			for (int i = 0; i < n - 1; i++) {
				j[i] = sc.nextInt();
			}
			Arrays.sort(j);
			long salary = pipe * n;
			for (int i = n - 2; i >= 0; i--) {
				pipe += j[i];
				n--;
				if (pipe * n > salary) {
					salary = pipe * n;
				} else {
					break;
				}
			}
			out.println(salary);
		}
		out.flush();
	}

	public static void main(String[] args) {
		solve();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 28488
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Double t;
        List<Double> a = new ArrayList<Double>();

        Double ave=0.0;
        //個々の数値-平均の合計
        double sum=0;
        while(true){
        	t = sc.nextDouble();
        	if (t==0) break;
        	int b[]=new int[1000];
        	for (int i=0; i < t; i++) {
        		b[i] = sc.nextInt();
        		ave += b[i];
        	}
        	ave = ave /t;
        	for (int j=0; j < t; j++) {
        		sum +=(b[j] - ave)*(b[j] - ave);
        	}
        	a.add(new Double(Math.sqrt(sum/t)));
        	ave=0.0;
        	sum=0;
        }
        sc.close();
        for (int l=0; l < a.size(); l++) {
        	System.out.println(a.get(l));
        }
    }
}



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

int main() {
	ll N;
	cin >> N;
	string S;
	int cnt = 1;
	while (N) {
		N--;
		S = string(1, 'a' + N%26) + S;
		N /= 26;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3616
n, x, m = map(int, input().split())
mn = min(n, m)
P = [] # pre_sum
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check & pre_len
for i in range(mn):
    if X[x] > -1:
        cyc_len = len(P) - X[x]
        n -= X[x]
        cyc = (sum_p - P[X[x]]) * (n // cyc_len)
        remain = P[X[x] + n % cyc_len]
        print(cyc + remain)
        exit()
    P.append(sum_p)
    sum_p += x
    X[x] = i
    x = x*x % m
print(sum_p)


Measured memory_bytes: 13612
#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);
    cout << std::fixed << std::setprecision(10);

    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 = mp.size() - (mp.size() + 1) % 2;
    cout << ans << endl;


    

    return 0;
}

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

int prime_judge(int);

int main()
{

    int i, j, n, num, flag = 0;
    double tmp;
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &num);
        if (prime_judge(num) == 1)
            flag += 1;
    }

    printf("%d\n", flag);
    return 0;
}

int prime_judge(int num)
{
    int j;
    if (num == 2)
        return 1;

    if (num < 2 || num % 2 == 0)
        return 0;

    j = 3;

    while (j <= sqrt(num))
    {
        if (num % j == 0)
            return 0;
        j += 2;
    }
    return 1;
}



Measured memory_bytes: 2056
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a+b+c<<endl;
}


Measured memory_bytes: 3172
#include <stdio.h>
int main(void){
    int b[9]={};
    int N,i,j,k;
    for(i=0;i!=9;i++){
        scanf("%d",&b[i]);
    }
    scanf("%d",&N);
    for(j=0;j!=N;j++){
        scanf("%d",&k);
        for(i=0;i!=9;i++){
            if(b[i]==k)b[i]=0;
        }
    }
    N=(b[0]+b[1]+b[2])*(b[3]+b[4]+b[5])*(b[6]+b[7]+b[8])*(b[0]+b[3]+b[6])*(b[1]+b[4]+b[7])*(b[2]+b[5]+b[8])*(b[0]+b[4]+b[8])*(b[2]+b[4]+b[6]);
    if(N==0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

#define L2 54
#define L5 29

int a[200000][2];
int D[L2][L5];
int d[L2][L5];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		char c=getchar();
		while(!isdigit(c)) c=getchar();
		long x=0;
		while(isdigit(c)){ x=x*10+c-'0'; c=getchar(); }
		if(c=='.'){
			int d=0;
			c=getchar();
			while(isdigit(c)){ x=x*10+c-'0'; c=getchar(); d++; }
			a[i][0]=a[i][1]=9-d;
		}else{
			a[i][0]=a[i][1]=9;
		}
		while(x%2==0){ x=x/2; a[i][0]++; }
		while(x%5==0){ x=x/5; a[i][1]++; }
		D[a[i][0]][a[i][1]]++;
	}
	for(int i5=L5-2; i5>=0; i5--){
		for(int i2=L2-2; i2>=0; i2--){
			d[i2][i5]=D[i2][i5]+d[i2][i5+1]+d[i2+1][i5]-d[i2+1][i5+1];
			//printf("%d ", d[i2][i5]);
		}
		//putchar(10);
	}
	long ans=0;
	for(int i=0; i<n; i++){
		int h2=18-a[i][0]; if(h2<0) h2=0;
		int h5=18-a[i][1]; if(h5<0) h5=0;
		ans+=d[h2][h5]-(h2<=9&&h5<=9);
	}
	printf("%ld\n", ans/2);
}


Measured memory_bytes: 3204
#include <stdio.h>

int m[100][100]={0};
int p[100];
int length;

void MatricCO(void){
    int l,j,q,k,n,i;
    
    n=length;
    for(i=1;i<=n;i++){
        m[i][i]=0;
    }
    
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            m[i][j] = 2147483647;
            for(k=i;k<=j-1;k++){
                q = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
               if(m[i][j]>q)m[i][j]=q;
            }
        }
        
        
    }
    
}

int main(void){
    int a,i;
    scanf("%d",&length);
    
    for(i=1;i<=length;i++){
        scanf("%d %d", &a,&p[i]);
        if(i==1){
            p[0]=a;
        }
        
    }
    
    
    MatricCO();
    
    printf("%d\n",m[1][length]);
    
    
    return 0;
}

Measured memory_bytes: 636
# 写経
N, M = map(int, input().split())


sw = []
for i in range(M):
    k, *s = map(int, input().split())
    sw.append(s)


p = list(map(int, input().split()))


ans = 0
for bit in range(2 ** N):
    flag = False
    for m in range(M):
        cnt = 0
        for s in sw[m]:
            if 1 << (s - 1) & bit:
                cnt += 1
        if cnt % 2 == p[m]:
            continue
        else:
            flag = True
            break
    if not flag:
        ans += 1


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define maxn 55
#define maxm 125005
#define int long long
#define INF 1e9 + 10
int n, X, D, ans, cnt, dp[maxn][maxm];
int w[maxn], val[maxn], pos[maxn];
int fa[maxn];

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

struct edge
{
	int cnp, to[maxn], last[maxn], head[maxn];
	edge() { cnp = 1; }
	void add(int u, int v) 
	{ to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++; }
}E1;

void dfs(int u)
{
	val[u] = 1;
	for(int i = E1.head[u]; i; i = E1.last[i])
	{
		int v = E1.to[i];
		dfs(v);
		w[u] += w[v]; val[u] += val[v];
	}
	cnt += val[u] * n; pos[u] = u;
}

bool cmp(int x, int y) { return val[x] * w[y] > val[y] * w[x]; }
void Get_min(int &x, int y) { x = x < y ? x : y; }

signed main()
{
	n = read(), X = read(), D = read();
	w[1] = read();
	for(int i = 2; i <= n; i ++)
		w[i] = read(), fa[i] = read();
	for (int i = n; i >= 1; i--) {
		w[fa[i]] += w[i];
		val[fa[i]] += ++ val[i];
		cnt += val[i] * n;
		pos[i] = i;
	}
	sort(pos + 1, pos + n + 1, cmp);
	int tmp = min(n, D);
	for(int i = 1; i <= cnt; i ++) dp[0][i] = INF;
	for(int i = 1; i <= n; i ++)
	{
		memcpy(dp[i], dp[i - 1], sizeof(dp[i - 1]));
		for(int j = 0; j <= cnt; j ++)
			for(int k = 1; k <= tmp && j - k * val[i] >= 0; k ++)
				Get_min(dp[i][j], dp[i - 1][j - k * val[i]] + k * w[i]);
	}
	int ans = 0;
	for(int i = 0; i <= cnt; i ++)
	{
		if(dp[n][i] > X) continue;
		int ret = i, left = X - dp[n][i];
		for(int j = 1; j <= n; j ++)
		{
			int tem = pos[j], used = min(max(D - n, 0LL), left / w[tem]);
			if(tem == 1) used = left / w[tem];
			left -= w[tem] * used;
			ret += val[tem] * used;
		}
		ans = max(ans, ret);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 50944
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	char t, c;
	vector<vector<char> > v(8, vector<char>(8, 0));

	while (cin >> c) {
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (i == 0 && j == 0) {
					v.at(0).at(0) = c;
				}
				else {
					cin >> c;
					v.at(i).at(j) = c;
				}
				/*
				cout << v.at(i).at(j);
				if (j == 7) cout << endl;
				if (i == 7 && j == 7) cout << endl;
				*/
			}
		}

		int f = 0;
		int cnt = 0;
		typedef struct point {
			int f, s;
		} Ps;
		Ps a, b;

		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				char ch = v.at(i).at(j);
				if (ch == '1') cnt++;

				if (ch == '1' && cnt == 1) {
					a.f = i;
					a.s = j;
				}
				else if (ch == '1' && cnt == 4) {
					b.f = i;
					b.s = j;
				}

				if (cnt == 4) break;
			}

			if (cnt == 4) break;
		}
		//cout << a.f << ' ' << a.s << endl;
		//cout << b.f << ' ' << b.s << endl;

		if (a.f + 1 == b.f) {
			if (a.s + 1 == b.s) t = 'A';
			if (a.s == b.s) t = 'G';
			if (a.s + 2 == b.s) t = 'E';
		}
		else if (a.f + 2 == b.f) {
			if (a.s - 1 == b.s) t = 'D';
			if (a.s + 1 == b.s) t = 'F';
		}
		else if (a.f == b.f) {
			t = 'C';
		}
		else if (a.f + 3 == b.f) {
			t = 'B';
		}

		cout << t << endl;
	}
}


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

using namespace std;

int N, M, Q;
int a[100], b[100], c[100], d[100];
int ans;

void dfs(vector<int> &v) {
    if(v.size() == N+1) {
        int sum = 0;
        for(int i=0; i<Q; i++) {
            if(v[b[i]]-v[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
    } else {
        for(int i=v.back(); i<=M; i++) {
            v.emplace_back(i);
            dfs(v);
            v.pop_back();
        }
    }
}

int main(void) {
    cin >> N >> M >> Q;
    for(int i=0; i<Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> v = {1};
    dfs(v);

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main() {
  int n, cnt[26] = {};
  string s;
  cin >> n >> s;
  for (char c : s) cnt[c - 'a']++;
  ll ans = 1;
  for (int i = 0; i < 26; i++) ans = (ans * (cnt[i] + 1)) % mod;
  cout << (ans + mod - 1) % mod << endl;
  return 0;
}


Measured memory_bytes: 512