akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  vector< string > s(n);
  for(int i = 0; i < n; i++) cin >> s[i];

  int ca = 0, cb = 0, cba = 0;
  for(int i = 0; i < n; i++){
    char s0 = s[i][0];
    char sl = s[i][s[i].length() - 1];
    if(s0 == 'B' && sl != 'A') ++cb;
    else if(s0 != 'B' && sl == 'A') ++ca;
    else if(s0 == 'B' && sl == 'A') ++cba;
  }

  int count = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j + 1 < s[i].length(); j++){
      if(s[i][j] == 'A' && s[i][j + 1] == 'B') ++count;
    }
  }

  if(cba > 0) count += cba - 1;
  if(cba > 0 && (ca > 0 || cb > 0)) ++count;
  count += min(ca, cb);

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1144
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll N,M,a=1;

int main(void){
	cin>>N>>M;
	rep(i,M){
		a*=2;
	}
	cout<<(100*N+1800*M)*a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  int sum = 100;
  cin >> n ;
  for(int i = 0; i < n; i++){
    int a ;
    cin >> a;
    int j = 0 ;
    while(true){
      if( a % 2 == 0){
        a /= 2 ;
          j++;
      }
      else{
        break;
      }
    }
    if( sum > j ){
      sum = j;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$queue = new SplPriorityQueue();
for($i=0; $i<$n; $i++) {
    // $queue->insert(a,b); $queueにaの値を優先度bで挿入
    $queue->insert($a[$i], $a[$i]);
}
while($m) {
    // $queue->extract(); $queueの最も優先度の高いキューを取り出す(取り出した後はキューから値が消える)
    $max = $queue->extract();
    $max = intval($max/2);
    $queue->insert($max, $max);
    $m--;
}
// $queue->count(); $queueの中のキュー数を数える。
$count = $queue->count();
$ans = 0;
for($i=0; $i<$count; $i++) {
    $ans += $queue->extract();
}
echo $ans;


Measured memory_bytes: 53748
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0,l=0,u[20];
  mem(u);
  rep(r,n) {
    rep(i,20) {
      if(a[r]&(1<<i)) u[i]++;
    }
    while(l<r) {
      bool f=0;
      rep(i,20) {
        if(u[i]>=2) f=1;
      }
      if(!f) break;
      rep(i,20) {
        if(a[l]&(1<<i)) u[i]--;
      }
      l++;
    }
    ans+=r-l+1;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll h;
int main()
{
    int i = 0;
    cin >> h;

    while(h > 1)
    {
        i++;
        h /= 2;
    }
    ll k = pow(2 , ++i) - 1;
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 7
for combs in itertools.product([0, 1], repeat=N):
    tCA = [0] * (M + 1)
    for i, c in enumerate(combs):
        if c:
            for j in range(M + 1):
                tCA[j] += CA[i][j]
    if sum([1 for a in tCA[1:] if a >= X]) == M:
        ans = min(ans, tCA[0])
print(-1 if ans == 10 ** 7 else ans)


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

int main(){
  while(1){
  int T,P,R,t,p,time;
  int ti[51][11]={},pe[51]={};
  string str;
  cin>>T>>P>>R;
  if(T+P+R==0) break;
  int ID[51][11][2]={},ac[51]={};
  for(int i=0;i<R;i++){
    cin>>t>>p>>time>>str;
    if(str=="WRONG") ID[t][p][0]++;
    else{
 ID[t][p][1]++;
 ac[t]++;
 ti[t][p]=time;
    }    
  }
  int ans[51],q;
  for(int i=1;i<=T;i++)
    for(int j=1;j<=P;j++)if(ID[i][j][1]==1)pe[i]+=ID[i][j][0]*1200+ti[i][j];
 
  for(int i=1;i<=T;i++) ans[i]=i;
  for(int i=1;i<=T-1;i++)
    for(int j=i+1;j<=T;j++){
      if(ac[ans[i]]<ac[ans[j]] || (ac[ans[i]]==ac[ans[j]] && pe[ans[i]]>pe[ans[j]])){
	q=ans[i];
	ans[i]=ans[j];
	ans[j]=q;
      }else if(ac[ans[i]]==ac[ans[j]] && ans[i]>ans[j] && pe[ans[i]]==pe[ans[j]]){
	  q=ans[i];
	  ans[i]=ans[j];
	  ans[j]=q;
	}
    }
  for(int i=1;i<=T;i++) cout<<ans[i]<<' '<<ac[ans[i]]<<' '<<pe[ans[i]]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1224
n, q = map(int, input().split())
s = input()
lr = [[0] * 2 for _ in range(q)]
for i in range(q):
    l, r = map(int, input().split())
    lr[i][0], lr[i][1] = l, r

chk = [0] * n
cnt = [0] * n
for i in range(1, n):
    if s[i] == 'C':
        if s[i-1] == 'A':
             chk[i] = 1
    cnt[i] = cnt[i-1] + chk[i]

for i in lr:
    print(cnt[i[1]-1] - cnt[i[0]-1])


Measured memory_bytes: 25220
#include <bits/stdc++.h>
#include <complex>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define int long long
#define INF 1e9
#define MOD 1e9 + 7
using namespace std;

template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

using P = complex<double>;
const double PI = acos(-1);
const double EPS = 1e-9;
// P p(a,b)=a+bi -> 点p(a,b)
namespace std {
  bool operator<(const P &a, const P &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); }
  bool operator==(const P &a, const P &b) { return a.real() == b.real() && a.imag() == b.imag(); }
} // namespace std

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a);
    push_back(b);
  }
};
//内積
double dot(P a, P b) { return real(conj(a) * b); }
//外戚
double cross(P a, P b) { return imag(conj(a) * b); }

//点pから直線aに推薦を下ろした足
P projection(L a, P p) {
  double t = dot(p - a[0], a[0] - a[1]) / norm(a[0] - a[1]);
  return a[0] + t * (a[0] - a[1]);
}

//点の位置関係
int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1; // counter clockwise
  if (cross(b, c) < 0) return -1; // clockwise
  if (dot(b, c) < 0) return +2; // c--a--b on line
  if (norm(b) < norm(c)) return -2; // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) { return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 && ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0; }
bool intersectSP(const L &s, const P &p) { // triangle inequality
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS;
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])), min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
signed main() {
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d, e, f, g, h;
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    L l(P(a, b), P(c, d)), m(P(e, f), P(g, h));
    double ans = distanceSS(l, m);
    printf("%.10lf\n", ans);
  }
  return 0;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
//template
#define int long long//ないとオーバーフローでやられる
int H,W;
int ans=1e9,a,b;
void f(int a,int b){
  int c=H*W-a-b;if(a<=0||b<=0||c<=0)return;
  ans=min(ans,max({a,b,c})-min({a,b,c}));
}
//main
signed main(){
  cin>>H>>W;
  for(int i=0;i<2;i++){
    //横線２本
    a=b=(H+1)/3*W;
    f(a,b);
    //縦１本->横１本
    for(int j=1;j<W;j++){//縦をどこで入れるか全探索
      a=j*H;b=H/2*(W-j);
      f(a,b);
    }
    swap(H,W);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s %s %s', $s[0], $s[1], $s[2]);

$five_flag = 0;
$seven_flag = 0;
foreach ($s as $value) {
  if ($value === "5") $five_flag ++;
  if ($value === "7") $seven_flag ++;
}
if ($seven_flag === 1 && $five_flag === 2 ) echo 'YES';
else echo 'NO';

?>


Measured memory_bytes: 4604
#include<cstdio>
#include<cstring>
const int L=10003,M=1e9+7;
inline int Mod(int a){return a<M?a:a-M;}
int d[L],l,m,f[L][103],s;char t[L];
signed main(){
	scanf("%s%d",t,&m);
	l=strlen(t);
	for(int i=1;i<=l;i++)d[i]=t[i-1]-48;
	for(int i=1;i<=l;i++){
	  for(int k=0;k<10;k++){
		for(int j=0;j<m;j++)
		  f[i][(j+k)%m]=Mod(f[i][(j+k)%m]+f[i-1][j]);
		if(k<d[i])f[i][(s+k)%m]=Mod(f[i][(s+k)%m]+1);
	  }
	  s=(s+d[i])%m;
	}
	printf("%d",(f[l][0]+(!s)-1+M)%M);
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>T chmax(T&a,T b){return a=a>b?a:b;}
template<class T>T chmin(T&a,T b){return a=a<b?a:b;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vi a(n);
	rep(i,n)cin>>a[i];
	vb dp(k+1,0);
	rep(i,k){
		if(dp[i])continue;
		rep(j,n)if(i+a[j]<=k){
			dp[i+a[j]]=1;
		}
	}
	tf(dp[k],"First","Second");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int num = 0;
 int s[10000], t[10000];
 int ns, nt, i;

 scanf("%d", &ns);
 for ( i = 0; i < ns; ++i ){
   scanf("%d", &s[i]);
   for ( int j = 0; j < i; ++j ){
     if ( s[i] == s[j] ){
       s[i] = -1;
     }
   }
 }

 scanf("%d", &nt);
 for ( i = 0; i < nt; ++i ){
   scanf("%d", &t[i]);
   for ( int j = 0; j < ns; ++j ){
     if ( t[i] == s[j] ){
       num++;
     }
   }
 }

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

 return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0, a; i < n; ++i)
    {
        cin >> a;
        if(a%2) ++cnt;
    }
    if (cnt%2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	if (N % 2 == 0)
	{
		cout << N / 2 - 1 << endl;
	}
	else
	{
		cout << N / 2 << endl;
	}
}


Measured memory_bytes: 3632
s = input()
t = input()
slen = len(s)
tlen = len(t)
min_diff = tlen

for si in range(slen - tlen + 1):
    diff = 0
    for ti in range(tlen):
        if s[si+ti] != t[ti]:
            diff += 1
    if diff < min_diff:
        min_diff = diff

print(min_diff)

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll kai(ll n,ll k){
  ll ret=1;
  ll jou=n;
  for(;;){
    if(k%2==1)ret=ret*jou%mod;
    k/=2;
    if(k==0)break;
    jou=jou*jou%mod;
  }
  return ret;
}
int main(){
  string s;cin>>s;
  ll a[s.size()+1],c[s.size()+1],h[s.size()+1];
  a[0]=0;c[0]=0;h[0]=0;
  for(ll i=0;i<s.size();i++){
    a[i+1]=a[i];
    c[i+1]=c[i];
    h[i+1]=h[i];
    if(s[i]=='A')a[i+1]++;
    if(s[i]=='C')c[i+1]++;
    if(s[i]=='?')h[i+1]++;
  }
  //cout<<a[1]<<c[4]<<h[3];return 0;
  ll ans=0;
  for(ll i=0;i<s.size();i++){
    if(s[i]=='B'||s[i]=='?'){
      ll p=(a[i]*kai(3,h[i])+h[i]*kai(3,h[i]-1))%mod;
      ll q=((c[s.size()]-c[i+1])*kai(3,h[s.size()]-h[i+1])+(h[s.size()]-h[i+1])*kai(3,h[s.size()]-h[i+1]-1))%mod;
      ans+=p*q%mod;
      ans%=mod;
      //cout<<p<<" "<<q<<endl;
    }
  }
  cout<<ans%mod<<endl;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vi A(N, 0);
  int tmp = 0;
  rep(i, Q) {
    cin >> tmp;
    A[tmp - 1] += 1;
  }

  rep(i, N) {
    if (A[i] > Q - K) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, K, ans=0;

    cin >> N >> K;

    vector<int> H(N);

    rep(i,N) {
        cin >> H[i];
    }

    if(N<=K) {
        cout << 0 << endl;
    } else {
        sort(H.begin(), H.end());
        rep(i, N-K) {
            ans += H[i];
        }
        cout << ans << endl;
    }

    return 0;
    
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdlib.h>
using namespace std;

main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  int difx,dify;
  cin >> x1>>y1>>x2>>y2;
  difx = abs(x1-x2);
  dify = abs(y1-y2);
  
  if(x1<x2) y3 = y2 + difx; 
  else y3 = y2 - difx; 
  if(y1<y2) x3 = x2 -dify; 
  else x3 = x2 + dify; 
  
  if(x1<x2) y4 = y1 + difx; 
  else y4 = y1 - difx; 
  if(y1<y2) x4 = x1 -dify;
  else x4 = x1 +dify;
  
  
  //cout<<difx<<endl;
  //cout<<dify<<endl;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var s string
	fmt.Fscanf(r, "%s\n", &s)

	if s == "AAA" || s == "BBB" {
		fmt.Fprintln(w, "No")
		return
	}

	fmt.Fprintln(w, "Yes")
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
template <class T>
istream& operator>>(istream& input, vector<T>& v) {
    for (T& i : v) input >> i;
    return input;
}
template <class T>
ostream& operator<<(ostream& output, const vector<T>& v) {
    for (auto itr = v.begin(); itr != v.end() - 1; ++itr)
        output << *itr << " ";
    output << v.back();
    return output;
}
int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N, 0), ans;
    cin >> a;
    for (int i = N - 1; i >= 0; i--) {
        int tmp = 0;
        for (int j = 2 * i + 1; j < N; j += i + 1) tmp += b[j];
        b[i] = (tmp & 1) != a[i];
        if (b[i]) ans.push_back(i + 1);
    }
    cout << ans.size() << endl;
    if (ans.size()) cout << ans << endl;
}

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

int main() {
    int n, k, res;
    cin >> n >> k;
    res = 0;

    rep(i, n) {
        int x;
        cin >> x;
        if (x < k - x) {
            res += x * 2;
        }
        else {
            res += (k - x) * 2;
        }
    }
    cout << res << endl;
}

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

sub = sum(a)
s = 0
ans = (10 ** 10) + 100
for i in range(n):
    s += a[i]
    if (i + 1) < n:
        ans = min(ans, abs(sub - (2 * s)))

print(ans)

Measured memory_bytes: 24824
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	A := make([]int64, N-2+1)
	for i := int64(0); i < N-2+1; i++ {
		scanner.Scan()
		A[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	solve(N, A)
}
func solve(N int64, A []int64) {
	m := map[int64]int64{}
	for _, a := range A {
		m[a]++
	}
	for i := int64(1); i <= N; i++ {
		fmt.Println(m[i])
	}
}


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

int main(){
  string s,ans="";
  cin >> s;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '0') ans += "0";
    else if(s.at(i) == '1') ans += "1";
    else if(s.at(i) =='B'){
      if(!i==0 && !ans.empty()){
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long ans=0;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    queue<int> conf;
    sort(A,A+N,greater<int>());
    conf.push(A[0]);
    for(int i=1; i<N; i++){
        ans+=conf.front();
        conf.pop();
        conf.push(A[i]);
        conf.push(A[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);

string s;
int n;

ll dp[N][15];


ll f(int  idx,int md){
    if(idx==n){
        if(md==5){
            return 1;
        }
        return 0;
    }
    ll &ret=dp[idx][md];
    if(ret!=-1)return ret;
    ret=0;
    if(s[idx]!='?'){
        return ret=f(idx+1,(md*10+(s[idx]-'0'))%13)%MOD;
    }
    for(int i=0;i<10;i++){
        ret+=f(idx+1,(md*10+i)%13)%MOD;
        ret%=MOD;
    }
    return ret;
}

void solve(int T){
    memset(dp,-1,sizeof dp);
    cin>>s;
    n=s.size();
    ll ans=f(0,0);
    cout<<ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





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

using namespace std;

int main()
{
   int n, k;
   cin >> n >> k;
   int a[n];
   for(int i = 0; i < n ; i++)
   {
     cin >> a[i];
   }
   sort(a, a+n);
   int sum = 0;
   for(int i =0; i < k ; i++)
   {
      sum += a[i];
   }
   cout << sum;
}


Measured memory_bytes: 3632
import sys
for s in sys.stdin:
  y,m,d=map(int,s[:-1].split())
  x="%d%02d%02d"%(y,m,d)
  w=" %d %d"%(m,d)
  if x<"18680908":e="pre-meiji"
  elif x<"19120730":e="meiji %d"%(y-1867)+w
  elif x<"19261225":e="taisho %d"%(y-1911)+w
  elif x<"19890108":e="showa %d"%(y-1925)+w
  else:e="heisei %d"%(y-1988)+w
  print e

Measured memory_bytes: 4220
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
const long nPrime = 1000000007;

int main(){
    long n,m;
    scanf("%ld %ld", &n, &m);
    long x[n],y[m];
    for(long i = 0; i < n; i++){
        scanf("%ld", &x[i]);
    }
    for(long i = 0; i < m; i++){
        scanf("%ld", &y[i]);
    }
    
    long xSum = 0;
    for(long i = 0; i < n-1; i++){
        long k = (x[i+1] - x[i]) * (i+1);
        k %= nPrime;
        xSum += k * (n-i-1);
        xSum %= nPrime;
    }
    long ySum = 0;
    for(long i = 0; i < m-1; i++){
        long k = (y[i+1] - y[i]) * (i+1);
        k %= nPrime;
        ySum += k * (m-i-1);
        ySum %= nPrime;
    }
    long nAns = xSum * ySum;
    nAns %= nPrime;
    if (nAns < 0){
        nAns += nPrime;
    }
  
    printf("%ld", nAns);
    return 0;
}


Measured memory_bytes: 4772
N = int(raw_input())
A = map(int,raw_input().split())

B = [0 for i in range(max(A))]
for i in range(len(A)):
    B[A[i]-1]+=1

score=0
res=0
for i in range(len(B)):
    if B[i]>=1:
        score+=1
    if B[i]>=2:
        res+=B[i]-1

if res%2==0:
    print score
else:
    print score-1

Measured memory_bytes: 11328
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll p[2010];

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> p[i];

  std::sort( p, p+N );

  ll ans = 0;

  rep( i, K )
    ans += p[i];

  std::cout << ans << std::endl;

  return 0;
}

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
    if (a == 0) return b;
    else
        return gcd(b % a, a);
}
// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
    return (a * b) / gcd(a, b);
}


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

    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    int64_t c = B / C - (A - 1) / C;
    int64_t d = B / D - (A - 1) / D;
    int64_t cd = B / lcm(C, D) - (A - 1) / lcm(C, D);
    cout << (B - A + 1) - (c + d - cd)  << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  int f = a;
  int r = a % b;
  do
  {
    if(a % b == c) {
      cout << "YES" <<endl;
      return 0;
    }
    a += f;
  } while (a % b != r);
  
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int inf = 1e8;

int dp[1005][1005];

int main() {
    int q;
    cin >> q;
    vector<int> ans;
    rep(_,q) {
        string x, y;
        cin >> x >> y;
        rep(i,x.size())rep(j,y.size()) {
            if (x[i] == y[j]) dp[i+1][j+1] = dp[i][j] +1;
            else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
        }
        ans.push_back(dp[x.size()][y.size()]);
        rep(i,x.size())rep(j,y.size()) dp[i][j] = 0;
    }
    rep(i,q) cout << ans[i] << endl;
}


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

#[fastout]
fn main() {
    input! {
        k: usize,
    }

    let mut a = vec![0; k];
    a[0] = 7 % k;
    for i in 1..k {
        a[i] = (a[i - 1] * 10 + 7) % k;
    }

    for i in 0..k {
        if a[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }

    println!("{}", -1);
}


Measured memory_bytes: 9920
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0)cout << "Even" << endl;
	else cout << "Odd" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int H, N, A[SIZE];
  ll sum = 0;

  cin >> H >> N;

  for (int i=0; i<N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if (sum < H)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m; cin >> n >> m;
    vector <ll> number(n, -1);
    loop(i,0,m)
    {
        int pos, digit;
        cin >> pos >> digit;
        pos--;
        if (number[pos] != -1 && number[pos]!=digit)
        {
            cout << -1 << "\n";
            return 0;
        }
        number[pos]=digit;
    }
    if (number[0]==-1) {
        if (n==1) 
            number[0]=0;
        else number[0]=1;
    }
    if (n>1 && number[1]==-1) number[1]=0;
    if (n>2 && number[2]==-1) number[2]=0;
    if (number[0]==0 && n>1) {
        cout << -1 << "\n";
        return 0;
    }
    loop (i,0,n) cout << number[i];
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    u64 N, X, T;
    cin >> N >> X >> T;

    cout << (N + X - 1) / X * T << endl;
    return 0;
}

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

int main() {
	ll x;
	cin >> x;
	ll dist = 0;
	ll t = 0;
	while(dist < x) {
		t++;
		dist += t;
	}
	cout << t << endl;
	return 0;
}


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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b)
{
	ll r = 1;
	for(; b ; b >>= 1, a = a * a % mod)
	{
		if(b & 1)
		{
			r = r * a % mod;
		}
	}
	return r;
}

ll getinv(ll n)
{
	return pw(n, mod - 2);
}

void upd(ll &a, ll b)
{
	a = (a + b) % mod;
}

int n;
ll fac[N], invfac[N];
vector<int> g[N];
void init(int n)
{
	fac[0] = invfac[0] = 1;
	for(int i = 1 ; i <= n ; ++ i)
	{
		fac[i] = fac[i - 1] * i % mod;
	}
	invfac[n] = pw(fac[n], mod - 2);
	for(int i = n - 1 ; i ; -- i)
	{
		invfac[i] = invfac[i + 1] * (i + 1) % mod;
	}
}

ll C(int n, int m)
{
	return n < m || m < 0 ? 0 : fac[n] * invfac[n - m] % mod;
}

ll ans;
int k;
int main()
{
	init(N - 1);
	scanf("%d%d", &n, &k);
	for(int i = 1, u, v ; i < n ; ++ i)
	{
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ans = k;
	for(int i = 1 ; i <= n ; ++ i)
	{
		int sz = g[i].size() - (i > 1);
		ans = ans * C(k - 1 - (i > 1), sz) % mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7672
#include<bits/stdc++.h>
using namespace std;
long long unit = 1;
int visited[105]={0};
bool check(long long curr){
	for(int j=0; j<25; j++){
		if((unit<<j)&curr){
			if(visited[j]) return false;
		}
	}
	for(int j=0; j<25; j++){
		if((unit<<j)&curr) visited[j]++;
	}
	return true;
}
void proccess(long long curr){
	for(int j=0; j<25; j++){
		if((unit<<j)&curr){
			visited[j]--;
		}
	}
}
int main(){
	int n;
	cin>>n;
	vector<long long>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	
	int start = 0;
	int fin = start;
	long long ret = 0;
	while(start<n){
		while(fin<n && check(arr[fin])) fin++;
		ret+=(fin-start);
		proccess(arr[start]);
		start++;
	}
	cout<<ret;
}

Measured memory_bytes: 4824
import itertools
import bisect

n = int(input())
l = list(map(int,input().split()))

l = sorted(l)

combinations = list(itertools.combinations(range(n),2))

cnt = 0

for i in combinations:
    a_b = l[i[0]] + l[i[1]]
    max_ab = max(i[0], i[1])
    c = bisect.bisect_left(l,a_b)
    
    cnt += (c - (max_ab+1))


print(cnt)

Measured memory_bytes: 123948
#include <stdio.h>

int main()
{
	int A,B,C,D;
	int t;

	scanf("%d %d %d %d\n",&A,&B,&C,&D);

	if(B<=C || D<=A){
		t=0;
	}
	else{
		if(A<=C){
			if(B<=D){
				t=B-C;
			}
			else{
				t=D-C;
			}
		}
		else{
			if(D<=B){
				t=D-A;
			}
			else{
				t=B-A;
			}
		}
	}

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

	return 0;
}


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

namespace AtCoder.Abc
{
    // https://atcoder.jp/contests/abc171/tasks/abc171_a
    class A_171_αlphabet
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            // 大文字の場合、「A」を表示
            if (System.Text.RegularExpressions.Regex.IsMatch(s, "[A-Z]"))
            {
                Console.WriteLine("A");
            }
            // 小文字の場合、「a」を表示
            else
            {
                Console.WriteLine("a");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26632
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    L = sorted(list(map(int, input().split())))

    res = 0
    for i in range(n * 2):
        if i % 2 == 0:
            res += L[i]
    print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;
using u64 = std::uint_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<u64>> A(N, vector<u64>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }

  vector<vector<bool>> D(N, vector<bool>(N, true));
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (A[i][j] > A[i][k] + A[k][j]) {
          cout << -1 << '\n';
          return 0;
        }

        if (A[i][j] == A[i][k] + A[k][j] && A[i][k] > 0 && A[k][j] > 0) {
          D[i][j] = false;
        }
      }
    }
  }

  u64 res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (D[i][j]) res += A[i][j];
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <cctype>
using namespace std;
int main() {
int R; 
cin >> R;  
if(R < 1200) cout << "ABC" << endl; 
else if(R < 2800) cout << "ARC" << endl;
else cout << "AGC" << endl; 
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 == 1:
    if A[0] != 0:
        print(0)
        exit()
    for i in range(N // 2):
        if A[2 * i + 1] != 2 * (i + 1) or A[2 * i + 2] != 2 * (i + 1):
            print(0)
            exit()
    print(pow(2, N // 2) % (10 ** 9 + 7))
else:
    for i in range(N // 2):
        if A[2 * i] != 2 * i + 1 or A[2 * i + 1] != 2 * i + 1:
            print(0)
            exit()
    print((pow(2, N // 2)) % (10 ** 9 + 7))


Measured memory_bytes: 13880
#include<iostream>
#include<vector>
#include<algorithm>
#define PII pair<int, int>
#define REP(i, n) for(int i=0;i<(n);++i)
#define atoi(x) (x - 'A')
using namespace std;
int H, W;
vector<vector<char> > map;
vector<vector<PII > > alp;
void outmap(){
    REP(y, H){
        REP(x, W){
            cout << map[y][x];
        }
        cout << endl;
    }
}
bool check(int sy, int sx, int gy, int gx) {
    if(abs(sy-gy)+abs(sx-gx)==1)return false;
	int count = 0;
	for (int x = min(sx, gx); x <= max(sx, gx); ++x) {
		count += map[sy][x] != '.';
	}
	for (int y = min(sy, gy); y <= max(sy, gy); ++y) {
		count += map[y][gx] != '.';
	}
    count -= map[sy][gx] != '.';
	if (count == 2)return true;
	count = 0;
	for (int y = min(sy, gy); y <= max(sy, gy); ++y) {
		count += map[y][sx] != '.';
	}
	for (int x = min(sx, gx); x <= max(sx, gx); ++x) {
		count += map[gy][x] != '.';
	}
    count -= map[gy][sx] != '.';
	if (count == 2)return true;
	return false;
}
int main() {
	cin >> H >> W;
	map.resize(H);
	alp.resize(26);
	REP(i, H) {
		map[i].resize(W);
		REP(j, W) {
			cin >> map[i][j];
			if (map[i][j] != '.') {
				alp[atoi(map[i][j])].push_back(PII(i, j));
			}
		}
	}
	bool flag = true;
	int ans = 0;
	while (flag) {
		flag = false;
		REP(i, 26) {
			if (alp[i].empty())continue;
			if (!check(alp[i][0].first, alp[i][0].second, alp[i][1].first, alp[i][1].second))continue;
            ans += 2;
			map[alp[i][0].first][alp[i][0].second] = '.';
			map[alp[i][1].first][alp[i][1].second] = '.';
            alp[i].clear();
            flag = true;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3368
h,w,n=map(int, input().split())
m=dict()
for _ in range(n):
    a,b=map(int, input().split())
    for i in range(3):
        for j in range(3):
            m[(a+i-1,b+j-1)]=m.get((a+i-1,b+j-1),0)+1
ans=[0]*10
for i,j in m.items():
    c,d=i
    if 1<c<h and 1<d<w:
        ans[j]+=1
ans[0]=(w-2)*(h-2)-sum(ans)
for i in ans:print(i)

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

typedef long long int ll;

int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll ans=1;
	sort(arr,arr+n);
	if(arr[0]==0)
		cout<<"0\n";
	else
	{
		ll flag=1;
		for(ll i=0;i<n;i++)
		{
			ans*=arr[i];
			if(ans<=0 || ans>1000000000000000000)
			{
				cout<<"-1\n";
				i=n;
				flag=0;
			}
		}
		if(flag==1)
			cout<<ans<<endl;
		//	sort(arr,arr+n);
	/*	if(arr[0]==0)
			cout<<"0\n";
		else if(ans<0 || ans>1000000000000000000)
			cout<<"-1\n";
		else
			cout<<ans<<endl;*/
	}
}


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

int main() {
    int n;
    string S;
    cin >> n;
    cin >> S;

    int r=0;
    for (int i = 0; i < n; ++i) {
        if (S[i]=='R'){
            ++r;
        }
    }
    int ans=0;
    rep(i, r) {
        if (S[i]=='W') ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
a,b=map(int,input().split())
if a==1 and b==1:
  print(1)
  exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
ans=0
A=factorization(a)
B=factorization(b)
for i in A:
  for j in B:
    if i[0]==j[0]:
      ans+=1
print(ans+1)


Measured memory_bytes: 9484
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll H, W; cin >> H >> W;
    if(H == 1 or W == 1) cout << 1 << endl;
    else if((H * W) % 2) cout << H*(W-1)/2 + H/2+1 << endl;
    else cout << H*W / 2 << endl;
    return 0;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> v){
  cout<<endl;
  rep(i,v.size()){
    cout<<v.at(i)<<" ";
  }
  cout<<endl;
}

template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
    }
  }
}


//---------------------------------------------------------------
int main(){
  ll X;

  cin>>X;
  ll ans = 0;
  ll cost = 100;
  while(1){
    if(cost>=X)break;
    cost = cost*1.01;
    ans++;


  }



  cout<<ans<<endl;



}


Measured memory_bytes: 3580
import java.util.HashMap;
import java.util.Map;

public class Main {


  private static void solve() {
    int n = ni();
    int[] c = na(n);
    long[] dp = new long[n];
    Map<Integer, Integer> map = new HashMap<>();

    int mod = (int)1e9+7;
    dp[0] = 1;
    map.put(c[0], 0);
    for (int i = 1; i < n; i ++) {
      dp[i] = dp[i-1];
      if (c[i-1] != c[i] && map.containsKey(c[i])) {
        dp[i] += dp[map.get(c[i])];
      }
      dp[i] %= mod;
      map.put(c[i], i);
    }

    System.out.println(dp[n-1]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 52476
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 25172
#include <map>
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int a[10][10];
string s;
int n, m, k, ans = 0;

bool check(int p1, int p2) {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if( (p1 & (1<<(i-1))) && (p2 & (1<<(j - 1)))
                && (a[i][j] == 2) ) cnt++;
        }
    }
    if(cnt == k) return true;
    return false;
}

int main(){
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        for (int j = 0; j < m; j++) {
            if(s[j] == '.') a[i][j + 1] = 1;
            else a[i][j + 1] = 2;
        }
    }
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < (1<<m); j++) {
            if (check(i, j)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int t;
	int s;
	int en;
	int sc;
	int ma;
	int in;
	
	scanf("%d %d %d %d", &in, &ma, &sc, &en);
	s = in + ma + sc + en;
	scanf("%d %d %d %d", &in, &ma, &sc, &en);
	t = in + ma + sc + en;
	
	if (s < t){
		printf("%d\n", t);
	}
	else {
		printf("%d\n", s);
	}
	
	return (0);
}

Measured memory_bytes: 592
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    print("\n".join(["".join(["#" if w == 0 or w == W-1 or h == 0 or h == H-1 else "." for w in range(W)]) for h in range(H)])+"\n")

Measured memory_bytes: 7632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    set<string> s;
    int n; cin >> n;
    while (n--) {
        string q, t; cin >> q >> t;
        if (q[0] == 'i') {
            s.insert(t);
        } else {
            set<string>::iterator it = s.find(t);
            if (it != s.end()) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
    
}



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

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

    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

    string s;
    cin >> s;
    int res = 1000;

    rep(i, s.length()-2){
        string sub = s.substr(i, 3);
        
        int n = 100 * (sub[0] - '0') + 10 * (sub[1] - '0') + (sub[2] - '0');
        res = min(res, abs(753-n));
    }
    cout << res << endl;
}

Measured memory_bytes: 256