akhauriyash/Code-Regression huggingface dataset:
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

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

int main(){
    std::ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
    	ll a,b,c,d,val,gg;
    	cin>>a>>b>>c>>d;
    	if(a<b || b>d){
    		cout<<"No"<<endl;
    		continue;
    	}
    	if(a>c){
    		a-=b*((a-c)/b);
    		if(a>c){
    			a-=b;
    		}
    		if(a<0){
    			cout<<"No"<<endl;
    			continue;
    		}

    	}
    	gg=__gcd(b,d);
    	val=c-a;
    	val/=gg;
    	a+=val*gg;
    	if(a<=c){
    		a+=gg;
    	}
    	if(a<b){
    		cout<<"No"<<endl;
    		continue;
    	}
    	cout<<"Yes"<<endl;

    }
    return 0;  
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

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

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)
int a[200010],b[200010];
ll N,M,K;
long long INF = 1LL<<60;
int main( ){
    cin>>N>>M>>K;
    rep(i,0,N)cin>>a[i];
    rep(j,0,M)cin>>b[j];
    vll asum(N+1,0);
    vll bsum(M+1,0);
    rep(i,0,N){
        asum[i+1]=asum[i]+a[i];
    }
    rep(i,0,M){
        bsum[i+1]=bsum[i]+b[i];
    }
    ll cnt=0;
    int bi=M;
    rep(i,0,N+1){
        ll bup=K-asum[i];
        while(bi>0&&bsum[bi]+asum[i]>K)bi--;
        if(bsum[bi]+asum[i]<=K) chmax(cnt,bi+i);
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 8012
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    for(auto &t : a) cin>>t;
    int sum = 0;
    for(int i=0;i<n;++i){int x; cin>>x;
                        sum += x;}
    for(auto &t : c) cin>>t;
    for(int i=0;i<n-1;++i){
        if(a[i+1] - a[i] == 1){
            sum +=c[a[i]-1];
        }
    }
    cout << sum << endl;
    return 0;
}



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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int r;
  cin>>r;
  if(r<1200)cout<<"ABC"<<endl;
  else if(r>=1200 && 2800>r)cout<<"ARC"<<endl;
  else if(r>=2800)cout<<"AGC"<<endl;
  




return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define speed(); ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;

int main() {
    speed();

    ll n, r;
    cin >> n >> r;
    int rating = 100 * (10-n);

    cout << (n >= 10 ? r : r+rating);
}

Measured memory_bytes: 256
#include<stdio.h>
int n,h[20],i,cs,top;
int main(void){
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&h[i]);
    }
    
    for(i = 0;i < n;i++){
    if(i==0){
        cs+=1;
        top = h[i];
    }else if(h[i] - top >= 0){
        top = h[i];
        cs += 1;
    }
    }
    printf("%d",cs);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;//文字列型変数ｎ

            n = Console.ReadLine();//キーボードから文字列を読み込む

            if (n[0] == '9' || n[1] == '9')//１文字目が'9'または
                Console.WriteLine("Yes");//2文字目が'9'なら"Yes"

            else//それ以外は"No"
                Console.WriteLine("No");

            Console.ReadKey();//キー入力待ち


        }
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    X,Y=pin()
    t=10**5
    a=[0,t*3,t*2,t*1]+[0]*1000
    print(a[X]+a[Y]+4*t*(X==Y and X==1))
#%%submit!
resolve()


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

typedef long long ll;

ll INF=1e10;

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int D;
  cin>>D;
  int E=15;

  vector<ll> c(27);
  for(int i=1;i<=26;++i) cin>>c[i];

  vector<vector<ll>> s(D+1,vector<ll>(27,0));
  for(int i=1;i<=D;++i){
    for(int j=1;j<=26;++j){
      cin>>s[i][j];
    }
  }

  vector<ll> t(D+1);
  vector<set<ll>> next(27);
  vector<ll> test(D+1);

  ll ans=0;
  ll val=-INF;

  for(int cnt=0;cnt<4000;++cnt){

    vector<set<ll>> nest(27);
    for(int i=1;i<=26;++i){
      nest[i].insert(0);
      nest[i].insert(D+1);
    }

    for(int i=1;i<=E;++i){
      test[i]=rand()%26;
      ++test[i];
      nest[test[i]].insert(i);
    }

    for(int i=E+1;i<=D;++i){
      ll ind=1;
      ll sum=-INF;
      for(int j=1;j<=26;++j){
        auto k=nest[j].lower_bound(i);
        --k;
        ll l=*k;
        ll cmp=s[i][j]+c[j]*(i-l);
        if(cmp>sum){
          sum=cmp;
          ind=j;
        }
      }
      test[i]=ind;
      nest[ind].insert(i);
    }

    ll ch=0;
    for(int i=1;i<=D;++i){
      ch += s[i][test[i]];
      for(int j=1;j<=26;++j){
        auto k=nest[j].upper_bound(i);
        --k;
        ll l=*k;
        ch -= c[j]*(i-l);
      }
    }

    if(ch>val){
      val=ch;
      ans=val;
      for(int i=1;i<=D;++i) t[i]=test[i];
    }
   }

  for(int i=1;i<=D;++i){
    next[t[i]].insert(i);
  }
  for(int i=1;i<=26;++i){
    next[i].insert(0);
    next[i].insert(D+1);
  }

  for(int i=0;i<5000000;++i){

    int d=rand()%D;
    ++d;
    int q=rand()%26;
    ++q;
    ll diff=0;

    //up
    ll l,r;
    auto j=next[q].lower_bound(d);
    r=*j;
    --j;
    l=*j;
    diff += s[d][q]+((r-d)*(d-l))*c[q];

    //down
    next[t[d]].erase(d);
    auto k=next[t[d]].lower_bound(d);
    r=*k;
    --k;
    l=*k;
    diff -= s[d][t[d]]+((r-d)*(d-l))*c[t[d]];

    //update
    if(diff>0){
      next[q].insert(d);
      t[d]=q;
      ans += diff;
    }
    else{
      next[t[d]].insert(d);
    }
  }

  for(int i=1;i<=D;++i) cout<<t[i]<<"\n";

  //cout<<ans<<"\n";

}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) (((a%MOD+MOD)%MOD-(b%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x/gcd(x,y)*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i = 0){ return accumulate(f, l, i); }


int a, b, x;


bool judge(double ang){
    if(a*sin(ang) <= b*cos(ang)){
        if(x <= a*a*a*tan(ang)/2) return false;
        double y = x-a*a*a*tan(ang)/2;
        if(a*sin(ang)+y/(a*a/cos(ang)) <= b*cos(ang)) return false;
    }
    else if(x <= a*b*(b/tan(ang))/2) return false;
    return true;
}


signed main(){
    cin >> a >> b >> x;

    double l = 0, u = PI/2;
    while(abs(u-l) > EPS){
        double mid = (u+l)/2;
        if(judge(mid)) u = mid;
        else l = mid;
    }

    fcout << l*180/PI << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>

using namespace std;

int main(){
    priority_queue<double, vector<double>, greater<double>> a;
    int n;
    double m;
    while(cin>>n){
        for (int i = 0; i < n;i++){
            cin >> m;
            a.push(m);
        }
        for (int ii = 0; ii < n - 1;ii++){
            m = a.top();
            a.pop();
            m += a.top();
            a.pop();
            m /= 2.0;
            a.push(m);
        }
        cout << a.top() << endl;
        a.pop();
    }
    return 0;
}

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

int main(){
    int n;cin>>n;
    string ans="No";
    for(int i=1;i<=9;i++){
        if(n%i==0){
            int m=n/i;
            if(1<=m&&m<=9){
                ans="Yes";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
hh=gsmi
ab=m.times.map{gsmi}
fl=Array.new(n,1)

ab.each do |a,b|
  if hh[a-1]>hh[b-1]
    fl[b-1]=0
  elsif hh[a-1]<hh[b-1]
    fl[a-1]=0
  else
    fl[a-1]=0
    fl[b-1]=0
  end
end

puts fl.count(1)



Measured memory_bytes: 29252
import math


def is_prime(x):
    root = int(math.sqrt(x))+1
    if x == 2:
        return True
    else:
        for i in range(2, root+1):
            if x % i == 0:
                return False
    return True


'''
def find_prime(x):
    while True:
        if x == 2:
            return x
        else:
            for i in range(2, x+1):
                if x % i == 0:
                    if i == x:
                        return x
                    else:
                        break
                else:
                    continue
            x += 1
'''


def main():
    x = int(input())
    while True:
        if is_prime(x) == False:
            x += 1
        else:
            print(x)
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 63140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
    cin >> n;
    int a[n];
    fr(i,n){
        cin >> a[i];
    }
    int q;
    cin >> q;
    int m[q];
    fr(i,q){
        cin >> m[i];
    }
    int dp[2001];
    memset(dp,0,2001);
    dp[0]=1;
    int sum=0;
    fr(i,n){
        ifr(j,sum+1){
            if(dp[j]==1){
              dp[j+a[i]]=1;
            }
        }
        sum+=a[i];
    }
    string ans;
    fr(i,q){
        if(sum<m[i])ans="no";
        else if(dp[m[i]]==1)ans="yes";
        else ans="no";
        cout << ans << endl;
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string s;
    cin >> s;

    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return;
        }
    }

    cout << "Good" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(m)]
    D.sort()
    result = 1
    checker = D[0][1]
    for i in range(m):
        if checker <= D[i][0]:
            result += 1
            checker = D[i][1]
        elif checker > D[i][1]:
            checker = D[i][1]
    print(result)
if __name__ == '__main__':
    main()

Measured memory_bytes: 27880
N,X,Y = map(int,input().split())

X,Y = X-1,Y-1
ans = [0]*N
for i in range(N):
    for j in range(i+1,N):
        d = j-i
        d = min(d,abs(X-i)+abs(Y-j)+1)
        ans[d] += 1
for out in ans[1:]:
    print(out)

Measured memory_bytes: 47196
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int A,B;
int main(){
	cin >> A >> B;
	if(B==1)cout << 0 << endl;
	else cout << (B-2)/(A-1)+1 << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

s = input()
t = input()
ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1

print(ans)

Measured memory_bytes: 10652
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,e,d;
  cin>>a>>b;
  d=a;
  e=b;
  while(e%d!=0 && d%e!=0){
    if(max(d,e)%min(d,e)!=0){
      if(d>=e)
        d%=e;
      else
        e%=d;
    }
  }
  
  cout<<a*b/min(e,d)<<endl;
  return(0);
}
 

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

using namespace std;

int main(void) {
  int a, b, c;
  vector<int> v;
  cin >> a >> b >> c;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end());
  cout << v[0] << ' ' << v[1] << ' ' << v[2] << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

/*bool operator<(const data &d)const{
	return hoge;
}*/
 
const int dx[]={0,1,1,-1,-1,0};
const int dy[]={1,1,0,0,-1,-1};
set<char>vowel={'a','i','u','e','o'};


 
signed main(){
	IOS();
	int N,M;
	vector<int>ans;
	while(cin>>N>>M,N||M){
		vector<int>h(N+1,0),w(M+1,0);
		REP(i,N)cin>>h[i+1];
		REP(i,M)cin>>w[i+1];
		REP(i,N)h[i+1]+=h[i];
		REP(i,M)w[i+1]+=w[i];
		int cnt = 0;
		map<int,int>mp;
		rep(i,0,N)rep(j,i,N){
			mp[h[j+1]-h[i]]++;
		}
		rep(i,0,M)rep(j,i,M){
			cnt+=mp[w[j+1]-w[i]];
		}
		ans.push_back(cnt);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 26724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int N = ni();
    	int K = ni();
    	int X = ni();
    	int Y = ni();

    	if (N > K) {
    		out.println(X * K + Y * (N-K));
    	} else {
    		out.println(X * N);
    	}
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 8020
#include<bits/stdc++.h>
using namespace std;
int pd(char c)
{
	if(c=='b') return 1;
	if(c=='d') return 4;
	if(c=='p') return 2;
	if(c=='q') return 3;
}
int main()
{
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<=s.length()-1;i++)
	{
		if(pd(s[i])+pd(s[s.length()-1-i])!=5)
		{
			flag=1;
			break;
		}
		
		
	}
	if(flag==1) cout<<"No";
	else cout<<"Yes";

 return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	list2 := make([]int, n)
	for i := 0; i < n-1; i++ {
		list2[i] = list[i+1] - list[i]
	}
	list2[n-1] = k + list[0] - list[n-1]

	sort.Sort(sort.IntSlice(list2))

	result := 0
	for i := 0; i < n-1; i++ {
		result += list2[i]
	}
	fmt.Println(result)
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    string s;
    cin >> s;
    s[5] = s[13] = ' ';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        for(int i = 0;i < n;i++){
            d[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine(d.Distinct().ToArray().Length);
	}
}

Measured memory_bytes: 13280
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)

typedef long long Int;
typedef long double Double;

int asc(const void *a, const void *b) {
    Int d = *(Int *)a - *(Int *)b;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}

int desc(const void *a, const void *b) {
    Int d = *(Int *)b - *(Int *)a;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}

// 昇順に並んだ values の中で searchValue を 左から探したときに初めて上回る(order>0) / 右から探したときに初めて下回る(order<0) ような index を探す（ない場合は -1 を返す）
int binary_search(Int searchValue, Int *values, int minIndex, int maxIndex, int order) {
    int midIndex = (minIndex + maxIndex) / 2;
    Int midValue = values[midIndex];
    Int maxValue = values[maxIndex];
    if (minIndex == midIndex) { // 区間の長さが2になったとき
        if (order > 0) {
            if (searchValue < midValue) { // 左がサーチ値を上回るなら左
                return midIndex;
            }
            if (searchValue < maxValue) { // 左がサーチ値以下かつ右がサーチ値を上回るなら右
                return maxIndex;
            }
        } else {
            if (searchValue > maxValue) { // 右がサーチ値を下回るなら右
                return maxIndex;
            }
            if (searchValue > midValue) { // 右がサーチ値以上かつ左がサーチ値を下回るなら左
                return midIndex;
            }
        }
        return -1; // 区間の長さが2のとき両端とも条件を満たさないなら存在しない
    }
    if (order > 0) {
        if (midValue <= searchValue) { // 中央での値がまだ上回っていないなら右半分
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        } else {
            return binary_search(searchValue, values, minIndex, midIndex, order);
        }
    } else {
        if (midValue >= searchValue) { // 中央での値がまだ下回っていないなら左半分
            return binary_search(searchValue, values, minIndex, midIndex, order);
        } else {
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        }
    }
}
int main() {
    Int n;
    scanf("%lld", &n);
    Int *a = (Int *)malloc(sizeof(Int) * n);
    rep(i, n) scanf("%lld", a + i);
    qsort(a, n, sizeof(Int), asc);
    Int m = a[n - 1];
    int index = binary_search(m / 2, a, 0, n - 1, 1);
    Double mm = ((Double)m) / 2.0;
    Int ans;
    if (index == 0) {
        ans = a[0];
    } else {
        Double candidate1 = a[index];
        Double candidate2 = a[index - 1];
        ans = (ABS(candidate1 - mm) < ABS(candidate2 - mm)) ? candidate1 : candidate2;
    }
    printf("%lld %lld\n", m, ans);
}


Measured memory_bytes: 7760
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a + n);

    int ans = 0;
    int tmp = a[0], cnt = 0;
    for (int i = 0; i < n + 1; i++) {
        if (tmp != a[i]) {
            if (cnt < tmp) ans += cnt;
            else if (cnt > tmp) ans += cnt - tmp;
            cnt = 0;
            tmp = a[i];
        }
        cnt++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){

int i,j,H,W;

while(1){
scanf("%d %d",&H,&W);
if(H==0&&W==0)break;
for(i=0; i<H; i++){
for(j=0; j<W; j++){
if((i+j)%2==0){
printf("#");
}else if((i+j)%2!=0){
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 10000000;
  for(int i = 0; i<n-2; i++) {
    string tmp = s.substr(i, 3);
    int x = stoi(tmp);
    ans = min(abs(753 - x), ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int ans =0;
  for( int i = 1 ; i<=n;i++){
    int counter = 0;
    for(int j = 1;j<=i;j++){
      if( i%j==0){
        counter +=1;
      }
    }
    if(counter == 8 && i%2 != 0){
      ans +=1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  int size;
  int mnsize;
  int nh,nw;
  while(1){
    cin>>h>>w;
    if(h==0 && w==0) break;
    mnsize=22500;
    size=(h*h+w*w);
    for(int i=1;i<150;i++){
      for(int j=i+1;j<=150;j++){
	if(i*i+j*j>size && mnsize>i*i+j*j){
	  mnsize=i*i+j*j;
	  nh=i;
	  nw=j;
	  break;
	}
	if(i*i+j*j==size && mnsize>i*i+j*j && i>h){
	  mnsize=i*i+j*j;
	  nh=i;
	  nw=j;
	  break;
	}
      }
    }
    cout<<nh<<" "<<nw<<endl;
  }
  return 0;
}



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

int main(){
  int n, d, ans = 0;
  cin >> n >> d;
  
  for(int i = 0; i < n; i++){
    double x, y;
    cin >> x >> y;
    if(sqrt(x * x + y * y) <= d)
      ans++;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3836
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 2010;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , cnt;
char s[N];
int a[N] , siz[N] , sum[N] , f[N] , head[N];
struct edge{ int v , nex; }e[N << 1];
inline void add(int u , int v) { e[++cnt].v = v; e[cnt].nex = head[u]; head[u] = cnt; }

void dfs(int x , int fa)
{
	siz[x] = a[x]; int mp = 0;
	for(int i = head[x] , v; i ; i = e[i].nex)
	{
		v = e[i].v; if(v == fa) continue; dfs(v , x);
		siz[x] += siz[v]; sum[v] += siz[v]; sum[x] += sum[v]; // sum[v] += siz[v] 得到这个子树内的距离和，必须的。 
		if(sum[mp] < sum[v]) mp = v;
	}
	if(!mp) { f[x] = 0; return ; }
	if(sum[x] - sum[mp] >= sum[mp]) f[x] = sum[x] / 2;
	else f[x] = sum[x] - sum[mp] + min(f[mp] , (2 * sum[mp] - sum[x]) / 2);
}

int calc(int rot)
{
	for(int i = 1 ; i <= n ; ++i) f[i] = siz[i] = sum[i] = 0;
	dfs(rot , 0); if((sum[rot] & 1) || (f[rot] * 2 < sum[rot])) return 2e9;
	return sum[rot] / 2;
}

int main()
{
	n = read(); scanf("%s" , s+1);
	for(int i = 1 ; i <= n ; ++i) a[i] = s[i] - '0';
	int u , v;
	for(int i = 1 ; i <  n ; ++i) u = read() , v = read() , add(u , v) , add(v , u);
	int ans = 2e9;
	for(int i = 1 ; i <= n ; ++i) ans = min(ans , calc(i));
	cout << (ans == 2e9 ? -1 : ans) << '\n'; 
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<tgmath.h>
using namespace std;

long double EPS = 1E-14;

// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(long double r){ return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(long double a, long double b){ return sgn(a - b); }

int main(){
    long double a,b,c;
    cin >> a >> b >> c;
    if(sgn(sqrtl(c),sqrtl(a)+sqrtl(b)) == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int work()
{
    string s ;
    int ans = 0 ;
    vector<int> v(5) ;
    cin >> s ;
    for(int i = 0 ;i < s.size() ;i ++ ) {
      if(s[i] == 'R') {
        if(i == 0) v[i] = 1 ;
        else if(i && s[i - 1] == 'R') v[i] = v[i - 1] + 1 ;
        else if(i) v[i] = 1 ;
      }else v[i] = 0 ;
    }
    cout << max(v[0] , max(v[1] , v[2])) << endl ;
    return 0 ;
}
int main()
{
  //   freopen("C:UsersspnooyseedDesktopin.txt" , "r" , stdin) ;
  //   freopen("C:UsersspnooyseedDesktopout.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3200
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		//Aiが到着順になるので、Aiを小さい方から順番にソートし、それに出席番号を紐づけておけば良い。
		List<List<Integer>> ll = new ArrayList<List<Integer>>();
		for(int i=0;i<N;i++) {
			List l = new ArrayList<Integer>();
			l.add(i+1);//出席番号
			l.add(sc.nextInt());//到着順
			ll.add(l);
		}
		
		Queue<List<Integer>> pq = 
				new PriorityQueue<List<Integer>>((l1,l2)->Integer.compare(l1.get(1),l2.get(1)));
		
		for(List l:ll) {
			pq.offer(l);
		}
		
		StringBuilder sb = new StringBuilder();
		while(pq.size()>0) {
			sb.append(pq.poll().get(0));
			sb.append(" ");
		}
		System.out.println(sb.toString());
		
	}
}

Measured memory_bytes: 74204
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////


int main(){
    string s;cin>>s;
    int n=s.size();
    if(n!=26){
        bool c[26];memset(c,false,sizeof(c));
        rep(i,0,n-1)c[s[i]-'a']=true;
        int pos;
        for(pos=0;pos<=25;pos++){
            if(!c[pos]){
                s+='a'+pos;
                break;
            }
        }
        cout<<s<<endl;
    }else{
        bool c[26];memset(c,false,sizeof(c));
        int pos;
        for(pos=24;pos>=0;pos--){
            if(s[pos]>s[pos+1]){
                c[s[pos+1]-'a']=true;
            }else{
                c[s[pos+1]-'a']=true;
                break;
            }
        }
        if(pos==-1)cout<<-1<<endl;
        //rep(i,0,25)cout<<c[i]<<" ";cout<<endl;
        else{
            rep(i,0,pos-1)cout<<s[i];
            int k=s[pos]-'a';
            rep(i,k+1,25){
                if(c[i]){
                    char t[2];
                    t[0]='a'+i;
                    cout<<t[0]<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s; 
	cin>>s;
	int w=1,x=0,y=0,n=s.size();
	for(int i=0;i<n;i++)
	{
		if(w!=(s[i]-'0'))
		x++;
		w=!w;
	}
	w=0;
	for(int i=0;i<n;i++)
	{
		if(w!=(s[i]-'0'))
		y++;
		w=!w;
	}
	cout<<min(x,y);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if ((A+B)%2 == 0) {
        printf("%d\n", (A+B)/2);
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let a_float: f64 = a as f64;
    let b_float: f64 = b as f64;
    println!("{} {} {}", (a / b), (a % b), (a_float / b_float));
}




Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << (x) << endl
#define IOS ios::sync_with_stdio(false); cin.tie(NULL)
// Greate commom divisor
#define gcd(a, b) __gcd(a, b) 

int main(int argc, char const *argv[])
{
    IOS;
	string x;
    cin >> x;


    if(x[2] == x[3] && x[4] == x[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

const ll INF = 1e18 + 7;
vector<ll> pre;
// pre[mask] - score of group 'mask'
vector<ll> dp;

void rec(int i, const vector<int>& not_taken, ll cur_score, int mask, int group){
	if(i == SZ(not_taken)){
		dp[mask] = max(dp[mask], cur_score + pre[group]);
		return;
	}
	rec(i + 1, not_taken, cur_score, mask, group);
	rec(i + 1, not_taken, cur_score, mask ^ (1 << not_taken[i]), group ^ (1 << not_taken[i]));

}

// O(2^n * n^2 * 3^n)
signed main(){
	IOS
	int n;
	scanf("%d", &n);

	vector<vector<ll>> in(n,vector<ll>(n));
	rep(i,n){
		rep(j,n)	scanf("%lld", &in[i][j]);
	}

	// O(2^n * n^2)
	pre.resize(1 << n);
	for(int mask = 0; mask < (1 << n); mask++){
		for(int i = 0; i < n; i++){
			if(mask & (1 << i)){
				for(int j = i+1; j < n; j++){
					if(mask & (1 << j)){
						pre[mask] += in[i][j];
					}
				}
			}
		}
	}
	// dp[mask] - best total score if we grouped the rabbits from 'mask' already
	dp.resize(1 << n, -INF);
	dp[0] = 0;
	for(int mask = 0; mask < (1 << n); mask++){
		vector<int> not_taken;
		for(int i = 0; i < n; i++){
			if(!(mask & (1 << i))){
				not_taken.pb(i);
			}

		}
		rec(0, not_taken, dp[mask], mask, 0);
	}
	printf("%lld\n", dp[(1 << n) - 1]);


}


Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var (
		n, q int
		s    string
	)
	fmt.Scan(&n, &q, &s)

	xs := make([]int, n)
	sum := 0
	for i := range s[:len(xs)-1] {
		if s[i] == 'A' && s[i+1] == 'C' {
			sum++
		}
		xs[i+1] = sum
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var l, r int
	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i < q; i++ {
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())
		wr.WriteString(strconv.Itoa(xs[r-1]-xs[l-1]) + "\n")
	}
	wr.Flush()
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)

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

	int n;
	cin >> n;
    int ans = 0;
    int last = -1;
    rep(i, n){
        int a;
        cin >> a;
        if(last != a){
            last = a;
        }else{
            last = -1;
            ans++;
        }
    }
    

    

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


Measured memory_bytes: 256
c = []
for _ in range(3):
    tmp = list(map(int, input().split()))
    c.append(tmp)

a_flag = [0,0,0]
b_flag = [0,0,0]
for i in range(3):
    if i !=0:
        if c[0][i] - c[0][i-1] == c[1][i] - c[1][i-1] and c[1][i] - c[1][i-1] == c[2][i] - c[2][i-1]:
            a_flag[i]=1
    else:
        if c[0][2] - c[0][0] == c[1][2] - c[1][0] and c[1][2] - c[1][0] == c[2][2] - c[2][0]:
            a_flag[i]=1
            
for j in range(3):
    if j !=0:
        if c[j][0] - c[j-1][0] == c[j][1] - c[j-1][1] and c[j][1] - c[j-1][1] == c[j][2] - c[j-1][2]:
            b_flag[j]=1
    else:
        if c[2][0] - c[0][0] == c[2][1] - c[0][1] and c[2][1] - c[0][1] == c[2][2] - c[0][2]:
            b_flag[j]=1

if sum(a_flag) ==3 and sum(b_flag)==3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
  int H,W;
  in(H>>W);
 vector<vector<char>> P(H,vector<char>(W));
  rep(i,H){
   rep(j,W) in(P[i][j]);
  }
  vector<bool> cuth(H,true),cutw(W,true);
  rep(i,H){
   bool f = true;
    rep(j,W) if(P[i][j]=='#') f = false;
    if(f) cuth[i]=false;
  }
  rep(i,W){
   bool g = true;
    rep(j,H) if(P[j][i]=='#') g = false;
    if(g) cutw[i]=false;
  }
 rep(i,H){
  rep(j,W){
   if(cuth[i]==true&&cutw[j]==true) cout <<P[i][j];
    if(cuth[i]==true&&j==W-1) cout<<endl;
  }
 }
}


Measured memory_bytes: 256
import sys

def maxs(s1, s2):
    if len(s1) > len(s2): return s1
    elif len(s1) < len(s2): return s2

    if s1 > s2: return s1
    else: return s2
    

while 1:
    w,h = map(int, raw_input().split())
    if not(w or h): break
    f = []
    for i in xrange(h):
        f.append(raw_input())

    ans = ''
    t = [['' for j in xrange(w)] for i in xrange(h)]
    for i in xrange(h):
        for j in xrange(w):
            if not(ord('0') <= ord(f[i][j]) <= ord('9')):
                continue
            if j>0: t[i][j] = maxs(t[i][j], t[i][j-1])
            if i>0: t[i][j] = maxs(t[i][j], t[i-1][j])
            t[i][j] += f[i][j]
            if t[i][j] is '0': t[i][j] = ''

            ans = maxs(ans, t[i][j])

    print ans

Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isPrime(ll x){
  for(int i=2 ; i*i<=x ; i++){
    if(x%i == 0){
      return false;
    }
  }
  return x != 1LL;
}

int main(){
  ll x; cin >> x;
  if(x==1 || x==2){
    cout << 2 << endl;
    return 0;
  }
  if(x%2==0) x++;
  for(int i=x; ; i+=2){
    if(isPrime(i)){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
from math import sqrt
a,b = map(int,input().split())
if b < 10:
    c = 10*a+b
elif b < 100:
    c = 100*a + b
else:
    c = 1000*a + b
if int(sqrt(c))**2 == c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def main():
    E,Y = map(int,input().split())
    if E == 0:
        if Y <= 1911:
            print("M"+str(Y-1867))
        elif Y <= 1925:
            print("T"+str(Y-1911))
        elif Y<= 1988:
            print("S"+str(Y-1925))
        else:
            print("H"+str(Y-1988))
    elif E == 1:
        print(str(1867+Y))
    elif E == 2:
        print(str(1911+Y))
    elif E == 3:
        print(str(1925+Y))
    else:
        print(str(1988+Y))

if __name__ == "__main__":
    main()

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

char str[200010];
int Res=0;

int main()
{
	scanf("%s", str);
	int len = strlen(str);
	for (int i=0; i<len; i++) Res+=(str[i]-'0');
	if (Res%9) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
double eps = 1.0e-12;
using namespace std;

int main()
{
	long long W,H;
	int x,y;
	cin>>W>>H>>x>>y;
	long double S = (long double)(W*H)/2;
	cout<<S<<" ";
	if(W == 2*x  && H == 2*y)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
from itertools import combinations
import numpy as np
n=int(input())
L=[]
for i in range(n):
    w=input()
    L.append(w[0])
CNT=Counter(L)
m=CNT['M']
a=CNT['A']
r=CNT['R']
c=CNT['C']
h=CNT['H']
comb=combinations([m,a,r,c,h], 3)
ans=0
for kumi in comb:
    ans+=np.prod(kumi)
print(ans)

Measured memory_bytes: 13512
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$l = explode(" ",trim(fgets(STDIN)));

if ($A >= 10 || $B >= 10) {
  printf("-1\n");
}
else {
  printf("%d\n",$A*$B);
}


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

using namespace std;

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

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


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


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


    //cin >> T;
    T = 1;

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

        cin >> n;
        vector<i64> a(n);

        for (i64 i = 0; i < n; ++i) {
            cin >> a[i];
        }

        i64 res = 0;

        for (i64 i = 0; i < n; ++i) {
            for (i64 j = 0; j < n; ++j) {
                for (i64 q = 0; q < n; ++q) {
                    if (i != j && i != q && j != q && a[i] != a[j] && a[j] != a[q] && a[i] != a[q]) {
                        vector <i64> x = {a[i], a[j], a[q]};
                        sort(x.begin(), x.end());
                        if (x[0] + x[1] > x[2]) {
                            res += 1;
                        }
                    }
                }
            }
        }

        res /= 6;
        cout << res << endl;

    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
	int n,x,t;
	cin >> n >> x >> t;
	int ans=(n/x)*t;
	if(n%x) ans+=t;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main(){
    int A, B;
    cin >> A >> B;

    int ans = -1;
    for(int i=1; i<=1000; ++i){
        if( (i*8)/100 == A && (i*10)/100 == B){
            ans = i;
            break;
        }
    }

    cout << ans << endl;


}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int h[2], m[2], k;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> h[0] >> m[0] >> h[1] >> m[1] >> k;
    int a = (h[1] - h[0]) * 60 + m[1] - m[0];
    cout << max(0, a - k) << endl;
    return 0;
}


Measured memory_bytes: 3640